babylon.d.ts 2.1 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644
  1. declare module 'babylonjs' {
  2. export = BABYLON;
  3. }
  4. declare module BABYLON {
  5. /**
  6. * Defines how the parser contract is defined.
  7. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  8. */
  9. type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  10. /**
  11. * Defines how the individual parser contract is defined.
  12. * These parser can parse an individual asset
  13. */
  14. type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  15. /**
  16. * Base class of the scene acting as a container for the different elements composing a scene.
  17. * This class is dynamically extended by the different components of the scene increasing
  18. * flexibility and reducing coupling
  19. */
  20. abstract class AbstractScene {
  21. /**
  22. * Stores the list of available parsers in the application.
  23. */
  24. private static _BabylonFileParsers;
  25. /**
  26. * Stores the list of available individual parsers in the application.
  27. */
  28. private static _IndividualBabylonFileParsers;
  29. /**
  30. * Adds a parser in the list of available ones
  31. * @param name Defines the name of the parser
  32. * @param parser Defines the parser to add
  33. */
  34. static AddParser(name: string, parser: BabylonFileParser): void;
  35. /**
  36. * Gets a general parser from the list of avaialble ones
  37. * @param name Defines the name of the parser
  38. * @returns the requested parser or null
  39. */
  40. static GetParser(name: string): Nullable<BabylonFileParser>;
  41. /**
  42. * Adds n individual parser in the list of available ones
  43. * @param name Defines the name of the parser
  44. * @param parser Defines the parser to add
  45. */
  46. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  47. /**
  48. * Gets an individual parser from the list of avaialble ones
  49. * @param name Defines the name of the parser
  50. * @returns the requested parser or null
  51. */
  52. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  53. /**
  54. * Parser json data and populate both a scene and its associated container object
  55. * @param jsonData Defines the data to parse
  56. * @param scene Defines the scene to parse the data for
  57. * @param container Defines the container attached to the parsing sequence
  58. * @param rootUrl Defines the root url of the data
  59. */
  60. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  61. /**
  62. * Gets the list of root nodes (ie. nodes with no parent)
  63. */
  64. rootNodes: Node[];
  65. /** All of the cameras added to this scene
  66. * @see http://doc.babylonjs.com/babylon101/cameras
  67. */
  68. cameras: Camera[];
  69. /**
  70. * All of the lights added to this scene
  71. * @see http://doc.babylonjs.com/babylon101/lights
  72. */
  73. lights: Light[];
  74. /**
  75. * All of the (abstract) meshes added to this scene
  76. */
  77. meshes: AbstractMesh[];
  78. /**
  79. * The list of skeletons added to the scene
  80. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  81. */
  82. skeletons: Skeleton[];
  83. /**
  84. * All of the particle systems added to this scene
  85. * @see http://doc.babylonjs.com/babylon101/particles
  86. */
  87. particleSystems: IParticleSystem[];
  88. /**
  89. * Gets a list of Animations associated with the scene
  90. */
  91. animations: Animation[];
  92. /**
  93. * All of the animation groups added to this scene
  94. * @see http://doc.babylonjs.com/how_to/group
  95. */
  96. animationGroups: AnimationGroup[];
  97. /**
  98. * All of the multi-materials added to this scene
  99. * @see http://doc.babylonjs.com/how_to/multi_materials
  100. */
  101. multiMaterials: MultiMaterial[];
  102. /**
  103. * All of the materials added to this scene
  104. * In the context of a Scene, it is not supposed to be modified manually.
  105. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  106. * Note also that the order of the Material wihin the array is not significant and might change.
  107. * @see http://doc.babylonjs.com/babylon101/materials
  108. */
  109. materials: Material[];
  110. /**
  111. * The list of morph target managers added to the scene
  112. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  113. */
  114. morphTargetManagers: MorphTargetManager[];
  115. /**
  116. * The list of geometries used in the scene.
  117. */
  118. geometries: Geometry[];
  119. /**
  120. * All of the tranform nodes added to this scene
  121. * In the context of a Scene, it is not supposed to be modified manually.
  122. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  123. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  124. * @see http://doc.babylonjs.com/how_to/transformnode
  125. */
  126. transformNodes: TransformNode[];
  127. /**
  128. * ActionManagers available on the scene.
  129. */
  130. actionManagers: ActionManager[];
  131. /**
  132. * Textures to keep.
  133. */
  134. textures: BaseTexture[];
  135. }
  136. }
  137. declare module BABYLON {
  138. /**
  139. * Set of assets to keep when moving a scene into an asset container.
  140. */
  141. class KeepAssets extends AbstractScene {
  142. }
  143. /**
  144. * Container with a set of assets that can be added or removed from a scene.
  145. */
  146. class AssetContainer extends AbstractScene {
  147. /**
  148. * The scene the AssetContainer belongs to.
  149. */
  150. scene: Scene;
  151. /**
  152. * Instantiates an AssetContainer.
  153. * @param scene The scene the AssetContainer belongs to.
  154. */
  155. constructor(scene: Scene);
  156. /**
  157. * Adds all the assets from the container to the scene.
  158. */
  159. addAllToScene(): void;
  160. /**
  161. * Removes all the assets in the container from the scene
  162. */
  163. removeAllFromScene(): void;
  164. /**
  165. * Disposes all the assets in the container
  166. */
  167. dispose(): void;
  168. private _moveAssets;
  169. /**
  170. * Removes all the assets contained in the scene and adds them to the container.
  171. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  172. */
  173. moveAllFromScene(keepAssets?: KeepAssets): void;
  174. /**
  175. * Adds all meshes in the asset container to a root mesh that can be used to position all the contained meshes. The root mesh is then added to the front of the meshes in the assetContainer.
  176. * @returns the root mesh
  177. */
  178. createRootMesh(): Mesh;
  179. }
  180. }
  181. interface Window {
  182. mozIndexedDB: IDBFactory;
  183. webkitIndexedDB: IDBFactory;
  184. msIndexedDB: IDBFactory;
  185. webkitURL: typeof URL;
  186. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  187. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  188. WebGLRenderingContext: WebGLRenderingContext;
  189. MSGesture: MSGesture;
  190. CANNON: any;
  191. AudioContext: AudioContext;
  192. webkitAudioContext: AudioContext;
  193. PointerEvent: any;
  194. Math: Math;
  195. Uint8Array: Uint8ArrayConstructor;
  196. Float32Array: Float32ArrayConstructor;
  197. mozURL: typeof URL;
  198. msURL: typeof URL;
  199. VRFrameData: any;
  200. DracoDecoderModule: any;
  201. setImmediate(handler: (...args: any[]) => void): number;
  202. }
  203. interface WebGLProgram {
  204. context?: WebGLRenderingContext;
  205. vertexShader?: WebGLShader;
  206. fragmentShader?: WebGLShader;
  207. isParallelCompiled: boolean;
  208. onCompiled?: () => void;
  209. }
  210. interface WebGLRenderingContext {
  211. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  212. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  213. vertexAttribDivisor(index: number, divisor: number): void;
  214. createVertexArray(): any;
  215. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  216. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  217. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  218. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  219. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  220. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  221. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  222. createQuery(): WebGLQuery;
  223. deleteQuery(query: WebGLQuery): void;
  224. beginQuery(target: number, query: WebGLQuery): void;
  225. endQuery(target: number): void;
  226. getQueryParameter(query: WebGLQuery, pname: number): any;
  227. getQuery(target: number, pname: number): any;
  228. MAX_SAMPLES: number;
  229. RGBA8: number;
  230. READ_FRAMEBUFFER: number;
  231. DRAW_FRAMEBUFFER: number;
  232. UNIFORM_BUFFER: number;
  233. HALF_FLOAT_OES: number;
  234. RGBA16F: number;
  235. RGBA32F: number;
  236. R32F: number;
  237. RG32F: number;
  238. RGB32F: number;
  239. R16F: number;
  240. RG16F: number;
  241. RGB16F: number;
  242. RED: number;
  243. RG: number;
  244. R8: number;
  245. RG8: number;
  246. UNSIGNED_INT_24_8: number;
  247. DEPTH24_STENCIL8: number;
  248. drawBuffers(buffers: number[]): void;
  249. readBuffer(src: number): void;
  250. readonly COLOR_ATTACHMENT0: number;
  251. readonly COLOR_ATTACHMENT1: number;
  252. readonly COLOR_ATTACHMENT2: number;
  253. readonly COLOR_ATTACHMENT3: number;
  254. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  255. ANY_SAMPLES_PASSED: number;
  256. QUERY_RESULT_AVAILABLE: number;
  257. QUERY_RESULT: number;
  258. }
  259. interface Document {
  260. mozCancelFullScreen(): void;
  261. msCancelFullScreen(): void;
  262. webkitCancelFullScreen(): void;
  263. requestPointerLock(): void;
  264. exitPointerLock(): void;
  265. mozFullScreen: boolean;
  266. msIsFullScreen: boolean;
  267. readonly webkitIsFullScreen: boolean;
  268. readonly pointerLockElement: Element;
  269. mozPointerLockElement: HTMLElement;
  270. msPointerLockElement: HTMLElement;
  271. webkitPointerLockElement: HTMLElement;
  272. }
  273. interface HTMLCanvasElement {
  274. requestPointerLock(): void;
  275. msRequestPointerLock?(): void;
  276. mozRequestPointerLock?(): void;
  277. webkitRequestPointerLock?(): void;
  278. }
  279. interface CanvasRenderingContext2D {
  280. msImageSmoothingEnabled: boolean;
  281. }
  282. interface WebGLBuffer {
  283. references: number;
  284. capacity: number;
  285. is32Bits: boolean;
  286. }
  287. interface WebGLProgram {
  288. transformFeedback?: WebGLTransformFeedback | null;
  289. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  290. }
  291. interface MouseEvent {
  292. mozMovementX: number;
  293. mozMovementY: number;
  294. webkitMovementX: number;
  295. webkitMovementY: number;
  296. msMovementX: number;
  297. msMovementY: number;
  298. }
  299. interface Navigator {
  300. mozGetVRDevices: (any: any) => any;
  301. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  302. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  303. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  304. webkitGetGamepads(): Gamepad[];
  305. msGetGamepads(): Gamepad[];
  306. webkitGamepads(): Gamepad[];
  307. }
  308. interface HTMLVideoElement {
  309. mozSrcObject: any;
  310. }
  311. interface Math {
  312. fround(x: number): number;
  313. imul(a: number, b: number): number;
  314. }
  315. interface EXT_disjoint_timer_query {
  316. QUERY_COUNTER_BITS_EXT: number;
  317. TIME_ELAPSED_EXT: number;
  318. TIMESTAMP_EXT: number;
  319. GPU_DISJOINT_EXT: number;
  320. QUERY_RESULT_EXT: number;
  321. QUERY_RESULT_AVAILABLE_EXT: number;
  322. queryCounterEXT(query: WebGLQuery, target: number): void;
  323. createQueryEXT(): WebGLQuery;
  324. beginQueryEXT(target: number, query: WebGLQuery): void;
  325. endQueryEXT(target: number): void;
  326. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  327. deleteQueryEXT(query: WebGLQuery): void;
  328. }
  329. interface WebGLUniformLocation {
  330. _currentState: any;
  331. }
  332. interface XRDevice {
  333. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  334. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  335. }
  336. interface XRSession {
  337. getInputSources(): Array<any>;
  338. baseLayer: XRWebGLLayer;
  339. requestFrameOfReference(type: string): Promise<void>;
  340. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  341. end(): Promise<void>;
  342. requestAnimationFrame: Function;
  343. addEventListener: Function;
  344. }
  345. interface XRSessionCreationOptions {
  346. outputContext?: WebGLRenderingContext | null;
  347. immersive?: boolean;
  348. environmentIntegration?: boolean;
  349. }
  350. interface XRLayer {
  351. getViewport: Function;
  352. framebufferWidth: number;
  353. framebufferHeight: number;
  354. }
  355. interface XRView {
  356. projectionMatrix: Float32Array;
  357. }
  358. interface XRFrame {
  359. getDevicePose: Function;
  360. getInputPose: Function;
  361. views: Array<XRView>;
  362. baseLayer: XRLayer;
  363. }
  364. interface XRFrameOfReference {
  365. }
  366. interface XRWebGLLayer extends XRLayer {
  367. framebuffer: WebGLFramebuffer;
  368. }
  369. declare var XRWebGLLayer: {
  370. prototype: XRWebGLLayer;
  371. new (session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  372. };
  373. declare module BABYLON {
  374. /**
  375. * Defines how a node can be built from a string name.
  376. */
  377. type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  378. /**
  379. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  380. */
  381. class Node implements IBehaviorAware<Node> {
  382. private static _NodeConstructors;
  383. /**
  384. * Add a new node constructor
  385. * @param type defines the type name of the node to construct
  386. * @param constructorFunc defines the constructor function
  387. */
  388. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  389. /**
  390. * Returns a node constructor based on type name
  391. * @param type defines the type name
  392. * @param name defines the new node name
  393. * @param scene defines the hosting scene
  394. * @param options defines optional options to transmit to constructors
  395. * @returns the new constructor or null
  396. */
  397. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  398. /**
  399. * Gets or sets the name of the node
  400. */
  401. name: string;
  402. /**
  403. * Gets or sets the id of the node
  404. */
  405. id: string;
  406. /**
  407. * Gets or sets the unique id of the node
  408. */
  409. uniqueId: number;
  410. /**
  411. * Gets or sets a string used to store user defined state for the node
  412. */
  413. state: string;
  414. /**
  415. * Gets or sets an object used to store user defined information for the node
  416. */
  417. metadata: any;
  418. /**
  419. * For internal use only. Please do not use.
  420. */
  421. reservedDataStore: any;
  422. /**
  423. * Gets or sets a boolean used to define if the node must be serialized
  424. */
  425. doNotSerialize: boolean;
  426. /** @hidden */
  427. _isDisposed: boolean;
  428. /**
  429. * Gets a list of Animations associated with the node
  430. */
  431. animations: Animation[];
  432. protected _ranges: {
  433. [name: string]: Nullable<AnimationRange>;
  434. };
  435. /**
  436. * Callback raised when the node is ready to be used
  437. */
  438. onReady: (node: Node) => void;
  439. private _isEnabled;
  440. private _isParentEnabled;
  441. private _isReady;
  442. /** @hidden */
  443. _currentRenderId: number;
  444. private _parentRenderId;
  445. protected _childRenderId: number;
  446. /** @hidden */
  447. _waitingParentId: Nullable<string>;
  448. /** @hidden */
  449. _scene: Scene;
  450. /** @hidden */
  451. _cache: any;
  452. private _parentNode;
  453. private _children;
  454. /** @hidden */
  455. _worldMatrix: Matrix;
  456. /** @hidden */
  457. _worldMatrixDeterminant: number;
  458. /** @hidden */
  459. private _sceneRootNodesIndex;
  460. /**
  461. * Gets a boolean indicating if the node has been disposed
  462. * @returns true if the node was disposed
  463. */
  464. isDisposed(): boolean;
  465. /**
  466. * Gets or sets the parent of the node
  467. */
  468. parent: Nullable<Node>;
  469. private addToSceneRootNodes;
  470. private removeFromSceneRootNodes;
  471. private _animationPropertiesOverride;
  472. /**
  473. * Gets or sets the animation properties override
  474. */
  475. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  476. /**
  477. * Gets a string idenfifying the name of the class
  478. * @returns "Node" string
  479. */
  480. getClassName(): string;
  481. /**
  482. * An event triggered when the mesh is disposed
  483. */
  484. onDisposeObservable: Observable<Node>;
  485. private _onDisposeObserver;
  486. /**
  487. * Sets a callback that will be raised when the node will be disposed
  488. */
  489. onDispose: () => void;
  490. /**
  491. * Creates a new Node
  492. * @param name the name and id to be given to this node
  493. * @param scene the scene this node will be added to
  494. * @param addToRootNodes the node will be added to scene.rootNodes
  495. */
  496. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  497. /**
  498. * Gets the scene of the node
  499. * @returns a scene
  500. */
  501. getScene(): Scene;
  502. /**
  503. * Gets the engine of the node
  504. * @returns a Engine
  505. */
  506. getEngine(): Engine;
  507. private _behaviors;
  508. /**
  509. * Attach a behavior to the node
  510. * @see http://doc.babylonjs.com/features/behaviour
  511. * @param behavior defines the behavior to attach
  512. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  513. * @returns the current Node
  514. */
  515. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  516. /**
  517. * Remove an attached behavior
  518. * @see http://doc.babylonjs.com/features/behaviour
  519. * @param behavior defines the behavior to attach
  520. * @returns the current Node
  521. */
  522. removeBehavior(behavior: Behavior<Node>): Node;
  523. /**
  524. * Gets the list of attached behaviors
  525. * @see http://doc.babylonjs.com/features/behaviour
  526. */
  527. readonly behaviors: Behavior<Node>[];
  528. /**
  529. * Gets an attached behavior by name
  530. * @param name defines the name of the behavior to look for
  531. * @see http://doc.babylonjs.com/features/behaviour
  532. * @returns null if behavior was not found else the requested behavior
  533. */
  534. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  535. /**
  536. * Returns the latest update of the World matrix
  537. * @returns a Matrix
  538. */
  539. getWorldMatrix(): Matrix;
  540. /** @hidden */
  541. _getWorldMatrixDeterminant(): number;
  542. /**
  543. * Returns directly the latest state of the mesh World matrix.
  544. * A Matrix is returned.
  545. */
  546. readonly worldMatrixFromCache: Matrix;
  547. /** @hidden */
  548. _initCache(): void;
  549. /** @hidden */
  550. updateCache(force?: boolean): void;
  551. /** @hidden */
  552. _updateCache(ignoreParentClass?: boolean): void;
  553. /** @hidden */
  554. _isSynchronized(): boolean;
  555. /** @hidden */
  556. _markSyncedWithParent(): void;
  557. /** @hidden */
  558. isSynchronizedWithParent(): boolean;
  559. /** @hidden */
  560. isSynchronized(): boolean;
  561. /**
  562. * Is this node ready to be used/rendered
  563. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  564. * @return true if the node is ready
  565. */
  566. isReady(completeCheck?: boolean): boolean;
  567. /**
  568. * Is this node enabled?
  569. * If the node has a parent, all ancestors will be checked and false will be returned if any are false (not enabled), otherwise will return true
  570. * @param checkAncestors indicates if this method should check the ancestors. The default is to check the ancestors. If set to false, the method will return the value of this node without checking ancestors
  571. * @return whether this node (and its parent) is enabled
  572. */
  573. isEnabled(checkAncestors?: boolean): boolean;
  574. /** @hidden */
  575. protected _syncParentEnabledState(): void;
  576. /**
  577. * Set the enabled state of this node
  578. * @param value defines the new enabled state
  579. */
  580. setEnabled(value: boolean): void;
  581. /**
  582. * Is this node a descendant of the given node?
  583. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  584. * @param ancestor defines the parent node to inspect
  585. * @returns a boolean indicating if this node is a descendant of the given node
  586. */
  587. isDescendantOf(ancestor: Node): boolean;
  588. /** @hidden */
  589. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  590. /**
  591. * Will return all nodes that have this node as ascendant
  592. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  593. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  594. * @return all children nodes of all types
  595. */
  596. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  597. /**
  598. * Get all child-meshes of this node
  599. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  600. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  601. * @returns an array of AbstractMesh
  602. */
  603. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  604. /**
  605. * Get all child-transformNodes of this node
  606. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  607. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  608. * @returns an array of TransformNode
  609. */
  610. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  611. /**
  612. * Get all direct children of this node
  613. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  614. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered (Default: true)
  615. * @returns an array of Node
  616. */
  617. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  618. /** @hidden */
  619. _setReady(state: boolean): void;
  620. /**
  621. * Get an animation by name
  622. * @param name defines the name of the animation to look for
  623. * @returns null if not found else the requested animation
  624. */
  625. getAnimationByName(name: string): Nullable<Animation>;
  626. /**
  627. * Creates an animation range for this node
  628. * @param name defines the name of the range
  629. * @param from defines the starting key
  630. * @param to defines the end key
  631. */
  632. createAnimationRange(name: string, from: number, to: number): void;
  633. /**
  634. * Delete a specific animation range
  635. * @param name defines the name of the range to delete
  636. * @param deleteFrames defines if animation frames from the range must be deleted as well
  637. */
  638. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  639. /**
  640. * Get an animation range by name
  641. * @param name defines the name of the animation range to look for
  642. * @returns null if not found else the requested animation range
  643. */
  644. getAnimationRange(name: string): Nullable<AnimationRange>;
  645. /**
  646. * Will start the animation sequence
  647. * @param name defines the range frames for animation sequence
  648. * @param loop defines if the animation should loop (false by default)
  649. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  650. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  651. * @returns the object created for this animation. If range does not exist, it will return null
  652. */
  653. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  654. /**
  655. * Serialize animation ranges into a JSON compatible object
  656. * @returns serialization object
  657. */
  658. serializeAnimationRanges(): any;
  659. /**
  660. * Computes the world matrix of the node
  661. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  662. * @returns the world matrix
  663. */
  664. computeWorldMatrix(force?: boolean): Matrix;
  665. /**
  666. * Releases resources associated with this node.
  667. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  668. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  669. */
  670. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  671. /**
  672. * Parse animation range data from a serialization object and store them into a given node
  673. * @param node defines where to store the animation ranges
  674. * @param parsedNode defines the serialization object to read data from
  675. * @param scene defines the hosting scene
  676. */
  677. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  678. }
  679. }
  680. declare module BABYLON {
  681. /**
  682. * Define an interface for all classes that will hold resources
  683. */
  684. interface IDisposable {
  685. /**
  686. * Releases all held resources
  687. */
  688. dispose(): void;
  689. }
  690. /**
  691. * This class is used by the onRenderingGroupObservable
  692. */
  693. class RenderingGroupInfo {
  694. /**
  695. * The Scene that being rendered
  696. */
  697. scene: Scene;
  698. /**
  699. * The camera currently used for the rendering pass
  700. */
  701. camera: Nullable<Camera>;
  702. /**
  703. * The ID of the renderingGroup being processed
  704. */
  705. renderingGroupId: number;
  706. }
  707. /** Interface defining initialization parameters for Scene class */
  708. interface SceneOptions {
  709. /**
  710. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  711. * It will improve performance when the number of geometries becomes important.
  712. */
  713. useGeometryUniqueIdsMap?: boolean;
  714. /**
  715. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  716. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  717. */
  718. useMaterialMeshMap?: boolean;
  719. /**
  720. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  721. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  722. */
  723. useClonedMeshhMap?: boolean;
  724. }
  725. /**
  726. * Represents a scene to be rendered by the engine.
  727. * @see http://doc.babylonjs.com/features/scene
  728. */
  729. class Scene extends AbstractScene implements IAnimatable {
  730. private static _uniqueIdCounter;
  731. /** The fog is deactivated */
  732. static readonly FOGMODE_NONE: number;
  733. /** The fog density is following an exponential function */
  734. static readonly FOGMODE_EXP: number;
  735. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  736. static readonly FOGMODE_EXP2: number;
  737. /** The fog density is following a linear function. */
  738. static readonly FOGMODE_LINEAR: number;
  739. /**
  740. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  741. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  742. */
  743. static MinDeltaTime: number;
  744. /**
  745. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  746. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  747. */
  748. static MaxDeltaTime: number;
  749. /**
  750. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  751. */
  752. autoClear: boolean;
  753. /**
  754. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  755. */
  756. autoClearDepthAndStencil: boolean;
  757. /**
  758. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  759. */
  760. clearColor: Color4;
  761. /**
  762. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  763. */
  764. ambientColor: Color3;
  765. /** @hidden */
  766. _environmentBRDFTexture: BaseTexture;
  767. /** @hidden */
  768. protected _environmentTexture: Nullable<BaseTexture>;
  769. /**
  770. * Texture used in all pbr material as the reflection texture.
  771. * As in the majority of the scene they are the same (exception for multi room and so on),
  772. * this is easier to reference from here than from all the materials.
  773. */
  774. /**
  775. * Texture used in all pbr material as the reflection texture.
  776. * As in the majority of the scene they are the same (exception for multi room and so on),
  777. * this is easier to set here than in all the materials.
  778. */
  779. environmentTexture: Nullable<BaseTexture>;
  780. /** @hidden */
  781. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  782. /**
  783. * Default image processing configuration used either in the rendering
  784. * Forward main pass or through the imageProcessingPostProcess if present.
  785. * As in the majority of the scene they are the same (exception for multi camera),
  786. * this is easier to reference from here than from all the materials and post process.
  787. *
  788. * No setter as we it is a shared configuration, you can set the values instead.
  789. */
  790. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  791. private _forceWireframe;
  792. /**
  793. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  794. */
  795. forceWireframe: boolean;
  796. private _forcePointsCloud;
  797. /**
  798. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  799. */
  800. forcePointsCloud: boolean;
  801. /**
  802. * Gets or sets the active clipplane 1
  803. */
  804. clipPlane: Nullable<Plane>;
  805. /**
  806. * Gets or sets the active clipplane 2
  807. */
  808. clipPlane2: Nullable<Plane>;
  809. /**
  810. * Gets or sets the active clipplane 3
  811. */
  812. clipPlane3: Nullable<Plane>;
  813. /**
  814. * Gets or sets the active clipplane 4
  815. */
  816. clipPlane4: Nullable<Plane>;
  817. /**
  818. * Gets or sets a boolean indicating if animations are enabled
  819. */
  820. animationsEnabled: boolean;
  821. private _animationPropertiesOverride;
  822. /**
  823. * Gets or sets the animation properties override
  824. */
  825. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  826. /**
  827. * Gets or sets a boolean indicating if a constant deltatime has to be used
  828. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  829. */
  830. useConstantAnimationDeltaTime: boolean;
  831. /**
  832. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  833. * Please note that it requires to run a ray cast through the scene on every frame
  834. */
  835. constantlyUpdateMeshUnderPointer: boolean;
  836. /**
  837. * Defines the HTML cursor to use when hovering over interactive elements
  838. */
  839. hoverCursor: string;
  840. /**
  841. * Defines the HTML default cursor to use (empty by default)
  842. */
  843. defaultCursor: string;
  844. /**
  845. * This is used to call preventDefault() on pointer down
  846. * in order to block unwanted artifacts like system double clicks
  847. */
  848. preventDefaultOnPointerDown: boolean;
  849. /**
  850. * This is used to call preventDefault() on pointer up
  851. * in order to block unwanted artifacts like system double clicks
  852. */
  853. preventDefaultOnPointerUp: boolean;
  854. /**
  855. * Gets or sets user defined metadata
  856. */
  857. metadata: any;
  858. /**
  859. * For internal use only. Please do not use.
  860. */
  861. reservedDataStore: any;
  862. /**
  863. * Gets the name of the plugin used to load this scene (null by default)
  864. */
  865. loadingPluginName: string;
  866. /**
  867. * Use this array to add regular expressions used to disable offline support for specific urls
  868. */
  869. disableOfflineSupportExceptionRules: RegExp[];
  870. /**
  871. * An event triggered when the scene is disposed.
  872. */
  873. onDisposeObservable: Observable<Scene>;
  874. private _onDisposeObserver;
  875. /** Sets a function to be executed when this scene is disposed. */
  876. onDispose: () => void;
  877. /**
  878. * An event triggered before rendering the scene (right after animations and physics)
  879. */
  880. onBeforeRenderObservable: Observable<Scene>;
  881. private _onBeforeRenderObserver;
  882. /** Sets a function to be executed before rendering this scene */
  883. beforeRender: Nullable<() => void>;
  884. /**
  885. * An event triggered after rendering the scene
  886. */
  887. onAfterRenderObservable: Observable<Scene>;
  888. private _onAfterRenderObserver;
  889. /** Sets a function to be executed after rendering this scene */
  890. afterRender: Nullable<() => void>;
  891. /**
  892. * An event triggered before animating the scene
  893. */
  894. onBeforeAnimationsObservable: Observable<Scene>;
  895. /**
  896. * An event triggered after animations processing
  897. */
  898. onAfterAnimationsObservable: Observable<Scene>;
  899. /**
  900. * An event triggered before draw calls are ready to be sent
  901. */
  902. onBeforeDrawPhaseObservable: Observable<Scene>;
  903. /**
  904. * An event triggered after draw calls have been sent
  905. */
  906. onAfterDrawPhaseObservable: Observable<Scene>;
  907. /**
  908. * An event triggered when the scene is ready
  909. */
  910. onReadyObservable: Observable<Scene>;
  911. /**
  912. * An event triggered before rendering a camera
  913. */
  914. onBeforeCameraRenderObservable: Observable<Camera>;
  915. private _onBeforeCameraRenderObserver;
  916. /** Sets a function to be executed before rendering a camera*/
  917. beforeCameraRender: () => void;
  918. /**
  919. * An event triggered after rendering a camera
  920. */
  921. onAfterCameraRenderObservable: Observable<Camera>;
  922. private _onAfterCameraRenderObserver;
  923. /** Sets a function to be executed after rendering a camera*/
  924. afterCameraRender: () => void;
  925. /**
  926. * An event triggered when active meshes evaluation is about to start
  927. */
  928. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  929. /**
  930. * An event triggered when active meshes evaluation is done
  931. */
  932. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  933. /**
  934. * An event triggered when particles rendering is about to start
  935. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  936. */
  937. onBeforeParticlesRenderingObservable: Observable<Scene>;
  938. /**
  939. * An event triggered when particles rendering is done
  940. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  941. */
  942. onAfterParticlesRenderingObservable: Observable<Scene>;
  943. /**
  944. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  945. */
  946. onDataLoadedObservable: Observable<Scene>;
  947. /**
  948. * An event triggered when a camera is created
  949. */
  950. onNewCameraAddedObservable: Observable<Camera>;
  951. /**
  952. * An event triggered when a camera is removed
  953. */
  954. onCameraRemovedObservable: Observable<Camera>;
  955. /**
  956. * An event triggered when a light is created
  957. */
  958. onNewLightAddedObservable: Observable<Light>;
  959. /**
  960. * An event triggered when a light is removed
  961. */
  962. onLightRemovedObservable: Observable<Light>;
  963. /**
  964. * An event triggered when a geometry is created
  965. */
  966. onNewGeometryAddedObservable: Observable<Geometry>;
  967. /**
  968. * An event triggered when a geometry is removed
  969. */
  970. onGeometryRemovedObservable: Observable<Geometry>;
  971. /**
  972. * An event triggered when a transform node is created
  973. */
  974. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  975. /**
  976. * An event triggered when a transform node is removed
  977. */
  978. onTransformNodeRemovedObservable: Observable<TransformNode>;
  979. /**
  980. * An event triggered when a mesh is created
  981. */
  982. onNewMeshAddedObservable: Observable<AbstractMesh>;
  983. /**
  984. * An event triggered when a mesh is removed
  985. */
  986. onMeshRemovedObservable: Observable<AbstractMesh>;
  987. /**
  988. * An event triggered when a material is created
  989. */
  990. onNewMaterialAddedObservable: Observable<Material>;
  991. /**
  992. * An event triggered when a material is removed
  993. */
  994. onMaterialRemovedObservable: Observable<Material>;
  995. /**
  996. * An event triggered when a texture is created
  997. */
  998. onNewTextureAddedObservable: Observable<BaseTexture>;
  999. /**
  1000. * An event triggered when a texture is removed
  1001. */
  1002. onTextureRemovedObservable: Observable<BaseTexture>;
  1003. /**
  1004. * An event triggered when render targets are about to be rendered
  1005. * Can happen multiple times per frame.
  1006. */
  1007. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  1008. /**
  1009. * An event triggered when render targets were rendered.
  1010. * Can happen multiple times per frame.
  1011. */
  1012. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  1013. /**
  1014. * An event triggered before calculating deterministic simulation step
  1015. */
  1016. onBeforeStepObservable: Observable<Scene>;
  1017. /**
  1018. * An event triggered after calculating deterministic simulation step
  1019. */
  1020. onAfterStepObservable: Observable<Scene>;
  1021. /**
  1022. * An event triggered when the activeCamera property is updated
  1023. */
  1024. onActiveCameraChanged: Observable<Scene>;
  1025. /**
  1026. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  1027. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  1028. * If you wish to register an Observer only for a given set of renderingGroup, use the mask with a combination of the renderingGroup index elevated to the power of two (1 for renderingGroup 0, 2 for renderingrOup1, 4 for 2 and 8 for 3)
  1029. */
  1030. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  1031. /**
  1032. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  1033. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  1034. * If you wish to register an Observer only for a given set of renderingGroup, use the mask with a combination of the renderingGroup index elevated to the power of two (1 for renderingGroup 0, 2 for renderingrOup1, 4 for 2 and 8 for 3)
  1035. */
  1036. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  1037. /**
  1038. * This Observable will when a mesh has been imported into the scene.
  1039. */
  1040. onMeshImportedObservable: Observable<AbstractMesh>;
  1041. private _registeredForLateAnimationBindings;
  1042. /**
  1043. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  1044. */
  1045. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  1046. /**
  1047. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  1048. */
  1049. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  1050. /**
  1051. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  1052. */
  1053. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  1054. private _onPointerMove;
  1055. private _onPointerDown;
  1056. private _onPointerUp;
  1057. /** Callback called when a pointer move is detected */
  1058. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  1059. /** Callback called when a pointer down is detected */
  1060. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  1061. /** Callback called when a pointer up is detected */
  1062. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  1063. /** Callback called when a pointer pick is detected */
  1064. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  1065. /**
  1066. * This observable event is triggered when any ponter event is triggered. It is registered during Scene.attachControl() and it is called BEFORE the 3D engine process anything (mesh/sprite picking for instance).
  1067. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  1068. */
  1069. onPrePointerObservable: Observable<PointerInfoPre>;
  1070. /**
  1071. * Observable event triggered each time an input event is received from the rendering canvas
  1072. */
  1073. onPointerObservable: Observable<PointerInfo>;
  1074. /**
  1075. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  1076. */
  1077. readonly unTranslatedPointer: Vector2;
  1078. /** The distance in pixel that you have to move to prevent some events */
  1079. static DragMovementThreshold: number;
  1080. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  1081. static LongPressDelay: number;
  1082. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  1083. static DoubleClickDelay: number;
  1084. /** If you need to check double click without raising a single click at first click, enable this flag */
  1085. static ExclusiveDoubleClickMode: boolean;
  1086. private _initClickEvent;
  1087. private _initActionManager;
  1088. private _delayedSimpleClick;
  1089. private _delayedSimpleClickTimeout;
  1090. private _previousDelayedSimpleClickTimeout;
  1091. private _meshPickProceed;
  1092. private _previousButtonPressed;
  1093. private _currentPickResult;
  1094. private _previousPickResult;
  1095. private _totalPointersPressed;
  1096. private _doubleClickOccured;
  1097. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  1098. cameraToUseForPointers: Nullable<Camera>;
  1099. private _pointerX;
  1100. private _pointerY;
  1101. private _unTranslatedPointerX;
  1102. private _unTranslatedPointerY;
  1103. private _startingPointerPosition;
  1104. private _previousStartingPointerPosition;
  1105. private _startingPointerTime;
  1106. private _previousStartingPointerTime;
  1107. private _pointerCaptures;
  1108. private _timeAccumulator;
  1109. private _currentStepId;
  1110. private _currentInternalStep;
  1111. /** @hidden */
  1112. _mirroredCameraPosition: Nullable<Vector3>;
  1113. /**
  1114. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  1115. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  1116. */
  1117. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  1118. /**
  1119. * Observable event triggered each time an keyboard event is received from the hosting window
  1120. */
  1121. onKeyboardObservable: Observable<KeyboardInfo>;
  1122. private _onKeyDown;
  1123. private _onKeyUp;
  1124. private _onCanvasFocusObserver;
  1125. private _onCanvasBlurObserver;
  1126. private _useRightHandedSystem;
  1127. /**
  1128. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  1129. */
  1130. useRightHandedSystem: boolean;
  1131. /**
  1132. * Sets the step Id used by deterministic lock step
  1133. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1134. * @param newStepId defines the step Id
  1135. */
  1136. setStepId(newStepId: number): void;
  1137. /**
  1138. * Gets the step Id used by deterministic lock step
  1139. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1140. * @returns the step Id
  1141. */
  1142. getStepId(): number;
  1143. /**
  1144. * Gets the internal step used by deterministic lock step
  1145. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1146. * @returns the internal step
  1147. */
  1148. getInternalStep(): number;
  1149. private _fogEnabled;
  1150. /**
  1151. * Gets or sets a boolean indicating if fog is enabled on this scene
  1152. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1153. * (Default is true)
  1154. */
  1155. fogEnabled: boolean;
  1156. private _fogMode;
  1157. /**
  1158. * Gets or sets the fog mode to use
  1159. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1160. * | mode | value |
  1161. * | --- | --- |
  1162. * | FOGMODE_NONE | 0 |
  1163. * | FOGMODE_EXP | 1 |
  1164. * | FOGMODE_EXP2 | 2 |
  1165. * | FOGMODE_LINEAR | 3 |
  1166. */
  1167. fogMode: number;
  1168. /**
  1169. * Gets or sets the fog color to use
  1170. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1171. * (Default is Color3(0.2, 0.2, 0.3))
  1172. */
  1173. fogColor: Color3;
  1174. /**
  1175. * Gets or sets the fog density to use
  1176. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1177. * (Default is 0.1)
  1178. */
  1179. fogDensity: number;
  1180. /**
  1181. * Gets or sets the fog start distance to use
  1182. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1183. * (Default is 0)
  1184. */
  1185. fogStart: number;
  1186. /**
  1187. * Gets or sets the fog end distance to use
  1188. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1189. * (Default is 1000)
  1190. */
  1191. fogEnd: number;
  1192. private _shadowsEnabled;
  1193. /**
  1194. * Gets or sets a boolean indicating if shadows are enabled on this scene
  1195. */
  1196. shadowsEnabled: boolean;
  1197. private _lightsEnabled;
  1198. /**
  1199. * Gets or sets a boolean indicating if lights are enabled on this scene
  1200. */
  1201. lightsEnabled: boolean;
  1202. /** All of the active cameras added to this scene. */
  1203. activeCameras: Camera[];
  1204. private _activeCamera;
  1205. /** Gets or sets the current active camera */
  1206. activeCamera: Nullable<Camera>;
  1207. private _defaultMaterial;
  1208. /** The default material used on meshes when no material is affected */
  1209. /** The default material used on meshes when no material is affected */
  1210. defaultMaterial: Material;
  1211. private _texturesEnabled;
  1212. /**
  1213. * Gets or sets a boolean indicating if textures are enabled on this scene
  1214. */
  1215. texturesEnabled: boolean;
  1216. /**
  1217. * Gets or sets a boolean indicating if particles are enabled on this scene
  1218. */
  1219. particlesEnabled: boolean;
  1220. /**
  1221. * Gets or sets a boolean indicating if sprites are enabled on this scene
  1222. */
  1223. spritesEnabled: boolean;
  1224. private _skeletonsEnabled;
  1225. /**
  1226. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  1227. */
  1228. skeletonsEnabled: boolean;
  1229. /**
  1230. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  1231. */
  1232. lensFlaresEnabled: boolean;
  1233. /**
  1234. * Gets or sets a boolean indicating if collisions are enabled on this scene
  1235. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1236. */
  1237. collisionsEnabled: boolean;
  1238. private _workerCollisions;
  1239. /** @hidden */
  1240. collisionCoordinator: ICollisionCoordinator;
  1241. /**
  1242. * Defines the gravity applied to this scene (used only for collisions)
  1243. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1244. */
  1245. gravity: Vector3;
  1246. /**
  1247. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  1248. */
  1249. postProcessesEnabled: boolean;
  1250. /**
  1251. * The list of postprocesses added to the scene
  1252. */
  1253. postProcesses: PostProcess[];
  1254. /**
  1255. * Gets the current postprocess manager
  1256. */
  1257. postProcessManager: PostProcessManager;
  1258. /**
  1259. * Gets or sets a boolean indicating if render targets are enabled on this scene
  1260. */
  1261. renderTargetsEnabled: boolean;
  1262. /**
  1263. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  1264. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  1265. */
  1266. dumpNextRenderTargets: boolean;
  1267. /**
  1268. * The list of user defined render targets added to the scene
  1269. */
  1270. customRenderTargets: RenderTargetTexture[];
  1271. /**
  1272. * Defines if texture loading must be delayed
  1273. * If true, textures will only be loaded when they need to be rendered
  1274. */
  1275. useDelayedTextureLoading: boolean;
  1276. /**
  1277. * Gets the list of meshes imported to the scene through SceneLoader
  1278. */
  1279. importedMeshesFiles: String[];
  1280. /**
  1281. * Gets or sets a boolean indicating if probes are enabled on this scene
  1282. */
  1283. probesEnabled: boolean;
  1284. /**
  1285. * Gets or sets the current offline provider to use to store scene data
  1286. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1287. */
  1288. offlineProvider: IOfflineProvider;
  1289. /**
  1290. * Gets or sets the action manager associated with the scene
  1291. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1292. */
  1293. actionManager: ActionManager;
  1294. private _meshesForIntersections;
  1295. /**
  1296. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  1297. */
  1298. proceduralTexturesEnabled: boolean;
  1299. private _engine;
  1300. private _totalVertices;
  1301. /** @hidden */
  1302. _activeIndices: PerfCounter;
  1303. /** @hidden */
  1304. _activeParticles: PerfCounter;
  1305. /** @hidden */
  1306. _activeBones: PerfCounter;
  1307. private _animationRatio;
  1308. private _animationTimeLast;
  1309. private _animationTime;
  1310. /**
  1311. * Gets or sets a general scale for animation speed
  1312. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  1313. */
  1314. animationTimeScale: number;
  1315. /** @hidden */
  1316. _cachedMaterial: Nullable<Material>;
  1317. /** @hidden */
  1318. _cachedEffect: Nullable<Effect>;
  1319. /** @hidden */
  1320. _cachedVisibility: Nullable<number>;
  1321. private _renderId;
  1322. private _frameId;
  1323. private _executeWhenReadyTimeoutId;
  1324. private _intermediateRendering;
  1325. private _viewUpdateFlag;
  1326. private _projectionUpdateFlag;
  1327. private _alternateViewUpdateFlag;
  1328. private _alternateProjectionUpdateFlag;
  1329. /** @hidden */
  1330. _toBeDisposed: Nullable<IDisposable>[];
  1331. private _activeRequests;
  1332. private _pendingData;
  1333. private _isDisposed;
  1334. /**
  1335. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  1336. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  1337. */
  1338. dispatchAllSubMeshesOfActiveMeshes: boolean;
  1339. private _activeMeshes;
  1340. private _processedMaterials;
  1341. private _renderTargets;
  1342. /** @hidden */
  1343. _activeParticleSystems: SmartArray<IParticleSystem>;
  1344. private _activeSkeletons;
  1345. private _softwareSkinnedMeshes;
  1346. private _renderingManager;
  1347. /** @hidden */
  1348. _activeAnimatables: Animatable[];
  1349. private _transformMatrix;
  1350. private _sceneUbo;
  1351. private _alternateSceneUbo;
  1352. private _pickWithRayInverseMatrix;
  1353. private _viewMatrix;
  1354. private _projectionMatrix;
  1355. private _alternateViewMatrix;
  1356. private _alternateProjectionMatrix;
  1357. private _alternateTransformMatrix;
  1358. private _useAlternateCameraConfiguration;
  1359. private _alternateRendering;
  1360. private _wheelEventName;
  1361. /** @hidden */
  1362. _forcedViewPosition: Nullable<Vector3>;
  1363. /** @hidden */
  1364. readonly _isAlternateRenderingEnabled: boolean;
  1365. private _frustumPlanes;
  1366. /**
  1367. * Gets the list of frustum planes (built from the active camera)
  1368. */
  1369. readonly frustumPlanes: Plane[];
  1370. /**
  1371. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  1372. * This is useful if there are more lights that the maximum simulteanous authorized
  1373. */
  1374. requireLightSorting: boolean;
  1375. /** @hidden */
  1376. readonly useMaterialMeshMap: boolean;
  1377. /** @hidden */
  1378. readonly useClonedMeshhMap: boolean;
  1379. private _pointerOverMesh;
  1380. private _pickedDownMesh;
  1381. private _pickedUpMesh;
  1382. private _externalData;
  1383. private _uid;
  1384. /**
  1385. * @hidden
  1386. * Backing store of defined scene components.
  1387. */
  1388. _components: ISceneComponent[];
  1389. /**
  1390. * @hidden
  1391. * Backing store of defined scene components.
  1392. */
  1393. _serializableComponents: ISceneSerializableComponent[];
  1394. /**
  1395. * List of components to register on the next registration step.
  1396. */
  1397. private _transientComponents;
  1398. /**
  1399. * Registers the transient components if needed.
  1400. */
  1401. private _registerTransientComponents;
  1402. /**
  1403. * @hidden
  1404. * Add a component to the scene.
  1405. * Note that the ccomponent could be registered on th next frame if this is called after
  1406. * the register component stage.
  1407. * @param component Defines the component to add to the scene
  1408. */
  1409. _addComponent(component: ISceneComponent): void;
  1410. /**
  1411. * @hidden
  1412. * Gets a component from the scene.
  1413. * @param name defines the name of the component to retrieve
  1414. * @returns the component or null if not present
  1415. */
  1416. _getComponent(name: string): Nullable<ISceneComponent>;
  1417. /**
  1418. * @hidden
  1419. * Defines the actions happening before camera updates.
  1420. */
  1421. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  1422. /**
  1423. * @hidden
  1424. * Defines the actions happening before clear the canvas.
  1425. */
  1426. _beforeClearStage: Stage<SimpleStageAction>;
  1427. /**
  1428. * @hidden
  1429. * Defines the actions when collecting render targets for the frame.
  1430. */
  1431. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  1432. /**
  1433. * @hidden
  1434. * Defines the actions happening for one camera in the frame.
  1435. */
  1436. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  1437. /**
  1438. * @hidden
  1439. * Defines the actions happening during the per mesh ready checks.
  1440. */
  1441. _isReadyForMeshStage: Stage<MeshStageAction>;
  1442. /**
  1443. * @hidden
  1444. * Defines the actions happening before evaluate active mesh checks.
  1445. */
  1446. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  1447. /**
  1448. * @hidden
  1449. * Defines the actions happening during the evaluate sub mesh checks.
  1450. */
  1451. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  1452. /**
  1453. * @hidden
  1454. * Defines the actions happening during the active mesh stage.
  1455. */
  1456. _activeMeshStage: Stage<ActiveMeshStageAction>;
  1457. /**
  1458. * @hidden
  1459. * Defines the actions happening during the per camera render target step.
  1460. */
  1461. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  1462. /**
  1463. * @hidden
  1464. * Defines the actions happening just before the active camera is drawing.
  1465. */
  1466. _beforeCameraDrawStage: Stage<CameraStageAction>;
  1467. /**
  1468. * @hidden
  1469. * Defines the actions happening just before a render target is drawing.
  1470. */
  1471. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  1472. /**
  1473. * @hidden
  1474. * Defines the actions happening just before a rendering group is drawing.
  1475. */
  1476. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  1477. /**
  1478. * @hidden
  1479. * Defines the actions happening just before a mesh is drawing.
  1480. */
  1481. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  1482. /**
  1483. * @hidden
  1484. * Defines the actions happening just after a mesh has been drawn.
  1485. */
  1486. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  1487. /**
  1488. * @hidden
  1489. * Defines the actions happening just after a rendering group has been drawn.
  1490. */
  1491. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  1492. /**
  1493. * @hidden
  1494. * Defines the actions happening just after the active camera has been drawn.
  1495. */
  1496. _afterCameraDrawStage: Stage<CameraStageAction>;
  1497. /**
  1498. * @hidden
  1499. * Defines the actions happening just after a render target has been drawn.
  1500. */
  1501. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  1502. /**
  1503. * @hidden
  1504. * Defines the actions happening just after rendering all cameras and computing intersections.
  1505. */
  1506. _afterRenderStage: Stage<SimpleStageAction>;
  1507. /**
  1508. * @hidden
  1509. * Defines the actions happening when a pointer move event happens.
  1510. */
  1511. _pointerMoveStage: Stage<PointerMoveStageAction>;
  1512. /**
  1513. * @hidden
  1514. * Defines the actions happening when a pointer down event happens.
  1515. */
  1516. _pointerDownStage: Stage<PointerUpDownStageAction>;
  1517. /**
  1518. * @hidden
  1519. * Defines the actions happening when a pointer up event happens.
  1520. */
  1521. _pointerUpStage: Stage<PointerUpDownStageAction>;
  1522. /**
  1523. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  1524. */
  1525. private geometriesByUniqueId;
  1526. /**
  1527. * Creates a new Scene
  1528. * @param engine defines the engine to use to render this scene
  1529. */
  1530. constructor(engine: Engine, options?: SceneOptions);
  1531. private _defaultMeshCandidates;
  1532. /**
  1533. * @hidden
  1534. */
  1535. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  1536. private _defaultSubMeshCandidates;
  1537. /**
  1538. * @hidden
  1539. */
  1540. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  1541. /**
  1542. * Sets the default candidate providers for the scene.
  1543. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  1544. * and getCollidingSubMeshCandidates to their default function
  1545. */
  1546. setDefaultCandidateProviders(): void;
  1547. /**
  1548. * Gets a boolean indicating if collisions are processed on a web worker
  1549. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#web-worker-based-collision-system-since-21
  1550. */
  1551. workerCollisions: boolean;
  1552. /**
  1553. * Gets the mesh that is currently under the pointer
  1554. */
  1555. readonly meshUnderPointer: Nullable<AbstractMesh>;
  1556. /**
  1557. * Gets the current on-screen X position of the pointer
  1558. */
  1559. readonly pointerX: number;
  1560. /**
  1561. * Gets the current on-screen Y position of the pointer
  1562. */
  1563. readonly pointerY: number;
  1564. /**
  1565. * Gets the cached material (ie. the latest rendered one)
  1566. * @returns the cached material
  1567. */
  1568. getCachedMaterial(): Nullable<Material>;
  1569. /**
  1570. * Gets the cached effect (ie. the latest rendered one)
  1571. * @returns the cached effect
  1572. */
  1573. getCachedEffect(): Nullable<Effect>;
  1574. /**
  1575. * Gets the cached visibility state (ie. the latest rendered one)
  1576. * @returns the cached visibility state
  1577. */
  1578. getCachedVisibility(): Nullable<number>;
  1579. /**
  1580. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  1581. * @param material defines the current material
  1582. * @param effect defines the current effect
  1583. * @param visibility defines the current visibility state
  1584. * @returns true if one parameter is not cached
  1585. */
  1586. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  1587. /**
  1588. * Gets the engine associated with the scene
  1589. * @returns an Engine
  1590. */
  1591. getEngine(): Engine;
  1592. /**
  1593. * Gets the total number of vertices rendered per frame
  1594. * @returns the total number of vertices rendered per frame
  1595. */
  1596. getTotalVertices(): number;
  1597. /**
  1598. * Gets the performance counter for total vertices
  1599. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1600. */
  1601. readonly totalVerticesPerfCounter: PerfCounter;
  1602. /**
  1603. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  1604. * @returns the total number of active indices rendered per frame
  1605. */
  1606. getActiveIndices(): number;
  1607. /**
  1608. * Gets the performance counter for active indices
  1609. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1610. */
  1611. readonly totalActiveIndicesPerfCounter: PerfCounter;
  1612. /**
  1613. * Gets the total number of active particles rendered per frame
  1614. * @returns the total number of active particles rendered per frame
  1615. */
  1616. getActiveParticles(): number;
  1617. /**
  1618. * Gets the performance counter for active particles
  1619. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1620. */
  1621. readonly activeParticlesPerfCounter: PerfCounter;
  1622. /**
  1623. * Gets the total number of active bones rendered per frame
  1624. * @returns the total number of active bones rendered per frame
  1625. */
  1626. getActiveBones(): number;
  1627. /**
  1628. * Gets the performance counter for active bones
  1629. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1630. */
  1631. readonly activeBonesPerfCounter: PerfCounter;
  1632. /**
  1633. * Gets the array of active meshes
  1634. * @returns an array of AbstractMesh
  1635. */
  1636. getActiveMeshes(): SmartArray<AbstractMesh>;
  1637. /**
  1638. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  1639. * @returns a number
  1640. */
  1641. getAnimationRatio(): number;
  1642. /**
  1643. * Gets an unique Id for the current render phase
  1644. * @returns a number
  1645. */
  1646. getRenderId(): number;
  1647. /**
  1648. * Gets an unique Id for the current frame
  1649. * @returns a number
  1650. */
  1651. getFrameId(): number;
  1652. /** Call this function if you want to manually increment the render Id*/
  1653. incrementRenderId(): void;
  1654. private _updatePointerPosition;
  1655. private _createUbo;
  1656. private _createAlternateUbo;
  1657. private _setRayOnPointerInfo;
  1658. /**
  1659. * Use this method to simulate a pointer move on a mesh
  1660. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1661. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1662. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1663. * @returns the current scene
  1664. */
  1665. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1666. private _processPointerMove;
  1667. private _checkPrePointerObservable;
  1668. /**
  1669. * Use this method to simulate a pointer down on a mesh
  1670. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1671. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1672. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1673. * @returns the current scene
  1674. */
  1675. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1676. private _processPointerDown;
  1677. /**
  1678. * Use this method to simulate a pointer up on a mesh
  1679. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1680. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1681. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1682. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  1683. * @returns the current scene
  1684. */
  1685. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  1686. private _processPointerUp;
  1687. /**
  1688. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  1689. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  1690. * @returns true if the pointer was captured
  1691. */
  1692. isPointerCaptured(pointerId?: number): boolean;
  1693. /** @hidden */
  1694. _isPointerSwiping(): boolean;
  1695. /**
  1696. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  1697. * @param attachUp defines if you want to attach events to pointerup
  1698. * @param attachDown defines if you want to attach events to pointerdown
  1699. * @param attachMove defines if you want to attach events to pointermove
  1700. */
  1701. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  1702. /** Detaches all event handlers*/
  1703. detachControl(): void;
  1704. /**
  1705. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  1706. * Delay loaded resources are not taking in account
  1707. * @return true if all required resources are ready
  1708. */
  1709. isReady(): boolean;
  1710. /** Resets all cached information relative to material (including effect and visibility) */
  1711. resetCachedMaterial(): void;
  1712. /**
  1713. * Registers a function to be called before every frame render
  1714. * @param func defines the function to register
  1715. */
  1716. registerBeforeRender(func: () => void): void;
  1717. /**
  1718. * Unregisters a function called before every frame render
  1719. * @param func defines the function to unregister
  1720. */
  1721. unregisterBeforeRender(func: () => void): void;
  1722. /**
  1723. * Registers a function to be called after every frame render
  1724. * @param func defines the function to register
  1725. */
  1726. registerAfterRender(func: () => void): void;
  1727. /**
  1728. * Unregisters a function called after every frame render
  1729. * @param func defines the function to unregister
  1730. */
  1731. unregisterAfterRender(func: () => void): void;
  1732. private _executeOnceBeforeRender;
  1733. /**
  1734. * The provided function will run before render once and will be disposed afterwards.
  1735. * A timeout delay can be provided so that the function will be executed in N ms.
  1736. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  1737. * @param func The function to be executed.
  1738. * @param timeout optional delay in ms
  1739. */
  1740. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  1741. /** @hidden */
  1742. _addPendingData(data: any): void;
  1743. /** @hidden */
  1744. _removePendingData(data: any): void;
  1745. /**
  1746. * Returns the number of items waiting to be loaded
  1747. * @returns the number of items waiting to be loaded
  1748. */
  1749. getWaitingItemsCount(): number;
  1750. /**
  1751. * Returns a boolean indicating if the scene is still loading data
  1752. */
  1753. readonly isLoading: boolean;
  1754. /**
  1755. * Registers a function to be executed when the scene is ready
  1756. * @param {Function} func - the function to be executed
  1757. */
  1758. executeWhenReady(func: () => void): void;
  1759. /**
  1760. * Returns a promise that resolves when the scene is ready
  1761. * @returns A promise that resolves when the scene is ready
  1762. */
  1763. whenReadyAsync(): Promise<void>;
  1764. /** @hidden */
  1765. _checkIsReady(): void;
  1766. /**
  1767. * Will start the animation sequence of a given target
  1768. * @param target defines the target
  1769. * @param from defines from which frame should animation start
  1770. * @param to defines until which frame should animation run.
  1771. * @param weight defines the weight to apply to the animation (1.0 by default)
  1772. * @param loop defines if the animation loops
  1773. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1774. * @param onAnimationEnd defines the function to be executed when the animation ends
  1775. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1776. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  1777. * @param onAnimationLoop defines the callback to call when an animation loops
  1778. * @returns the animatable object created for this animation
  1779. */
  1780. beginWeightedAnimation(target: any, from: number, to: number, weight?: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  1781. /**
  1782. * Will start the animation sequence of a given target
  1783. * @param target defines the target
  1784. * @param from defines from which frame should animation start
  1785. * @param to defines until which frame should animation run.
  1786. * @param loop defines if the animation loops
  1787. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1788. * @param onAnimationEnd defines the function to be executed when the animation ends
  1789. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1790. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  1791. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  1792. * @param onAnimationLoop defines the callback to call when an animation loops
  1793. * @returns the animatable object created for this animation
  1794. */
  1795. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  1796. /**
  1797. * Will start the animation sequence of a given target and its hierarchy
  1798. * @param target defines the target
  1799. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  1800. * @param from defines from which frame should animation start
  1801. * @param to defines until which frame should animation run.
  1802. * @param loop defines if the animation loops
  1803. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1804. * @param onAnimationEnd defines the function to be executed when the animation ends
  1805. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1806. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  1807. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  1808. * @param onAnimationLoop defines the callback to call when an animation loops
  1809. * @returns the list of created animatables
  1810. */
  1811. beginHierarchyAnimation(target: any, directDescendantsOnly: boolean, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable[];
  1812. /**
  1813. * Begin a new animation on a given node
  1814. * @param target defines the target where the animation will take place
  1815. * @param animations defines the list of animations to start
  1816. * @param from defines the initial value
  1817. * @param to defines the final value
  1818. * @param loop defines if you want animation to loop (off by default)
  1819. * @param speedRatio defines the speed ratio to apply to all animations
  1820. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1821. * @param onAnimationLoop defines the callback to call when an animation loops
  1822. * @returns the list of created animatables
  1823. */
  1824. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  1825. /**
  1826. * Begin a new animation on a given node and its hierarchy
  1827. * @param target defines the root node where the animation will take place
  1828. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  1829. * @param animations defines the list of animations to start
  1830. * @param from defines the initial value
  1831. * @param to defines the final value
  1832. * @param loop defines if you want animation to loop (off by default)
  1833. * @param speedRatio defines the speed ratio to apply to all animations
  1834. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1835. * @param onAnimationLoop defines the callback to call when an animation loops
  1836. * @returns the list of animatables created for all nodes
  1837. */
  1838. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  1839. /**
  1840. * Gets the animatable associated with a specific target
  1841. * @param target defines the target of the animatable
  1842. * @returns the required animatable if found
  1843. */
  1844. getAnimatableByTarget(target: any): Nullable<Animatable>;
  1845. /**
  1846. * Gets all animatables associated with a given target
  1847. * @param target defines the target to look animatables for
  1848. * @returns an array of Animatables
  1849. */
  1850. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  1851. /**
  1852. * Gets all animatable attached to the scene
  1853. */
  1854. readonly animatables: Animatable[];
  1855. /**
  1856. * Will stop the animation of the given target
  1857. * @param target - the target
  1858. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  1859. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  1860. */
  1861. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  1862. /**
  1863. * Stops and removes all animations that have been applied to the scene
  1864. */
  1865. stopAllAnimations(): void;
  1866. private _animate;
  1867. /** @hidden */
  1868. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  1869. private _processLateAnimationBindingsForMatrices;
  1870. private _processLateAnimationBindingsForQuaternions;
  1871. private _processLateAnimationBindings;
  1872. /** @hidden */
  1873. _switchToAlternateCameraConfiguration(active: boolean): void;
  1874. /**
  1875. * Gets the current view matrix
  1876. * @returns a Matrix
  1877. */
  1878. getViewMatrix(): Matrix;
  1879. /**
  1880. * Gets the current projection matrix
  1881. * @returns a Matrix
  1882. */
  1883. getProjectionMatrix(): Matrix;
  1884. /**
  1885. * Gets the current transform matrix
  1886. * @returns a Matrix made of View * Projection
  1887. */
  1888. getTransformMatrix(): Matrix;
  1889. /**
  1890. * Sets the current transform matrix
  1891. * @param view defines the View matrix to use
  1892. * @param projection defines the Projection matrix to use
  1893. */
  1894. setTransformMatrix(view: Matrix, projection: Matrix): void;
  1895. /** @hidden */
  1896. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  1897. /**
  1898. * Gets the uniform buffer used to store scene data
  1899. * @returns a UniformBuffer
  1900. */
  1901. getSceneUniformBuffer(): UniformBuffer;
  1902. /**
  1903. * Gets an unique (relatively to the current scene) Id
  1904. * @returns an unique number for the scene
  1905. */
  1906. getUniqueId(): number;
  1907. /**
  1908. * Add a mesh to the list of scene's meshes
  1909. * @param newMesh defines the mesh to add
  1910. * @param recursive if all child meshes should also be added to the scene
  1911. */
  1912. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  1913. /**
  1914. * Remove a mesh for the list of scene's meshes
  1915. * @param toRemove defines the mesh to remove
  1916. * @param recursive if all child meshes should also be removed from the scene
  1917. * @returns the index where the mesh was in the mesh list
  1918. */
  1919. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  1920. /**
  1921. * Add a transform node to the list of scene's transform nodes
  1922. * @param newTransformNode defines the transform node to add
  1923. */
  1924. addTransformNode(newTransformNode: TransformNode): void;
  1925. /**
  1926. * Remove a transform node for the list of scene's transform nodes
  1927. * @param toRemove defines the transform node to remove
  1928. * @returns the index where the transform node was in the transform node list
  1929. */
  1930. removeTransformNode(toRemove: TransformNode): number;
  1931. /**
  1932. * Remove a skeleton for the list of scene's skeletons
  1933. * @param toRemove defines the skeleton to remove
  1934. * @returns the index where the skeleton was in the skeleton list
  1935. */
  1936. removeSkeleton(toRemove: Skeleton): number;
  1937. /**
  1938. * Remove a morph target for the list of scene's morph targets
  1939. * @param toRemove defines the morph target to remove
  1940. * @returns the index where the morph target was in the morph target list
  1941. */
  1942. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  1943. /**
  1944. * Remove a light for the list of scene's lights
  1945. * @param toRemove defines the light to remove
  1946. * @returns the index where the light was in the light list
  1947. */
  1948. removeLight(toRemove: Light): number;
  1949. /**
  1950. * Remove a camera for the list of scene's cameras
  1951. * @param toRemove defines the camera to remove
  1952. * @returns the index where the camera was in the camera list
  1953. */
  1954. removeCamera(toRemove: Camera): number;
  1955. /**
  1956. * Remove a particle system for the list of scene's particle systems
  1957. * @param toRemove defines the particle system to remove
  1958. * @returns the index where the particle system was in the particle system list
  1959. */
  1960. removeParticleSystem(toRemove: IParticleSystem): number;
  1961. /**
  1962. * Remove a animation for the list of scene's animations
  1963. * @param toRemove defines the animation to remove
  1964. * @returns the index where the animation was in the animation list
  1965. */
  1966. removeAnimation(toRemove: Animation): number;
  1967. /**
  1968. * Removes the given animation group from this scene.
  1969. * @param toRemove The animation group to remove
  1970. * @returns The index of the removed animation group
  1971. */
  1972. removeAnimationGroup(toRemove: AnimationGroup): number;
  1973. /**
  1974. * Removes the given multi-material from this scene.
  1975. * @param toRemove The multi-material to remove
  1976. * @returns The index of the removed multi-material
  1977. */
  1978. removeMultiMaterial(toRemove: MultiMaterial): number;
  1979. /**
  1980. * Removes the given material from this scene.
  1981. * @param toRemove The material to remove
  1982. * @returns The index of the removed material
  1983. */
  1984. removeMaterial(toRemove: Material): number;
  1985. /**
  1986. * Removes the given action manager from this scene.
  1987. * @param toRemove The action manager to remove
  1988. * @returns The index of the removed action manager
  1989. */
  1990. removeActionManager(toRemove: ActionManager): number;
  1991. /**
  1992. * Removes the given texture from this scene.
  1993. * @param toRemove The texture to remove
  1994. * @returns The index of the removed texture
  1995. */
  1996. removeTexture(toRemove: BaseTexture): number;
  1997. /**
  1998. * Adds the given light to this scene
  1999. * @param newLight The light to add
  2000. */
  2001. addLight(newLight: Light): void;
  2002. /**
  2003. * Sorts the list list based on light priorities
  2004. */
  2005. sortLightsByPriority(): void;
  2006. /**
  2007. * Adds the given camera to this scene
  2008. * @param newCamera The camera to add
  2009. */
  2010. addCamera(newCamera: Camera): void;
  2011. /**
  2012. * Adds the given skeleton to this scene
  2013. * @param newSkeleton The skeleton to add
  2014. */
  2015. addSkeleton(newSkeleton: Skeleton): void;
  2016. /**
  2017. * Adds the given particle system to this scene
  2018. * @param newParticleSystem The particle system to add
  2019. */
  2020. addParticleSystem(newParticleSystem: IParticleSystem): void;
  2021. /**
  2022. * Adds the given animation to this scene
  2023. * @param newAnimation The animation to add
  2024. */
  2025. addAnimation(newAnimation: Animation): void;
  2026. /**
  2027. * Adds the given animation group to this scene.
  2028. * @param newAnimationGroup The animation group to add
  2029. */
  2030. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  2031. /**
  2032. * Adds the given multi-material to this scene
  2033. * @param newMultiMaterial The multi-material to add
  2034. */
  2035. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  2036. /**
  2037. * Adds the given material to this scene
  2038. * @param newMaterial The material to add
  2039. */
  2040. addMaterial(newMaterial: Material): void;
  2041. /**
  2042. * Adds the given morph target to this scene
  2043. * @param newMorphTargetManager The morph target to add
  2044. */
  2045. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  2046. /**
  2047. * Adds the given geometry to this scene
  2048. * @param newGeometry The geometry to add
  2049. */
  2050. addGeometry(newGeometry: Geometry): void;
  2051. /**
  2052. * Adds the given action manager to this scene
  2053. * @param newActionManager The action manager to add
  2054. */
  2055. addActionManager(newActionManager: ActionManager): void;
  2056. /**
  2057. * Adds the given texture to this scene.
  2058. * @param newTexture The texture to add
  2059. */
  2060. addTexture(newTexture: BaseTexture): void;
  2061. /**
  2062. * Switch active camera
  2063. * @param newCamera defines the new active camera
  2064. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  2065. */
  2066. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  2067. /**
  2068. * sets the active camera of the scene using its ID
  2069. * @param id defines the camera's ID
  2070. * @return the new active camera or null if none found.
  2071. */
  2072. setActiveCameraByID(id: string): Nullable<Camera>;
  2073. /**
  2074. * sets the active camera of the scene using its name
  2075. * @param name defines the camera's name
  2076. * @returns the new active camera or null if none found.
  2077. */
  2078. setActiveCameraByName(name: string): Nullable<Camera>;
  2079. /**
  2080. * get an animation group using its name
  2081. * @param name defines the material's name
  2082. * @return the animation group or null if none found.
  2083. */
  2084. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  2085. /**
  2086. * get a material using its id
  2087. * @param id defines the material's ID
  2088. * @return the material or null if none found.
  2089. */
  2090. getMaterialByID(id: string): Nullable<Material>;
  2091. /**
  2092. * Gets a material using its name
  2093. * @param name defines the material's name
  2094. * @return the material or null if none found.
  2095. */
  2096. getMaterialByName(name: string): Nullable<Material>;
  2097. /**
  2098. * Gets a camera using its id
  2099. * @param id defines the id to look for
  2100. * @returns the camera or null if not found
  2101. */
  2102. getCameraByID(id: string): Nullable<Camera>;
  2103. /**
  2104. * Gets a camera using its unique id
  2105. * @param uniqueId defines the unique id to look for
  2106. * @returns the camera or null if not found
  2107. */
  2108. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  2109. /**
  2110. * Gets a camera using its name
  2111. * @param name defines the camera's name
  2112. * @return the camera or null if none found.
  2113. */
  2114. getCameraByName(name: string): Nullable<Camera>;
  2115. /**
  2116. * Gets a bone using its id
  2117. * @param id defines the bone's id
  2118. * @return the bone or null if not found
  2119. */
  2120. getBoneByID(id: string): Nullable<Bone>;
  2121. /**
  2122. * Gets a bone using its id
  2123. * @param name defines the bone's name
  2124. * @return the bone or null if not found
  2125. */
  2126. getBoneByName(name: string): Nullable<Bone>;
  2127. /**
  2128. * Gets a light node using its name
  2129. * @param name defines the the light's name
  2130. * @return the light or null if none found.
  2131. */
  2132. getLightByName(name: string): Nullable<Light>;
  2133. /**
  2134. * Gets a light node using its id
  2135. * @param id defines the light's id
  2136. * @return the light or null if none found.
  2137. */
  2138. getLightByID(id: string): Nullable<Light>;
  2139. /**
  2140. * Gets a light node using its scene-generated unique ID
  2141. * @param uniqueId defines the light's unique id
  2142. * @return the light or null if none found.
  2143. */
  2144. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  2145. /**
  2146. * Gets a particle system by id
  2147. * @param id defines the particle system id
  2148. * @return the corresponding system or null if none found
  2149. */
  2150. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  2151. /**
  2152. * Gets a geometry using its ID
  2153. * @param id defines the geometry's id
  2154. * @return the geometry or null if none found.
  2155. */
  2156. getGeometryByID(id: string): Nullable<Geometry>;
  2157. private _getGeometryByUniqueID;
  2158. /**
  2159. * Add a new geometry to this scene
  2160. * @param geometry defines the geometry to be added to the scene.
  2161. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  2162. * @return a boolean defining if the geometry was added or not
  2163. */
  2164. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  2165. /**
  2166. * Removes an existing geometry
  2167. * @param geometry defines the geometry to be removed from the scene
  2168. * @return a boolean defining if the geometry was removed or not
  2169. */
  2170. removeGeometry(geometry: Geometry): boolean;
  2171. /**
  2172. * Gets the list of geometries attached to the scene
  2173. * @returns an array of Geometry
  2174. */
  2175. getGeometries(): Geometry[];
  2176. /**
  2177. * Gets the first added mesh found of a given ID
  2178. * @param id defines the id to search for
  2179. * @return the mesh found or null if not found at all
  2180. */
  2181. getMeshByID(id: string): Nullable<AbstractMesh>;
  2182. /**
  2183. * Gets a list of meshes using their id
  2184. * @param id defines the id to search for
  2185. * @returns a list of meshes
  2186. */
  2187. getMeshesByID(id: string): Array<AbstractMesh>;
  2188. /**
  2189. * Gets the first added transform node found of a given ID
  2190. * @param id defines the id to search for
  2191. * @return the found transform node or null if not found at all.
  2192. */
  2193. getTransformNodeByID(id: string): Nullable<TransformNode>;
  2194. /**
  2195. * Gets a list of transform nodes using their id
  2196. * @param id defines the id to search for
  2197. * @returns a list of transform nodes
  2198. */
  2199. getTransformNodesByID(id: string): Array<TransformNode>;
  2200. /**
  2201. * Gets a mesh with its auto-generated unique id
  2202. * @param uniqueId defines the unique id to search for
  2203. * @return the found mesh or null if not found at all.
  2204. */
  2205. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  2206. /**
  2207. * Gets a the last added mesh using a given id
  2208. * @param id defines the id to search for
  2209. * @return the found mesh or null if not found at all.
  2210. */
  2211. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  2212. /**
  2213. * Gets a the last added node (Mesh, Camera, Light) using a given id
  2214. * @param id defines the id to search for
  2215. * @return the found node or null if not found at all
  2216. */
  2217. getLastEntryByID(id: string): Nullable<Node>;
  2218. /**
  2219. * Gets a node (Mesh, Camera, Light) using a given id
  2220. * @param id defines the id to search for
  2221. * @return the found node or null if not found at all
  2222. */
  2223. getNodeByID(id: string): Nullable<Node>;
  2224. /**
  2225. * Gets a node (Mesh, Camera, Light) using a given name
  2226. * @param name defines the name to search for
  2227. * @return the found node or null if not found at all.
  2228. */
  2229. getNodeByName(name: string): Nullable<Node>;
  2230. /**
  2231. * Gets a mesh using a given name
  2232. * @param name defines the name to search for
  2233. * @return the found mesh or null if not found at all.
  2234. */
  2235. getMeshByName(name: string): Nullable<AbstractMesh>;
  2236. /**
  2237. * Gets a transform node using a given name
  2238. * @param name defines the name to search for
  2239. * @return the found transform node or null if not found at all.
  2240. */
  2241. getTransformNodeByName(name: string): Nullable<TransformNode>;
  2242. /**
  2243. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  2244. * @param id defines the id to search for
  2245. * @return the found skeleton or null if not found at all.
  2246. */
  2247. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  2248. /**
  2249. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  2250. * @param id defines the id to search for
  2251. * @return the found skeleton or null if not found at all.
  2252. */
  2253. getSkeletonById(id: string): Nullable<Skeleton>;
  2254. /**
  2255. * Gets a skeleton using a given name
  2256. * @param name defines the name to search for
  2257. * @return the found skeleton or null if not found at all.
  2258. */
  2259. getSkeletonByName(name: string): Nullable<Skeleton>;
  2260. /**
  2261. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  2262. * @param id defines the id to search for
  2263. * @return the found morph target manager or null if not found at all.
  2264. */
  2265. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  2266. /**
  2267. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  2268. * @param id defines the id to search for
  2269. * @return the found morph target or null if not found at all.
  2270. */
  2271. getMorphTargetById(id: string): Nullable<MorphTarget>;
  2272. /**
  2273. * Gets a boolean indicating if the given mesh is active
  2274. * @param mesh defines the mesh to look for
  2275. * @returns true if the mesh is in the active list
  2276. */
  2277. isActiveMesh(mesh: AbstractMesh): boolean;
  2278. /**
  2279. * Return a unique id as a string which can serve as an identifier for the scene
  2280. */
  2281. readonly uid: string;
  2282. /**
  2283. * Add an externaly attached data from its key.
  2284. * This method call will fail and return false, if such key already exists.
  2285. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  2286. * @param key the unique key that identifies the data
  2287. * @param data the data object to associate to the key for this Engine instance
  2288. * @return true if no such key were already present and the data was added successfully, false otherwise
  2289. */
  2290. addExternalData<T>(key: string, data: T): boolean;
  2291. /**
  2292. * Get an externaly attached data from its key
  2293. * @param key the unique key that identifies the data
  2294. * @return the associated data, if present (can be null), or undefined if not present
  2295. */
  2296. getExternalData<T>(key: string): Nullable<T>;
  2297. /**
  2298. * Get an externaly attached data from its key, create it using a factory if it's not already present
  2299. * @param key the unique key that identifies the data
  2300. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  2301. * @return the associated data, can be null if the factory returned null.
  2302. */
  2303. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  2304. /**
  2305. * Remove an externaly attached data from the Engine instance
  2306. * @param key the unique key that identifies the data
  2307. * @return true if the data was successfully removed, false if it doesn't exist
  2308. */
  2309. removeExternalData(key: string): boolean;
  2310. private _evaluateSubMesh;
  2311. /**
  2312. * Clear the processed materials smart array preventing retention point in material dispose.
  2313. */
  2314. freeProcessedMaterials(): void;
  2315. private _preventFreeActiveMeshesAndRenderingGroups;
  2316. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  2317. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  2318. * when disposing several meshes in a row or a hierarchy of meshes.
  2319. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  2320. */
  2321. blockfreeActiveMeshesAndRenderingGroups: boolean;
  2322. /**
  2323. * Clear the active meshes smart array preventing retention point in mesh dispose.
  2324. */
  2325. freeActiveMeshes(): void;
  2326. /**
  2327. * Clear the info related to rendering groups preventing retention points during dispose.
  2328. */
  2329. freeRenderingGroups(): void;
  2330. /** @hidden */
  2331. _isInIntermediateRendering(): boolean;
  2332. /**
  2333. * Lambda returning the list of potentially active meshes.
  2334. */
  2335. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  2336. /**
  2337. * Lambda returning the list of potentially active sub meshes.
  2338. */
  2339. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  2340. /**
  2341. * Lambda returning the list of potentially intersecting sub meshes.
  2342. */
  2343. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  2344. /**
  2345. * Lambda returning the list of potentially colliding sub meshes.
  2346. */
  2347. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  2348. private _activeMeshesFrozen;
  2349. /**
  2350. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  2351. * @returns the current scene
  2352. */
  2353. freezeActiveMeshes(): Scene;
  2354. /**
  2355. * Use this function to restart evaluating active meshes on every frame
  2356. * @returns the current scene
  2357. */
  2358. unfreezeActiveMeshes(): Scene;
  2359. private _evaluateActiveMeshes;
  2360. private _activeMesh;
  2361. /**
  2362. * Update the transform matrix to update from the current active camera
  2363. * @param force defines a boolean used to force the update even if cache is up to date
  2364. */
  2365. updateTransformMatrix(force?: boolean): void;
  2366. /**
  2367. * Defines an alternate camera (used mostly in VR-like scenario where two cameras can render the same scene from a slightly different point of view)
  2368. * @param alternateCamera defines the camera to use
  2369. */
  2370. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  2371. /** @hidden */
  2372. _allowPostProcessClearColor: boolean;
  2373. private _renderForCamera;
  2374. private _processSubCameras;
  2375. private _checkIntersections;
  2376. /** @hidden */
  2377. _advancePhysicsEngineStep(step: number): void;
  2378. /**
  2379. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  2380. */
  2381. getDeterministicFrameTime: () => number;
  2382. /**
  2383. * Render the scene
  2384. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  2385. */
  2386. render(updateCameras?: boolean): void;
  2387. /**
  2388. * Freeze all materials
  2389. * A frozen material will not be updatable but should be faster to render
  2390. */
  2391. freezeMaterials(): void;
  2392. /**
  2393. * Unfreeze all materials
  2394. * A frozen material will not be updatable but should be faster to render
  2395. */
  2396. unfreezeMaterials(): void;
  2397. /**
  2398. * Releases all held ressources
  2399. */
  2400. dispose(): void;
  2401. /**
  2402. * Gets if the scene is already disposed
  2403. */
  2404. readonly isDisposed: boolean;
  2405. /**
  2406. * Call this function to reduce memory footprint of the scene.
  2407. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  2408. */
  2409. clearCachedVertexData(): void;
  2410. /**
  2411. * This function will remove the local cached buffer data from texture.
  2412. * It will save memory but will prevent the texture from being rebuilt
  2413. */
  2414. cleanCachedTextureBuffer(): void;
  2415. /**
  2416. * Get the world extend vectors with an optional filter
  2417. *
  2418. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  2419. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  2420. */
  2421. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  2422. min: Vector3;
  2423. max: Vector3;
  2424. };
  2425. /**
  2426. * Creates a ray that can be used to pick in the scene
  2427. * @param x defines the x coordinate of the origin (on-screen)
  2428. * @param y defines the y coordinate of the origin (on-screen)
  2429. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2430. * @param camera defines the camera to use for the picking
  2431. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2432. * @returns a Ray
  2433. */
  2434. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  2435. /**
  2436. * Creates a ray that can be used to pick in the scene
  2437. * @param x defines the x coordinate of the origin (on-screen)
  2438. * @param y defines the y coordinate of the origin (on-screen)
  2439. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2440. * @param result defines the ray where to store the picking ray
  2441. * @param camera defines the camera to use for the picking
  2442. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2443. * @returns the current scene
  2444. */
  2445. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  2446. /**
  2447. * Creates a ray that can be used to pick in the scene
  2448. * @param x defines the x coordinate of the origin (on-screen)
  2449. * @param y defines the y coordinate of the origin (on-screen)
  2450. * @param camera defines the camera to use for the picking
  2451. * @returns a Ray
  2452. */
  2453. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  2454. /**
  2455. * Creates a ray that can be used to pick in the scene
  2456. * @param x defines the x coordinate of the origin (on-screen)
  2457. * @param y defines the y coordinate of the origin (on-screen)
  2458. * @param result defines the ray where to store the picking ray
  2459. * @param camera defines the camera to use for the picking
  2460. * @returns the current scene
  2461. */
  2462. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  2463. private _internalPick;
  2464. private _internalMultiPick;
  2465. private _tempPickingRay;
  2466. /** Launch a ray to try to pick a mesh in the scene
  2467. * @param x position on screen
  2468. * @param y position on screen
  2469. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  2470. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  2471. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2472. * @returns a PickingInfo
  2473. */
  2474. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  2475. private _cachedRayForTransform;
  2476. /** Use the given ray to pick a mesh in the scene
  2477. * @param ray The ray to use to pick meshes
  2478. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must have isPickable set to true
  2479. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  2480. * @returns a PickingInfo
  2481. */
  2482. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  2483. /**
  2484. * Launch a ray to try to pick a mesh in the scene
  2485. * @param x X position on screen
  2486. * @param y Y position on screen
  2487. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  2488. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2489. * @returns an array of PickingInfo
  2490. */
  2491. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  2492. /**
  2493. * Launch a ray to try to pick a mesh in the scene
  2494. * @param ray Ray to use
  2495. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  2496. * @returns an array of PickingInfo
  2497. */
  2498. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  2499. /**
  2500. * Force the value of meshUnderPointer
  2501. * @param mesh defines the mesh to use
  2502. */
  2503. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  2504. /**
  2505. * Gets the mesh under the pointer
  2506. * @returns a Mesh or null if no mesh is under the pointer
  2507. */
  2508. getPointerOverMesh(): Nullable<AbstractMesh>;
  2509. /** @hidden */
  2510. _rebuildGeometries(): void;
  2511. /** @hidden */
  2512. _rebuildTextures(): void;
  2513. private _getByTags;
  2514. /**
  2515. * Get a list of meshes by tags
  2516. * @param tagsQuery defines the tags query to use
  2517. * @param forEach defines a predicate used to filter results
  2518. * @returns an array of Mesh
  2519. */
  2520. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  2521. /**
  2522. * Get a list of cameras by tags
  2523. * @param tagsQuery defines the tags query to use
  2524. * @param forEach defines a predicate used to filter results
  2525. * @returns an array of Camera
  2526. */
  2527. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  2528. /**
  2529. * Get a list of lights by tags
  2530. * @param tagsQuery defines the tags query to use
  2531. * @param forEach defines a predicate used to filter results
  2532. * @returns an array of Light
  2533. */
  2534. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  2535. /**
  2536. * Get a list of materials by tags
  2537. * @param tagsQuery defines the tags query to use
  2538. * @param forEach defines a predicate used to filter results
  2539. * @returns an array of Material
  2540. */
  2541. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  2542. /**
  2543. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  2544. * This allowed control for front to back rendering or reversly depending of the special needs.
  2545. *
  2546. * @param renderingGroupId The rendering group id corresponding to its index
  2547. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  2548. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  2549. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  2550. */
  2551. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  2552. /**
  2553. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  2554. *
  2555. * @param renderingGroupId The rendering group id corresponding to its index
  2556. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  2557. * @param depth Automatically clears depth between groups if true and autoClear is true.
  2558. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  2559. */
  2560. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  2561. /**
  2562. * Gets the current auto clear configuration for one rendering group of the rendering
  2563. * manager.
  2564. * @param index the rendering group index to get the information for
  2565. * @returns The auto clear setup for the requested rendering group
  2566. */
  2567. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  2568. private _blockMaterialDirtyMechanism;
  2569. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  2570. blockMaterialDirtyMechanism: boolean;
  2571. /**
  2572. * Will flag all materials as dirty to trigger new shader compilation
  2573. * @param flag defines the flag used to specify which material part must be marked as dirty
  2574. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  2575. */
  2576. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  2577. /** @hidden */
  2578. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  2579. /** @hidden */
  2580. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  2581. }
  2582. }
  2583. declare module BABYLON {
  2584. /**
  2585. * Groups all the scene component constants in one place to ease maintenance.
  2586. * @hidden
  2587. */
  2588. class SceneComponentConstants {
  2589. static readonly NAME_EFFECTLAYER: string;
  2590. static readonly NAME_LAYER: string;
  2591. static readonly NAME_LENSFLARESYSTEM: string;
  2592. static readonly NAME_BOUNDINGBOXRENDERER: string;
  2593. static readonly NAME_PARTICLESYSTEM: string;
  2594. static readonly NAME_GAMEPAD: string;
  2595. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  2596. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  2597. static readonly NAME_DEPTHRENDERER: string;
  2598. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  2599. static readonly NAME_SPRITE: string;
  2600. static readonly NAME_OUTLINERENDERER: string;
  2601. static readonly NAME_PROCEDURALTEXTURE: string;
  2602. static readonly NAME_SHADOWGENERATOR: string;
  2603. static readonly NAME_OCTREE: string;
  2604. static readonly NAME_PHYSICSENGINE: string;
  2605. static readonly NAME_AUDIO: string;
  2606. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  2607. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  2608. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  2609. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  2610. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  2611. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  2612. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  2613. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  2614. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  2615. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  2616. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  2617. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  2618. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  2619. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  2620. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  2621. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  2622. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  2623. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  2624. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  2625. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  2626. static readonly STEP_AFTERRENDER_AUDIO: number;
  2627. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  2628. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  2629. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  2630. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  2631. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  2632. static readonly STEP_POINTERMOVE_SPRITE: number;
  2633. static readonly STEP_POINTERDOWN_SPRITE: number;
  2634. static readonly STEP_POINTERUP_SPRITE: number;
  2635. }
  2636. /**
  2637. * This represents a scene component.
  2638. *
  2639. * This is used to decouple the dependency the scene is having on the different workloads like
  2640. * layers, post processes...
  2641. */
  2642. interface ISceneComponent {
  2643. /**
  2644. * The name of the component. Each component must have a unique name.
  2645. */
  2646. name: string;
  2647. /**
  2648. * The scene the component belongs to.
  2649. */
  2650. scene: Scene;
  2651. /**
  2652. * Register the component to one instance of a scene.
  2653. */
  2654. register(): void;
  2655. /**
  2656. * Rebuilds the elements related to this component in case of
  2657. * context lost for instance.
  2658. */
  2659. rebuild(): void;
  2660. /**
  2661. * Disposes the component and the associated ressources.
  2662. */
  2663. dispose(): void;
  2664. }
  2665. /**
  2666. * This represents a SERIALIZABLE scene component.
  2667. *
  2668. * This extends Scene Component to add Serialization methods on top.
  2669. */
  2670. interface ISceneSerializableComponent extends ISceneComponent {
  2671. /**
  2672. * Adds all the element from the container to the scene
  2673. * @param container the container holding the elements
  2674. */
  2675. addFromContainer(container: AbstractScene): void;
  2676. /**
  2677. * Removes all the elements in the container from the scene
  2678. * @param container contains the elements to remove
  2679. */
  2680. removeFromContainer(container: AbstractScene): void;
  2681. /**
  2682. * Serializes the component data to the specified json object
  2683. * @param serializationObject The object to serialize to
  2684. */
  2685. serialize(serializationObject: any): void;
  2686. }
  2687. /**
  2688. * Strong typing of a Mesh related stage step action
  2689. */
  2690. type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  2691. /**
  2692. * Strong typing of a Evaluate Sub Mesh related stage step action
  2693. */
  2694. type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  2695. /**
  2696. * Strong typing of a Active Mesh related stage step action
  2697. */
  2698. type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  2699. /**
  2700. * Strong typing of a Camera related stage step action
  2701. */
  2702. type CameraStageAction = (camera: Camera) => void;
  2703. /**
  2704. * Strong typing of a Render Target related stage step action
  2705. */
  2706. type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  2707. /**
  2708. * Strong typing of a RenderingGroup related stage step action
  2709. */
  2710. type RenderingGroupStageAction = (renderingGroupId: number) => void;
  2711. /**
  2712. * Strong typing of a Mesh Render related stage step action
  2713. */
  2714. type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  2715. /**
  2716. * Strong typing of a simple stage step action
  2717. */
  2718. type SimpleStageAction = () => void;
  2719. /**
  2720. * Strong typing of a render target action.
  2721. */
  2722. type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  2723. /**
  2724. * Strong typing of a pointer move action.
  2725. */
  2726. type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  2727. /**
  2728. * Strong typing of a pointer up/down action.
  2729. */
  2730. type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  2731. /**
  2732. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  2733. * @hidden
  2734. */
  2735. class Stage<T extends Function> extends Array<{
  2736. index: number;
  2737. component: ISceneComponent;
  2738. action: T;
  2739. }> {
  2740. /**
  2741. * Hide ctor from the rest of the world.
  2742. * @param items The items to add.
  2743. */
  2744. private constructor();
  2745. /**
  2746. * Creates a new Stage.
  2747. * @returns A new instance of a Stage
  2748. */
  2749. static Create<T extends Function>(): Stage<T>;
  2750. /**
  2751. * Registers a step in an ordered way in the targeted stage.
  2752. * @param index Defines the position to register the step in
  2753. * @param component Defines the component attached to the step
  2754. * @param action Defines the action to launch during the step
  2755. */
  2756. registerStep(index: number, component: ISceneComponent, action: T): void;
  2757. /**
  2758. * Clears all the steps from the stage.
  2759. */
  2760. clear(): void;
  2761. }
  2762. }
  2763. declare module BABYLON {
  2764. /** Alias type for value that can be null */
  2765. type Nullable<T> = T | null;
  2766. /**
  2767. * Alias type for number that are floats
  2768. * @ignorenaming
  2769. */
  2770. type float = number;
  2771. /**
  2772. * Alias type for number that are doubles.
  2773. * @ignorenaming
  2774. */
  2775. type double = number;
  2776. /**
  2777. * Alias type for number that are integer
  2778. * @ignorenaming
  2779. */
  2780. type int = number;
  2781. /** Alias type for number array or Float32Array */
  2782. type FloatArray = number[] | Float32Array;
  2783. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  2784. type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  2785. /**
  2786. * Alias for types that can be used by a Buffer or VertexBuffer.
  2787. */
  2788. type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  2789. /**
  2790. * Alias type for primitive types
  2791. * @ignorenaming
  2792. */
  2793. type Primitive = undefined | null | boolean | string | number | Function;
  2794. /**
  2795. * Type modifier to make all the properties of an object Readonly
  2796. */
  2797. type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  2798. /**
  2799. * Type modifier to make all the properties of an object Readonly recursively
  2800. */
  2801. type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  2802. /** @hidden */
  2803. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  2804. }
  2805. /** @hidden */
  2806. /** @hidden */
  2807. type DeepImmutableObject<T> = {
  2808. readonly [K in keyof T]: DeepImmutable<T[K]>;
  2809. };
  2810. }
  2811. declare module BABYLON {
  2812. /**
  2813. * Class used to store an actual running animation
  2814. */
  2815. class Animatable {
  2816. /** defines the target object */
  2817. target: any;
  2818. /** defines the starting frame number (default is 0) */
  2819. fromFrame: number;
  2820. /** defines the ending frame number (default is 100) */
  2821. toFrame: number;
  2822. /** defines if the animation must loop (default is false) */
  2823. loopAnimation: boolean;
  2824. /** defines a callback to call when animation ends if it is not looping */
  2825. onAnimationEnd?: (() => void) | null | undefined;
  2826. /** defines a callback to call when animation loops */
  2827. onAnimationLoop?: (() => void) | null | undefined;
  2828. private _localDelayOffset;
  2829. private _pausedDelay;
  2830. private _runtimeAnimations;
  2831. private _paused;
  2832. private _scene;
  2833. private _speedRatio;
  2834. private _weight;
  2835. private _syncRoot;
  2836. /**
  2837. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  2838. * This will only apply for non looping animation (default is true)
  2839. */
  2840. disposeOnEnd: boolean;
  2841. /**
  2842. * Gets a boolean indicating if the animation has started
  2843. */
  2844. animationStarted: boolean;
  2845. /**
  2846. * Observer raised when the animation ends
  2847. */
  2848. onAnimationEndObservable: Observable<Animatable>;
  2849. /**
  2850. * Observer raised when the animation loops
  2851. */
  2852. onAnimationLoopObservable: Observable<Animatable>;
  2853. /**
  2854. * Gets the root Animatable used to synchronize and normalize animations
  2855. */
  2856. readonly syncRoot: Animatable;
  2857. /**
  2858. * Gets the current frame of the first RuntimeAnimation
  2859. * Used to synchronize Animatables
  2860. */
  2861. readonly masterFrame: number;
  2862. /**
  2863. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  2864. */
  2865. weight: number;
  2866. /**
  2867. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  2868. */
  2869. speedRatio: number;
  2870. /**
  2871. * Creates a new Animatable
  2872. * @param scene defines the hosting scene
  2873. * @param target defines the target object
  2874. * @param fromFrame defines the starting frame number (default is 0)
  2875. * @param toFrame defines the ending frame number (default is 100)
  2876. * @param loopAnimation defines if the animation must loop (default is false)
  2877. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  2878. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  2879. * @param animations defines a group of animation to add to the new Animatable
  2880. * @param onAnimationLoop defines a callback to call when animation loops
  2881. */
  2882. constructor(scene: Scene,
  2883. /** defines the target object */
  2884. target: any,
  2885. /** defines the starting frame number (default is 0) */
  2886. fromFrame?: number,
  2887. /** defines the ending frame number (default is 100) */
  2888. toFrame?: number,
  2889. /** defines if the animation must loop (default is false) */
  2890. loopAnimation?: boolean, speedRatio?: number,
  2891. /** defines a callback to call when animation ends if it is not looping */
  2892. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  2893. /** defines a callback to call when animation loops */
  2894. onAnimationLoop?: (() => void) | null | undefined);
  2895. /**
  2896. * Synchronize and normalize current Animatable with a source Animatable
  2897. * This is useful when using animation weights and when animations are not of the same length
  2898. * @param root defines the root Animatable to synchronize with
  2899. * @returns the current Animatable
  2900. */
  2901. syncWith(root: Animatable): Animatable;
  2902. /**
  2903. * Gets the list of runtime animations
  2904. * @returns an array of RuntimeAnimation
  2905. */
  2906. getAnimations(): RuntimeAnimation[];
  2907. /**
  2908. * Adds more animations to the current animatable
  2909. * @param target defines the target of the animations
  2910. * @param animations defines the new animations to add
  2911. */
  2912. appendAnimations(target: any, animations: Animation[]): void;
  2913. /**
  2914. * Gets the source animation for a specific property
  2915. * @param property defines the propertyu to look for
  2916. * @returns null or the source animation for the given property
  2917. */
  2918. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  2919. /**
  2920. * Gets the runtime animation for a specific property
  2921. * @param property defines the propertyu to look for
  2922. * @returns null or the runtime animation for the given property
  2923. */
  2924. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  2925. /**
  2926. * Resets the animatable to its original state
  2927. */
  2928. reset(): void;
  2929. /**
  2930. * Allows the animatable to blend with current running animations
  2931. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  2932. * @param blendingSpeed defines the blending speed to use
  2933. */
  2934. enableBlending(blendingSpeed: number): void;
  2935. /**
  2936. * Disable animation blending
  2937. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  2938. */
  2939. disableBlending(): void;
  2940. /**
  2941. * Jump directly to a given frame
  2942. * @param frame defines the frame to jump to
  2943. */
  2944. goToFrame(frame: number): void;
  2945. /**
  2946. * Pause the animation
  2947. */
  2948. pause(): void;
  2949. /**
  2950. * Restart the animation
  2951. */
  2952. restart(): void;
  2953. private _raiseOnAnimationEnd;
  2954. /**
  2955. * Stop and delete the current animation
  2956. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  2957. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  2958. */
  2959. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  2960. /**
  2961. * Wait asynchronously for the animation to end
  2962. * @returns a promise which will be fullfilled when the animation ends
  2963. */
  2964. waitAsync(): Promise<Animatable>;
  2965. /** @hidden */
  2966. _animate(delay: number): boolean;
  2967. }
  2968. }
  2969. declare module BABYLON {
  2970. /**
  2971. * Represents the range of an animation
  2972. */
  2973. class AnimationRange {
  2974. /**The name of the animation range**/
  2975. name: string;
  2976. /**The starting frame of the animation */
  2977. from: number;
  2978. /**The ending frame of the animation*/
  2979. to: number;
  2980. /**
  2981. * Initializes the range of an animation
  2982. * @param name The name of the animation range
  2983. * @param from The starting frame of the animation
  2984. * @param to The ending frame of the animation
  2985. */
  2986. constructor(
  2987. /**The name of the animation range**/
  2988. name: string,
  2989. /**The starting frame of the animation */
  2990. from: number,
  2991. /**The ending frame of the animation*/
  2992. to: number);
  2993. /**
  2994. * Makes a copy of the animation range
  2995. * @returns A copy of the animation range
  2996. */
  2997. clone(): AnimationRange;
  2998. }
  2999. /**
  3000. * Composed of a frame, and an action function
  3001. */
  3002. class AnimationEvent {
  3003. /** The frame for which the event is triggered **/
  3004. frame: number;
  3005. /** The event to perform when triggered **/
  3006. action: (currentFrame: number) => void;
  3007. /** Specifies if the event should be triggered only once**/
  3008. onlyOnce?: boolean | undefined;
  3009. /**
  3010. * Specifies if the animation event is done
  3011. */
  3012. isDone: boolean;
  3013. /**
  3014. * Initializes the animation event
  3015. * @param frame The frame for which the event is triggered
  3016. * @param action The event to perform when triggered
  3017. * @param onlyOnce Specifies if the event should be triggered only once
  3018. */
  3019. constructor(
  3020. /** The frame for which the event is triggered **/
  3021. frame: number,
  3022. /** The event to perform when triggered **/
  3023. action: (currentFrame: number) => void,
  3024. /** Specifies if the event should be triggered only once**/
  3025. onlyOnce?: boolean | undefined);
  3026. /** @hidden */
  3027. _clone(): AnimationEvent;
  3028. }
  3029. /**
  3030. * A cursor which tracks a point on a path
  3031. */
  3032. class PathCursor {
  3033. private path;
  3034. /**
  3035. * Stores path cursor callbacks for when an onchange event is triggered
  3036. */
  3037. private _onchange;
  3038. /**
  3039. * The value of the path cursor
  3040. */
  3041. value: number;
  3042. /**
  3043. * The animation array of the path cursor
  3044. */
  3045. animations: Animation[];
  3046. /**
  3047. * Initializes the path cursor
  3048. * @param path The path to track
  3049. */
  3050. constructor(path: Path2);
  3051. /**
  3052. * Gets the cursor point on the path
  3053. * @returns A point on the path cursor at the cursor location
  3054. */
  3055. getPoint(): Vector3;
  3056. /**
  3057. * Moves the cursor ahead by the step amount
  3058. * @param step The amount to move the cursor forward
  3059. * @returns This path cursor
  3060. */
  3061. moveAhead(step?: number): PathCursor;
  3062. /**
  3063. * Moves the cursor behind by the step amount
  3064. * @param step The amount to move the cursor back
  3065. * @returns This path cursor
  3066. */
  3067. moveBack(step?: number): PathCursor;
  3068. /**
  3069. * Moves the cursor by the step amount
  3070. * If the step amount is greater than one, an exception is thrown
  3071. * @param step The amount to move the cursor
  3072. * @returns This path cursor
  3073. */
  3074. move(step: number): PathCursor;
  3075. /**
  3076. * Ensures that the value is limited between zero and one
  3077. * @returns This path cursor
  3078. */
  3079. private ensureLimits;
  3080. /**
  3081. * Runs onchange callbacks on change (used by the animation engine)
  3082. * @returns This path cursor
  3083. */
  3084. private raiseOnChange;
  3085. /**
  3086. * Executes a function on change
  3087. * @param f A path cursor onchange callback
  3088. * @returns This path cursor
  3089. */
  3090. onchange(f: (cursor: PathCursor) => void): PathCursor;
  3091. }
  3092. /**
  3093. * Defines an interface which represents an animation key frame
  3094. */
  3095. interface IAnimationKey {
  3096. /**
  3097. * Frame of the key frame
  3098. */
  3099. frame: number;
  3100. /**
  3101. * Value at the specifies key frame
  3102. */
  3103. value: any;
  3104. /**
  3105. * The input tangent for the cubic hermite spline
  3106. */
  3107. inTangent?: any;
  3108. /**
  3109. * The output tangent for the cubic hermite spline
  3110. */
  3111. outTangent?: any;
  3112. /**
  3113. * The animation interpolation type
  3114. */
  3115. interpolation?: AnimationKeyInterpolation;
  3116. }
  3117. /**
  3118. * Enum for the animation key frame interpolation type
  3119. */
  3120. enum AnimationKeyInterpolation {
  3121. /**
  3122. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  3123. */
  3124. STEP = 1
  3125. }
  3126. /**
  3127. * Class used to store any kind of animation
  3128. */
  3129. class Animation {
  3130. /**Name of the animation */
  3131. name: string;
  3132. /**Property to animate */
  3133. targetProperty: string;
  3134. /**The frames per second of the animation */
  3135. framePerSecond: number;
  3136. /**The data type of the animation */
  3137. dataType: number;
  3138. /**The loop mode of the animation */
  3139. loopMode?: number | undefined;
  3140. /**Specifies if blending should be enabled */
  3141. enableBlending?: boolean | undefined;
  3142. /**
  3143. * Use matrix interpolation instead of using direct key value when animating matrices
  3144. */
  3145. static AllowMatricesInterpolation: boolean;
  3146. /**
  3147. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  3148. */
  3149. static AllowMatrixDecomposeForInterpolation: boolean;
  3150. /**
  3151. * Stores the key frames of the animation
  3152. */
  3153. private _keys;
  3154. /**
  3155. * Stores the easing function of the animation
  3156. */
  3157. private _easingFunction;
  3158. /**
  3159. * @hidden Internal use only
  3160. */
  3161. _runtimeAnimations: RuntimeAnimation[];
  3162. /**
  3163. * The set of event that will be linked to this animation
  3164. */
  3165. private _events;
  3166. /**
  3167. * Stores an array of target property paths
  3168. */
  3169. targetPropertyPath: string[];
  3170. /**
  3171. * Stores the blending speed of the animation
  3172. */
  3173. blendingSpeed: number;
  3174. /**
  3175. * Stores the animation ranges for the animation
  3176. */
  3177. private _ranges;
  3178. /**
  3179. * @hidden Internal use
  3180. */
  3181. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  3182. /**
  3183. * Sets up an animation
  3184. * @param property The property to animate
  3185. * @param animationType The animation type to apply
  3186. * @param framePerSecond The frames per second of the animation
  3187. * @param easingFunction The easing function used in the animation
  3188. * @returns The created animation
  3189. */
  3190. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  3191. /**
  3192. * Create and start an animation on a node
  3193. * @param name defines the name of the global animation that will be run on all nodes
  3194. * @param node defines the root node where the animation will take place
  3195. * @param targetProperty defines property to animate
  3196. * @param framePerSecond defines the number of frame per second yo use
  3197. * @param totalFrame defines the number of frames in total
  3198. * @param from defines the initial value
  3199. * @param to defines the final value
  3200. * @param loopMode defines which loop mode you want to use (off by default)
  3201. * @param easingFunction defines the easing function to use (linear by default)
  3202. * @param onAnimationEnd defines the callback to call when animation end
  3203. * @returns the animatable created for this animation
  3204. */
  3205. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  3206. /**
  3207. * Create and start an animation on a node and its descendants
  3208. * @param name defines the name of the global animation that will be run on all nodes
  3209. * @param node defines the root node where the animation will take place
  3210. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used
  3211. * @param targetProperty defines property to animate
  3212. * @param framePerSecond defines the number of frame per second to use
  3213. * @param totalFrame defines the number of frames in total
  3214. * @param from defines the initial value
  3215. * @param to defines the final value
  3216. * @param loopMode defines which loop mode you want to use (off by default)
  3217. * @param easingFunction defines the easing function to use (linear by default)
  3218. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  3219. * @returns the list of animatables created for all nodes
  3220. * @example https://www.babylonjs-playground.com/#MH0VLI
  3221. */
  3222. static CreateAndStartHierarchyAnimation(name: string, node: Node, directDescendantsOnly: boolean, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable[]>;
  3223. /**
  3224. * Creates a new animation, merges it with the existing animations and starts it
  3225. * @param name Name of the animation
  3226. * @param node Node which contains the scene that begins the animations
  3227. * @param targetProperty Specifies which property to animate
  3228. * @param framePerSecond The frames per second of the animation
  3229. * @param totalFrame The total number of frames
  3230. * @param from The frame at the beginning of the animation
  3231. * @param to The frame at the end of the animation
  3232. * @param loopMode Specifies the loop mode of the animation
  3233. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  3234. * @param onAnimationEnd Callback to run once the animation is complete
  3235. * @returns Nullable animation
  3236. */
  3237. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  3238. /**
  3239. * Transition property of an host to the target Value
  3240. * @param property The property to transition
  3241. * @param targetValue The target Value of the property
  3242. * @param host The object where the property to animate belongs
  3243. * @param scene Scene used to run the animation
  3244. * @param frameRate Framerate (in frame/s) to use
  3245. * @param transition The transition type we want to use
  3246. * @param duration The duration of the animation, in milliseconds
  3247. * @param onAnimationEnd Callback trigger at the end of the animation
  3248. * @returns Nullable animation
  3249. */
  3250. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  3251. /**
  3252. * Return the array of runtime animations currently using this animation
  3253. */
  3254. readonly runtimeAnimations: RuntimeAnimation[];
  3255. /**
  3256. * Specifies if any of the runtime animations are currently running
  3257. */
  3258. readonly hasRunningRuntimeAnimations: boolean;
  3259. /**
  3260. * Initializes the animation
  3261. * @param name Name of the animation
  3262. * @param targetProperty Property to animate
  3263. * @param framePerSecond The frames per second of the animation
  3264. * @param dataType The data type of the animation
  3265. * @param loopMode The loop mode of the animation
  3266. * @param enableBlendings Specifies if blending should be enabled
  3267. */
  3268. constructor(
  3269. /**Name of the animation */
  3270. name: string,
  3271. /**Property to animate */
  3272. targetProperty: string,
  3273. /**The frames per second of the animation */
  3274. framePerSecond: number,
  3275. /**The data type of the animation */
  3276. dataType: number,
  3277. /**The loop mode of the animation */
  3278. loopMode?: number | undefined,
  3279. /**Specifies if blending should be enabled */
  3280. enableBlending?: boolean | undefined);
  3281. /**
  3282. * Converts the animation to a string
  3283. * @param fullDetails support for multiple levels of logging within scene loading
  3284. * @returns String form of the animation
  3285. */
  3286. toString(fullDetails?: boolean): string;
  3287. /**
  3288. * Add an event to this animation
  3289. * @param event Event to add
  3290. */
  3291. addEvent(event: AnimationEvent): void;
  3292. /**
  3293. * Remove all events found at the given frame
  3294. * @param frame The frame to remove events from
  3295. */
  3296. removeEvents(frame: number): void;
  3297. /**
  3298. * Retrieves all the events from the animation
  3299. * @returns Events from the animation
  3300. */
  3301. getEvents(): AnimationEvent[];
  3302. /**
  3303. * Creates an animation range
  3304. * @param name Name of the animation range
  3305. * @param from Starting frame of the animation range
  3306. * @param to Ending frame of the animation
  3307. */
  3308. createRange(name: string, from: number, to: number): void;
  3309. /**
  3310. * Deletes an animation range by name
  3311. * @param name Name of the animation range to delete
  3312. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  3313. */
  3314. deleteRange(name: string, deleteFrames?: boolean): void;
  3315. /**
  3316. * Gets the animation range by name, or null if not defined
  3317. * @param name Name of the animation range
  3318. * @returns Nullable animation range
  3319. */
  3320. getRange(name: string): Nullable<AnimationRange>;
  3321. /**
  3322. * Gets the key frames from the animation
  3323. * @returns The key frames of the animation
  3324. */
  3325. getKeys(): Array<IAnimationKey>;
  3326. /**
  3327. * Gets the highest frame rate of the animation
  3328. * @returns Highest frame rate of the animation
  3329. */
  3330. getHighestFrame(): number;
  3331. /**
  3332. * Gets the easing function of the animation
  3333. * @returns Easing function of the animation
  3334. */
  3335. getEasingFunction(): IEasingFunction;
  3336. /**
  3337. * Sets the easing function of the animation
  3338. * @param easingFunction A custom mathematical formula for animation
  3339. */
  3340. setEasingFunction(easingFunction: EasingFunction): void;
  3341. /**
  3342. * Interpolates a scalar linearly
  3343. * @param startValue Start value of the animation curve
  3344. * @param endValue End value of the animation curve
  3345. * @param gradient Scalar amount to interpolate
  3346. * @returns Interpolated scalar value
  3347. */
  3348. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  3349. /**
  3350. * Interpolates a scalar cubically
  3351. * @param startValue Start value of the animation curve
  3352. * @param outTangent End tangent of the animation
  3353. * @param endValue End value of the animation curve
  3354. * @param inTangent Start tangent of the animation curve
  3355. * @param gradient Scalar amount to interpolate
  3356. * @returns Interpolated scalar value
  3357. */
  3358. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  3359. /**
  3360. * Interpolates a quaternion using a spherical linear interpolation
  3361. * @param startValue Start value of the animation curve
  3362. * @param endValue End value of the animation curve
  3363. * @param gradient Scalar amount to interpolate
  3364. * @returns Interpolated quaternion value
  3365. */
  3366. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  3367. /**
  3368. * Interpolates a quaternion cubically
  3369. * @param startValue Start value of the animation curve
  3370. * @param outTangent End tangent of the animation curve
  3371. * @param endValue End value of the animation curve
  3372. * @param inTangent Start tangent of the animation curve
  3373. * @param gradient Scalar amount to interpolate
  3374. * @returns Interpolated quaternion value
  3375. */
  3376. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  3377. /**
  3378. * Interpolates a Vector3 linearl
  3379. * @param startValue Start value of the animation curve
  3380. * @param endValue End value of the animation curve
  3381. * @param gradient Scalar amount to interpolate
  3382. * @returns Interpolated scalar value
  3383. */
  3384. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  3385. /**
  3386. * Interpolates a Vector3 cubically
  3387. * @param startValue Start value of the animation curve
  3388. * @param outTangent End tangent of the animation
  3389. * @param endValue End value of the animation curve
  3390. * @param inTangent Start tangent of the animation curve
  3391. * @param gradient Scalar amount to interpolate
  3392. * @returns InterpolatedVector3 value
  3393. */
  3394. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  3395. /**
  3396. * Interpolates a Vector2 linearly
  3397. * @param startValue Start value of the animation curve
  3398. * @param endValue End value of the animation curve
  3399. * @param gradient Scalar amount to interpolate
  3400. * @returns Interpolated Vector2 value
  3401. */
  3402. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  3403. /**
  3404. * Interpolates a Vector2 cubically
  3405. * @param startValue Start value of the animation curve
  3406. * @param outTangent End tangent of the animation
  3407. * @param endValue End value of the animation curve
  3408. * @param inTangent Start tangent of the animation curve
  3409. * @param gradient Scalar amount to interpolate
  3410. * @returns Interpolated Vector2 value
  3411. */
  3412. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  3413. /**
  3414. * Interpolates a size linearly
  3415. * @param startValue Start value of the animation curve
  3416. * @param endValue End value of the animation curve
  3417. * @param gradient Scalar amount to interpolate
  3418. * @returns Interpolated Size value
  3419. */
  3420. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  3421. /**
  3422. * Interpolates a Color3 linearly
  3423. * @param startValue Start value of the animation curve
  3424. * @param endValue End value of the animation curve
  3425. * @param gradient Scalar amount to interpolate
  3426. * @returns Interpolated Color3 value
  3427. */
  3428. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  3429. /**
  3430. * @hidden Internal use only
  3431. */
  3432. _getKeyValue(value: any): any;
  3433. /**
  3434. * @hidden Internal use only
  3435. */
  3436. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  3437. /**
  3438. * Defines the function to use to interpolate matrices
  3439. * @param startValue defines the start matrix
  3440. * @param endValue defines the end matrix
  3441. * @param gradient defines the gradient between both matrices
  3442. * @param result defines an optional target matrix where to store the interpolation
  3443. * @returns the interpolated matrix
  3444. */
  3445. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  3446. /**
  3447. * Makes a copy of the animation
  3448. * @returns Cloned animation
  3449. */
  3450. clone(): Animation;
  3451. /**
  3452. * Sets the key frames of the animation
  3453. * @param values The animation key frames to set
  3454. */
  3455. setKeys(values: Array<IAnimationKey>): void;
  3456. /**
  3457. * Serializes the animation to an object
  3458. * @returns Serialized object
  3459. */
  3460. serialize(): any;
  3461. /**
  3462. * Float animation type
  3463. */
  3464. private static _ANIMATIONTYPE_FLOAT;
  3465. /**
  3466. * Vector3 animation type
  3467. */
  3468. private static _ANIMATIONTYPE_VECTOR3;
  3469. /**
  3470. * Quaternion animation type
  3471. */
  3472. private static _ANIMATIONTYPE_QUATERNION;
  3473. /**
  3474. * Matrix animation type
  3475. */
  3476. private static _ANIMATIONTYPE_MATRIX;
  3477. /**
  3478. * Color3 animation type
  3479. */
  3480. private static _ANIMATIONTYPE_COLOR3;
  3481. /**
  3482. * Vector2 animation type
  3483. */
  3484. private static _ANIMATIONTYPE_VECTOR2;
  3485. /**
  3486. * Size animation type
  3487. */
  3488. private static _ANIMATIONTYPE_SIZE;
  3489. /**
  3490. * Relative Loop Mode
  3491. */
  3492. private static _ANIMATIONLOOPMODE_RELATIVE;
  3493. /**
  3494. * Cycle Loop Mode
  3495. */
  3496. private static _ANIMATIONLOOPMODE_CYCLE;
  3497. /**
  3498. * Constant Loop Mode
  3499. */
  3500. private static _ANIMATIONLOOPMODE_CONSTANT;
  3501. /**
  3502. * Get the float animation type
  3503. */
  3504. static readonly ANIMATIONTYPE_FLOAT: number;
  3505. /**
  3506. * Get the Vector3 animation type
  3507. */
  3508. static readonly ANIMATIONTYPE_VECTOR3: number;
  3509. /**
  3510. * Get the Vector2 animation type
  3511. */
  3512. static readonly ANIMATIONTYPE_VECTOR2: number;
  3513. /**
  3514. * Get the Size animation type
  3515. */
  3516. static readonly ANIMATIONTYPE_SIZE: number;
  3517. /**
  3518. * Get the Quaternion animation type
  3519. */
  3520. static readonly ANIMATIONTYPE_QUATERNION: number;
  3521. /**
  3522. * Get the Matrix animation type
  3523. */
  3524. static readonly ANIMATIONTYPE_MATRIX: number;
  3525. /**
  3526. * Get the Color3 animation type
  3527. */
  3528. static readonly ANIMATIONTYPE_COLOR3: number;
  3529. /**
  3530. * Get the Relative Loop Mode
  3531. */
  3532. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  3533. /**
  3534. * Get the Cycle Loop Mode
  3535. */
  3536. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  3537. /**
  3538. * Get the Constant Loop Mode
  3539. */
  3540. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  3541. /** @hidden */
  3542. static _UniversalLerp(left: any, right: any, amount: number): any;
  3543. /**
  3544. * Parses an animation object and creates an animation
  3545. * @param parsedAnimation Parsed animation object
  3546. * @returns Animation object
  3547. */
  3548. static Parse(parsedAnimation: any): Animation;
  3549. /**
  3550. * Appends the serialized animations from the source animations
  3551. * @param source Source containing the animations
  3552. * @param destination Target to store the animations
  3553. */
  3554. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  3555. }
  3556. }
  3557. declare module BABYLON {
  3558. /**
  3559. * This class defines the direct association between an animation and a target
  3560. */
  3561. class TargetedAnimation {
  3562. /**
  3563. * Animation to perform
  3564. */
  3565. animation: Animation;
  3566. /**
  3567. * Target to animate
  3568. */
  3569. target: any;
  3570. }
  3571. /**
  3572. * Use this class to create coordinated animations on multiple targets
  3573. */
  3574. class AnimationGroup implements IDisposable {
  3575. /** The name of the animation group */
  3576. name: string;
  3577. private _scene;
  3578. private _targetedAnimations;
  3579. private _animatables;
  3580. private _from;
  3581. private _to;
  3582. private _isStarted;
  3583. private _isPaused;
  3584. private _speedRatio;
  3585. /**
  3586. * Gets or sets the unique id of the node
  3587. */
  3588. uniqueId: number;
  3589. /**
  3590. * This observable will notify when one animation have ended
  3591. */
  3592. onAnimationEndObservable: Observable<TargetedAnimation>;
  3593. /**
  3594. * Observer raised when one animation loops
  3595. */
  3596. onAnimationLoopObservable: Observable<TargetedAnimation>;
  3597. /**
  3598. * This observable will notify when all animations have ended.
  3599. */
  3600. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  3601. /**
  3602. * This observable will notify when all animations have paused.
  3603. */
  3604. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  3605. /**
  3606. * This observable will notify when all animations are playing.
  3607. */
  3608. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  3609. /**
  3610. * Gets the first frame
  3611. */
  3612. readonly from: number;
  3613. /**
  3614. * Gets the last frame
  3615. */
  3616. readonly to: number;
  3617. /**
  3618. * Define if the animations are started
  3619. */
  3620. readonly isStarted: boolean;
  3621. /**
  3622. * Gets a value indicating that the current group is playing
  3623. */
  3624. readonly isPlaying: boolean;
  3625. /**
  3626. * Gets or sets the speed ratio to use for all animations
  3627. */
  3628. /**
  3629. * Gets or sets the speed ratio to use for all animations
  3630. */
  3631. speedRatio: number;
  3632. /**
  3633. * Gets the targeted animations for this animation group
  3634. */
  3635. readonly targetedAnimations: Array<TargetedAnimation>;
  3636. /**
  3637. * returning the list of animatables controlled by this animation group.
  3638. */
  3639. readonly animatables: Array<Animatable>;
  3640. /**
  3641. * Instantiates a new Animation Group.
  3642. * This helps managing several animations at once.
  3643. * @see http://doc.babylonjs.com/how_to/group
  3644. * @param name Defines the name of the group
  3645. * @param scene Defines the scene the group belongs to
  3646. */
  3647. constructor(
  3648. /** The name of the animation group */
  3649. name: string, scene?: Nullable<Scene>);
  3650. /**
  3651. * Add an animation (with its target) in the group
  3652. * @param animation defines the animation we want to add
  3653. * @param target defines the target of the animation
  3654. * @returns the TargetedAnimation object
  3655. */
  3656. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  3657. /**
  3658. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  3659. * It can add constant keys at begin or end
  3660. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  3661. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  3662. * @returns the animation group
  3663. */
  3664. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  3665. /**
  3666. * Start all animations on given targets
  3667. * @param loop defines if animations must loop
  3668. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  3669. * @param from defines the from key (optional)
  3670. * @param to defines the to key (optional)
  3671. * @returns the current animation group
  3672. */
  3673. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  3674. /**
  3675. * Pause all animations
  3676. * @returns the animation group
  3677. */
  3678. pause(): AnimationGroup;
  3679. /**
  3680. * Play all animations to initial state
  3681. * This function will start() the animations if they were not started or will restart() them if they were paused
  3682. * @param loop defines if animations must loop
  3683. * @returns the animation group
  3684. */
  3685. play(loop?: boolean): AnimationGroup;
  3686. /**
  3687. * Reset all animations to initial state
  3688. * @returns the animation group
  3689. */
  3690. reset(): AnimationGroup;
  3691. /**
  3692. * Restart animations from key 0
  3693. * @returns the animation group
  3694. */
  3695. restart(): AnimationGroup;
  3696. /**
  3697. * Stop all animations
  3698. * @returns the animation group
  3699. */
  3700. stop(): AnimationGroup;
  3701. /**
  3702. * Set animation weight for all animatables
  3703. * @param weight defines the weight to use
  3704. * @return the animationGroup
  3705. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  3706. */
  3707. setWeightForAllAnimatables(weight: number): AnimationGroup;
  3708. /**
  3709. * Synchronize and normalize all animatables with a source animatable
  3710. * @param root defines the root animatable to synchronize with
  3711. * @return the animationGroup
  3712. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  3713. */
  3714. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  3715. /**
  3716. * Goes to a specific frame in this animation group
  3717. * @param frame the frame number to go to
  3718. * @return the animationGroup
  3719. */
  3720. goToFrame(frame: number): AnimationGroup;
  3721. /**
  3722. * Dispose all associated resources
  3723. */
  3724. dispose(): void;
  3725. private _checkAnimationGroupEnded;
  3726. /**
  3727. * Returns a new AnimationGroup object parsed from the source provided.
  3728. * @param parsedAnimationGroup defines the source
  3729. * @param scene defines the scene that will receive the animationGroup
  3730. * @returns a new AnimationGroup
  3731. */
  3732. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  3733. /**
  3734. * Returns the string "AnimationGroup"
  3735. * @returns "AnimationGroup"
  3736. */
  3737. getClassName(): string;
  3738. /**
  3739. * Creates a detailled string about the object
  3740. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  3741. * @returns a string representing the object
  3742. */
  3743. toString(fullDetails?: boolean): string;
  3744. }
  3745. }
  3746. declare module BABYLON {
  3747. /**
  3748. * Class used to override all child animations of a given target
  3749. */
  3750. class AnimationPropertiesOverride {
  3751. /**
  3752. * Gets or sets a value indicating if animation blending must be used
  3753. */
  3754. enableBlending: boolean;
  3755. /**
  3756. * Gets or sets the blending speed to use when enableBlending is true
  3757. */
  3758. blendingSpeed: number;
  3759. /**
  3760. * Gets or sets the default loop mode to use
  3761. */
  3762. loopMode: number;
  3763. }
  3764. }
  3765. declare module BABYLON {
  3766. /**
  3767. * This represents the main contract an easing function should follow.
  3768. * Easing functions are used throughout the animation system.
  3769. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  3770. */
  3771. interface IEasingFunction {
  3772. /**
  3773. * Given an input gradient between 0 and 1, this returns the corrseponding value
  3774. * of the easing function.
  3775. * The link below provides some of the most common examples of easing functions.
  3776. * @see https://easings.net/
  3777. * @param gradient Defines the value between 0 and 1 we want the easing value for
  3778. * @returns the corresponding value on the curve defined by the easing function
  3779. */
  3780. ease(gradient: number): number;
  3781. }
  3782. /**
  3783. * Base class used for every default easing function.
  3784. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  3785. */
  3786. class EasingFunction implements IEasingFunction {
  3787. /**
  3788. * Interpolation follows the mathematical formula associated with the easing function.
  3789. */
  3790. static readonly EASINGMODE_EASEIN: number;
  3791. /**
  3792. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  3793. */
  3794. static readonly EASINGMODE_EASEOUT: number;
  3795. /**
  3796. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  3797. */
  3798. static readonly EASINGMODE_EASEINOUT: number;
  3799. private _easingMode;
  3800. /**
  3801. * Sets the easing mode of the current function.
  3802. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  3803. */
  3804. setEasingMode(easingMode: number): void;
  3805. /**
  3806. * Gets the current easing mode.
  3807. * @returns the easing mode
  3808. */
  3809. getEasingMode(): number;
  3810. /**
  3811. * @hidden
  3812. */
  3813. easeInCore(gradient: number): number;
  3814. /**
  3815. * Given an input gradient between 0 and 1, this returns the corrseponding value
  3816. * of the easing function.
  3817. * @param gradient Defines the value between 0 and 1 we want the easing value for
  3818. * @returns the corresponding value on the curve defined by the easing function
  3819. */
  3820. ease(gradient: number): number;
  3821. }
  3822. /**
  3823. * Easing function with a circle shape (see link below).
  3824. * @see https://easings.net/#easeInCirc
  3825. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  3826. */
  3827. class CircleEase extends EasingFunction implements IEasingFunction {
  3828. /** @hidden */
  3829. easeInCore(gradient: number): number;
  3830. }
  3831. /**
  3832. * Easing function with a ease back shape (see link below).
  3833. * @see https://easings.net/#easeInBack
  3834. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  3835. */
  3836. class BackEase extends EasingFunction implements IEasingFunction {
  3837. /** Defines the amplitude of the function */
  3838. amplitude: number;
  3839. /**
  3840. * Instantiates a back ease easing
  3841. * @see https://easings.net/#easeInBack
  3842. * @param amplitude Defines the amplitude of the function
  3843. */
  3844. constructor(
  3845. /** Defines the amplitude of the function */
  3846. amplitude?: number);
  3847. /** @hidden */
  3848. easeInCore(gradient: number): number;
  3849. }
  3850. /**
  3851. * Easing function with a bouncing shape (see link below).
  3852. * @see https://easings.net/#easeInBounce
  3853. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  3854. */
  3855. class BounceEase extends EasingFunction implements IEasingFunction {
  3856. /** Defines the number of bounces */
  3857. bounces: number;
  3858. /** Defines the amplitude of the bounce */
  3859. bounciness: number;
  3860. /**
  3861. * Instantiates a bounce easing
  3862. * @see https://easings.net/#easeInBounce
  3863. * @param bounces Defines the number of bounces
  3864. * @param bounciness Defines the amplitude of the bounce
  3865. */
  3866. constructor(
  3867. /** Defines the number of bounces */
  3868. bounces?: number,
  3869. /** Defines the amplitude of the bounce */
  3870. bounciness?: number);
  3871. /** @hidden */
  3872. easeInCore(gradient: number): number;
  3873. }
  3874. /**
  3875. * Easing function with a power of 3 shape (see link below).
  3876. * @see https://easings.net/#easeInCubic
  3877. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  3878. */
  3879. class CubicEase extends EasingFunction implements IEasingFunction {
  3880. /** @hidden */
  3881. easeInCore(gradient: number): number;
  3882. }
  3883. /**
  3884. * Easing function with an elastic shape (see link below).
  3885. * @see https://easings.net/#easeInElastic
  3886. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  3887. */
  3888. class ElasticEase extends EasingFunction implements IEasingFunction {
  3889. /** Defines the number of oscillations*/
  3890. oscillations: number;
  3891. /** Defines the amplitude of the oscillations*/
  3892. springiness: number;
  3893. /**
  3894. * Instantiates an elastic easing function
  3895. * @see https://easings.net/#easeInElastic
  3896. * @param oscillations Defines the number of oscillations
  3897. * @param springiness Defines the amplitude of the oscillations
  3898. */
  3899. constructor(
  3900. /** Defines the number of oscillations*/
  3901. oscillations?: number,
  3902. /** Defines the amplitude of the oscillations*/
  3903. springiness?: number);
  3904. /** @hidden */
  3905. easeInCore(gradient: number): number;
  3906. }
  3907. /**
  3908. * Easing function with an exponential shape (see link below).
  3909. * @see https://easings.net/#easeInExpo
  3910. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  3911. */
  3912. class ExponentialEase extends EasingFunction implements IEasingFunction {
  3913. /** Defines the exponent of the function */
  3914. exponent: number;
  3915. /**
  3916. * Instantiates an exponential easing function
  3917. * @see https://easings.net/#easeInExpo
  3918. * @param exponent Defines the exponent of the function
  3919. */
  3920. constructor(
  3921. /** Defines the exponent of the function */
  3922. exponent?: number);
  3923. /** @hidden */
  3924. easeInCore(gradient: number): number;
  3925. }
  3926. /**
  3927. * Easing function with a power shape (see link below).
  3928. * @see https://easings.net/#easeInQuad
  3929. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  3930. */
  3931. class PowerEase extends EasingFunction implements IEasingFunction {
  3932. /** Defines the power of the function */
  3933. power: number;
  3934. /**
  3935. * Instantiates an power base easing function
  3936. * @see https://easings.net/#easeInQuad
  3937. * @param power Defines the power of the function
  3938. */
  3939. constructor(
  3940. /** Defines the power of the function */
  3941. power?: number);
  3942. /** @hidden */
  3943. easeInCore(gradient: number): number;
  3944. }
  3945. /**
  3946. * Easing function with a power of 2 shape (see link below).
  3947. * @see https://easings.net/#easeInQuad
  3948. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  3949. */
  3950. class QuadraticEase extends EasingFunction implements IEasingFunction {
  3951. /** @hidden */
  3952. easeInCore(gradient: number): number;
  3953. }
  3954. /**
  3955. * Easing function with a power of 4 shape (see link below).
  3956. * @see https://easings.net/#easeInQuart
  3957. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  3958. */
  3959. class QuarticEase extends EasingFunction implements IEasingFunction {
  3960. /** @hidden */
  3961. easeInCore(gradient: number): number;
  3962. }
  3963. /**
  3964. * Easing function with a power of 5 shape (see link below).
  3965. * @see https://easings.net/#easeInQuint
  3966. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  3967. */
  3968. class QuinticEase extends EasingFunction implements IEasingFunction {
  3969. /** @hidden */
  3970. easeInCore(gradient: number): number;
  3971. }
  3972. /**
  3973. * Easing function with a sin shape (see link below).
  3974. * @see https://easings.net/#easeInSine
  3975. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  3976. */
  3977. class SineEase extends EasingFunction implements IEasingFunction {
  3978. /** @hidden */
  3979. easeInCore(gradient: number): number;
  3980. }
  3981. /**
  3982. * Easing function with a bezier shape (see link below).
  3983. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  3984. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  3985. */
  3986. class BezierCurveEase extends EasingFunction implements IEasingFunction {
  3987. /** Defines the x component of the start tangent in the bezier curve */
  3988. x1: number;
  3989. /** Defines the y component of the start tangent in the bezier curve */
  3990. y1: number;
  3991. /** Defines the x component of the end tangent in the bezier curve */
  3992. x2: number;
  3993. /** Defines the y component of the end tangent in the bezier curve */
  3994. y2: number;
  3995. /**
  3996. * Instantiates a bezier function
  3997. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  3998. * @param x1 Defines the x component of the start tangent in the bezier curve
  3999. * @param y1 Defines the y component of the start tangent in the bezier curve
  4000. * @param x2 Defines the x component of the end tangent in the bezier curve
  4001. * @param y2 Defines the y component of the end tangent in the bezier curve
  4002. */
  4003. constructor(
  4004. /** Defines the x component of the start tangent in the bezier curve */
  4005. x1?: number,
  4006. /** Defines the y component of the start tangent in the bezier curve */
  4007. y1?: number,
  4008. /** Defines the x component of the end tangent in the bezier curve */
  4009. x2?: number,
  4010. /** Defines the y component of the end tangent in the bezier curve */
  4011. y2?: number);
  4012. /** @hidden */
  4013. easeInCore(gradient: number): number;
  4014. }
  4015. }
  4016. declare module BABYLON {
  4017. /**
  4018. * Defines a runtime animation
  4019. */
  4020. class RuntimeAnimation {
  4021. private _events;
  4022. /**
  4023. * The current frame of the runtime animation
  4024. */
  4025. private _currentFrame;
  4026. /**
  4027. * The animation used by the runtime animation
  4028. */
  4029. private _animation;
  4030. /**
  4031. * The target of the runtime animation
  4032. */
  4033. private _target;
  4034. /**
  4035. * The initiating animatable
  4036. */
  4037. private _host;
  4038. /**
  4039. * The original value of the runtime animation
  4040. */
  4041. private _originalValue;
  4042. /**
  4043. * The original blend value of the runtime animation
  4044. */
  4045. private _originalBlendValue;
  4046. /**
  4047. * The offsets cache of the runtime animation
  4048. */
  4049. private _offsetsCache;
  4050. /**
  4051. * The high limits cache of the runtime animation
  4052. */
  4053. private _highLimitsCache;
  4054. /**
  4055. * Specifies if the runtime animation has been stopped
  4056. */
  4057. private _stopped;
  4058. /**
  4059. * The blending factor of the runtime animation
  4060. */
  4061. private _blendingFactor;
  4062. /**
  4063. * The BabylonJS scene
  4064. */
  4065. private _scene;
  4066. /**
  4067. * The current value of the runtime animation
  4068. */
  4069. private _currentValue;
  4070. /** @hidden */
  4071. _workValue: any;
  4072. /**
  4073. * The active target of the runtime animation
  4074. */
  4075. private _activeTarget;
  4076. /**
  4077. * The target path of the runtime animation
  4078. */
  4079. private _targetPath;
  4080. /**
  4081. * The weight of the runtime animation
  4082. */
  4083. private _weight;
  4084. /**
  4085. * The ratio offset of the runtime animation
  4086. */
  4087. private _ratioOffset;
  4088. /**
  4089. * The previous delay of the runtime animation
  4090. */
  4091. private _previousDelay;
  4092. /**
  4093. * The previous ratio of the runtime animation
  4094. */
  4095. private _previousRatio;
  4096. /**
  4097. * Gets the current frame of the runtime animation
  4098. */
  4099. readonly currentFrame: number;
  4100. /**
  4101. * Gets the weight of the runtime animation
  4102. */
  4103. readonly weight: number;
  4104. /**
  4105. * Gets the current value of the runtime animation
  4106. */
  4107. readonly currentValue: any;
  4108. /**
  4109. * Gets the target path of the runtime animation
  4110. */
  4111. readonly targetPath: string;
  4112. /**
  4113. * Gets the actual target of the runtime animation
  4114. */
  4115. readonly target: any;
  4116. /**
  4117. * Create a new RuntimeAnimation object
  4118. * @param target defines the target of the animation
  4119. * @param animation defines the source animation object
  4120. * @param scene defines the hosting scene
  4121. * @param host defines the initiating Animatable
  4122. */
  4123. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  4124. /**
  4125. * Gets the animation from the runtime animation
  4126. */
  4127. readonly animation: Animation;
  4128. /**
  4129. * Resets the runtime animation to the beginning
  4130. * @param restoreOriginal defines whether to restore the target property to the original value
  4131. */
  4132. reset(restoreOriginal?: boolean): void;
  4133. /**
  4134. * Specifies if the runtime animation is stopped
  4135. * @returns Boolean specifying if the runtime animation is stopped
  4136. */
  4137. isStopped(): boolean;
  4138. /**
  4139. * Disposes of the runtime animation
  4140. */
  4141. dispose(): void;
  4142. /**
  4143. * Interpolates the animation from the current frame
  4144. * @param currentFrame The frame to interpolate the animation to
  4145. * @param repeatCount The number of times that the animation should loop
  4146. * @param loopMode The type of looping mode to use
  4147. * @param offsetValue Animation offset value
  4148. * @param highLimitValue The high limit value
  4149. * @returns The interpolated value
  4150. */
  4151. private _interpolate;
  4152. /**
  4153. * Apply the interpolated value to the target
  4154. * @param currentValue defines the value computed by the animation
  4155. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  4156. */
  4157. setValue(currentValue: any, weight?: number): void;
  4158. private _setValue;
  4159. /**
  4160. * Gets the loop pmode of the runtime animation
  4161. * @returns Loop Mode
  4162. */
  4163. private _getCorrectLoopMode;
  4164. /**
  4165. * Move the current animation to a given frame
  4166. * @param frame defines the frame to move to
  4167. */
  4168. goToFrame(frame: number): void;
  4169. /**
  4170. * @hidden Internal use only
  4171. */
  4172. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  4173. /**
  4174. * Execute the current animation
  4175. * @param delay defines the delay to add to the current frame
  4176. * @param from defines the lower bound of the animation range
  4177. * @param to defines the upper bound of the animation range
  4178. * @param loop defines if the current animation must loop
  4179. * @param speedRatio defines the current speed ratio
  4180. * @param weight defines the weight of the animation (default is -1 so no weight)
  4181. * @param onLoop optional callback called when animation loops
  4182. * @returns a boolean indicating if the animation is running
  4183. */
  4184. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  4185. }
  4186. }
  4187. declare module BABYLON {
  4188. /**
  4189. * The action to be carried out following a trigger
  4190. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  4191. */
  4192. class Action {
  4193. /** the trigger, with or without parameters, for the action */
  4194. triggerOptions: any;
  4195. /**
  4196. * Trigger for the action
  4197. */
  4198. trigger: number;
  4199. /**
  4200. * Internal only - manager for action
  4201. * @hidden
  4202. */
  4203. _actionManager: ActionManager;
  4204. private _nextActiveAction;
  4205. private _child;
  4206. private _condition?;
  4207. private _triggerParameter;
  4208. /**
  4209. * An event triggered prior to action being executed.
  4210. */
  4211. onBeforeExecuteObservable: Observable<Action>;
  4212. /**
  4213. * Creates a new Action
  4214. * @param triggerOptions the trigger, with or without parameters, for the action
  4215. * @param condition an optional determinant of action
  4216. */
  4217. constructor(
  4218. /** the trigger, with or without parameters, for the action */
  4219. triggerOptions: any, condition?: Condition);
  4220. /**
  4221. * Internal only
  4222. * @hidden
  4223. */
  4224. _prepare(): void;
  4225. /**
  4226. * Gets the trigger parameters
  4227. * @returns the trigger parameters
  4228. */
  4229. getTriggerParameter(): any;
  4230. /**
  4231. * Internal only - executes current action event
  4232. * @hidden
  4233. */
  4234. _executeCurrent(evt?: ActionEvent): void;
  4235. /**
  4236. * Execute placeholder for child classes
  4237. * @param evt optional action event
  4238. */
  4239. execute(evt?: ActionEvent): void;
  4240. /**
  4241. * Skips to next active action
  4242. */
  4243. skipToNextActiveAction(): void;
  4244. /**
  4245. * Adds action to chain of actions, may be a DoNothingAction
  4246. * @param action defines the next action to execute
  4247. * @returns The action passed in
  4248. * @see https://www.babylonjs-playground.com/#1T30HR#0
  4249. */
  4250. then(action: Action): Action;
  4251. /**
  4252. * Internal only
  4253. * @hidden
  4254. */
  4255. _getProperty(propertyPath: string): string;
  4256. /**
  4257. * Internal only
  4258. * @hidden
  4259. */
  4260. _getEffectiveTarget(target: any, propertyPath: string): any;
  4261. /**
  4262. * Serialize placeholder for child classes
  4263. * @param parent of child
  4264. * @returns the serialized object
  4265. */
  4266. serialize(parent: any): any;
  4267. /**
  4268. * Internal only called by serialize
  4269. * @hidden
  4270. */
  4271. protected _serialize(serializedAction: any, parent?: any): any;
  4272. /**
  4273. * Internal only
  4274. * @hidden
  4275. */
  4276. static _SerializeValueAsString: (value: any) => string;
  4277. /**
  4278. * Internal only
  4279. * @hidden
  4280. */
  4281. static _GetTargetProperty: (target: Scene | Node) => {
  4282. name: string;
  4283. targetType: string;
  4284. value: string;
  4285. };
  4286. }
  4287. }
  4288. declare module BABYLON {
  4289. /**
  4290. * ActionEvent is the event being sent when an action is triggered.
  4291. */
  4292. class ActionEvent {
  4293. /** The mesh or sprite that triggered the action */
  4294. source: any;
  4295. /** The X mouse cursor position at the time of the event */
  4296. pointerX: number;
  4297. /** The Y mouse cursor position at the time of the event */
  4298. pointerY: number;
  4299. /** The mesh that is currently pointed at (can be null) */
  4300. meshUnderPointer: Nullable<AbstractMesh>;
  4301. /** the original (browser) event that triggered the ActionEvent */
  4302. sourceEvent?: any;
  4303. /** additional data for the event */
  4304. additionalData?: any;
  4305. /**
  4306. * Creates a new ActionEvent
  4307. * @param source The mesh or sprite that triggered the action
  4308. * @param pointerX The X mouse cursor position at the time of the event
  4309. * @param pointerY The Y mouse cursor position at the time of the event
  4310. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  4311. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  4312. * @param additionalData additional data for the event
  4313. */
  4314. constructor(
  4315. /** The mesh or sprite that triggered the action */
  4316. source: any,
  4317. /** The X mouse cursor position at the time of the event */
  4318. pointerX: number,
  4319. /** The Y mouse cursor position at the time of the event */
  4320. pointerY: number,
  4321. /** The mesh that is currently pointed at (can be null) */
  4322. meshUnderPointer: Nullable<AbstractMesh>,
  4323. /** the original (browser) event that triggered the ActionEvent */
  4324. sourceEvent?: any,
  4325. /** additional data for the event */
  4326. additionalData?: any);
  4327. /**
  4328. * Helper function to auto-create an ActionEvent from a source mesh.
  4329. * @param source The source mesh that triggered the event
  4330. * @param evt The original (browser) event
  4331. * @param additionalData additional data for the event
  4332. * @returns the new ActionEvent
  4333. */
  4334. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  4335. /**
  4336. * Helper function to auto-create an ActionEvent from a source sprite
  4337. * @param source The source sprite that triggered the event
  4338. * @param scene Scene associated with the sprite
  4339. * @param evt The original (browser) event
  4340. * @param additionalData additional data for the event
  4341. * @returns the new ActionEvent
  4342. */
  4343. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  4344. /**
  4345. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  4346. * @param scene the scene where the event occurred
  4347. * @param evt The original (browser) event
  4348. * @returns the new ActionEvent
  4349. */
  4350. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  4351. /**
  4352. * Helper function to auto-create an ActionEvent from a primitive
  4353. * @param prim defines the target primitive
  4354. * @param pointerPos defines the pointer position
  4355. * @param evt The original (browser) event
  4356. * @param additionalData additional data for the event
  4357. * @returns the new ActionEvent
  4358. */
  4359. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  4360. }
  4361. /**
  4362. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  4363. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  4364. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  4365. */
  4366. class ActionManager {
  4367. /**
  4368. * Nothing
  4369. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4370. */
  4371. static readonly NothingTrigger: number;
  4372. /**
  4373. * On pick
  4374. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4375. */
  4376. static readonly OnPickTrigger: number;
  4377. /**
  4378. * On left pick
  4379. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4380. */
  4381. static readonly OnLeftPickTrigger: number;
  4382. /**
  4383. * On right pick
  4384. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4385. */
  4386. static readonly OnRightPickTrigger: number;
  4387. /**
  4388. * On center pick
  4389. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4390. */
  4391. static readonly OnCenterPickTrigger: number;
  4392. /**
  4393. * On pick down
  4394. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4395. */
  4396. static readonly OnPickDownTrigger: number;
  4397. /**
  4398. * On double pick
  4399. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4400. */
  4401. static readonly OnDoublePickTrigger: number;
  4402. /**
  4403. * On pick up
  4404. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4405. */
  4406. static readonly OnPickUpTrigger: number;
  4407. /**
  4408. * On pick out.
  4409. * This trigger will only be raised if you also declared a OnPickDown
  4410. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4411. */
  4412. static readonly OnPickOutTrigger: number;
  4413. /**
  4414. * On long press
  4415. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4416. */
  4417. static readonly OnLongPressTrigger: number;
  4418. /**
  4419. * On pointer over
  4420. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4421. */
  4422. static readonly OnPointerOverTrigger: number;
  4423. /**
  4424. * On pointer out
  4425. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4426. */
  4427. static readonly OnPointerOutTrigger: number;
  4428. /**
  4429. * On every frame
  4430. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4431. */
  4432. static readonly OnEveryFrameTrigger: number;
  4433. /**
  4434. * On intersection enter
  4435. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4436. */
  4437. static readonly OnIntersectionEnterTrigger: number;
  4438. /**
  4439. * On intersection exit
  4440. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4441. */
  4442. static readonly OnIntersectionExitTrigger: number;
  4443. /**
  4444. * On key down
  4445. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4446. */
  4447. static readonly OnKeyDownTrigger: number;
  4448. /**
  4449. * On key up
  4450. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4451. */
  4452. static readonly OnKeyUpTrigger: number;
  4453. /** Gets the list of active triggers */
  4454. static Triggers: {
  4455. [key: string]: number;
  4456. };
  4457. /** Gets the list of actions */
  4458. actions: Action[];
  4459. /** Gets the cursor to use when hovering items */
  4460. hoverCursor: string;
  4461. private _scene;
  4462. /**
  4463. * Creates a new action manager
  4464. * @param scene defines the hosting scene
  4465. */
  4466. constructor(scene: Scene);
  4467. /**
  4468. * Releases all associated resources
  4469. */
  4470. dispose(): void;
  4471. /**
  4472. * Gets hosting scene
  4473. * @returns the hosting scene
  4474. */
  4475. getScene(): Scene;
  4476. /**
  4477. * Does this action manager handles actions of any of the given triggers
  4478. * @param triggers defines the triggers to be tested
  4479. * @return a boolean indicating whether one (or more) of the triggers is handled
  4480. */
  4481. hasSpecificTriggers(triggers: number[]): boolean;
  4482. /**
  4483. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  4484. * speed.
  4485. * @param triggerA defines the trigger to be tested
  4486. * @param triggerB defines the trigger to be tested
  4487. * @return a boolean indicating whether one (or more) of the triggers is handled
  4488. */
  4489. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  4490. /**
  4491. * Does this action manager handles actions of a given trigger
  4492. * @param trigger defines the trigger to be tested
  4493. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  4494. * @return whether the trigger is handled
  4495. */
  4496. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  4497. /**
  4498. * Does this action manager has pointer triggers
  4499. */
  4500. readonly hasPointerTriggers: boolean;
  4501. /**
  4502. * Does this action manager has pick triggers
  4503. */
  4504. readonly hasPickTriggers: boolean;
  4505. /**
  4506. * Does exist one action manager with at least one trigger
  4507. **/
  4508. static readonly HasTriggers: boolean;
  4509. /**
  4510. * Does exist one action manager with at least one pick trigger
  4511. **/
  4512. static readonly HasPickTriggers: boolean;
  4513. /**
  4514. * Does exist one action manager that handles actions of a given trigger
  4515. * @param trigger defines the trigger to be tested
  4516. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  4517. **/
  4518. static HasSpecificTrigger(trigger: number): boolean;
  4519. /**
  4520. * Registers an action to this action manager
  4521. * @param action defines the action to be registered
  4522. * @return the action amended (prepared) after registration
  4523. */
  4524. registerAction(action: Action): Nullable<Action>;
  4525. /**
  4526. * Unregisters an action to this action manager
  4527. * @param action defines the action to be unregistered
  4528. * @return a boolean indicating whether the action has been unregistered
  4529. */
  4530. unregisterAction(action: Action): Boolean;
  4531. /**
  4532. * Process a specific trigger
  4533. * @param trigger defines the trigger to process
  4534. * @param evt defines the event details to be processed
  4535. */
  4536. processTrigger(trigger: number, evt?: ActionEvent): void;
  4537. /** @hidden */
  4538. _getEffectiveTarget(target: any, propertyPath: string): any;
  4539. /** @hidden */
  4540. _getProperty(propertyPath: string): string;
  4541. /**
  4542. * Serialize this manager to a JSON object
  4543. * @param name defines the property name to store this manager
  4544. * @returns a JSON representation of this manager
  4545. */
  4546. serialize(name: string): any;
  4547. /**
  4548. * Creates a new ActionManager from a JSON data
  4549. * @param parsedActions defines the JSON data to read from
  4550. * @param object defines the hosting mesh
  4551. * @param scene defines the hosting scene
  4552. */
  4553. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  4554. /**
  4555. * Get a trigger name by index
  4556. * @param trigger defines the trigger index
  4557. * @returns a trigger name
  4558. */
  4559. static GetTriggerName(trigger: number): string;
  4560. }
  4561. }
  4562. declare module BABYLON {
  4563. /**
  4564. * A Condition applied to an Action
  4565. */
  4566. class Condition {
  4567. /**
  4568. * Internal only - manager for action
  4569. * @hidden
  4570. */
  4571. _actionManager: ActionManager;
  4572. /**
  4573. * Internal only
  4574. * @hidden
  4575. */
  4576. _evaluationId: number;
  4577. /**
  4578. * Internal only
  4579. * @hidden
  4580. */
  4581. _currentResult: boolean;
  4582. /**
  4583. * Creates a new Condition
  4584. * @param actionManager the manager of the action the condition is applied to
  4585. */
  4586. constructor(actionManager: ActionManager);
  4587. /**
  4588. * Check if the current condition is valid
  4589. * @returns a boolean
  4590. */
  4591. isValid(): boolean;
  4592. /**
  4593. * Internal only
  4594. * @hidden
  4595. */
  4596. _getProperty(propertyPath: string): string;
  4597. /**
  4598. * Internal only
  4599. * @hidden
  4600. */
  4601. _getEffectiveTarget(target: any, propertyPath: string): any;
  4602. /**
  4603. * Serialize placeholder for child classes
  4604. * @returns the serialized object
  4605. */
  4606. serialize(): any;
  4607. /**
  4608. * Internal only
  4609. * @hidden
  4610. */
  4611. protected _serialize(serializedCondition: any): any;
  4612. }
  4613. /**
  4614. * Defines specific conditional operators as extensions of Condition
  4615. */
  4616. class ValueCondition extends Condition {
  4617. /** path to specify the property of the target the conditional operator uses */
  4618. propertyPath: string;
  4619. /** the value compared by the conditional operator against the current value of the property */
  4620. value: any;
  4621. /** the conditional operator, default ValueCondition.IsEqual */
  4622. operator: number;
  4623. /**
  4624. * Internal only
  4625. * @hidden
  4626. */
  4627. private static _IsEqual;
  4628. /**
  4629. * Internal only
  4630. * @hidden
  4631. */
  4632. private static _IsDifferent;
  4633. /**
  4634. * Internal only
  4635. * @hidden
  4636. */
  4637. private static _IsGreater;
  4638. /**
  4639. * Internal only
  4640. * @hidden
  4641. */
  4642. private static _IsLesser;
  4643. /**
  4644. * returns the number for IsEqual
  4645. */
  4646. static readonly IsEqual: number;
  4647. /**
  4648. * Returns the number for IsDifferent
  4649. */
  4650. static readonly IsDifferent: number;
  4651. /**
  4652. * Returns the number for IsGreater
  4653. */
  4654. static readonly IsGreater: number;
  4655. /**
  4656. * Returns the number for IsLesser
  4657. */
  4658. static readonly IsLesser: number;
  4659. /**
  4660. * Internal only The action manager for the condition
  4661. * @hidden
  4662. */
  4663. _actionManager: ActionManager;
  4664. /**
  4665. * Internal only
  4666. * @hidden
  4667. */
  4668. private _target;
  4669. /**
  4670. * Internal only
  4671. * @hidden
  4672. */
  4673. private _effectiveTarget;
  4674. /**
  4675. * Internal only
  4676. * @hidden
  4677. */
  4678. private _property;
  4679. /**
  4680. * Creates a new ValueCondition
  4681. * @param actionManager manager for the action the condition applies to
  4682. * @param target for the action
  4683. * @param propertyPath path to specify the property of the target the conditional operator uses
  4684. * @param value the value compared by the conditional operator against the current value of the property
  4685. * @param operator the conditional operator, default ValueCondition.IsEqual
  4686. */
  4687. constructor(actionManager: ActionManager, target: any,
  4688. /** path to specify the property of the target the conditional operator uses */
  4689. propertyPath: string,
  4690. /** the value compared by the conditional operator against the current value of the property */
  4691. value: any,
  4692. /** the conditional operator, default ValueCondition.IsEqual */
  4693. operator?: number);
  4694. /**
  4695. * Compares the given value with the property value for the specified conditional operator
  4696. * @returns the result of the comparison
  4697. */
  4698. isValid(): boolean;
  4699. /**
  4700. * Serialize the ValueCondition into a JSON compatible object
  4701. * @returns serialization object
  4702. */
  4703. serialize(): any;
  4704. /**
  4705. * Gets the name of the conditional operator for the ValueCondition
  4706. * @param operator the conditional operator
  4707. * @returns the name
  4708. */
  4709. static GetOperatorName(operator: number): string;
  4710. }
  4711. /**
  4712. * Defines a predicate condition as an extension of Condition
  4713. */
  4714. class PredicateCondition extends Condition {
  4715. /** defines the predicate function used to validate the condition */
  4716. predicate: () => boolean;
  4717. /**
  4718. * Internal only - manager for action
  4719. * @hidden
  4720. */
  4721. _actionManager: ActionManager;
  4722. /**
  4723. * Creates a new PredicateCondition
  4724. * @param actionManager manager for the action the condition applies to
  4725. * @param predicate defines the predicate function used to validate the condition
  4726. */
  4727. constructor(actionManager: ActionManager,
  4728. /** defines the predicate function used to validate the condition */
  4729. predicate: () => boolean);
  4730. /**
  4731. * @returns the validity of the predicate condition
  4732. */
  4733. isValid(): boolean;
  4734. }
  4735. /**
  4736. * Defines a state condition as an extension of Condition
  4737. */
  4738. class StateCondition extends Condition {
  4739. /** Value to compare with target state */
  4740. value: string;
  4741. /**
  4742. * Internal only - manager for action
  4743. * @hidden
  4744. */
  4745. _actionManager: ActionManager;
  4746. /**
  4747. * Internal only
  4748. * @hidden
  4749. */
  4750. private _target;
  4751. /**
  4752. * Creates a new StateCondition
  4753. * @param actionManager manager for the action the condition applies to
  4754. * @param target of the condition
  4755. * @param value to compare with target state
  4756. */
  4757. constructor(actionManager: ActionManager, target: any,
  4758. /** Value to compare with target state */
  4759. value: string);
  4760. /**
  4761. * Gets a boolean indicating if the current condition is met
  4762. * @returns the validity of the state
  4763. */
  4764. isValid(): boolean;
  4765. /**
  4766. * Serialize the StateCondition into a JSON compatible object
  4767. * @returns serialization object
  4768. */
  4769. serialize(): any;
  4770. }
  4771. }
  4772. declare module BABYLON {
  4773. /**
  4774. * This defines an action responsible to toggle a boolean once triggered.
  4775. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  4776. */
  4777. class SwitchBooleanAction extends Action {
  4778. /**
  4779. * The path to the boolean property in the target object
  4780. */
  4781. propertyPath: string;
  4782. private _target;
  4783. private _effectiveTarget;
  4784. private _property;
  4785. /**
  4786. * Instantiate the action
  4787. * @param triggerOptions defines the trigger options
  4788. * @param target defines the object containing the boolean
  4789. * @param propertyPath defines the path to the boolean property in the target object
  4790. * @param condition defines the trigger related conditions
  4791. */
  4792. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  4793. /** @hidden */
  4794. _prepare(): void;
  4795. /**
  4796. * Execute the action toggle the boolean value.
  4797. */
  4798. execute(): void;
  4799. /**
  4800. * Serializes the actions and its related information.
  4801. * @param parent defines the object to serialize in
  4802. * @returns the serialized object
  4803. */
  4804. serialize(parent: any): any;
  4805. }
  4806. /**
  4807. * This defines an action responsible to set a the state field of the target
  4808. * to a desired value once triggered.
  4809. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  4810. */
  4811. class SetStateAction extends Action {
  4812. /**
  4813. * The value to store in the state field.
  4814. */
  4815. value: string;
  4816. private _target;
  4817. /**
  4818. * Instantiate the action
  4819. * @param triggerOptions defines the trigger options
  4820. * @param target defines the object containing the state property
  4821. * @param value defines the value to store in the state field
  4822. * @param condition defines the trigger related conditions
  4823. */
  4824. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  4825. /**
  4826. * Execute the action and store the value on the target state property.
  4827. */
  4828. execute(): void;
  4829. /**
  4830. * Serializes the actions and its related information.
  4831. * @param parent defines the object to serialize in
  4832. * @returns the serialized object
  4833. */
  4834. serialize(parent: any): any;
  4835. }
  4836. /**
  4837. * This defines an action responsible to set a property of the target
  4838. * to a desired value once triggered.
  4839. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  4840. */
  4841. class SetValueAction extends Action {
  4842. /**
  4843. * The path of the property to set in the target.
  4844. */
  4845. propertyPath: string;
  4846. /**
  4847. * The value to set in the property
  4848. */
  4849. value: any;
  4850. private _target;
  4851. private _effectiveTarget;
  4852. private _property;
  4853. /**
  4854. * Instantiate the action
  4855. * @param triggerOptions defines the trigger options
  4856. * @param target defines the object containing the property
  4857. * @param propertyPath defines the path of the property to set in the target
  4858. * @param value defines the value to set in the property
  4859. * @param condition defines the trigger related conditions
  4860. */
  4861. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  4862. /** @hidden */
  4863. _prepare(): void;
  4864. /**
  4865. * Execute the action and set the targetted property to the desired value.
  4866. */
  4867. execute(): void;
  4868. /**
  4869. * Serializes the actions and its related information.
  4870. * @param parent defines the object to serialize in
  4871. * @returns the serialized object
  4872. */
  4873. serialize(parent: any): any;
  4874. }
  4875. /**
  4876. * This defines an action responsible to increment the target value
  4877. * to a desired value once triggered.
  4878. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  4879. */
  4880. class IncrementValueAction extends Action {
  4881. /**
  4882. * The path of the property to increment in the target.
  4883. */
  4884. propertyPath: string;
  4885. /**
  4886. * The value we should increment the property by.
  4887. */
  4888. value: any;
  4889. private _target;
  4890. private _effectiveTarget;
  4891. private _property;
  4892. /**
  4893. * Instantiate the action
  4894. * @param triggerOptions defines the trigger options
  4895. * @param target defines the object containing the property
  4896. * @param propertyPath defines the path of the property to increment in the target
  4897. * @param value defines the value value we should increment the property by
  4898. * @param condition defines the trigger related conditions
  4899. */
  4900. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  4901. /** @hidden */
  4902. _prepare(): void;
  4903. /**
  4904. * Execute the action and increment the target of the value amount.
  4905. */
  4906. execute(): void;
  4907. /**
  4908. * Serializes the actions and its related information.
  4909. * @param parent defines the object to serialize in
  4910. * @returns the serialized object
  4911. */
  4912. serialize(parent: any): any;
  4913. }
  4914. /**
  4915. * This defines an action responsible to start an animation once triggered.
  4916. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  4917. */
  4918. class PlayAnimationAction extends Action {
  4919. /**
  4920. * Where the animation should start (animation frame)
  4921. */
  4922. from: number;
  4923. /**
  4924. * Where the animation should stop (animation frame)
  4925. */
  4926. to: number;
  4927. /**
  4928. * Define if the animation should loop or stop after the first play.
  4929. */
  4930. loop?: boolean;
  4931. private _target;
  4932. /**
  4933. * Instantiate the action
  4934. * @param triggerOptions defines the trigger options
  4935. * @param target defines the target animation or animation name
  4936. * @param from defines from where the animation should start (animation frame)
  4937. * @param end defines where the animation should stop (animation frame)
  4938. * @param loop defines if the animation should loop or stop after the first play
  4939. * @param condition defines the trigger related conditions
  4940. */
  4941. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  4942. /** @hidden */
  4943. _prepare(): void;
  4944. /**
  4945. * Execute the action and play the animation.
  4946. */
  4947. execute(): void;
  4948. /**
  4949. * Serializes the actions and its related information.
  4950. * @param parent defines the object to serialize in
  4951. * @returns the serialized object
  4952. */
  4953. serialize(parent: any): any;
  4954. }
  4955. /**
  4956. * This defines an action responsible to stop an animation once triggered.
  4957. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  4958. */
  4959. class StopAnimationAction extends Action {
  4960. private _target;
  4961. /**
  4962. * Instantiate the action
  4963. * @param triggerOptions defines the trigger options
  4964. * @param target defines the target animation or animation name
  4965. * @param condition defines the trigger related conditions
  4966. */
  4967. constructor(triggerOptions: any, target: any, condition?: Condition);
  4968. /** @hidden */
  4969. _prepare(): void;
  4970. /**
  4971. * Execute the action and stop the animation.
  4972. */
  4973. execute(): void;
  4974. /**
  4975. * Serializes the actions and its related information.
  4976. * @param parent defines the object to serialize in
  4977. * @returns the serialized object
  4978. */
  4979. serialize(parent: any): any;
  4980. }
  4981. /**
  4982. * This defines an action responsible that does nothing once triggered.
  4983. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  4984. */
  4985. class DoNothingAction extends Action {
  4986. /**
  4987. * Instantiate the action
  4988. * @param triggerOptions defines the trigger options
  4989. * @param condition defines the trigger related conditions
  4990. */
  4991. constructor(triggerOptions?: any, condition?: Condition);
  4992. /**
  4993. * Execute the action and do nothing.
  4994. */
  4995. execute(): void;
  4996. /**
  4997. * Serializes the actions and its related information.
  4998. * @param parent defines the object to serialize in
  4999. * @returns the serialized object
  5000. */
  5001. serialize(parent: any): any;
  5002. }
  5003. /**
  5004. * This defines an action responsible to trigger several actions once triggered.
  5005. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  5006. */
  5007. class CombineAction extends Action {
  5008. /**
  5009. * The list of aggregated animations to run.
  5010. */
  5011. children: Action[];
  5012. /**
  5013. * Instantiate the action
  5014. * @param triggerOptions defines the trigger options
  5015. * @param children defines the list of aggregated animations to run
  5016. * @param condition defines the trigger related conditions
  5017. */
  5018. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  5019. /** @hidden */
  5020. _prepare(): void;
  5021. /**
  5022. * Execute the action and executes all the aggregated actions.
  5023. */
  5024. execute(evt: ActionEvent): void;
  5025. /**
  5026. * Serializes the actions and its related information.
  5027. * @param parent defines the object to serialize in
  5028. * @returns the serialized object
  5029. */
  5030. serialize(parent: any): any;
  5031. }
  5032. /**
  5033. * This defines an action responsible to run code (external event) once triggered.
  5034. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  5035. */
  5036. class ExecuteCodeAction extends Action {
  5037. /**
  5038. * The callback function to run.
  5039. */
  5040. func: (evt: ActionEvent) => void;
  5041. /**
  5042. * Instantiate the action
  5043. * @param triggerOptions defines the trigger options
  5044. * @param func defines the callback function to run
  5045. * @param condition defines the trigger related conditions
  5046. */
  5047. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  5048. /**
  5049. * Execute the action and run the attached code.
  5050. */
  5051. execute(evt: ActionEvent): void;
  5052. }
  5053. /**
  5054. * This defines an action responsible to set the parent property of the target once triggered.
  5055. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  5056. */
  5057. class SetParentAction extends Action {
  5058. private _parent;
  5059. private _target;
  5060. /**
  5061. * Instantiate the action
  5062. * @param triggerOptions defines the trigger options
  5063. * @param target defines the target containing the parent property
  5064. * @param parent defines from where the animation should start (animation frame)
  5065. * @param condition defines the trigger related conditions
  5066. */
  5067. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  5068. /** @hidden */
  5069. _prepare(): void;
  5070. /**
  5071. * Execute the action and set the parent property.
  5072. */
  5073. execute(): void;
  5074. /**
  5075. * Serializes the actions and its related information.
  5076. * @param parent defines the object to serialize in
  5077. * @returns the serialized object
  5078. */
  5079. serialize(parent: any): any;
  5080. }
  5081. }
  5082. declare module BABYLON {
  5083. /**
  5084. * This defines an action helpful to play a defined sound on a triggered action.
  5085. */
  5086. class PlaySoundAction extends Action {
  5087. private _sound;
  5088. /**
  5089. * Instantiate the action
  5090. * @param triggerOptions defines the trigger options
  5091. * @param sound defines the sound to play
  5092. * @param condition defines the trigger related conditions
  5093. */
  5094. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  5095. /** @hidden */
  5096. _prepare(): void;
  5097. /**
  5098. * Execute the action and play the sound.
  5099. */
  5100. execute(): void;
  5101. /**
  5102. * Serializes the actions and its related information.
  5103. * @param parent defines the object to serialize in
  5104. * @returns the serialized object
  5105. */
  5106. serialize(parent: any): any;
  5107. }
  5108. /**
  5109. * This defines an action helpful to stop a defined sound on a triggered action.
  5110. */
  5111. class StopSoundAction extends Action {
  5112. private _sound;
  5113. /**
  5114. * Instantiate the action
  5115. * @param triggerOptions defines the trigger options
  5116. * @param sound defines the sound to stop
  5117. * @param condition defines the trigger related conditions
  5118. */
  5119. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  5120. /** @hidden */
  5121. _prepare(): void;
  5122. /**
  5123. * Execute the action and stop the sound.
  5124. */
  5125. execute(): void;
  5126. /**
  5127. * Serializes the actions and its related information.
  5128. * @param parent defines the object to serialize in
  5129. * @returns the serialized object
  5130. */
  5131. serialize(parent: any): any;
  5132. }
  5133. }
  5134. declare module BABYLON {
  5135. /**
  5136. * This defines an action responsible to change the value of a property
  5137. * by interpolating between its current value and the newly set one once triggered.
  5138. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  5139. */
  5140. class InterpolateValueAction extends Action {
  5141. /**
  5142. * Defines the path of the property where the value should be interpolated
  5143. */
  5144. propertyPath: string;
  5145. /**
  5146. * Defines the target value at the end of the interpolation.
  5147. */
  5148. value: any;
  5149. /**
  5150. * Defines the time it will take for the property to interpolate to the value.
  5151. */
  5152. duration: number;
  5153. /**
  5154. * Defines if the other scene animations should be stopped when the action has been triggered
  5155. */
  5156. stopOtherAnimations?: boolean;
  5157. /**
  5158. * Defines a callback raised once the interpolation animation has been done.
  5159. */
  5160. onInterpolationDone?: () => void;
  5161. /**
  5162. * Observable triggered once the interpolation animation has been done.
  5163. */
  5164. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  5165. private _target;
  5166. private _effectiveTarget;
  5167. private _property;
  5168. /**
  5169. * Instantiate the action
  5170. * @param triggerOptions defines the trigger options
  5171. * @param target defines the object containing the value to interpolate
  5172. * @param propertyPath defines the path to the property in the target object
  5173. * @param value defines the target value at the end of the interpolation
  5174. * @param duration deines the time it will take for the property to interpolate to the value.
  5175. * @param condition defines the trigger related conditions
  5176. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  5177. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  5178. */
  5179. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  5180. /** @hidden */
  5181. _prepare(): void;
  5182. /**
  5183. * Execute the action starts the value interpolation.
  5184. */
  5185. execute(): void;
  5186. /**
  5187. * Serializes the actions and its related information.
  5188. * @param parent defines the object to serialize in
  5189. * @returns the serialized object
  5190. */
  5191. serialize(parent: any): any;
  5192. }
  5193. }
  5194. declare module BABYLON {
  5195. /**
  5196. * Class used to work with sound analyzer using fast fourier transform (FFT)
  5197. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5198. */
  5199. class Analyser {
  5200. /**
  5201. * Gets or sets the smoothing
  5202. * @ignorenaming
  5203. */
  5204. SMOOTHING: number;
  5205. /**
  5206. * Gets or sets the FFT table size
  5207. * @ignorenaming
  5208. */
  5209. FFT_SIZE: number;
  5210. /**
  5211. * Gets or sets the bar graph amplitude
  5212. * @ignorenaming
  5213. */
  5214. BARGRAPHAMPLITUDE: number;
  5215. /**
  5216. * Gets or sets the position of the debug canvas
  5217. * @ignorenaming
  5218. */
  5219. DEBUGCANVASPOS: {
  5220. x: number;
  5221. y: number;
  5222. };
  5223. /**
  5224. * Gets or sets the debug canvas size
  5225. * @ignorenaming
  5226. */
  5227. DEBUGCANVASSIZE: {
  5228. width: number;
  5229. height: number;
  5230. };
  5231. private _byteFreqs;
  5232. private _byteTime;
  5233. private _floatFreqs;
  5234. private _webAudioAnalyser;
  5235. private _debugCanvas;
  5236. private _debugCanvasContext;
  5237. private _scene;
  5238. private _registerFunc;
  5239. private _audioEngine;
  5240. /**
  5241. * Creates a new analyser
  5242. * @param scene defines hosting scene
  5243. */
  5244. constructor(scene: Scene);
  5245. /**
  5246. * Get the number of data values you will have to play with for the visualization
  5247. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  5248. * @returns a number
  5249. */
  5250. getFrequencyBinCount(): number;
  5251. /**
  5252. * Gets the current frequency data as a byte array
  5253. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  5254. * @returns a Uint8Array
  5255. */
  5256. getByteFrequencyData(): Uint8Array;
  5257. /**
  5258. * Gets the current waveform as a byte array
  5259. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  5260. * @returns a Uint8Array
  5261. */
  5262. getByteTimeDomainData(): Uint8Array;
  5263. /**
  5264. * Gets the current frequency data as a float array
  5265. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  5266. * @returns a Float32Array
  5267. */
  5268. getFloatFrequencyData(): Float32Array;
  5269. /**
  5270. * Renders the debug canvas
  5271. */
  5272. drawDebugCanvas(): void;
  5273. /**
  5274. * Stops rendering the debug canvas and removes it
  5275. */
  5276. stopDebugCanvas(): void;
  5277. /**
  5278. * Connects two audio nodes
  5279. * @param inputAudioNode defines first node to connect
  5280. * @param outputAudioNode defines second node to connect
  5281. */
  5282. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  5283. /**
  5284. * Releases all associated resources
  5285. */
  5286. dispose(): void;
  5287. }
  5288. }
  5289. declare module BABYLON {
  5290. /**
  5291. * This represents an audio engine and it is responsible
  5292. * to play, synchronize and analyse sounds throughout the application.
  5293. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5294. */
  5295. interface IAudioEngine extends IDisposable {
  5296. /**
  5297. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  5298. */
  5299. readonly canUseWebAudio: boolean;
  5300. /**
  5301. * Gets the current AudioContext if available.
  5302. */
  5303. readonly audioContext: Nullable<AudioContext>;
  5304. /**
  5305. * The master gain node defines the global audio volume of your audio engine.
  5306. */
  5307. readonly masterGain: GainNode;
  5308. /**
  5309. * Gets whether or not mp3 are supported by your browser.
  5310. */
  5311. readonly isMP3supported: boolean;
  5312. /**
  5313. * Gets whether or not ogg are supported by your browser.
  5314. */
  5315. readonly isOGGsupported: boolean;
  5316. /**
  5317. * Defines if Babylon should emit a warning if WebAudio is not supported.
  5318. * @ignoreNaming
  5319. */
  5320. WarnedWebAudioUnsupported: boolean;
  5321. /**
  5322. * Defines if the audio engine relies on a custom unlocked button.
  5323. * In this case, the embedded button will not be displayed.
  5324. */
  5325. useCustomUnlockedButton: boolean;
  5326. /**
  5327. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  5328. */
  5329. readonly unlocked: boolean;
  5330. /**
  5331. * Event raised when audio has been unlocked on the browser.
  5332. */
  5333. onAudioUnlockedObservable: Observable<AudioEngine>;
  5334. /**
  5335. * Event raised when audio has been locked on the browser.
  5336. */
  5337. onAudioLockedObservable: Observable<AudioEngine>;
  5338. /**
  5339. * Flags the audio engine in Locked state.
  5340. * This happens due to new browser policies preventing audio to autoplay.
  5341. */
  5342. lock(): void;
  5343. /**
  5344. * Unlocks the audio engine once a user action has been done on the dom.
  5345. * This is helpful to resume play once browser policies have been satisfied.
  5346. */
  5347. unlock(): void;
  5348. }
  5349. /**
  5350. * This represents the default audio engine used in babylon.
  5351. * It is responsible to play, synchronize and analyse sounds throughout the application.
  5352. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5353. */
  5354. class AudioEngine implements IAudioEngine {
  5355. private _audioContext;
  5356. private _audioContextInitialized;
  5357. private _muteButton;
  5358. private _hostElement;
  5359. /**
  5360. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  5361. */
  5362. canUseWebAudio: boolean;
  5363. /**
  5364. * The master gain node defines the global audio volume of your audio engine.
  5365. */
  5366. masterGain: GainNode;
  5367. /**
  5368. * Defines if Babylon should emit a warning if WebAudio is not supported.
  5369. * @ignoreNaming
  5370. */
  5371. WarnedWebAudioUnsupported: boolean;
  5372. /**
  5373. * Gets whether or not mp3 are supported by your browser.
  5374. */
  5375. isMP3supported: boolean;
  5376. /**
  5377. * Gets whether or not ogg are supported by your browser.
  5378. */
  5379. isOGGsupported: boolean;
  5380. /**
  5381. * Gets whether audio has been unlocked on the device.
  5382. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  5383. * a user interaction has happened.
  5384. */
  5385. unlocked: boolean;
  5386. /**
  5387. * Defines if the audio engine relies on a custom unlocked button.
  5388. * In this case, the embedded button will not be displayed.
  5389. */
  5390. useCustomUnlockedButton: boolean;
  5391. /**
  5392. * Event raised when audio has been unlocked on the browser.
  5393. */
  5394. onAudioUnlockedObservable: Observable<AudioEngine>;
  5395. /**
  5396. * Event raised when audio has been locked on the browser.
  5397. */
  5398. onAudioLockedObservable: Observable<AudioEngine>;
  5399. /**
  5400. * Gets the current AudioContext if available.
  5401. */
  5402. readonly audioContext: Nullable<AudioContext>;
  5403. private _connectedAnalyser;
  5404. /**
  5405. * Instantiates a new audio engine.
  5406. *
  5407. * There should be only one per page as some browsers restrict the number
  5408. * of audio contexts you can create.
  5409. * @param hostElement defines the host element where to display the mute icon if necessary
  5410. */
  5411. constructor(hostElement?: Nullable<HTMLElement>);
  5412. /**
  5413. * Flags the audio engine in Locked state.
  5414. * This happens due to new browser policies preventing audio to autoplay.
  5415. */
  5416. lock(): void;
  5417. /**
  5418. * Unlocks the audio engine once a user action has been done on the dom.
  5419. * This is helpful to resume play once browser policies have been satisfied.
  5420. */
  5421. unlock(): void;
  5422. private _resumeAudioContext;
  5423. private _initializeAudioContext;
  5424. private _tryToRun;
  5425. private _triggerRunningState;
  5426. private _triggerSuspendedState;
  5427. private _displayMuteButton;
  5428. private _moveButtonToTopLeft;
  5429. private _onResize;
  5430. private _hideMuteButton;
  5431. /**
  5432. * Destroy and release the resources associated with the audio ccontext.
  5433. */
  5434. dispose(): void;
  5435. /**
  5436. * Gets the global volume sets on the master gain.
  5437. * @returns the global volume if set or -1 otherwise
  5438. */
  5439. getGlobalVolume(): number;
  5440. /**
  5441. * Sets the global volume of your experience (sets on the master gain).
  5442. * @param newVolume Defines the new global volume of the application
  5443. */
  5444. setGlobalVolume(newVolume: number): void;
  5445. /**
  5446. * Connect the audio engine to an audio analyser allowing some amazing
  5447. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  5448. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  5449. * @param analyser The analyser to connect to the engine
  5450. */
  5451. connectToAnalyser(analyser: Analyser): void;
  5452. }
  5453. }
  5454. declare module BABYLON {
  5455. interface AbstractScene {
  5456. /**
  5457. * The list of sounds used in the scene.
  5458. */
  5459. sounds: Nullable<Array<Sound>>;
  5460. }
  5461. interface Scene {
  5462. /**
  5463. * @hidden
  5464. * Backing field
  5465. */
  5466. _mainSoundTrack: SoundTrack;
  5467. /**
  5468. * The main sound track played by the scene.
  5469. * It cotains your primary collection of sounds.
  5470. */
  5471. mainSoundTrack: SoundTrack;
  5472. /**
  5473. * The list of sound tracks added to the scene
  5474. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5475. */
  5476. soundTracks: Nullable<Array<SoundTrack>>;
  5477. /**
  5478. * Gets a sound using a given name
  5479. * @param name defines the name to search for
  5480. * @return the found sound or null if not found at all.
  5481. */
  5482. getSoundByName(name: string): Nullable<Sound>;
  5483. /**
  5484. * Gets or sets if audio support is enabled
  5485. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5486. */
  5487. audioEnabled: boolean;
  5488. /**
  5489. * Gets or sets if audio will be output to headphones
  5490. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5491. */
  5492. headphone: boolean;
  5493. }
  5494. /**
  5495. * Defines the sound scene component responsible to manage any sounds
  5496. * in a given scene.
  5497. */
  5498. class AudioSceneComponent implements ISceneSerializableComponent {
  5499. /**
  5500. * The component name helpfull to identify the component in the list of scene components.
  5501. */
  5502. readonly name: string;
  5503. /**
  5504. * The scene the component belongs to.
  5505. */
  5506. scene: Scene;
  5507. private _audioEnabled;
  5508. /**
  5509. * Gets whether audio is enabled or not.
  5510. * Please use related enable/disable method to switch state.
  5511. */
  5512. readonly audioEnabled: boolean;
  5513. private _headphone;
  5514. /**
  5515. * Gets whether audio is outputing to headphone or not.
  5516. * Please use the according Switch methods to change output.
  5517. */
  5518. readonly headphone: boolean;
  5519. /**
  5520. * Creates a new instance of the component for the given scene
  5521. * @param scene Defines the scene to register the component in
  5522. */
  5523. constructor(scene: Scene);
  5524. /**
  5525. * Registers the component in a given scene
  5526. */
  5527. register(): void;
  5528. /**
  5529. * Rebuilds the elements related to this component in case of
  5530. * context lost for instance.
  5531. */
  5532. rebuild(): void;
  5533. /**
  5534. * Serializes the component data to the specified json object
  5535. * @param serializationObject The object to serialize to
  5536. */
  5537. serialize(serializationObject: any): void;
  5538. /**
  5539. * Adds all the element from the container to the scene
  5540. * @param container the container holding the elements
  5541. */
  5542. addFromContainer(container: AbstractScene): void;
  5543. /**
  5544. * Removes all the elements in the container from the scene
  5545. * @param container contains the elements to remove
  5546. */
  5547. removeFromContainer(container: AbstractScene): void;
  5548. /**
  5549. * Disposes the component and the associated ressources.
  5550. */
  5551. dispose(): void;
  5552. /**
  5553. * Disables audio in the associated scene.
  5554. */
  5555. disableAudio(): void;
  5556. /**
  5557. * Enables audio in the associated scene.
  5558. */
  5559. enableAudio(): void;
  5560. /**
  5561. * Switch audio to headphone output.
  5562. */
  5563. switchAudioModeForHeadphones(): void;
  5564. /**
  5565. * Switch audio to normal speakers.
  5566. */
  5567. switchAudioModeForNormalSpeakers(): void;
  5568. private _afterRender;
  5569. }
  5570. }
  5571. declare module BABYLON {
  5572. /**
  5573. * Defines a sound that can be played in the application.
  5574. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  5575. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5576. */
  5577. class Sound {
  5578. /**
  5579. * The name of the sound in the scene.
  5580. */
  5581. name: string;
  5582. /**
  5583. * Does the sound autoplay once loaded.
  5584. */
  5585. autoplay: boolean;
  5586. /**
  5587. * Does the sound loop after it finishes playing once.
  5588. */
  5589. loop: boolean;
  5590. /**
  5591. * Does the sound use a custom attenuation curve to simulate the falloff
  5592. * happening when the source gets further away from the camera.
  5593. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  5594. */
  5595. useCustomAttenuation: boolean;
  5596. /**
  5597. * The sound track id this sound belongs to.
  5598. */
  5599. soundTrackId: number;
  5600. /**
  5601. * Is this sound currently played.
  5602. */
  5603. isPlaying: boolean;
  5604. /**
  5605. * Is this sound currently paused.
  5606. */
  5607. isPaused: boolean;
  5608. /**
  5609. * Does this sound enables spatial sound.
  5610. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5611. */
  5612. spatialSound: boolean;
  5613. /**
  5614. * Define the reference distance the sound should be heard perfectly.
  5615. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5616. */
  5617. refDistance: number;
  5618. /**
  5619. * Define the roll off factor of spatial sounds.
  5620. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5621. */
  5622. rolloffFactor: number;
  5623. /**
  5624. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  5625. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5626. */
  5627. maxDistance: number;
  5628. /**
  5629. * Define the distance attenuation model the sound will follow.
  5630. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5631. */
  5632. distanceModel: string;
  5633. /**
  5634. * @hidden
  5635. * Back Compat
  5636. **/
  5637. onended: () => any;
  5638. /**
  5639. * Observable event when the current playing sound finishes.
  5640. */
  5641. onEndedObservable: Observable<Sound>;
  5642. private _panningModel;
  5643. private _playbackRate;
  5644. private _streaming;
  5645. private _startTime;
  5646. private _startOffset;
  5647. private _position;
  5648. /** @hidden */
  5649. _positionInEmitterSpace: boolean;
  5650. private _localDirection;
  5651. private _volume;
  5652. private _isReadyToPlay;
  5653. private _isDirectional;
  5654. private _readyToPlayCallback;
  5655. private _audioBuffer;
  5656. private _soundSource;
  5657. private _streamingSource;
  5658. private _soundPanner;
  5659. private _soundGain;
  5660. private _inputAudioNode;
  5661. private _outputAudioNode;
  5662. private _coneInnerAngle;
  5663. private _coneOuterAngle;
  5664. private _coneOuterGain;
  5665. private _scene;
  5666. private _connectedTransformNode;
  5667. private _customAttenuationFunction;
  5668. private _registerFunc;
  5669. private _isOutputConnected;
  5670. private _htmlAudioElement;
  5671. private _urlType;
  5672. /**
  5673. * Create a sound and attach it to a scene
  5674. * @param name Name of your sound
  5675. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  5676. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  5677. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  5678. */
  5679. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  5680. /**
  5681. * Release the sound and its associated resources
  5682. */
  5683. dispose(): void;
  5684. /**
  5685. * Gets if the sounds is ready to be played or not.
  5686. * @returns true if ready, otherwise false
  5687. */
  5688. isReady(): boolean;
  5689. private _soundLoaded;
  5690. /**
  5691. * Sets the data of the sound from an audiobuffer
  5692. * @param audioBuffer The audioBuffer containing the data
  5693. */
  5694. setAudioBuffer(audioBuffer: AudioBuffer): void;
  5695. /**
  5696. * Updates the current sounds options such as maxdistance, loop...
  5697. * @param options A JSON object containing values named as the object properties
  5698. */
  5699. updateOptions(options: any): void;
  5700. private _createSpatialParameters;
  5701. private _updateSpatialParameters;
  5702. /**
  5703. * Switch the panning model to HRTF:
  5704. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  5705. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5706. */
  5707. switchPanningModelToHRTF(): void;
  5708. /**
  5709. * Switch the panning model to Equal Power:
  5710. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  5711. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5712. */
  5713. switchPanningModelToEqualPower(): void;
  5714. private _switchPanningModel;
  5715. /**
  5716. * Connect this sound to a sound track audio node like gain...
  5717. * @param soundTrackAudioNode the sound track audio node to connect to
  5718. */
  5719. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  5720. /**
  5721. * Transform this sound into a directional source
  5722. * @param coneInnerAngle Size of the inner cone in degree
  5723. * @param coneOuterAngle Size of the outer cone in degree
  5724. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  5725. */
  5726. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  5727. /**
  5728. * Gets or sets the inner angle for the directional cone.
  5729. */
  5730. /**
  5731. * Gets or sets the inner angle for the directional cone.
  5732. */
  5733. directionalConeInnerAngle: number;
  5734. /**
  5735. * Gets or sets the outer angle for the directional cone.
  5736. */
  5737. /**
  5738. * Gets or sets the outer angle for the directional cone.
  5739. */
  5740. directionalConeOuterAngle: number;
  5741. /**
  5742. * Sets the position of the emitter if spatial sound is enabled
  5743. * @param newPosition Defines the new posisiton
  5744. */
  5745. setPosition(newPosition: Vector3): void;
  5746. /**
  5747. * Sets the local direction of the emitter if spatial sound is enabled
  5748. * @param newLocalDirection Defines the new local direction
  5749. */
  5750. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  5751. private _updateDirection;
  5752. /** @hidden */
  5753. updateDistanceFromListener(): void;
  5754. /**
  5755. * Sets a new custom attenuation function for the sound.
  5756. * @param callback Defines the function used for the attenuation
  5757. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  5758. */
  5759. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  5760. /**
  5761. * Play the sound
  5762. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  5763. * @param offset (optional) Start the sound setting it at a specific time
  5764. */
  5765. play(time?: number, offset?: number): void;
  5766. private _onended;
  5767. /**
  5768. * Stop the sound
  5769. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  5770. */
  5771. stop(time?: number): void;
  5772. /**
  5773. * Put the sound in pause
  5774. */
  5775. pause(): void;
  5776. /**
  5777. * Sets a dedicated volume for this sounds
  5778. * @param newVolume Define the new volume of the sound
  5779. * @param time Define in how long the sound should be at this value
  5780. */
  5781. setVolume(newVolume: number, time?: number): void;
  5782. /**
  5783. * Set the sound play back rate
  5784. * @param newPlaybackRate Define the playback rate the sound should be played at
  5785. */
  5786. setPlaybackRate(newPlaybackRate: number): void;
  5787. /**
  5788. * Gets the volume of the sound.
  5789. * @returns the volume of the sound
  5790. */
  5791. getVolume(): number;
  5792. /**
  5793. * Attach the sound to a dedicated mesh
  5794. * @param transformNode The transform node to connect the sound with
  5795. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  5796. */
  5797. attachToMesh(transformNode: TransformNode): void;
  5798. /**
  5799. * Detach the sound from the previously attached mesh
  5800. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  5801. */
  5802. detachFromMesh(): void;
  5803. private _onRegisterAfterWorldMatrixUpdate;
  5804. /**
  5805. * Clone the current sound in the scene.
  5806. * @returns the new sound clone
  5807. */
  5808. clone(): Nullable<Sound>;
  5809. /**
  5810. * Gets the current underlying audio buffer containing the data
  5811. * @returns the audio buffer
  5812. */
  5813. getAudioBuffer(): Nullable<AudioBuffer>;
  5814. /**
  5815. * Serializes the Sound in a JSON representation
  5816. * @returns the JSON representation of the sound
  5817. */
  5818. serialize(): any;
  5819. /**
  5820. * Parse a JSON representation of a sound to innstantiate in a given scene
  5821. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  5822. * @param scene Define the scene the new parsed sound should be created in
  5823. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  5824. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  5825. * @returns the newly parsed sound
  5826. */
  5827. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  5828. }
  5829. }
  5830. declare module BABYLON {
  5831. /**
  5832. * Options allowed during the creation of a sound track.
  5833. */
  5834. interface ISoundTrackOptions {
  5835. /**
  5836. * The volume the sound track should take during creation
  5837. */
  5838. volume?: number;
  5839. /**
  5840. * Define if the sound track is the main sound track of the scene
  5841. */
  5842. mainTrack?: boolean;
  5843. }
  5844. /**
  5845. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  5846. * It will be also used in a future release to apply effects on a specific track.
  5847. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  5848. */
  5849. class SoundTrack {
  5850. /**
  5851. * The unique identifier of the sound track in the scene.
  5852. */
  5853. id: number;
  5854. /**
  5855. * The list of sounds included in the sound track.
  5856. */
  5857. soundCollection: Array<Sound>;
  5858. private _outputAudioNode;
  5859. private _scene;
  5860. private _isMainTrack;
  5861. private _connectedAnalyser;
  5862. private _options;
  5863. private _isInitialized;
  5864. /**
  5865. * Creates a new sound track.
  5866. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  5867. * @param scene Define the scene the sound track belongs to
  5868. * @param options
  5869. */
  5870. constructor(scene: Scene, options?: ISoundTrackOptions);
  5871. private _initializeSoundTrackAudioGraph;
  5872. /**
  5873. * Release the sound track and its associated resources
  5874. */
  5875. dispose(): void;
  5876. /**
  5877. * Adds a sound to this sound track
  5878. * @param sound define the cound to add
  5879. * @ignoreNaming
  5880. */
  5881. AddSound(sound: Sound): void;
  5882. /**
  5883. * Removes a sound to this sound track
  5884. * @param sound define the cound to remove
  5885. * @ignoreNaming
  5886. */
  5887. RemoveSound(sound: Sound): void;
  5888. /**
  5889. * Set a global volume for the full sound track.
  5890. * @param newVolume Define the new volume of the sound track
  5891. */
  5892. setVolume(newVolume: number): void;
  5893. /**
  5894. * Switch the panning model to HRTF:
  5895. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  5896. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5897. */
  5898. switchPanningModelToHRTF(): void;
  5899. /**
  5900. * Switch the panning model to Equal Power:
  5901. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  5902. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5903. */
  5904. switchPanningModelToEqualPower(): void;
  5905. /**
  5906. * Connect the sound track to an audio analyser allowing some amazing
  5907. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  5908. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  5909. * @param analyser The analyser to connect to the engine
  5910. */
  5911. connectToAnalyser(analyser: Analyser): void;
  5912. }
  5913. }
  5914. declare module BABYLON {
  5915. /**
  5916. * Wraps one or more Sound objects and selects one with random weight for playback.
  5917. */
  5918. class WeightedSound {
  5919. /** When true a Sound will be selected and played when the current playing Sound completes. */
  5920. loop: boolean;
  5921. private _coneInnerAngle;
  5922. private _coneOuterAngle;
  5923. private _volume;
  5924. /** A Sound is currently playing. */
  5925. isPlaying: boolean;
  5926. /** A Sound is currently paused. */
  5927. isPaused: boolean;
  5928. private _sounds;
  5929. private _weights;
  5930. private _currentIndex?;
  5931. /**
  5932. * Creates a new WeightedSound from the list of sounds given.
  5933. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  5934. * @param sounds Array of Sounds that will be selected from.
  5935. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  5936. */
  5937. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  5938. /**
  5939. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  5940. */
  5941. /**
  5942. * The size of cone in degress for a directional sound in which there will be no attenuation.
  5943. */
  5944. directionalConeInnerAngle: number;
  5945. /**
  5946. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  5947. * Listener angles between innerAngle and outerAngle will falloff linearly.
  5948. */
  5949. /**
  5950. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  5951. * Listener angles between innerAngle and outerAngle will falloff linearly.
  5952. */
  5953. directionalConeOuterAngle: number;
  5954. /**
  5955. * Playback volume.
  5956. */
  5957. /**
  5958. * Playback volume.
  5959. */
  5960. volume: number;
  5961. private _onended;
  5962. /**
  5963. * Suspend playback
  5964. */
  5965. pause(): void;
  5966. /**
  5967. * Stop playback
  5968. */
  5969. stop(): void;
  5970. /**
  5971. * Start playback.
  5972. * @param startOffset Position the clip head at a specific time in seconds.
  5973. */
  5974. play(startOffset?: number): void;
  5975. }
  5976. }
  5977. declare module BABYLON {
  5978. /**
  5979. * Interface used to define a behavior
  5980. */
  5981. interface Behavior<T> {
  5982. /** gets or sets behavior's name */
  5983. name: string;
  5984. /**
  5985. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5986. */
  5987. init(): void;
  5988. /**
  5989. * Called when the behavior is attached to a target
  5990. * @param target defines the target where the behavior is attached to
  5991. */
  5992. attach(target: T): void;
  5993. /**
  5994. * Called when the behavior is detached from its target
  5995. */
  5996. detach(): void;
  5997. }
  5998. /**
  5999. * Interface implemented by classes supporting behaviors
  6000. */
  6001. interface IBehaviorAware<T> {
  6002. /**
  6003. * Attach a behavior
  6004. * @param behavior defines the behavior to attach
  6005. * @returns the current host
  6006. */
  6007. addBehavior(behavior: Behavior<T>): T;
  6008. /**
  6009. * Remove a behavior from the current object
  6010. * @param behavior defines the behavior to detach
  6011. * @returns the current host
  6012. */
  6013. removeBehavior(behavior: Behavior<T>): T;
  6014. /**
  6015. * Gets a behavior using its name to search
  6016. * @param name defines the name to search
  6017. * @returns the behavior or null if not found
  6018. */
  6019. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6020. }
  6021. }
  6022. declare module BABYLON {
  6023. /**
  6024. * Class used to store bone information
  6025. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  6026. */
  6027. class Bone extends Node {
  6028. /**
  6029. * defines the bone name
  6030. */
  6031. name: string;
  6032. private static _tmpVecs;
  6033. private static _tmpQuat;
  6034. private static _tmpMats;
  6035. /**
  6036. * Gets the list of child bones
  6037. */
  6038. children: Bone[];
  6039. /** Gets the animations associated with this bone */
  6040. animations: Animation[];
  6041. /**
  6042. * Gets or sets bone length
  6043. */
  6044. length: number;
  6045. /**
  6046. * @hidden Internal only
  6047. * Set this value to map this bone to a different index in the transform matrices
  6048. * Set this value to -1 to exclude the bone from the transform matrices
  6049. */
  6050. _index: Nullable<number>;
  6051. private _skeleton;
  6052. private _localMatrix;
  6053. private _restPose;
  6054. private _baseMatrix;
  6055. private _absoluteTransform;
  6056. private _invertedAbsoluteTransform;
  6057. private _parent;
  6058. private _scalingDeterminant;
  6059. private _worldTransform;
  6060. private _localScaling;
  6061. private _localRotation;
  6062. private _localPosition;
  6063. private _needToDecompose;
  6064. private _needToCompose;
  6065. /** @hidden */
  6066. _linkedTransformNode: Nullable<TransformNode>;
  6067. /** @hidden */
  6068. /** @hidden */
  6069. _matrix: Matrix;
  6070. /**
  6071. * Create a new bone
  6072. * @param name defines the bone name
  6073. * @param skeleton defines the parent skeleton
  6074. * @param parentBone defines the parent (can be null if the bone is the root)
  6075. * @param localMatrix defines the local matrix
  6076. * @param restPose defines the rest pose matrix
  6077. * @param baseMatrix defines the base matrix
  6078. * @param index defines index of the bone in the hiearchy
  6079. */
  6080. constructor(
  6081. /**
  6082. * defines the bone name
  6083. */
  6084. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  6085. /**
  6086. * Gets the parent skeleton
  6087. * @returns a skeleton
  6088. */
  6089. getSkeleton(): Skeleton;
  6090. /**
  6091. * Gets parent bone
  6092. * @returns a bone or null if the bone is the root of the bone hierarchy
  6093. */
  6094. getParent(): Nullable<Bone>;
  6095. /**
  6096. * Sets the parent bone
  6097. * @param parent defines the parent (can be null if the bone is the root)
  6098. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  6099. */
  6100. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  6101. /**
  6102. * Gets the local matrix
  6103. * @returns a matrix
  6104. */
  6105. getLocalMatrix(): Matrix;
  6106. /**
  6107. * Gets the base matrix (initial matrix which remains unchanged)
  6108. * @returns a matrix
  6109. */
  6110. getBaseMatrix(): Matrix;
  6111. /**
  6112. * Gets the rest pose matrix
  6113. * @returns a matrix
  6114. */
  6115. getRestPose(): Matrix;
  6116. /**
  6117. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  6118. */
  6119. getWorldMatrix(): Matrix;
  6120. /**
  6121. * Sets the local matrix to rest pose matrix
  6122. */
  6123. returnToRest(): void;
  6124. /**
  6125. * Gets the inverse of the absolute transform matrix.
  6126. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  6127. * @returns a matrix
  6128. */
  6129. getInvertedAbsoluteTransform(): Matrix;
  6130. /**
  6131. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  6132. * @returns a matrix
  6133. */
  6134. getAbsoluteTransform(): Matrix;
  6135. /**
  6136. * Links with the given transform node.
  6137. * The local matrix of this bone is copied from the transform node every frame.
  6138. * @param transformNode defines the transform node to link to
  6139. */
  6140. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  6141. /** Gets or sets current position (in local space) */
  6142. position: Vector3;
  6143. /** Gets or sets current rotation (in local space) */
  6144. rotation: Vector3;
  6145. /** Gets or sets current rotation quaternion (in local space) */
  6146. rotationQuaternion: Quaternion;
  6147. /** Gets or sets current scaling (in local space) */
  6148. scaling: Vector3;
  6149. /**
  6150. * Gets the animation properties override
  6151. */
  6152. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  6153. private _decompose;
  6154. private _compose;
  6155. /**
  6156. * Update the base and local matrices
  6157. * @param matrix defines the new base or local matrix
  6158. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  6159. * @param updateLocalMatrix defines if the local matrix should be updated
  6160. */
  6161. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  6162. /** @hidden */
  6163. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  6164. /**
  6165. * Flag the bone as dirty (Forcing it to update everything)
  6166. */
  6167. markAsDirty(): void;
  6168. private _markAsDirtyAndCompose;
  6169. private _markAsDirtyAndDecompose;
  6170. /**
  6171. * Copy an animation range from another bone
  6172. * @param source defines the source bone
  6173. * @param rangeName defines the range name to copy
  6174. * @param frameOffset defines the frame offset
  6175. * @param rescaleAsRequired defines if rescaling must be applied if required
  6176. * @param skelDimensionsRatio defines the scaling ratio
  6177. * @returns true if operation was successful
  6178. */
  6179. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired?: boolean, skelDimensionsRatio?: Nullable<Vector3>): boolean;
  6180. /**
  6181. * Translate the bone in local or world space
  6182. * @param vec The amount to translate the bone
  6183. * @param space The space that the translation is in
  6184. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6185. */
  6186. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  6187. /**
  6188. * Set the postion of the bone in local or world space
  6189. * @param position The position to set the bone
  6190. * @param space The space that the position is in
  6191. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6192. */
  6193. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  6194. /**
  6195. * Set the absolute position of the bone (world space)
  6196. * @param position The position to set the bone
  6197. * @param mesh The mesh that this bone is attached to
  6198. */
  6199. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  6200. /**
  6201. * Scale the bone on the x, y and z axes (in local space)
  6202. * @param x The amount to scale the bone on the x axis
  6203. * @param y The amount to scale the bone on the y axis
  6204. * @param z The amount to scale the bone on the z axis
  6205. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  6206. */
  6207. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  6208. /**
  6209. * Set the bone scaling in local space
  6210. * @param scale defines the scaling vector
  6211. */
  6212. setScale(scale: Vector3): void;
  6213. /**
  6214. * Gets the current scaling in local space
  6215. * @returns the current scaling vector
  6216. */
  6217. getScale(): Vector3;
  6218. /**
  6219. * Gets the current scaling in local space and stores it in a target vector
  6220. * @param result defines the target vector
  6221. */
  6222. getScaleToRef(result: Vector3): void;
  6223. /**
  6224. * Set the yaw, pitch, and roll of the bone in local or world space
  6225. * @param yaw The rotation of the bone on the y axis
  6226. * @param pitch The rotation of the bone on the x axis
  6227. * @param roll The rotation of the bone on the z axis
  6228. * @param space The space that the axes of rotation are in
  6229. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6230. */
  6231. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  6232. /**
  6233. * Add a rotation to the bone on an axis in local or world space
  6234. * @param axis The axis to rotate the bone on
  6235. * @param amount The amount to rotate the bone
  6236. * @param space The space that the axis is in
  6237. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6238. */
  6239. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  6240. /**
  6241. * Set the rotation of the bone to a particular axis angle in local or world space
  6242. * @param axis The axis to rotate the bone on
  6243. * @param angle The angle that the bone should be rotated to
  6244. * @param space The space that the axis is in
  6245. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6246. */
  6247. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  6248. /**
  6249. * Set the euler rotation of the bone in local of world space
  6250. * @param rotation The euler rotation that the bone should be set to
  6251. * @param space The space that the rotation is in
  6252. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6253. */
  6254. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  6255. /**
  6256. * Set the quaternion rotation of the bone in local of world space
  6257. * @param quat The quaternion rotation that the bone should be set to
  6258. * @param space The space that the rotation is in
  6259. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6260. */
  6261. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  6262. /**
  6263. * Set the rotation matrix of the bone in local of world space
  6264. * @param rotMat The rotation matrix that the bone should be set to
  6265. * @param space The space that the rotation is in
  6266. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6267. */
  6268. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  6269. private _rotateWithMatrix;
  6270. private _getNegativeRotationToRef;
  6271. /**
  6272. * Get the position of the bone in local or world space
  6273. * @param space The space that the returned position is in
  6274. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6275. * @returns The position of the bone
  6276. */
  6277. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  6278. /**
  6279. * Copy the position of the bone to a vector3 in local or world space
  6280. * @param space The space that the returned position is in
  6281. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6282. * @param result The vector3 to copy the position to
  6283. */
  6284. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  6285. /**
  6286. * Get the absolute position of the bone (world space)
  6287. * @param mesh The mesh that this bone is attached to
  6288. * @returns The absolute position of the bone
  6289. */
  6290. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  6291. /**
  6292. * Copy the absolute position of the bone (world space) to the result param
  6293. * @param mesh The mesh that this bone is attached to
  6294. * @param result The vector3 to copy the absolute position to
  6295. */
  6296. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  6297. /**
  6298. * Compute the absolute transforms of this bone and its children
  6299. */
  6300. computeAbsoluteTransforms(): void;
  6301. /**
  6302. * Get the world direction from an axis that is in the local space of the bone
  6303. * @param localAxis The local direction that is used to compute the world direction
  6304. * @param mesh The mesh that this bone is attached to
  6305. * @returns The world direction
  6306. */
  6307. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  6308. /**
  6309. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  6310. * @param localAxis The local direction that is used to compute the world direction
  6311. * @param mesh The mesh that this bone is attached to
  6312. * @param result The vector3 that the world direction will be copied to
  6313. */
  6314. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6315. /**
  6316. * Get the euler rotation of the bone in local or world space
  6317. * @param space The space that the rotation should be in
  6318. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6319. * @returns The euler rotation
  6320. */
  6321. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  6322. /**
  6323. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  6324. * @param space The space that the rotation should be in
  6325. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6326. * @param result The vector3 that the rotation should be copied to
  6327. */
  6328. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6329. /**
  6330. * Get the quaternion rotation of the bone in either local or world space
  6331. * @param space The space that the rotation should be in
  6332. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6333. * @returns The quaternion rotation
  6334. */
  6335. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  6336. /**
  6337. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  6338. * @param space The space that the rotation should be in
  6339. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6340. * @param result The quaternion that the rotation should be copied to
  6341. */
  6342. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  6343. /**
  6344. * Get the rotation matrix of the bone in local or world space
  6345. * @param space The space that the rotation should be in
  6346. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6347. * @returns The rotation matrix
  6348. */
  6349. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  6350. /**
  6351. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  6352. * @param space The space that the rotation should be in
  6353. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6354. * @param result The quaternion that the rotation should be copied to
  6355. */
  6356. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  6357. /**
  6358. * Get the world position of a point that is in the local space of the bone
  6359. * @param position The local position
  6360. * @param mesh The mesh that this bone is attached to
  6361. * @returns The world position
  6362. */
  6363. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  6364. /**
  6365. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  6366. * @param position The local position
  6367. * @param mesh The mesh that this bone is attached to
  6368. * @param result The vector3 that the world position should be copied to
  6369. */
  6370. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6371. /**
  6372. * Get the local position of a point that is in world space
  6373. * @param position The world position
  6374. * @param mesh The mesh that this bone is attached to
  6375. * @returns The local position
  6376. */
  6377. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  6378. /**
  6379. * Get the local position of a point that is in world space and copy it to the result param
  6380. * @param position The world position
  6381. * @param mesh The mesh that this bone is attached to
  6382. * @param result The vector3 that the local position should be copied to
  6383. */
  6384. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6385. }
  6386. }
  6387. declare module BABYLON {
  6388. /**
  6389. * Class used to apply inverse kinematics to bones
  6390. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  6391. */
  6392. class BoneIKController {
  6393. private static _tmpVecs;
  6394. private static _tmpQuat;
  6395. private static _tmpMats;
  6396. /**
  6397. * Gets or sets the target mesh
  6398. */
  6399. targetMesh: AbstractMesh;
  6400. /** Gets or sets the mesh used as pole */
  6401. poleTargetMesh: AbstractMesh;
  6402. /**
  6403. * Gets or sets the bone used as pole
  6404. */
  6405. poleTargetBone: Nullable<Bone>;
  6406. /**
  6407. * Gets or sets the target position
  6408. */
  6409. targetPosition: Vector3;
  6410. /**
  6411. * Gets or sets the pole target position
  6412. */
  6413. poleTargetPosition: Vector3;
  6414. /**
  6415. * Gets or sets the pole target local offset
  6416. */
  6417. poleTargetLocalOffset: Vector3;
  6418. /**
  6419. * Gets or sets the pole angle
  6420. */
  6421. poleAngle: number;
  6422. /**
  6423. * Gets or sets the mesh associated with the controller
  6424. */
  6425. mesh: AbstractMesh;
  6426. /**
  6427. * The amount to slerp (spherical linear interpolation) to the target. Set this to a value between 0 and 1 (a value of 1 disables slerp)
  6428. */
  6429. slerpAmount: number;
  6430. private _bone1Quat;
  6431. private _bone1Mat;
  6432. private _bone2Ang;
  6433. private _bone1;
  6434. private _bone2;
  6435. private _bone1Length;
  6436. private _bone2Length;
  6437. private _maxAngle;
  6438. private _maxReach;
  6439. private _rightHandedSystem;
  6440. private _bendAxis;
  6441. private _slerping;
  6442. private _adjustRoll;
  6443. /**
  6444. * Gets or sets maximum allowed angle
  6445. */
  6446. maxAngle: number;
  6447. /**
  6448. * Creates a new BoneIKController
  6449. * @param mesh defines the mesh to control
  6450. * @param bone defines the bone to control
  6451. * @param options defines options to set up the controller
  6452. */
  6453. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  6454. targetMesh?: AbstractMesh;
  6455. poleTargetMesh?: AbstractMesh;
  6456. poleTargetBone?: Bone;
  6457. poleTargetLocalOffset?: Vector3;
  6458. poleAngle?: number;
  6459. bendAxis?: Vector3;
  6460. maxAngle?: number;
  6461. slerpAmount?: number;
  6462. });
  6463. private _setMaxAngle;
  6464. /**
  6465. * Force the controller to update the bones
  6466. */
  6467. update(): void;
  6468. }
  6469. }
  6470. declare module BABYLON {
  6471. /**
  6472. * Class used to make a bone look toward a point in space
  6473. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  6474. */
  6475. class BoneLookController {
  6476. private static _tmpVecs;
  6477. private static _tmpQuat;
  6478. private static _tmpMats;
  6479. /**
  6480. * The target Vector3 that the bone will look at
  6481. */
  6482. target: Vector3;
  6483. /**
  6484. * The mesh that the bone is attached to
  6485. */
  6486. mesh: AbstractMesh;
  6487. /**
  6488. * The bone that will be looking to the target
  6489. */
  6490. bone: Bone;
  6491. /**
  6492. * The up axis of the coordinate system that is used when the bone is rotated
  6493. */
  6494. upAxis: Vector3;
  6495. /**
  6496. * The space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD
  6497. */
  6498. upAxisSpace: Space;
  6499. /**
  6500. * Used to make an adjustment to the yaw of the bone
  6501. */
  6502. adjustYaw: number;
  6503. /**
  6504. * Used to make an adjustment to the pitch of the bone
  6505. */
  6506. adjustPitch: number;
  6507. /**
  6508. * Used to make an adjustment to the roll of the bone
  6509. */
  6510. adjustRoll: number;
  6511. /**
  6512. * The amount to slerp (spherical linear interpolation) to the target. Set this to a value between 0 and 1 (a value of 1 disables slerp)
  6513. */
  6514. slerpAmount: number;
  6515. private _minYaw;
  6516. private _maxYaw;
  6517. private _minPitch;
  6518. private _maxPitch;
  6519. private _minYawSin;
  6520. private _minYawCos;
  6521. private _maxYawSin;
  6522. private _maxYawCos;
  6523. private _midYawConstraint;
  6524. private _minPitchTan;
  6525. private _maxPitchTan;
  6526. private _boneQuat;
  6527. private _slerping;
  6528. private _transformYawPitch;
  6529. private _transformYawPitchInv;
  6530. private _firstFrameSkipped;
  6531. private _yawRange;
  6532. private _fowardAxis;
  6533. /**
  6534. * Gets or sets the minimum yaw angle that the bone can look to
  6535. */
  6536. minYaw: number;
  6537. /**
  6538. * Gets or sets the maximum yaw angle that the bone can look to
  6539. */
  6540. maxYaw: number;
  6541. /**
  6542. * Gets or sets the minimum pitch angle that the bone can look to
  6543. */
  6544. minPitch: number;
  6545. /**
  6546. * Gets or sets the maximum pitch angle that the bone can look to
  6547. */
  6548. maxPitch: number;
  6549. /**
  6550. * Create a BoneLookController
  6551. * @param mesh the mesh that the bone belongs to
  6552. * @param bone the bone that will be looking to the target
  6553. * @param target the target Vector3 to look at
  6554. * @param settings optional settings:
  6555. * * maxYaw: the maximum angle the bone will yaw to
  6556. * * minYaw: the minimum angle the bone will yaw to
  6557. * * maxPitch: the maximum angle the bone will pitch to
  6558. * * minPitch: the minimum angle the bone will yaw to
  6559. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  6560. * * upAxis: the up axis of the coordinate system
  6561. * * upAxisSpace: the space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD.
  6562. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  6563. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  6564. * * adjustYaw: used to make an adjustment to the yaw of the bone
  6565. * * adjustPitch: used to make an adjustment to the pitch of the bone
  6566. * * adjustRoll: used to make an adjustment to the roll of the bone
  6567. **/
  6568. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  6569. maxYaw?: number;
  6570. minYaw?: number;
  6571. maxPitch?: number;
  6572. minPitch?: number;
  6573. slerpAmount?: number;
  6574. upAxis?: Vector3;
  6575. upAxisSpace?: Space;
  6576. yawAxis?: Vector3;
  6577. pitchAxis?: Vector3;
  6578. adjustYaw?: number;
  6579. adjustPitch?: number;
  6580. adjustRoll?: number;
  6581. });
  6582. /**
  6583. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  6584. */
  6585. update(): void;
  6586. private _getAngleDiff;
  6587. private _getAngleBetween;
  6588. private _isAngleBetween;
  6589. }
  6590. }
  6591. declare module BABYLON {
  6592. /**
  6593. * Class used to handle skinning animations
  6594. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  6595. */
  6596. class Skeleton implements IAnimatable {
  6597. /** defines the skeleton name */
  6598. name: string;
  6599. /** defines the skeleton Id */
  6600. id: string;
  6601. /**
  6602. * Defines the list of child bones
  6603. */
  6604. bones: Bone[];
  6605. /**
  6606. * Defines an estimate of the dimension of the skeleton at rest
  6607. */
  6608. dimensionsAtRest: Vector3;
  6609. /**
  6610. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  6611. */
  6612. needInitialSkinMatrix: boolean;
  6613. /**
  6614. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  6615. */
  6616. overrideMesh: Nullable<AbstractMesh>;
  6617. /**
  6618. * Gets the list of animations attached to this skeleton
  6619. */
  6620. animations: Array<Animation>;
  6621. private _scene;
  6622. private _isDirty;
  6623. private _transformMatrices;
  6624. private _transformMatrixTexture;
  6625. private _meshesWithPoseMatrix;
  6626. private _animatables;
  6627. private _identity;
  6628. private _synchronizedWithMesh;
  6629. private _ranges;
  6630. private _lastAbsoluteTransformsUpdateId;
  6631. private _canUseTextureForBones;
  6632. /** @hidden */
  6633. _numBonesWithLinkedTransformNode: number;
  6634. /**
  6635. * Specifies if the skeleton should be serialized
  6636. */
  6637. doNotSerialize: boolean;
  6638. /**
  6639. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  6640. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  6641. */
  6642. useTextureToStoreBoneMatrices: boolean;
  6643. private _animationPropertiesOverride;
  6644. /**
  6645. * Gets or sets the animation properties override
  6646. */
  6647. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  6648. /**
  6649. * An observable triggered before computing the skeleton's matrices
  6650. */
  6651. onBeforeComputeObservable: Observable<Skeleton>;
  6652. /**
  6653. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  6654. */
  6655. readonly isUsingTextureForMatrices: boolean;
  6656. /**
  6657. * Creates a new skeleton
  6658. * @param name defines the skeleton name
  6659. * @param id defines the skeleton Id
  6660. * @param scene defines the hosting scene
  6661. */
  6662. constructor(
  6663. /** defines the skeleton name */
  6664. name: string,
  6665. /** defines the skeleton Id */
  6666. id: string, scene: Scene);
  6667. /**
  6668. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  6669. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  6670. * @returns a Float32Array containing matrices data
  6671. */
  6672. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  6673. /**
  6674. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  6675. * @returns a raw texture containing the data
  6676. */
  6677. getTransformMatrixTexture(): Nullable<RawTexture>;
  6678. /**
  6679. * Gets the current hosting scene
  6680. * @returns a scene object
  6681. */
  6682. getScene(): Scene;
  6683. /**
  6684. * Gets a string representing the current skeleton data
  6685. * @param fullDetails defines a boolean indicating if we want a verbose version
  6686. * @returns a string representing the current skeleton data
  6687. */
  6688. toString(fullDetails?: boolean): string;
  6689. /**
  6690. * Get bone's index searching by name
  6691. * @param name defines bone's name to search for
  6692. * @return the indice of the bone. Returns -1 if not found
  6693. */
  6694. getBoneIndexByName(name: string): number;
  6695. /**
  6696. * Creater a new animation range
  6697. * @param name defines the name of the range
  6698. * @param from defines the start key
  6699. * @param to defines the end key
  6700. */
  6701. createAnimationRange(name: string, from: number, to: number): void;
  6702. /**
  6703. * Delete a specific animation range
  6704. * @param name defines the name of the range
  6705. * @param deleteFrames defines if frames must be removed as well
  6706. */
  6707. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  6708. /**
  6709. * Gets a specific animation range
  6710. * @param name defines the name of the range to look for
  6711. * @returns the requested animation range or null if not found
  6712. */
  6713. getAnimationRange(name: string): Nullable<AnimationRange>;
  6714. /**
  6715. * Gets the list of all animation ranges defined on this skeleton
  6716. * @returns an array
  6717. */
  6718. getAnimationRanges(): Nullable<AnimationRange>[];
  6719. /**
  6720. * Copy animation range from a source skeleton.
  6721. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  6722. * @param source defines the source skeleton
  6723. * @param name defines the name of the range to copy
  6724. * @param rescaleAsRequired defines if rescaling must be applied if required
  6725. * @returns true if operation was successful
  6726. */
  6727. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  6728. /**
  6729. * Forces the skeleton to go to rest pose
  6730. */
  6731. returnToRest(): void;
  6732. private _getHighestAnimationFrame;
  6733. /**
  6734. * Begin a specific animation range
  6735. * @param name defines the name of the range to start
  6736. * @param loop defines if looping must be turned on (false by default)
  6737. * @param speedRatio defines the speed ratio to apply (1 by default)
  6738. * @param onAnimationEnd defines a callback which will be called when animation will end
  6739. * @returns a new animatable
  6740. */
  6741. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  6742. /** @hidden */
  6743. _markAsDirty(): void;
  6744. /** @hidden */
  6745. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  6746. /** @hidden */
  6747. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  6748. private _computeTransformMatrices;
  6749. /**
  6750. * Build all resources required to render a skeleton
  6751. */
  6752. prepare(): void;
  6753. /**
  6754. * Gets the list of animatables currently running for this skeleton
  6755. * @returns an array of animatables
  6756. */
  6757. getAnimatables(): IAnimatable[];
  6758. /**
  6759. * Clone the current skeleton
  6760. * @param name defines the name of the new skeleton
  6761. * @param id defines the id of the enw skeleton
  6762. * @returns the new skeleton
  6763. */
  6764. clone(name: string, id: string): Skeleton;
  6765. /**
  6766. * Enable animation blending for this skeleton
  6767. * @param blendingSpeed defines the blending speed to apply
  6768. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  6769. */
  6770. enableBlending(blendingSpeed?: number): void;
  6771. /**
  6772. * Releases all resources associated with the current skeleton
  6773. */
  6774. dispose(): void;
  6775. /**
  6776. * Serialize the skeleton in a JSON object
  6777. * @returns a JSON object
  6778. */
  6779. serialize(): any;
  6780. /**
  6781. * Creates a new skeleton from serialized data
  6782. * @param parsedSkeleton defines the serialized data
  6783. * @param scene defines the hosting scene
  6784. * @returns a new skeleton
  6785. */
  6786. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  6787. /**
  6788. * Compute all node absolute transforms
  6789. * @param forceUpdate defines if computation must be done even if cache is up to date
  6790. */
  6791. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  6792. /**
  6793. * Gets the root pose matrix
  6794. * @returns a matrix
  6795. */
  6796. getPoseMatrix(): Nullable<Matrix>;
  6797. /**
  6798. * Sorts bones per internal index
  6799. */
  6800. sortBones(): void;
  6801. private _sortBones;
  6802. }
  6803. }
  6804. declare module BABYLON {
  6805. /** @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. * This represents an orbital type of camera.
  7154. *
  7155. * 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.
  7156. * 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.
  7157. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  7158. */
  7159. class ArcRotateCamera extends TargetCamera {
  7160. /**
  7161. * Defines the rotation angle of the camera along the longitudinal axis.
  7162. */
  7163. alpha: number;
  7164. /**
  7165. * Defines the rotation angle of the camera along the latitudinal axis.
  7166. */
  7167. beta: number;
  7168. /**
  7169. * Defines the radius of the camera from it s target point.
  7170. */
  7171. radius: number;
  7172. protected _target: Vector3;
  7173. protected _targetHost: Nullable<AbstractMesh>;
  7174. /**
  7175. * Defines the target point of the camera.
  7176. * The camera looks towards it form the radius distance.
  7177. */
  7178. target: Vector3;
  7179. /**
  7180. * Current inertia value on the longitudinal axis.
  7181. * The bigger this number the longer it will take for the camera to stop.
  7182. */
  7183. inertialAlphaOffset: number;
  7184. /**
  7185. * Current inertia value on the latitudinal axis.
  7186. * The bigger this number the longer it will take for the camera to stop.
  7187. */
  7188. inertialBetaOffset: number;
  7189. /**
  7190. * Current inertia value on the radius axis.
  7191. * The bigger this number the longer it will take for the camera to stop.
  7192. */
  7193. inertialRadiusOffset: number;
  7194. /**
  7195. * Minimum allowed angle on the longitudinal axis.
  7196. * This can help limiting how the Camera is able to move in the scene.
  7197. */
  7198. lowerAlphaLimit: Nullable<number>;
  7199. /**
  7200. * Maximum allowed angle on the longitudinal axis.
  7201. * This can help limiting how the Camera is able to move in the scene.
  7202. */
  7203. upperAlphaLimit: Nullable<number>;
  7204. /**
  7205. * Minimum allowed angle on the latitudinal axis.
  7206. * This can help limiting how the Camera is able to move in the scene.
  7207. */
  7208. lowerBetaLimit: number;
  7209. /**
  7210. * Maximum allowed angle on the latitudinal axis.
  7211. * This can help limiting how the Camera is able to move in the scene.
  7212. */
  7213. upperBetaLimit: number;
  7214. /**
  7215. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  7216. * This can help limiting how the Camera is able to move in the scene.
  7217. */
  7218. lowerRadiusLimit: Nullable<number>;
  7219. /**
  7220. * Maximum allowed distance of the camera to the target (The camera can not get further).
  7221. * This can help limiting how the Camera is able to move in the scene.
  7222. */
  7223. upperRadiusLimit: Nullable<number>;
  7224. /**
  7225. * Defines the current inertia value used during panning of the camera along the X axis.
  7226. */
  7227. inertialPanningX: number;
  7228. /**
  7229. * Defines the current inertia value used during panning of the camera along the Y axis.
  7230. */
  7231. inertialPanningY: number;
  7232. /**
  7233. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  7234. * Basically if your fingers moves away from more than this distance you will be considered
  7235. * in pinch mode.
  7236. */
  7237. pinchToPanMaxDistance: number;
  7238. /**
  7239. * Defines the maximum distance the camera can pan.
  7240. * This could help keeping the cammera always in your scene.
  7241. */
  7242. panningDistanceLimit: Nullable<number>;
  7243. /**
  7244. * Defines the target of the camera before paning.
  7245. */
  7246. panningOriginTarget: Vector3;
  7247. /**
  7248. * Defines the value of the inertia used during panning.
  7249. * 0 would mean stop inertia and one would mean no decelleration at all.
  7250. */
  7251. panningInertia: number;
  7252. /**
  7253. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  7254. */
  7255. angularSensibilityX: number;
  7256. /**
  7257. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  7258. */
  7259. angularSensibilityY: number;
  7260. /**
  7261. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  7262. */
  7263. pinchPrecision: number;
  7264. /**
  7265. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  7266. * It will be used instead of pinchDeltaPrecision if different from 0.
  7267. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  7268. */
  7269. pinchDeltaPercentage: number;
  7270. /**
  7271. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  7272. */
  7273. panningSensibility: number;
  7274. /**
  7275. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  7276. */
  7277. keysUp: number[];
  7278. /**
  7279. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  7280. */
  7281. keysDown: number[];
  7282. /**
  7283. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  7284. */
  7285. keysLeft: number[];
  7286. /**
  7287. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  7288. */
  7289. keysRight: number[];
  7290. /**
  7291. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  7292. */
  7293. wheelPrecision: number;
  7294. /**
  7295. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  7296. * It will be used instead of pinchDeltaPrecision if different from 0.
  7297. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  7298. */
  7299. wheelDeltaPercentage: number;
  7300. /**
  7301. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  7302. */
  7303. zoomOnFactor: number;
  7304. /**
  7305. * Defines a screen offset for the camera position.
  7306. */
  7307. targetScreenOffset: Vector2;
  7308. /**
  7309. * Allows the camera to be completely reversed.
  7310. * If false the camera can not arrive upside down.
  7311. */
  7312. allowUpsideDown: boolean;
  7313. /**
  7314. * Define if double tap/click is used to restore the previously saved state of the camera.
  7315. */
  7316. useInputToRestoreState: boolean;
  7317. /** @hidden */
  7318. _viewMatrix: Matrix;
  7319. /** @hidden */
  7320. _useCtrlForPanning: boolean;
  7321. /** @hidden */
  7322. _panningMouseButton: number;
  7323. /**
  7324. * Defines the inpute associated to the camera.
  7325. */
  7326. inputs: ArcRotateCameraInputsManager;
  7327. /** @hidden */
  7328. _reset: () => void;
  7329. /**
  7330. * Defines the allowed panning axis.
  7331. */
  7332. panningAxis: Vector3;
  7333. protected _localDirection: Vector3;
  7334. protected _transformedDirection: Vector3;
  7335. private _bouncingBehavior;
  7336. /**
  7337. * Gets the bouncing behavior of the camera if it has been enabled.
  7338. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  7339. */
  7340. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  7341. /**
  7342. * Defines if the bouncing behavior of the camera is enabled on the camera.
  7343. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  7344. */
  7345. useBouncingBehavior: boolean;
  7346. private _framingBehavior;
  7347. /**
  7348. * Gets the framing behavior of the camera if it has been enabled.
  7349. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  7350. */
  7351. readonly framingBehavior: Nullable<FramingBehavior>;
  7352. /**
  7353. * Defines if the framing behavior of the camera is enabled on the camera.
  7354. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  7355. */
  7356. useFramingBehavior: boolean;
  7357. private _autoRotationBehavior;
  7358. /**
  7359. * Gets the auto rotation behavior of the camera if it has been enabled.
  7360. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  7361. */
  7362. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  7363. /**
  7364. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  7365. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  7366. */
  7367. useAutoRotationBehavior: boolean;
  7368. /**
  7369. * Observable triggered when the mesh target has been changed on the camera.
  7370. */
  7371. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  7372. /**
  7373. * Event raised when the camera is colliding with a mesh.
  7374. */
  7375. onCollide: (collidedMesh: AbstractMesh) => void;
  7376. /**
  7377. * Defines whether the camera should check collision with the objects oh the scene.
  7378. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  7379. */
  7380. checkCollisions: boolean;
  7381. /**
  7382. * Defines the collision radius of the camera.
  7383. * This simulates a sphere around the camera.
  7384. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  7385. */
  7386. collisionRadius: Vector3;
  7387. protected _collider: Collider;
  7388. protected _previousPosition: Vector3;
  7389. protected _collisionVelocity: Vector3;
  7390. protected _newPosition: Vector3;
  7391. protected _previousAlpha: number;
  7392. protected _previousBeta: number;
  7393. protected _previousRadius: number;
  7394. protected _collisionTriggered: boolean;
  7395. protected _targetBoundingCenter: Nullable<Vector3>;
  7396. private _computationVector;
  7397. private _tempAxisVector;
  7398. private _tempAxisRotationMatrix;
  7399. /**
  7400. * Instantiates a new ArcRotateCamera in a given scene
  7401. * @param name Defines the name of the camera
  7402. * @param alpha Defines the camera rotation along the logitudinal axis
  7403. * @param beta Defines the camera rotation along the latitudinal axis
  7404. * @param radius Defines the camera distance from its target
  7405. * @param target Defines the camera target
  7406. * @param scene Defines the scene the camera belongs to
  7407. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  7408. */
  7409. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  7410. /** @hidden */
  7411. _initCache(): void;
  7412. /** @hidden */
  7413. _updateCache(ignoreParentClass?: boolean): void;
  7414. protected _getTargetPosition(): Vector3;
  7415. private _storedAlpha;
  7416. private _storedBeta;
  7417. private _storedRadius;
  7418. private _storedTarget;
  7419. /**
  7420. * Stores the current state of the camera (alpha, beta, radius and target)
  7421. * @returns the camera itself
  7422. */
  7423. storeState(): Camera;
  7424. /**
  7425. * @hidden
  7426. * Restored camera state. You must call storeState() first
  7427. */
  7428. _restoreStateValues(): boolean;
  7429. /** @hidden */
  7430. _isSynchronizedViewMatrix(): boolean;
  7431. /**
  7432. * Attached controls to the current camera.
  7433. * @param element Defines the element the controls should be listened from
  7434. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7435. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  7436. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  7437. */
  7438. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  7439. /**
  7440. * Detach the current controls from the camera.
  7441. * The camera will stop reacting to inputs.
  7442. * @param element Defines the element to stop listening the inputs from
  7443. */
  7444. detachControl(element: HTMLElement): void;
  7445. /** @hidden */
  7446. _checkInputs(): void;
  7447. protected _checkLimits(): void;
  7448. /**
  7449. * Rebuilds angles (alpha, beta) and radius from the give position and target.
  7450. */
  7451. rebuildAnglesAndRadius(): void;
  7452. /**
  7453. * Use a position to define the current camera related information like aplha, beta and radius
  7454. * @param position Defines the position to set the camera at
  7455. */
  7456. setPosition(position: Vector3): void;
  7457. /**
  7458. * Defines the target the camera should look at.
  7459. * This will automatically adapt alpha beta and radius to fit within the new target.
  7460. * @param target Defines the new target as a Vector or a mesh
  7461. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  7462. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  7463. */
  7464. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  7465. /** @hidden */
  7466. _getViewMatrix(): Matrix;
  7467. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  7468. /**
  7469. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  7470. * @param meshes Defines the mesh to zoom on
  7471. * @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)
  7472. */
  7473. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  7474. /**
  7475. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  7476. * The target will be changed but the radius
  7477. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  7478. * @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)
  7479. */
  7480. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  7481. min: Vector3;
  7482. max: Vector3;
  7483. distance: number;
  7484. }, doNotUpdateMaxZ?: boolean): void;
  7485. /**
  7486. * @override
  7487. * Override Camera.createRigCamera
  7488. */
  7489. createRigCamera(name: string, cameraIndex: number): Camera;
  7490. /**
  7491. * @hidden
  7492. * @override
  7493. * Override Camera._updateRigCameras
  7494. */
  7495. _updateRigCameras(): void;
  7496. /**
  7497. * Destroy the camera and release the current resources hold by it.
  7498. */
  7499. dispose(): void;
  7500. /**
  7501. * Gets the current object class name.
  7502. * @return the class name
  7503. */
  7504. getClassName(): string;
  7505. }
  7506. }
  7507. declare module BABYLON {
  7508. /**
  7509. * Default Inputs manager for the ArcRotateCamera.
  7510. * It groups all the default supported inputs for ease of use.
  7511. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  7512. */
  7513. class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  7514. /**
  7515. * Instantiates a new ArcRotateCameraInputsManager.
  7516. * @param camera Defines the camera the inputs belong to
  7517. */
  7518. constructor(camera: ArcRotateCamera);
  7519. /**
  7520. * Add mouse wheel input support to the input manager.
  7521. * @returns the current input manager
  7522. */
  7523. addMouseWheel(): ArcRotateCameraInputsManager;
  7524. /**
  7525. * Add pointers input support to the input manager.
  7526. * @returns the current input manager
  7527. */
  7528. addPointers(): ArcRotateCameraInputsManager;
  7529. /**
  7530. * Add keyboard input support to the input manager.
  7531. * @returns the current input manager
  7532. */
  7533. addKeyboard(): ArcRotateCameraInputsManager;
  7534. /**
  7535. * Add orientation input support to the input manager.
  7536. * @returns the current input manager
  7537. */
  7538. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  7539. }
  7540. }
  7541. declare module BABYLON {
  7542. /**
  7543. * This is the base class of all the camera used in the application.
  7544. * @see http://doc.babylonjs.com/features/cameras
  7545. */
  7546. class Camera extends Node {
  7547. /**
  7548. * This is the default projection mode used by the cameras.
  7549. * It helps recreating a feeling of perspective and better appreciate depth.
  7550. * This is the best way to simulate real life cameras.
  7551. */
  7552. static readonly PERSPECTIVE_CAMERA: number;
  7553. /**
  7554. * This helps creating camera with an orthographic mode.
  7555. * 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.
  7556. */
  7557. static readonly ORTHOGRAPHIC_CAMERA: number;
  7558. /**
  7559. * This is the default FOV mode for perspective cameras.
  7560. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  7561. */
  7562. static readonly FOVMODE_VERTICAL_FIXED: number;
  7563. /**
  7564. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  7565. */
  7566. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  7567. /**
  7568. * This specifies ther is no need for a camera rig.
  7569. * Basically only one eye is rendered corresponding to the camera.
  7570. */
  7571. static readonly RIG_MODE_NONE: number;
  7572. /**
  7573. * Simulates a camera Rig with one blue eye and one red eye.
  7574. * This can be use with 3d blue and red glasses.
  7575. */
  7576. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  7577. /**
  7578. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  7579. */
  7580. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  7581. /**
  7582. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  7583. */
  7584. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  7585. /**
  7586. * Defines that both eyes of the camera will be rendered over under each other.
  7587. */
  7588. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  7589. /**
  7590. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  7591. */
  7592. static readonly RIG_MODE_VR: number;
  7593. /**
  7594. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  7595. */
  7596. static readonly RIG_MODE_WEBVR: number;
  7597. /**
  7598. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  7599. */
  7600. static readonly RIG_MODE_CUSTOM: number;
  7601. /**
  7602. * Defines if by default attaching controls should prevent the default javascript event to continue.
  7603. */
  7604. static ForceAttachControlToAlwaysPreventDefault: boolean;
  7605. /**
  7606. * @hidden
  7607. * Might be removed once multiview will be a thing
  7608. */
  7609. static UseAlternateWebVRRendering: boolean;
  7610. /**
  7611. * Define the input manager associated with the camera.
  7612. */
  7613. inputs: CameraInputsManager<Camera>;
  7614. /**
  7615. * Define the current local position of the camera in the scene
  7616. */
  7617. position: Vector3;
  7618. /**
  7619. * The vector the camera should consider as up.
  7620. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  7621. */
  7622. upVector: Vector3;
  7623. /**
  7624. * Define the current limit on the left side for an orthographic camera
  7625. * In scene unit
  7626. */
  7627. orthoLeft: Nullable<number>;
  7628. /**
  7629. * Define the current limit on the right side for an orthographic camera
  7630. * In scene unit
  7631. */
  7632. orthoRight: Nullable<number>;
  7633. /**
  7634. * Define the current limit on the bottom side for an orthographic camera
  7635. * In scene unit
  7636. */
  7637. orthoBottom: Nullable<number>;
  7638. /**
  7639. * Define the current limit on the top side for an orthographic camera
  7640. * In scene unit
  7641. */
  7642. orthoTop: Nullable<number>;
  7643. /**
  7644. * Field Of View is set in Radians. (default is 0.8)
  7645. */
  7646. fov: number;
  7647. /**
  7648. * Define the minimum distance the camera can see from.
  7649. * This is important to note that the depth buffer are not infinite and the closer it starts
  7650. * the more your scene might encounter depth fighting issue.
  7651. */
  7652. minZ: number;
  7653. /**
  7654. * Define the maximum distance the camera can see to.
  7655. * This is important to note that the depth buffer are not infinite and the further it end
  7656. * the more your scene might encounter depth fighting issue.
  7657. */
  7658. maxZ: number;
  7659. /**
  7660. * Define the default inertia of the camera.
  7661. * This helps giving a smooth feeling to the camera movement.
  7662. */
  7663. inertia: number;
  7664. /**
  7665. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  7666. */
  7667. mode: number;
  7668. /**
  7669. * Define wether the camera is intermediate.
  7670. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  7671. */
  7672. isIntermediate: boolean;
  7673. /**
  7674. * Define the viewport of the camera.
  7675. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  7676. */
  7677. viewport: Viewport;
  7678. /**
  7679. * Restricts the camera to viewing objects with the same layerMask.
  7680. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  7681. */
  7682. layerMask: number;
  7683. /**
  7684. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  7685. */
  7686. fovMode: number;
  7687. /**
  7688. * Rig mode of the camera.
  7689. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  7690. * This is normally controlled byt the camera themselves as internal use.
  7691. */
  7692. cameraRigMode: number;
  7693. /**
  7694. * Defines the distance between both "eyes" in case of a RIG
  7695. */
  7696. interaxialDistance: number;
  7697. /**
  7698. * Defines if stereoscopic rendering is done side by side or over under.
  7699. */
  7700. isStereoscopicSideBySide: boolean;
  7701. /**
  7702. * 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
  7703. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  7704. * else in the scene.
  7705. */
  7706. customRenderTargets: RenderTargetTexture[];
  7707. /**
  7708. * When set, the camera will render to this render target instead of the default canvas
  7709. */
  7710. outputRenderTarget: Nullable<RenderTargetTexture>;
  7711. /**
  7712. * Observable triggered when the camera view matrix has changed.
  7713. */
  7714. onViewMatrixChangedObservable: Observable<Camera>;
  7715. /**
  7716. * Observable triggered when the camera Projection matrix has changed.
  7717. */
  7718. onProjectionMatrixChangedObservable: Observable<Camera>;
  7719. /**
  7720. * Observable triggered when the inputs have been processed.
  7721. */
  7722. onAfterCheckInputsObservable: Observable<Camera>;
  7723. /**
  7724. * Observable triggered when reset has been called and applied to the camera.
  7725. */
  7726. onRestoreStateObservable: Observable<Camera>;
  7727. /** @hidden */
  7728. _cameraRigParams: any;
  7729. /** @hidden */
  7730. _rigCameras: Camera[];
  7731. /** @hidden */
  7732. _rigPostProcess: Nullable<PostProcess>;
  7733. protected _webvrViewMatrix: Matrix;
  7734. /** @hidden */
  7735. _skipRendering: boolean;
  7736. /** @hidden */
  7737. _alternateCamera: Camera;
  7738. /** @hidden */
  7739. _projectionMatrix: Matrix;
  7740. /** @hidden */
  7741. _postProcesses: Nullable<PostProcess>[];
  7742. /** @hidden */
  7743. _activeMeshes: SmartArray<AbstractMesh>;
  7744. protected _globalPosition: Vector3;
  7745. /** hidden */
  7746. _computedViewMatrix: Matrix;
  7747. private _doNotComputeProjectionMatrix;
  7748. private _transformMatrix;
  7749. private _frustumPlanes;
  7750. private _refreshFrustumPlanes;
  7751. private _storedFov;
  7752. private _stateStored;
  7753. /**
  7754. * Instantiates a new camera object.
  7755. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  7756. * @see http://doc.babylonjs.com/features/cameras
  7757. * @param name Defines the name of the camera in the scene
  7758. * @param position Defines the position of the camera
  7759. * @param scene Defines the scene the camera belongs too
  7760. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  7761. */
  7762. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  7763. /**
  7764. * Store current camera state (fov, position, etc..)
  7765. * @returns the camera
  7766. */
  7767. storeState(): Camera;
  7768. /**
  7769. * Restores the camera state values if it has been stored. You must call storeState() first
  7770. */
  7771. protected _restoreStateValues(): boolean;
  7772. /**
  7773. * Restored camera state. You must call storeState() first.
  7774. * @returns true if restored and false otherwise
  7775. */
  7776. restoreState(): boolean;
  7777. /**
  7778. * Gets the class name of the camera.
  7779. * @returns the class name
  7780. */
  7781. getClassName(): string;
  7782. /**
  7783. * Gets a string representation of the camera useful for debug purpose.
  7784. * @param fullDetails Defines that a more verboe level of logging is required
  7785. * @returns the string representation
  7786. */
  7787. toString(fullDetails?: boolean): string;
  7788. /**
  7789. * Gets the current world space position of the camera.
  7790. */
  7791. readonly globalPosition: Vector3;
  7792. /**
  7793. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  7794. * @returns the active meshe list
  7795. */
  7796. getActiveMeshes(): SmartArray<AbstractMesh>;
  7797. /**
  7798. * Check wether a mesh is part of the current active mesh list of the camera
  7799. * @param mesh Defines the mesh to check
  7800. * @returns true if active, false otherwise
  7801. */
  7802. isActiveMesh(mesh: Mesh): boolean;
  7803. /**
  7804. * Is this camera ready to be used/rendered
  7805. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  7806. * @return true if the camera is ready
  7807. */
  7808. isReady(completeCheck?: boolean): boolean;
  7809. /** @hidden */
  7810. _initCache(): void;
  7811. /** @hidden */
  7812. _updateCache(ignoreParentClass?: boolean): void;
  7813. /** @hidden */
  7814. _isSynchronized(): boolean;
  7815. /** @hidden */
  7816. _isSynchronizedViewMatrix(): boolean;
  7817. /** @hidden */
  7818. _isSynchronizedProjectionMatrix(): boolean;
  7819. /**
  7820. * Attach the input controls to a specific dom element to get the input from.
  7821. * @param element Defines the element the controls should be listened from
  7822. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7823. */
  7824. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  7825. /**
  7826. * Detach the current controls from the specified dom element.
  7827. * @param element Defines the element to stop listening the inputs from
  7828. */
  7829. detachControl(element: HTMLElement): void;
  7830. /**
  7831. * Update the camera state according to the different inputs gathered during the frame.
  7832. */
  7833. update(): void;
  7834. /** @hidden */
  7835. _checkInputs(): void;
  7836. /** @hidden */
  7837. readonly rigCameras: Camera[];
  7838. /**
  7839. * Gets the post process used by the rig cameras
  7840. */
  7841. readonly rigPostProcess: Nullable<PostProcess>;
  7842. /**
  7843. * Internal, gets the first post proces.
  7844. * @returns the first post process to be run on this camera.
  7845. */
  7846. _getFirstPostProcess(): Nullable<PostProcess>;
  7847. private _cascadePostProcessesToRigCams;
  7848. /**
  7849. * Attach a post process to the camera.
  7850. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  7851. * @param postProcess The post process to attach to the camera
  7852. * @param insertAt The position of the post process in case several of them are in use in the scene
  7853. * @returns the position the post process has been inserted at
  7854. */
  7855. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  7856. /**
  7857. * Detach a post process to the camera.
  7858. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  7859. * @param postProcess The post process to detach from the camera
  7860. */
  7861. detachPostProcess(postProcess: PostProcess): void;
  7862. /**
  7863. * Gets the current world matrix of the camera
  7864. */
  7865. getWorldMatrix(): Matrix;
  7866. /** @hidden */
  7867. protected _getViewMatrix(): Matrix;
  7868. /**
  7869. * Gets the current view matrix of the camera.
  7870. * @param force forces the camera to recompute the matrix without looking at the cached state
  7871. * @returns the view matrix
  7872. */
  7873. getViewMatrix(force?: boolean): Matrix;
  7874. /**
  7875. * Freeze the projection matrix.
  7876. * It will prevent the cache check of the camera projection compute and can speed up perf
  7877. * if no parameter of the camera are meant to change
  7878. * @param projection Defines manually a projection if necessary
  7879. */
  7880. freezeProjectionMatrix(projection?: Matrix): void;
  7881. /**
  7882. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  7883. */
  7884. unfreezeProjectionMatrix(): void;
  7885. /**
  7886. * Gets the current projection matrix of the camera.
  7887. * @param force forces the camera to recompute the matrix without looking at the cached state
  7888. * @returns the projection matrix
  7889. */
  7890. getProjectionMatrix(force?: boolean): Matrix;
  7891. /**
  7892. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  7893. * @returns a Matrix
  7894. */
  7895. getTransformationMatrix(): Matrix;
  7896. private _updateFrustumPlanes;
  7897. /**
  7898. * Checks if a cullable object (mesh...) is in the camera frustum
  7899. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  7900. * @param target The object to check
  7901. * @returns true if the object is in frustum otherwise false
  7902. */
  7903. isInFrustum(target: ICullable): boolean;
  7904. /**
  7905. * Checks if a cullable object (mesh...) is in the camera frustum
  7906. * Unlike isInFrustum this cheks the full bounding box
  7907. * @param target The object to check
  7908. * @returns true if the object is in frustum otherwise false
  7909. */
  7910. isCompletelyInFrustum(target: ICullable): boolean;
  7911. /**
  7912. * Gets a ray in the forward direction from the camera.
  7913. * @param length Defines the length of the ray to create
  7914. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  7915. * @param origin Defines the start point of the ray which defaults to the camera position
  7916. * @returns the forward ray
  7917. */
  7918. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  7919. /**
  7920. * Releases resources associated with this node.
  7921. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7922. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7923. */
  7924. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7925. /**
  7926. * Gets the left camera of a rig setup in case of Rigged Camera
  7927. */
  7928. readonly leftCamera: Nullable<FreeCamera>;
  7929. /**
  7930. * Gets the right camera of a rig setup in case of Rigged Camera
  7931. */
  7932. readonly rightCamera: Nullable<FreeCamera>;
  7933. /**
  7934. * Gets the left camera target of a rig setup in case of Rigged Camera
  7935. * @returns the target position
  7936. */
  7937. getLeftTarget(): Nullable<Vector3>;
  7938. /**
  7939. * Gets the right camera target of a rig setup in case of Rigged Camera
  7940. * @returns the target position
  7941. */
  7942. getRightTarget(): Nullable<Vector3>;
  7943. /**
  7944. * @hidden
  7945. */
  7946. setCameraRigMode(mode: number, rigParams: any): void;
  7947. private _getVRProjectionMatrix;
  7948. protected _updateCameraRotationMatrix(): void;
  7949. protected _updateWebVRCameraRotationMatrix(): void;
  7950. /**
  7951. * This function MUST be overwritten by the different WebVR cameras available.
  7952. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  7953. */
  7954. protected _getWebVRProjectionMatrix(): Matrix;
  7955. /**
  7956. * This function MUST be overwritten by the different WebVR cameras available.
  7957. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  7958. */
  7959. protected _getWebVRViewMatrix(): Matrix;
  7960. /** @hidden */
  7961. setCameraRigParameter(name: string, value: any): void;
  7962. /**
  7963. * needs to be overridden by children so sub has required properties to be copied
  7964. * @hidden
  7965. */
  7966. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  7967. /**
  7968. * May need to be overridden by children
  7969. * @hidden
  7970. */
  7971. _updateRigCameras(): void;
  7972. /** @hidden */
  7973. _setupInputs(): void;
  7974. /**
  7975. * Serialiaze the camera setup to a json represention
  7976. * @returns the JSON representation
  7977. */
  7978. serialize(): any;
  7979. /**
  7980. * Clones the current camera.
  7981. * @param name The cloned camera name
  7982. * @returns the cloned camera
  7983. */
  7984. clone(name: string): Camera;
  7985. /**
  7986. * Gets the direction of the camera relative to a given local axis.
  7987. * @param localAxis Defines the reference axis to provide a relative direction.
  7988. * @return the direction
  7989. */
  7990. getDirection(localAxis: Vector3): Vector3;
  7991. /**
  7992. * Gets the direction of the camera relative to a given local axis into a passed vector.
  7993. * @param localAxis Defines the reference axis to provide a relative direction.
  7994. * @param result Defines the vector to store the result in
  7995. */
  7996. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  7997. /**
  7998. * Gets a camera constructor for a given camera type
  7999. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  8000. * @param name The name of the camera the result will be able to instantiate
  8001. * @param scene The scene the result will construct the camera in
  8002. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  8003. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  8004. * @returns a factory method to construc the camera
  8005. */
  8006. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  8007. /**
  8008. * Compute the world matrix of the camera.
  8009. * @returns the camera workd matrix
  8010. */
  8011. computeWorldMatrix(): Matrix;
  8012. /**
  8013. * Parse a JSON and creates the camera from the parsed information
  8014. * @param parsedCamera The JSON to parse
  8015. * @param scene The scene to instantiate the camera in
  8016. * @returns the newly constructed camera
  8017. */
  8018. static Parse(parsedCamera: any, scene: Scene): Camera;
  8019. }
  8020. }
  8021. declare module BABYLON {
  8022. /**
  8023. * @ignore
  8024. * This is a list of all the different input types that are available in the application.
  8025. * Fo instance: ArcRotateCameraGamepadInput...
  8026. */
  8027. var CameraInputTypes: {};
  8028. /**
  8029. * This is the contract to implement in order to create a new input class.
  8030. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8031. */
  8032. interface ICameraInput<TCamera extends Camera> {
  8033. /**
  8034. * Defines the camera the input is attached to.
  8035. */
  8036. camera: Nullable<TCamera>;
  8037. /**
  8038. * Gets the class name of the current intput.
  8039. * @returns the class name
  8040. */
  8041. getClassName(): string;
  8042. /**
  8043. * Get the friendly name associated with the input class.
  8044. * @returns the input friendly name
  8045. */
  8046. getSimpleName(): string;
  8047. /**
  8048. * Attach the input controls to a specific dom element to get the input from.
  8049. * @param element Defines the element the controls should be listened from
  8050. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8051. */
  8052. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8053. /**
  8054. * Detach the current controls from the specified dom element.
  8055. * @param element Defines the element to stop listening the inputs from
  8056. */
  8057. detachControl(element: Nullable<HTMLElement>): void;
  8058. /**
  8059. * Update the current camera state depending on the inputs that have been used this frame.
  8060. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8061. */
  8062. checkInputs?: () => void;
  8063. }
  8064. /**
  8065. * Represents a map of input types to input instance or input index to input instance.
  8066. */
  8067. interface CameraInputsMap<TCamera extends Camera> {
  8068. /**
  8069. * Accessor to the input by input type.
  8070. */
  8071. [name: string]: ICameraInput<TCamera>;
  8072. /**
  8073. * Accessor to the input by input index.
  8074. */
  8075. [idx: number]: ICameraInput<TCamera>;
  8076. }
  8077. /**
  8078. * This represents the input manager used within a camera.
  8079. * It helps dealing with all the different kind of input attached to a camera.
  8080. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8081. */
  8082. class CameraInputsManager<TCamera extends Camera> {
  8083. /**
  8084. * Defines the list of inputs attahed to the camera.
  8085. */
  8086. attached: CameraInputsMap<TCamera>;
  8087. /**
  8088. * Defines the dom element the camera is collecting inputs from.
  8089. * This is null if the controls have not been attached.
  8090. */
  8091. attachedElement: Nullable<HTMLElement>;
  8092. /**
  8093. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8094. */
  8095. noPreventDefault: boolean;
  8096. /**
  8097. * Defined the camera the input manager belongs to.
  8098. */
  8099. camera: TCamera;
  8100. /**
  8101. * Update the current camera state depending on the inputs that have been used this frame.
  8102. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8103. */
  8104. checkInputs: () => void;
  8105. /**
  8106. * Instantiate a new Camera Input Manager.
  8107. * @param camera Defines the camera the input manager blongs to
  8108. */
  8109. constructor(camera: TCamera);
  8110. /**
  8111. * Add an input method to a camera
  8112. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8113. * @param input camera input method
  8114. */
  8115. add(input: ICameraInput<TCamera>): void;
  8116. /**
  8117. * Remove a specific input method from a camera
  8118. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8119. * @param inputToRemove camera input method
  8120. */
  8121. remove(inputToRemove: ICameraInput<TCamera>): void;
  8122. /**
  8123. * Remove a specific input type from a camera
  8124. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8125. * @param inputType the type of the input to remove
  8126. */
  8127. removeByType(inputType: string): void;
  8128. private _addCheckInputs;
  8129. /**
  8130. * Attach the input controls to the currently attached dom element to listen the events from.
  8131. * @param input Defines the input to attach
  8132. */
  8133. attachInput(input: ICameraInput<TCamera>): void;
  8134. /**
  8135. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8136. * @param element Defines the dom element to collect the events from
  8137. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8138. */
  8139. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8140. /**
  8141. * Detach the current manager inputs controls from a specific dom element.
  8142. * @param element Defines the dom element to collect the events from
  8143. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8144. */
  8145. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8146. /**
  8147. * Rebuild the dynamic inputCheck function from the current list of
  8148. * defined inputs in the manager.
  8149. */
  8150. rebuildInputCheck(): void;
  8151. /**
  8152. * Remove all attached input methods from a camera
  8153. */
  8154. clear(): void;
  8155. /**
  8156. * Serialize the current input manager attached to a camera.
  8157. * This ensures than once parsed,
  8158. * the input associated to the camera will be identical to the current ones
  8159. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8160. */
  8161. serialize(serializedCamera: any): void;
  8162. /**
  8163. * Parses an input manager serialized JSON to restore the previous list of inputs
  8164. * and states associated to a camera.
  8165. * @param parsedCamera Defines the JSON to parse
  8166. */
  8167. parse(parsedCamera: any): void;
  8168. }
  8169. }
  8170. declare module BABYLON {
  8171. /**
  8172. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  8173. * being tilted forward or back and left or right.
  8174. */
  8175. class DeviceOrientationCamera extends FreeCamera {
  8176. private _initialQuaternion;
  8177. private _quaternionCache;
  8178. /**
  8179. * Creates a new device orientation camera
  8180. * @param name The name of the camera
  8181. * @param position The start position camera
  8182. * @param scene The scene the camera belongs to
  8183. */
  8184. constructor(name: string, position: Vector3, scene: Scene);
  8185. /**
  8186. * Gets the current instance class name ("DeviceOrientationCamera").
  8187. * This helps avoiding instanceof at run time.
  8188. * @returns the class name
  8189. */
  8190. getClassName(): string;
  8191. /**
  8192. * @hidden
  8193. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  8194. */
  8195. _checkInputs(): void;
  8196. /**
  8197. * Reset the camera to its default orientation on the specified axis only.
  8198. * @param axis The axis to reset
  8199. */
  8200. resetToCurrentRotation(axis?: Axis): void;
  8201. }
  8202. }
  8203. declare module BABYLON {
  8204. /**
  8205. * This is a flying camera, designed for 3D movement and rotation in all directions,
  8206. * such as in a 3D Space Shooter or a Flight Simulator.
  8207. */
  8208. class FlyCamera extends TargetCamera {
  8209. /**
  8210. * Define the collision ellipsoid of the camera.
  8211. * This is helpful for simulating a camera body, like a player's body.
  8212. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  8213. */
  8214. ellipsoid: Vector3;
  8215. /**
  8216. * Define an offset for the position of the ellipsoid around the camera.
  8217. * This can be helpful if the camera is attached away from the player's body center,
  8218. * such as at its head.
  8219. */
  8220. ellipsoidOffset: Vector3;
  8221. /**
  8222. * Enable or disable collisions of the camera with the rest of the scene objects.
  8223. */
  8224. checkCollisions: boolean;
  8225. /**
  8226. * Enable or disable gravity on the camera.
  8227. */
  8228. applyGravity: boolean;
  8229. /**
  8230. * Define the current direction the camera is moving to.
  8231. */
  8232. cameraDirection: Vector3;
  8233. /**
  8234. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  8235. * This overrides and empties cameraRotation.
  8236. */
  8237. rotationQuaternion: BABYLON.Quaternion;
  8238. /**
  8239. * Track Roll to maintain the wanted Rolling when looking around.
  8240. */
  8241. _trackRoll: number;
  8242. /**
  8243. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  8244. */
  8245. rollCorrect: number;
  8246. /**
  8247. * Mimic a banked turn, Rolling the camera when Yawing.
  8248. * It's recommended to use rollCorrect = 10 for faster banking correction.
  8249. */
  8250. bankedTurn: boolean;
  8251. /**
  8252. * Limit in radians for how much Roll banking will add. (Default: 90°)
  8253. */
  8254. bankedTurnLimit: number;
  8255. /**
  8256. * Value of 0 disables the banked Roll.
  8257. * Value of 1 is equal to the Yaw angle in radians.
  8258. */
  8259. bankedTurnMultiplier: number;
  8260. /**
  8261. * The inputs manager loads all the input sources, such as keyboard and mouse.
  8262. */
  8263. inputs: FlyCameraInputsManager;
  8264. /**
  8265. * Gets the input sensibility for mouse input.
  8266. * Higher values reduce sensitivity.
  8267. */
  8268. /**
  8269. * Sets the input sensibility for a mouse input.
  8270. * Higher values reduce sensitivity.
  8271. */
  8272. angularSensibility: number;
  8273. /**
  8274. * Get the keys for camera movement forward.
  8275. */
  8276. /**
  8277. * Set the keys for camera movement forward.
  8278. */
  8279. keysForward: number[];
  8280. /**
  8281. * Get the keys for camera movement backward.
  8282. */
  8283. keysBackward: number[];
  8284. /**
  8285. * Get the keys for camera movement up.
  8286. */
  8287. /**
  8288. * Set the keys for camera movement up.
  8289. */
  8290. keysUp: number[];
  8291. /**
  8292. * Get the keys for camera movement down.
  8293. */
  8294. /**
  8295. * Set the keys for camera movement down.
  8296. */
  8297. keysDown: number[];
  8298. /**
  8299. * Get the keys for camera movement left.
  8300. */
  8301. /**
  8302. * Set the keys for camera movement left.
  8303. */
  8304. keysLeft: number[];
  8305. /**
  8306. * Set the keys for camera movement right.
  8307. */
  8308. /**
  8309. * Set the keys for camera movement right.
  8310. */
  8311. keysRight: number[];
  8312. /**
  8313. * Event raised when the camera collides with a mesh in the scene.
  8314. */
  8315. onCollide: (collidedMesh: AbstractMesh) => void;
  8316. private _collider;
  8317. private _needMoveForGravity;
  8318. private _oldPosition;
  8319. private _diffPosition;
  8320. private _newPosition;
  8321. /** @hidden */
  8322. _localDirection: Vector3;
  8323. /** @hidden */
  8324. _transformedDirection: Vector3;
  8325. /**
  8326. * Instantiates a FlyCamera.
  8327. * This is a flying camera, designed for 3D movement and rotation in all directions,
  8328. * such as in a 3D Space Shooter or a Flight Simulator.
  8329. * @param name Define the name of the camera in the scene.
  8330. * @param position Define the starting position of the camera in the scene.
  8331. * @param scene Define the scene the camera belongs to.
  8332. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  8333. */
  8334. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8335. /**
  8336. * Attach a control to the HTML DOM element.
  8337. * @param element Defines the element that listens to the input events.
  8338. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  8339. */
  8340. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8341. /**
  8342. * Detach a control from the HTML DOM element.
  8343. * The camera will stop reacting to that input.
  8344. * @param element Defines the element that listens to the input events.
  8345. */
  8346. detachControl(element: HTMLElement): void;
  8347. private _collisionMask;
  8348. /**
  8349. * Get the mask that the camera ignores in collision events.
  8350. */
  8351. /**
  8352. * Set the mask that the camera ignores in collision events.
  8353. */
  8354. collisionMask: number;
  8355. /** @hidden */
  8356. _collideWithWorld(displacement: Vector3): void;
  8357. /** @hidden */
  8358. private _onCollisionPositionChange;
  8359. /** @hidden */
  8360. _checkInputs(): void;
  8361. /** @hidden */
  8362. _decideIfNeedsToMove(): boolean;
  8363. /** @hidden */
  8364. _updatePosition(): void;
  8365. /**
  8366. * Restore the Roll to its target value at the rate specified.
  8367. * @param rate - Higher means slower restoring.
  8368. * @hidden
  8369. */
  8370. restoreRoll(rate: number): void;
  8371. /**
  8372. * Destroy the camera and release the current resources held by it.
  8373. */
  8374. dispose(): void;
  8375. /**
  8376. * Get the current object class name.
  8377. * @returns the class name.
  8378. */
  8379. getClassName(): string;
  8380. }
  8381. }
  8382. declare module BABYLON {
  8383. /**
  8384. * Default Inputs manager for the FlyCamera.
  8385. * It groups all the default supported inputs for ease of use.
  8386. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8387. */
  8388. class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  8389. /**
  8390. * Instantiates a new FlyCameraInputsManager.
  8391. * @param camera Defines the camera the inputs belong to.
  8392. */
  8393. constructor(camera: FlyCamera);
  8394. /**
  8395. * Add keyboard input support to the input manager.
  8396. * @returns the new FlyCameraKeyboardMoveInput().
  8397. */
  8398. addKeyboard(): FlyCameraInputsManager;
  8399. /**
  8400. * Add mouse input support to the input manager.
  8401. * @param touchEnabled Enable touch screen support.
  8402. * @returns the new FlyCameraMouseInput().
  8403. */
  8404. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  8405. }
  8406. }
  8407. declare module BABYLON {
  8408. /**
  8409. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  8410. * an arc rotate version arcFollowCamera are available.
  8411. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  8412. */
  8413. class FollowCamera extends TargetCamera {
  8414. /**
  8415. * Distance the follow camera should follow an object at
  8416. */
  8417. radius: number;
  8418. /**
  8419. * Define a rotation offset between the camera and the object it follows
  8420. */
  8421. rotationOffset: number;
  8422. /**
  8423. * Define a height offset between the camera and the object it follows.
  8424. * It can help following an object from the top (like a car chaing a plane)
  8425. */
  8426. heightOffset: number;
  8427. /**
  8428. * Define how fast the camera can accelerate to follow it s target.
  8429. */
  8430. cameraAcceleration: number;
  8431. /**
  8432. * Define the speed limit of the camera following an object.
  8433. */
  8434. maxCameraSpeed: number;
  8435. /**
  8436. * Define the target of the camera.
  8437. */
  8438. lockedTarget: Nullable<AbstractMesh>;
  8439. /**
  8440. * Instantiates the follow camera.
  8441. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  8442. * @param name Define the name of the camera in the scene
  8443. * @param position Define the position of the camera
  8444. * @param scene Define the scene the camera belong to
  8445. * @param lockedTarget Define the target of the camera
  8446. */
  8447. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  8448. private _follow;
  8449. /** @hidden */
  8450. _checkInputs(): void;
  8451. /**
  8452. * Gets the camera class name.
  8453. * @returns the class name
  8454. */
  8455. getClassName(): string;
  8456. }
  8457. /**
  8458. * Arc Rotate version of the follow camera.
  8459. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  8460. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  8461. */
  8462. class ArcFollowCamera extends TargetCamera {
  8463. /** The longitudinal angle of the camera */
  8464. alpha: number;
  8465. /** The latitudinal angle of the camera */
  8466. beta: number;
  8467. /** The radius of the camera from its target */
  8468. radius: number;
  8469. /** Define the camera target (the messh it should follow) */
  8470. target: Nullable<AbstractMesh>;
  8471. private _cartesianCoordinates;
  8472. /**
  8473. * Instantiates a new ArcFollowCamera
  8474. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  8475. * @param name Define the name of the camera
  8476. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  8477. * @param beta Define the rotation angle of the camera around the elevation axis
  8478. * @param radius Define the radius of the camera from its target point
  8479. * @param target Define the target of the camera
  8480. * @param scene Define the scene the camera belongs to
  8481. */
  8482. constructor(name: string,
  8483. /** The longitudinal angle of the camera */
  8484. alpha: number,
  8485. /** The latitudinal angle of the camera */
  8486. beta: number,
  8487. /** The radius of the camera from its target */
  8488. radius: number,
  8489. /** Define the camera target (the messh it should follow) */
  8490. target: Nullable<AbstractMesh>, scene: Scene);
  8491. private _follow;
  8492. /** @hidden */
  8493. _checkInputs(): void;
  8494. /**
  8495. * Returns the class name of the object.
  8496. * It is mostly used internally for serialization purposes.
  8497. */
  8498. getClassName(): string;
  8499. }
  8500. }
  8501. declare module BABYLON {
  8502. /**
  8503. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  8504. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  8505. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8506. */
  8507. class FreeCamera extends TargetCamera {
  8508. /**
  8509. * Define the collision ellipsoid of the camera.
  8510. * This is helpful to simulate a camera body like the player body around the camera
  8511. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  8512. */
  8513. ellipsoid: Vector3;
  8514. /**
  8515. * Define an offset for the position of the ellipsoid around the camera.
  8516. * This can be helpful to determine the center of the body near the gravity center of the body
  8517. * instead of its head.
  8518. */
  8519. ellipsoidOffset: Vector3;
  8520. /**
  8521. * Enable or disable collisions of the camera with the rest of the scene objects.
  8522. */
  8523. checkCollisions: boolean;
  8524. /**
  8525. * Enable or disable gravity on the camera.
  8526. */
  8527. applyGravity: boolean;
  8528. /**
  8529. * Define the input manager associated to the camera.
  8530. */
  8531. inputs: FreeCameraInputsManager;
  8532. /**
  8533. * Gets the input sensibility for a mouse input. (default is 2000.0)
  8534. * Higher values reduce sensitivity.
  8535. */
  8536. /**
  8537. * Sets the input sensibility for a mouse input. (default is 2000.0)
  8538. * Higher values reduce sensitivity.
  8539. */
  8540. angularSensibility: number;
  8541. /**
  8542. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8543. */
  8544. keysUp: number[];
  8545. /**
  8546. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8547. */
  8548. keysDown: number[];
  8549. /**
  8550. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8551. */
  8552. keysLeft: number[];
  8553. /**
  8554. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8555. */
  8556. keysRight: number[];
  8557. /**
  8558. * Event raised when the camera collide with a mesh in the scene.
  8559. */
  8560. onCollide: (collidedMesh: AbstractMesh) => void;
  8561. private _collider;
  8562. private _needMoveForGravity;
  8563. private _oldPosition;
  8564. private _diffPosition;
  8565. private _newPosition;
  8566. /** @hidden */
  8567. _localDirection: Vector3;
  8568. /** @hidden */
  8569. _transformedDirection: Vector3;
  8570. /**
  8571. * Instantiates a Free Camera.
  8572. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  8573. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  8574. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8575. * @param name Define the name of the camera in the scene
  8576. * @param position Define the start position of the camera in the scene
  8577. * @param scene Define the scene the camera belongs to
  8578. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8579. */
  8580. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8581. /**
  8582. * Attached controls to the current camera.
  8583. * @param element Defines the element the controls should be listened from
  8584. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8585. */
  8586. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8587. /**
  8588. * Detach the current controls from the camera.
  8589. * The camera will stop reacting to inputs.
  8590. * @param element Defines the element to stop listening the inputs from
  8591. */
  8592. detachControl(element: HTMLElement): void;
  8593. private _collisionMask;
  8594. /**
  8595. * Define a collision mask to limit the list of object the camera can collide with
  8596. */
  8597. collisionMask: number;
  8598. /** @hidden */
  8599. _collideWithWorld(displacement: Vector3): void;
  8600. private _onCollisionPositionChange;
  8601. /** @hidden */
  8602. _checkInputs(): void;
  8603. /** @hidden */
  8604. _decideIfNeedsToMove(): boolean;
  8605. /** @hidden */
  8606. _updatePosition(): void;
  8607. /**
  8608. * Destroy the camera and release the current resources hold by it.
  8609. */
  8610. dispose(): void;
  8611. /**
  8612. * Gets the current object class name.
  8613. * @return the class name
  8614. */
  8615. getClassName(): string;
  8616. }
  8617. }
  8618. declare module BABYLON {
  8619. /**
  8620. * Default Inputs manager for the FreeCamera.
  8621. * It groups all the default supported inputs for ease of use.
  8622. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8623. */
  8624. class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  8625. /**
  8626. * Instantiates a new FreeCameraInputsManager.
  8627. * @param camera Defines the camera the inputs belong to
  8628. */
  8629. constructor(camera: FreeCamera);
  8630. /**
  8631. * Add keyboard input support to the input manager.
  8632. * @returns the current input manager
  8633. */
  8634. addKeyboard(): FreeCameraInputsManager;
  8635. /**
  8636. * Add mouse input support to the input manager.
  8637. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  8638. * @returns the current input manager
  8639. */
  8640. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  8641. /**
  8642. * Add orientation input support to the input manager.
  8643. * @returns the current input manager
  8644. */
  8645. addDeviceOrientation(): FreeCameraInputsManager;
  8646. /**
  8647. * Add touch input support to the input manager.
  8648. * @returns the current input manager
  8649. */
  8650. addTouch(): FreeCameraInputsManager;
  8651. /**
  8652. * Add virtual joystick input support to the input manager.
  8653. * @returns the current input manager
  8654. */
  8655. addVirtualJoystick(): FreeCameraInputsManager;
  8656. }
  8657. }
  8658. declare module BABYLON {
  8659. /**
  8660. * This represents a FPS type of camera. This is only here for back compat purpose.
  8661. * Please use the UniversalCamera instead as both are identical.
  8662. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8663. */
  8664. class GamepadCamera extends UniversalCamera {
  8665. /**
  8666. * Instantiates a new Gamepad Camera
  8667. * This represents a FPS type of camera. This is only here for back compat purpose.
  8668. * Please use the UniversalCamera instead as both are identical.
  8669. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8670. * @param name Define the name of the camera in the scene
  8671. * @param position Define the start position of the camera in the scene
  8672. * @param scene Define the scene the camera belongs to
  8673. */
  8674. constructor(name: string, position: Vector3, scene: Scene);
  8675. /**
  8676. * Gets the current object class name.
  8677. * @return the class name
  8678. */
  8679. getClassName(): string;
  8680. }
  8681. }
  8682. declare module BABYLON {
  8683. /**
  8684. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8685. * This is the base of the follow, arc rotate cameras and Free camera
  8686. * @see http://doc.babylonjs.com/features/cameras
  8687. */
  8688. class TargetCamera extends Camera {
  8689. private static _RigCamTransformMatrix;
  8690. private static _TargetTransformMatrix;
  8691. private static _TargetFocalPoint;
  8692. /**
  8693. * Define the current direction the camera is moving to
  8694. */
  8695. cameraDirection: Vector3;
  8696. /**
  8697. * Define the current rotation the camera is rotating to
  8698. */
  8699. cameraRotation: Vector2;
  8700. /**
  8701. * When set, the up vector of the camera will be updated by the rotation of the camera
  8702. */
  8703. updateUpVectorFromRotation: boolean;
  8704. private _tmpQuaternion;
  8705. /**
  8706. * Define the current rotation of the camera
  8707. */
  8708. rotation: Vector3;
  8709. /**
  8710. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8711. */
  8712. rotationQuaternion: Quaternion;
  8713. /**
  8714. * Define the current speed of the camera
  8715. */
  8716. speed: number;
  8717. /**
  8718. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8719. * around all axis.
  8720. */
  8721. noRotationConstraint: boolean;
  8722. /**
  8723. * Define the current target of the camera as an object or a position.
  8724. */
  8725. lockedTarget: any;
  8726. /** @hidden */
  8727. _currentTarget: Vector3;
  8728. /** @hidden */
  8729. _initialFocalDistance: number;
  8730. /** @hidden */
  8731. _viewMatrix: Matrix;
  8732. /** @hidden */
  8733. _camMatrix: Matrix;
  8734. /** @hidden */
  8735. _cameraTransformMatrix: Matrix;
  8736. /** @hidden */
  8737. _cameraRotationMatrix: Matrix;
  8738. /** @hidden */
  8739. _referencePoint: Vector3;
  8740. /** @hidden */
  8741. _transformedReferencePoint: Vector3;
  8742. protected _globalCurrentTarget: Vector3;
  8743. protected _globalCurrentUpVector: Vector3;
  8744. /** @hidden */
  8745. _reset: () => void;
  8746. private _defaultUp;
  8747. /**
  8748. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8749. * This is the base of the follow, arc rotate cameras and Free camera
  8750. * @see http://doc.babylonjs.com/features/cameras
  8751. * @param name Defines the name of the camera in the scene
  8752. * @param position Defines the start position of the camera in the scene
  8753. * @param scene Defines the scene the camera belongs to
  8754. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8755. */
  8756. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8757. /**
  8758. * Gets the position in front of the camera at a given distance.
  8759. * @param distance The distance from the camera we want the position to be
  8760. * @returns the position
  8761. */
  8762. getFrontPosition(distance: number): Vector3;
  8763. /** @hidden */
  8764. _getLockedTargetPosition(): Nullable<Vector3>;
  8765. private _storedPosition;
  8766. private _storedRotation;
  8767. private _storedRotationQuaternion;
  8768. /**
  8769. * Store current camera state of the camera (fov, position, rotation, etc..)
  8770. * @returns the camera
  8771. */
  8772. storeState(): Camera;
  8773. /**
  8774. * Restored camera state. You must call storeState() first
  8775. * @returns whether it was successful or not
  8776. * @hidden
  8777. */
  8778. _restoreStateValues(): boolean;
  8779. /** @hidden */
  8780. _initCache(): void;
  8781. /** @hidden */
  8782. _updateCache(ignoreParentClass?: boolean): void;
  8783. /** @hidden */
  8784. _isSynchronizedViewMatrix(): boolean;
  8785. /** @hidden */
  8786. _computeLocalCameraSpeed(): number;
  8787. /** @hidden */
  8788. setTarget(target: Vector3): void;
  8789. /**
  8790. * Return the current target position of the camera. This value is expressed in local space.
  8791. * @returns the target position
  8792. */
  8793. getTarget(): Vector3;
  8794. /** @hidden */
  8795. _decideIfNeedsToMove(): boolean;
  8796. /** @hidden */
  8797. _updatePosition(): void;
  8798. /** @hidden */
  8799. _checkInputs(): void;
  8800. protected _updateCameraRotationMatrix(): void;
  8801. /**
  8802. * 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)
  8803. * @returns the current camera
  8804. */
  8805. private _rotateUpVectorWithCameraRotationMatrix;
  8806. private _cachedRotationZ;
  8807. private _cachedQuaternionRotationZ;
  8808. /** @hidden */
  8809. _getViewMatrix(): Matrix;
  8810. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8811. /**
  8812. * @hidden
  8813. */
  8814. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8815. /**
  8816. * @hidden
  8817. */
  8818. _updateRigCameras(): void;
  8819. private _getRigCamPositionAndTarget;
  8820. /**
  8821. * Gets the current object class name.
  8822. * @return the class name
  8823. */
  8824. getClassName(): string;
  8825. }
  8826. }
  8827. declare module BABYLON {
  8828. /**
  8829. * This represents a FPS type of camera controlled by touch.
  8830. * This is like a universal camera minus the Gamepad controls.
  8831. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8832. */
  8833. class TouchCamera extends FreeCamera {
  8834. /**
  8835. * Defines the touch sensibility for rotation.
  8836. * The higher the faster.
  8837. */
  8838. touchAngularSensibility: number;
  8839. /**
  8840. * Defines the touch sensibility for move.
  8841. * The higher the faster.
  8842. */
  8843. touchMoveSensibility: number;
  8844. /**
  8845. * Instantiates a new touch camera.
  8846. * This represents a FPS type of camera controlled by touch.
  8847. * This is like a universal camera minus the Gamepad controls.
  8848. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8849. * @param name Define the name of the camera in the scene
  8850. * @param position Define the start position of the camera in the scene
  8851. * @param scene Define the scene the camera belongs to
  8852. */
  8853. constructor(name: string, position: Vector3, scene: Scene);
  8854. /**
  8855. * Gets the current object class name.
  8856. * @return the class name
  8857. */
  8858. getClassName(): string;
  8859. /** @hidden */
  8860. _setupInputs(): void;
  8861. }
  8862. }
  8863. declare module BABYLON {
  8864. /**
  8865. * 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,
  8866. * which still works and will still be found in many Playgrounds.
  8867. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8868. */
  8869. class UniversalCamera extends TouchCamera {
  8870. /**
  8871. * Defines the gamepad rotation sensiblity.
  8872. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  8873. */
  8874. gamepadAngularSensibility: number;
  8875. /**
  8876. * Defines the gamepad move sensiblity.
  8877. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  8878. */
  8879. gamepadMoveSensibility: number;
  8880. /**
  8881. * 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,
  8882. * which still works and will still be found in many Playgrounds.
  8883. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8884. * @param name Define the name of the camera in the scene
  8885. * @param position Define the start position of the camera in the scene
  8886. * @param scene Define the scene the camera belongs to
  8887. */
  8888. constructor(name: string, position: Vector3, scene: Scene);
  8889. /**
  8890. * Gets the current object class name.
  8891. * @return the class name
  8892. */
  8893. getClassName(): string;
  8894. }
  8895. }
  8896. declare module BABYLON {
  8897. /**
  8898. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  8899. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  8900. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  8901. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  8902. */
  8903. class VirtualJoysticksCamera extends FreeCamera {
  8904. /**
  8905. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  8906. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  8907. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  8908. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  8909. * @param name Define the name of the camera in the scene
  8910. * @param position Define the start position of the camera in the scene
  8911. * @param scene Define the scene the camera belongs to
  8912. */
  8913. constructor(name: string, position: Vector3, scene: Scene);
  8914. /**
  8915. * Gets the current object class name.
  8916. * @return the class name
  8917. */
  8918. getClassName(): string;
  8919. }
  8920. }
  8921. interface VRDisplay extends EventTarget {
  8922. /**
  8923. * Dictionary of capabilities describing the VRDisplay.
  8924. */
  8925. readonly capabilities: VRDisplayCapabilities;
  8926. /**
  8927. * z-depth defining the far plane of the eye view frustum
  8928. * enables mapping of values in the render target depth
  8929. * attachment to scene coordinates. Initially set to 10000.0.
  8930. */
  8931. depthFar: number;
  8932. /**
  8933. * z-depth defining the near plane of the eye view frustum
  8934. * enables mapping of values in the render target depth
  8935. * attachment to scene coordinates. Initially set to 0.01.
  8936. */
  8937. depthNear: number;
  8938. /**
  8939. * An identifier for this distinct VRDisplay. Used as an
  8940. * association point in the Gamepad API.
  8941. */
  8942. readonly displayId: number;
  8943. /**
  8944. * A display name, a user-readable name identifying it.
  8945. */
  8946. readonly displayName: string;
  8947. readonly isConnected: boolean;
  8948. readonly isPresenting: boolean;
  8949. /**
  8950. * If this VRDisplay supports room-scale experiences, the optional
  8951. * stage attribute contains details on the room-scale parameters.
  8952. */
  8953. readonly stageParameters: VRStageParameters | null;
  8954. /**
  8955. * Passing the value returned by `requestAnimationFrame` to
  8956. * `cancelAnimationFrame` will unregister the callback.
  8957. * @param handle Define the hanle of the request to cancel
  8958. */
  8959. cancelAnimationFrame(handle: number): void;
  8960. /**
  8961. * Stops presenting to the VRDisplay.
  8962. * @returns a promise to know when it stopped
  8963. */
  8964. exitPresent(): Promise<void>;
  8965. /**
  8966. * Return the current VREyeParameters for the given eye.
  8967. * @param whichEye Define the eye we want the parameter for
  8968. * @returns the eye parameters
  8969. */
  8970. getEyeParameters(whichEye: string): VREyeParameters;
  8971. /**
  8972. * Populates the passed VRFrameData with the information required to render
  8973. * the current frame.
  8974. * @param frameData Define the data structure to populate
  8975. * @returns true if ok otherwise false
  8976. */
  8977. getFrameData(frameData: VRFrameData): boolean;
  8978. /**
  8979. * Get the layers currently being presented.
  8980. * @returns the list of VR layers
  8981. */
  8982. getLayers(): VRLayer[];
  8983. /**
  8984. * Return a VRPose containing the future predicted pose of the VRDisplay
  8985. * when the current frame will be presented. The value returned will not
  8986. * change until JavaScript has returned control to the browser.
  8987. *
  8988. * The VRPose will contain the position, orientation, velocity,
  8989. * and acceleration of each of these properties.
  8990. * @returns the pose object
  8991. */
  8992. getPose(): VRPose;
  8993. /**
  8994. * Return the current instantaneous pose of the VRDisplay, with no
  8995. * prediction applied.
  8996. * @returns the current instantaneous pose
  8997. */
  8998. getImmediatePose(): VRPose;
  8999. /**
  9000. * The callback passed to `requestAnimationFrame` will be called
  9001. * any time a new frame should be rendered. When the VRDisplay is
  9002. * presenting the callback will be called at the native refresh
  9003. * rate of the HMD. When not presenting this function acts
  9004. * identically to how window.requestAnimationFrame acts. Content should
  9005. * make no assumptions of frame rate or vsync behavior as the HMD runs
  9006. * asynchronously from other displays and at differing refresh rates.
  9007. * @param callback Define the eaction to run next frame
  9008. * @returns the request handle it
  9009. */
  9010. requestAnimationFrame(callback: FrameRequestCallback): number;
  9011. /**
  9012. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  9013. * Repeat calls while already presenting will update the VRLayers being displayed.
  9014. * @param layers Define the list of layer to present
  9015. * @returns a promise to know when the request has been fulfilled
  9016. */
  9017. requestPresent(layers: VRLayer[]): Promise<void>;
  9018. /**
  9019. * Reset the pose for this display, treating its current position and
  9020. * orientation as the "origin/zero" values. VRPose.position,
  9021. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  9022. * updated when calling resetPose(). This should be called in only
  9023. * sitting-space experiences.
  9024. */
  9025. resetPose(): void;
  9026. /**
  9027. * The VRLayer provided to the VRDisplay will be captured and presented
  9028. * in the HMD. Calling this function has the same effect on the source
  9029. * canvas as any other operation that uses its source image, and canvases
  9030. * created without preserveDrawingBuffer set to true will be cleared.
  9031. * @param pose Define the pose to submit
  9032. */
  9033. submitFrame(pose?: VRPose): void;
  9034. }
  9035. declare var VRDisplay: {
  9036. prototype: VRDisplay;
  9037. new (): VRDisplay;
  9038. };
  9039. interface VRLayer {
  9040. leftBounds?: number[] | Float32Array | null;
  9041. rightBounds?: number[] | Float32Array | null;
  9042. source?: HTMLCanvasElement | null;
  9043. }
  9044. interface VRDisplayCapabilities {
  9045. readonly canPresent: boolean;
  9046. readonly hasExternalDisplay: boolean;
  9047. readonly hasOrientation: boolean;
  9048. readonly hasPosition: boolean;
  9049. readonly maxLayers: number;
  9050. }
  9051. interface VREyeParameters {
  9052. /** @deprecated */
  9053. readonly fieldOfView: VRFieldOfView;
  9054. readonly offset: Float32Array;
  9055. readonly renderHeight: number;
  9056. readonly renderWidth: number;
  9057. }
  9058. interface VRFieldOfView {
  9059. readonly downDegrees: number;
  9060. readonly leftDegrees: number;
  9061. readonly rightDegrees: number;
  9062. readonly upDegrees: number;
  9063. }
  9064. interface VRFrameData {
  9065. readonly leftProjectionMatrix: Float32Array;
  9066. readonly leftViewMatrix: Float32Array;
  9067. readonly pose: VRPose;
  9068. readonly rightProjectionMatrix: Float32Array;
  9069. readonly rightViewMatrix: Float32Array;
  9070. readonly timestamp: number;
  9071. }
  9072. interface VRPose {
  9073. readonly angularAcceleration: Float32Array | null;
  9074. readonly angularVelocity: Float32Array | null;
  9075. readonly linearAcceleration: Float32Array | null;
  9076. readonly linearVelocity: Float32Array | null;
  9077. readonly orientation: Float32Array | null;
  9078. readonly position: Float32Array | null;
  9079. readonly timestamp: number;
  9080. }
  9081. interface VRStageParameters {
  9082. sittingToStandingTransform?: Float32Array;
  9083. sizeX?: number;
  9084. sizeY?: number;
  9085. }
  9086. interface Navigator {
  9087. getVRDisplays(): Promise<VRDisplay[]>;
  9088. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  9089. }
  9090. interface Window {
  9091. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  9092. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  9093. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  9094. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  9095. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  9096. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  9097. }
  9098. interface Gamepad {
  9099. readonly displayId: number;
  9100. }
  9101. declare module BABYLON {
  9102. /**
  9103. * Class used to store bounding box information
  9104. */
  9105. class BoundingBox implements ICullable {
  9106. /**
  9107. * Gets the 8 vectors representing the bounding box in local space
  9108. */
  9109. readonly vectors: Vector3[];
  9110. /**
  9111. * Gets the center of the bounding box in local space
  9112. */
  9113. readonly center: Vector3;
  9114. /**
  9115. * Gets the center of the bounding box in world space
  9116. */
  9117. readonly centerWorld: Vector3;
  9118. /**
  9119. * Gets the extend size in local space
  9120. */
  9121. readonly extendSize: Vector3;
  9122. /**
  9123. * Gets the extend size in world space
  9124. */
  9125. readonly extendSizeWorld: Vector3;
  9126. /**
  9127. * Gets the OBB (object bounding box) directions
  9128. */
  9129. readonly directions: Vector3[];
  9130. /**
  9131. * Gets the 8 vectors representing the bounding box in world space
  9132. */
  9133. readonly vectorsWorld: Vector3[];
  9134. /**
  9135. * Gets the minimum vector in world space
  9136. */
  9137. readonly minimumWorld: Vector3;
  9138. /**
  9139. * Gets the maximum vector in world space
  9140. */
  9141. readonly maximumWorld: Vector3;
  9142. /**
  9143. * Gets the minimum vector in local space
  9144. */
  9145. readonly minimum: Vector3;
  9146. /**
  9147. * Gets the maximum vector in local space
  9148. */
  9149. readonly maximum: Vector3;
  9150. private _worldMatrix;
  9151. private static readonly TmpVector3;
  9152. /**
  9153. * @hidden
  9154. */
  9155. _tag: number;
  9156. /**
  9157. * Creates a new bounding box
  9158. * @param min defines the minimum vector (in local space)
  9159. * @param max defines the maximum vector (in local space)
  9160. * @param worldMatrix defines the new world matrix
  9161. */
  9162. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  9163. /**
  9164. * Recreates the entire bounding box from scratch as if we call the constructor in place
  9165. * @param min defines the new minimum vector (in local space)
  9166. * @param max defines the new maximum vector (in local space)
  9167. * @param worldMatrix defines the new world matrix
  9168. */
  9169. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  9170. /**
  9171. * Scale the current bounding box by applying a scale factor
  9172. * @param factor defines the scale factor to apply
  9173. * @returns the current bounding box
  9174. */
  9175. scale(factor: number): BoundingBox;
  9176. /**
  9177. * Gets the world matrix of the bounding box
  9178. * @returns a matrix
  9179. */
  9180. getWorldMatrix(): DeepImmutable<Matrix>;
  9181. /** @hidden */
  9182. _update(world: DeepImmutable<Matrix>): void;
  9183. /**
  9184. * Tests if the bounding box is intersecting the frustum planes
  9185. * @param frustumPlanes defines the frustum planes to test
  9186. * @returns true if there is an intersection
  9187. */
  9188. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  9189. /**
  9190. * Tests if the bounding box is entirely inside the frustum planes
  9191. * @param frustumPlanes defines the frustum planes to test
  9192. * @returns true if there is an inclusion
  9193. */
  9194. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  9195. /**
  9196. * Tests if a point is inside the bounding box
  9197. * @param point defines the point to test
  9198. * @returns true if the point is inside the bounding box
  9199. */
  9200. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  9201. /**
  9202. * Tests if the bounding box intersects with a bounding sphere
  9203. * @param sphere defines the sphere to test
  9204. * @returns true if there is an intersection
  9205. */
  9206. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  9207. /**
  9208. * Tests if the bounding box intersects with a box defined by a min and max vectors
  9209. * @param min defines the min vector to use
  9210. * @param max defines the max vector to use
  9211. * @returns true if there is an intersection
  9212. */
  9213. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  9214. /**
  9215. * Tests if two bounding boxes are intersections
  9216. * @param box0 defines the first box to test
  9217. * @param box1 defines the second box to test
  9218. * @returns true if there is an intersection
  9219. */
  9220. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  9221. /**
  9222. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  9223. * @param minPoint defines the minimum vector of the bounding box
  9224. * @param maxPoint defines the maximum vector of the bounding box
  9225. * @param sphereCenter defines the sphere center
  9226. * @param sphereRadius defines the sphere radius
  9227. * @returns true if there is an intersection
  9228. */
  9229. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  9230. /**
  9231. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  9232. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  9233. * @param frustumPlanes defines the frustum planes to test
  9234. * @return true if there is an inclusion
  9235. */
  9236. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  9237. /**
  9238. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  9239. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  9240. * @param frustumPlanes defines the frustum planes to test
  9241. * @return true if there is an intersection
  9242. */
  9243. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  9244. }
  9245. }
  9246. declare module BABYLON {
  9247. /**
  9248. * Interface for cullable objects
  9249. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  9250. */
  9251. interface ICullable {
  9252. /**
  9253. * Checks if the object or part of the object is in the frustum
  9254. * @param frustumPlanes Camera near/planes
  9255. * @returns true if the object is in frustum otherwise false
  9256. */
  9257. isInFrustum(frustumPlanes: Plane[]): boolean;
  9258. /**
  9259. * Checks if a cullable object (mesh...) is in the camera frustum
  9260. * Unlike isInFrustum this cheks the full bounding box
  9261. * @param frustumPlanes Camera near/planes
  9262. * @returns true if the object is in frustum otherwise false
  9263. */
  9264. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  9265. }
  9266. /**
  9267. * Info for a bounding data of a mesh
  9268. */
  9269. class BoundingInfo implements ICullable {
  9270. /**
  9271. * Bounding box for the mesh
  9272. */
  9273. readonly boundingBox: BoundingBox;
  9274. /**
  9275. * Bounding sphere for the mesh
  9276. */
  9277. readonly boundingSphere: BoundingSphere;
  9278. private _isLocked;
  9279. private static readonly TmpVector3;
  9280. /**
  9281. * Constructs bounding info
  9282. * @param minimum min vector of the bounding box/sphere
  9283. * @param maximum max vector of the bounding box/sphere
  9284. * @param worldMatrix defines the new world matrix
  9285. */
  9286. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  9287. /**
  9288. * Recreates the entire bounding info from scratch as if we call the constructor in place
  9289. * @param min defines the new minimum vector (in local space)
  9290. * @param max defines the new maximum vector (in local space)
  9291. * @param worldMatrix defines the new world matrix
  9292. */
  9293. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  9294. /**
  9295. * min vector of the bounding box/sphere
  9296. */
  9297. readonly minimum: Vector3;
  9298. /**
  9299. * max vector of the bounding box/sphere
  9300. */
  9301. readonly maximum: Vector3;
  9302. /**
  9303. * If the info is locked and won't be updated to avoid perf overhead
  9304. */
  9305. isLocked: boolean;
  9306. /**
  9307. * Updates the bounding sphere and box
  9308. * @param world world matrix to be used to update
  9309. */
  9310. update(world: DeepImmutable<Matrix>): void;
  9311. /**
  9312. * Recreate the bounding info to be centered around a specific point given a specific extend.
  9313. * @param center New center of the bounding info
  9314. * @param extend New extend of the bounding info
  9315. * @returns the current bounding info
  9316. */
  9317. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  9318. /**
  9319. * Scale the current bounding info by applying a scale factor
  9320. * @param factor defines the scale factor to apply
  9321. * @returns the current bounding info
  9322. */
  9323. scale(factor: number): BoundingInfo;
  9324. /**
  9325. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  9326. * @param frustumPlanes defines the frustum to test
  9327. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  9328. * @returns true if the bounding info is in the frustum planes
  9329. */
  9330. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  9331. /**
  9332. * Gets the world distance between the min and max points of the bounding box
  9333. */
  9334. readonly diagonalLength: number;
  9335. /**
  9336. * Checks if a cullable object (mesh...) is in the camera frustum
  9337. * Unlike isInFrustum this cheks the full bounding box
  9338. * @param frustumPlanes Camera near/planes
  9339. * @returns true if the object is in frustum otherwise false
  9340. */
  9341. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  9342. /** @hidden */
  9343. _checkCollision(collider: Collider): boolean;
  9344. /**
  9345. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  9346. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  9347. * @param point the point to check intersection with
  9348. * @returns if the point intersects
  9349. */
  9350. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  9351. /**
  9352. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  9353. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  9354. * @param boundingInfo the bounding info to check intersection with
  9355. * @param precise if the intersection should be done using OBB
  9356. * @returns if the bounding info intersects
  9357. */
  9358. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  9359. }
  9360. }
  9361. declare module BABYLON {
  9362. /**
  9363. * Class used to store bounding sphere information
  9364. */
  9365. class BoundingSphere {
  9366. /**
  9367. * Gets the center of the bounding sphere in local space
  9368. */
  9369. readonly center: Vector3;
  9370. /**
  9371. * Radius of the bounding sphere in local space
  9372. */
  9373. radius: number;
  9374. /**
  9375. * Gets the center of the bounding sphere in world space
  9376. */
  9377. readonly centerWorld: Vector3;
  9378. /**
  9379. * Radius of the bounding sphere in world space
  9380. */
  9381. radiusWorld: number;
  9382. /**
  9383. * Gets the minimum vector in local space
  9384. */
  9385. readonly minimum: Vector3;
  9386. /**
  9387. * Gets the maximum vector in local space
  9388. */
  9389. readonly maximum: Vector3;
  9390. private _worldMatrix;
  9391. private static readonly TmpVector3;
  9392. /**
  9393. * Creates a new bounding sphere
  9394. * @param min defines the minimum vector (in local space)
  9395. * @param max defines the maximum vector (in local space)
  9396. * @param worldMatrix defines the new world matrix
  9397. */
  9398. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  9399. /**
  9400. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  9401. * @param min defines the new minimum vector (in local space)
  9402. * @param max defines the new maximum vector (in local space)
  9403. * @param worldMatrix defines the new world matrix
  9404. */
  9405. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  9406. /**
  9407. * Scale the current bounding sphere by applying a scale factor
  9408. * @param factor defines the scale factor to apply
  9409. * @returns the current bounding box
  9410. */
  9411. scale(factor: number): BoundingSphere;
  9412. /**
  9413. * Gets the world matrix of the bounding box
  9414. * @returns a matrix
  9415. */
  9416. getWorldMatrix(): DeepImmutable<Matrix>;
  9417. /** @hidden */
  9418. _update(worldMatrix: DeepImmutable<Matrix>): void;
  9419. /**
  9420. * Tests if the bounding sphere is intersecting the frustum planes
  9421. * @param frustumPlanes defines the frustum planes to test
  9422. * @returns true if there is an intersection
  9423. */
  9424. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  9425. /**
  9426. * Tests if the bounding sphere center is in between the frustum planes.
  9427. * Used for optimistic fast inclusion.
  9428. * @param frustumPlanes defines the frustum planes to test
  9429. * @returns true if the sphere center is in between the frustum planes
  9430. */
  9431. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  9432. /**
  9433. * Tests if a point is inside the bounding sphere
  9434. * @param point defines the point to test
  9435. * @returns true if the point is inside the bounding sphere
  9436. */
  9437. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  9438. /**
  9439. * Checks if two sphere intersct
  9440. * @param sphere0 sphere 0
  9441. * @param sphere1 sphere 1
  9442. * @returns true if the speres intersect
  9443. */
  9444. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  9445. }
  9446. }
  9447. declare module BABYLON {
  9448. /**
  9449. * Class representing a ray with position and direction
  9450. */
  9451. class Ray {
  9452. /** origin point */
  9453. origin: Vector3;
  9454. /** direction */
  9455. direction: Vector3;
  9456. /** length of the ray */
  9457. length: number;
  9458. private static readonly TmpVector3;
  9459. private _tmpRay;
  9460. /**
  9461. * Creates a new ray
  9462. * @param origin origin point
  9463. * @param direction direction
  9464. * @param length length of the ray
  9465. */
  9466. constructor(
  9467. /** origin point */
  9468. origin: Vector3,
  9469. /** direction */
  9470. direction: Vector3,
  9471. /** length of the ray */
  9472. length?: number);
  9473. /**
  9474. * Checks if the ray intersects a box
  9475. * @param minimum bound of the box
  9476. * @param maximum bound of the box
  9477. * @param intersectionTreshold extra extend to be added to the box in all direction
  9478. * @returns if the box was hit
  9479. */
  9480. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  9481. /**
  9482. * Checks if the ray intersects a box
  9483. * @param box the bounding box to check
  9484. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  9485. * @returns if the box was hit
  9486. */
  9487. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  9488. /**
  9489. * If the ray hits a sphere
  9490. * @param sphere the bounding sphere to check
  9491. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  9492. * @returns true if it hits the sphere
  9493. */
  9494. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  9495. /**
  9496. * If the ray hits a triange
  9497. * @param vertex0 triangle vertex
  9498. * @param vertex1 triangle vertex
  9499. * @param vertex2 triangle vertex
  9500. * @returns intersection information if hit
  9501. */
  9502. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  9503. /**
  9504. * Checks if ray intersects a plane
  9505. * @param plane the plane to check
  9506. * @returns the distance away it was hit
  9507. */
  9508. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  9509. /**
  9510. * Checks if ray intersects a mesh
  9511. * @param mesh the mesh to check
  9512. * @param fastCheck if only the bounding box should checked
  9513. * @returns picking info of the intersecton
  9514. */
  9515. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  9516. /**
  9517. * Checks if ray intersects a mesh
  9518. * @param meshes the meshes to check
  9519. * @param fastCheck if only the bounding box should checked
  9520. * @param results array to store result in
  9521. * @returns Array of picking infos
  9522. */
  9523. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  9524. private _comparePickingInfo;
  9525. private static smallnum;
  9526. private static rayl;
  9527. /**
  9528. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  9529. * @param sega the first point of the segment to test the intersection against
  9530. * @param segb the second point of the segment to test the intersection against
  9531. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  9532. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  9533. */
  9534. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  9535. /**
  9536. * Update the ray from viewport position
  9537. * @param x position
  9538. * @param y y position
  9539. * @param viewportWidth viewport width
  9540. * @param viewportHeight viewport height
  9541. * @param world world matrix
  9542. * @param view view matrix
  9543. * @param projection projection matrix
  9544. * @returns this ray updated
  9545. */
  9546. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9547. /**
  9548. * Creates a ray with origin and direction of 0,0,0
  9549. * @returns the new ray
  9550. */
  9551. static Zero(): Ray;
  9552. /**
  9553. * Creates a new ray from screen space and viewport
  9554. * @param x position
  9555. * @param y y position
  9556. * @param viewportWidth viewport width
  9557. * @param viewportHeight viewport height
  9558. * @param world world matrix
  9559. * @param view view matrix
  9560. * @param projection projection matrix
  9561. * @returns new ray
  9562. */
  9563. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9564. /**
  9565. * Function will create a new transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be
  9566. * transformed to the given world matrix.
  9567. * @param origin The origin point
  9568. * @param end The end point
  9569. * @param world a matrix to transform the ray to. Default is the identity matrix.
  9570. * @returns the new ray
  9571. */
  9572. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  9573. /**
  9574. * Transforms a ray by a matrix
  9575. * @param ray ray to transform
  9576. * @param matrix matrix to apply
  9577. * @returns the resulting new ray
  9578. */
  9579. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  9580. /**
  9581. * Transforms a ray by a matrix
  9582. * @param ray ray to transform
  9583. * @param matrix matrix to apply
  9584. * @param result ray to store result in
  9585. */
  9586. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  9587. }
  9588. }
  9589. /**
  9590. * Module Debug contains the (visual) components to debug a scene correctly
  9591. */
  9592. declare module BABYLON.Debug {
  9593. /**
  9594. * The Axes viewer will show 3 axes in a specific point in space
  9595. */
  9596. class AxesViewer {
  9597. private _xAxis;
  9598. private _yAxis;
  9599. private _zAxis;
  9600. private _scaleLinesFactor;
  9601. private _instanced;
  9602. /**
  9603. * Gets the hosting scene
  9604. */
  9605. scene: Scene;
  9606. /**
  9607. * Gets or sets a number used to scale line length
  9608. */
  9609. scaleLines: number;
  9610. /** Gets the node hierarchy used to render x-axis */
  9611. readonly xAxis: TransformNode;
  9612. /** Gets the node hierarchy used to render y-axis */
  9613. readonly yAxis: TransformNode;
  9614. /** Gets the node hierarchy used to render z-axis */
  9615. readonly zAxis: TransformNode;
  9616. /**
  9617. * Creates a new AxesViewer
  9618. * @param scene defines the hosting scene
  9619. * @param scaleLines defines a number used to scale line length (1 by default)
  9620. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  9621. * @param xAxis defines the node hierarchy used to render the x-axis
  9622. * @param yAxis defines the node hierarchy used to render the y-axis
  9623. * @param zAxis defines the node hierarchy used to render the z-axis
  9624. */
  9625. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  9626. /**
  9627. * Force the viewer to update
  9628. * @param position defines the position of the viewer
  9629. * @param xaxis defines the x axis of the viewer
  9630. * @param yaxis defines the y axis of the viewer
  9631. * @param zaxis defines the z axis of the viewer
  9632. */
  9633. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  9634. /**
  9635. * Creates an instance of this axes viewer.
  9636. * @returns a new axes viewer with instanced meshes
  9637. */
  9638. createInstance(): AxesViewer;
  9639. /** Releases resources */
  9640. dispose(): void;
  9641. private static _SetRenderingGroupId;
  9642. }
  9643. }
  9644. declare module BABYLON.Debug {
  9645. /**
  9646. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  9647. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  9648. */
  9649. class BoneAxesViewer extends AxesViewer {
  9650. /**
  9651. * Gets or sets the target mesh where to display the axes viewer
  9652. */
  9653. mesh: Nullable<Mesh>;
  9654. /**
  9655. * Gets or sets the target bone where to display the axes viewer
  9656. */
  9657. bone: Nullable<Bone>;
  9658. /** Gets current position */
  9659. pos: Vector3;
  9660. /** Gets direction of X axis */
  9661. xaxis: Vector3;
  9662. /** Gets direction of Y axis */
  9663. yaxis: Vector3;
  9664. /** Gets direction of Z axis */
  9665. zaxis: Vector3;
  9666. /**
  9667. * Creates a new BoneAxesViewer
  9668. * @param scene defines the hosting scene
  9669. * @param bone defines the target bone
  9670. * @param mesh defines the target mesh
  9671. * @param scaleLines defines a scaling factor for line length (1 by default)
  9672. */
  9673. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  9674. /**
  9675. * Force the viewer to update
  9676. */
  9677. update(): void;
  9678. /** Releases resources */
  9679. dispose(): void;
  9680. }
  9681. }
  9682. declare module BABYLON {
  9683. /**
  9684. * Interface used to define scene explorer extensibility option
  9685. */
  9686. interface IExplorerExtensibilityOption {
  9687. /**
  9688. * Define the option label
  9689. */
  9690. label: string;
  9691. /**
  9692. * Defines the action to execute on click
  9693. */
  9694. action: (entity: any) => void;
  9695. }
  9696. /**
  9697. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  9698. */
  9699. interface IExplorerExtensibilityGroup {
  9700. /**
  9701. * Defines a predicate to test if a given type mut be extended
  9702. */
  9703. predicate: (entity: any) => boolean;
  9704. /**
  9705. * Gets the list of options added to a type
  9706. */
  9707. entries: IExplorerExtensibilityOption[];
  9708. }
  9709. /**
  9710. * Interface used to define the options to use to create the Inspector
  9711. */
  9712. interface IInspectorOptions {
  9713. /**
  9714. * Display in overlay mode (default: false)
  9715. */
  9716. overlay?: boolean;
  9717. /**
  9718. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  9719. */
  9720. globalRoot?: HTMLElement;
  9721. /**
  9722. * Display the Scene explorer
  9723. */
  9724. showExplorer?: boolean;
  9725. /**
  9726. * Display the property inspector
  9727. */
  9728. showInspector?: boolean;
  9729. /**
  9730. * Display in embed mode (both panes on the right)
  9731. */
  9732. embedMode?: boolean;
  9733. /**
  9734. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  9735. */
  9736. handleResize?: boolean;
  9737. /**
  9738. * Allow the panes to popup (default: true)
  9739. */
  9740. enablePopup?: boolean;
  9741. /**
  9742. * Allow the panes to be closed by users (default: true)
  9743. */
  9744. enableClose?: boolean;
  9745. /**
  9746. * Optional list of extensibility entries
  9747. */
  9748. explorerExtensibility?: IExplorerExtensibilityGroup[];
  9749. }
  9750. interface Scene {
  9751. /**
  9752. * @hidden
  9753. * Backing field
  9754. */
  9755. _debugLayer: DebugLayer;
  9756. /**
  9757. * Gets the debug layer (aka Inspector) associated with the scene
  9758. * @see http://doc.babylonjs.com/features/playground_debuglayer
  9759. */
  9760. debugLayer: DebugLayer;
  9761. }
  9762. /**
  9763. * The debug layer (aka Inspector) is the go to tool in order to better understand
  9764. * what is happening in your scene
  9765. * @see http://doc.babylonjs.com/features/playground_debuglayer
  9766. */
  9767. class DebugLayer {
  9768. /**
  9769. * Define the url to get the inspector script from.
  9770. * By default it uses the babylonjs CDN.
  9771. * @ignoreNaming
  9772. */
  9773. static InspectorURL: string;
  9774. private _scene;
  9775. private BJSINSPECTOR;
  9776. /**
  9777. * Observable triggered when a property is changed through the inspector.
  9778. */
  9779. onPropertyChangedObservable: Observable<{
  9780. object: any;
  9781. property: string;
  9782. value: any;
  9783. initialValue: any;
  9784. }>;
  9785. /**
  9786. * Instantiates a new debug layer.
  9787. * The debug layer (aka Inspector) is the go to tool in order to better understand
  9788. * what is happening in your scene
  9789. * @see http://doc.babylonjs.com/features/playground_debuglayer
  9790. * @param scene Defines the scene to inspect
  9791. */
  9792. constructor(scene: Scene);
  9793. /** Creates the inspector window. */
  9794. private _createInspector;
  9795. /** Get the inspector from bundle or global */
  9796. private _getGlobalInspector;
  9797. /**
  9798. * Get if the inspector is visible or not.
  9799. * @returns true if visible otherwise, false
  9800. */
  9801. isVisible(): boolean;
  9802. /**
  9803. * Hide the inspector and close its window.
  9804. */
  9805. hide(): void;
  9806. /**
  9807. * Launch the debugLayer.
  9808. * @param config Define the configuration of the inspector
  9809. */
  9810. show(config?: IInspectorOptions): void;
  9811. }
  9812. }
  9813. declare module BABYLON.Debug {
  9814. /**
  9815. * Used to show the physics impostor around the specific mesh
  9816. */
  9817. class PhysicsViewer {
  9818. /** @hidden */
  9819. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  9820. /** @hidden */
  9821. protected _meshes: Array<Nullable<AbstractMesh>>;
  9822. /** @hidden */
  9823. protected _scene: Nullable<Scene>;
  9824. /** @hidden */
  9825. protected _numMeshes: number;
  9826. /** @hidden */
  9827. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  9828. private _renderFunction;
  9829. private _utilityLayer;
  9830. private _debugBoxMesh;
  9831. private _debugSphereMesh;
  9832. private _debugMaterial;
  9833. /**
  9834. * Creates a new PhysicsViewer
  9835. * @param scene defines the hosting scene
  9836. */
  9837. constructor(scene: Scene);
  9838. /** @hidden */
  9839. protected _updateDebugMeshes(): void;
  9840. /**
  9841. * Renders a specified physic impostor
  9842. * @param impostor defines the impostor to render
  9843. * @returns the new debug mesh used to render the impostor
  9844. */
  9845. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  9846. /**
  9847. * Hides a specified physic impostor
  9848. * @param impostor defines the impostor to hide
  9849. */
  9850. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  9851. private _getDebugMaterial;
  9852. private _getDebugBoxMesh;
  9853. private _getDebugSphereMesh;
  9854. private _getDebugMesh;
  9855. /** Releases all resources */
  9856. dispose(): void;
  9857. }
  9858. }
  9859. declare module BABYLON {
  9860. /**
  9861. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  9862. * in order to better appreciate the issue one might have.
  9863. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  9864. */
  9865. class RayHelper {
  9866. /**
  9867. * Defines the ray we are currently tryin to visualize.
  9868. */
  9869. ray: Nullable<Ray>;
  9870. private _renderPoints;
  9871. private _renderLine;
  9872. private _renderFunction;
  9873. private _scene;
  9874. private _updateToMeshFunction;
  9875. private _attachedToMesh;
  9876. private _meshSpaceDirection;
  9877. private _meshSpaceOrigin;
  9878. /**
  9879. * Helper function to create a colored helper in a scene in one line.
  9880. * @param ray Defines the ray we are currently tryin to visualize
  9881. * @param scene Defines the scene the ray is used in
  9882. * @param color Defines the color we want to see the ray in
  9883. * @returns The newly created ray helper.
  9884. */
  9885. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  9886. /**
  9887. * Instantiate a new ray helper.
  9888. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  9889. * in order to better appreciate the issue one might have.
  9890. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  9891. * @param ray Defines the ray we are currently tryin to visualize
  9892. */
  9893. constructor(ray: Ray);
  9894. /**
  9895. * Shows the ray we are willing to debug.
  9896. * @param scene Defines the scene the ray needs to be rendered in
  9897. * @param color Defines the color the ray needs to be rendered in
  9898. */
  9899. show(scene: Scene, color?: Color3): void;
  9900. /**
  9901. * Hides the ray we are debugging.
  9902. */
  9903. hide(): void;
  9904. private _render;
  9905. /**
  9906. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  9907. * @param mesh Defines the mesh we want the helper attached to
  9908. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  9909. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  9910. * @param length Defines the length of the ray
  9911. */
  9912. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  9913. /**
  9914. * Detach the ray helper from the mesh it has previously been attached to.
  9915. */
  9916. detachFromMesh(): void;
  9917. private _updateToMesh;
  9918. /**
  9919. * Dispose the helper and release its associated resources.
  9920. */
  9921. dispose(): void;
  9922. }
  9923. }
  9924. declare module BABYLON.Debug {
  9925. /**
  9926. * Class used to render a debug view of a given skeleton
  9927. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  9928. */
  9929. class SkeletonViewer {
  9930. /** defines the skeleton to render */
  9931. skeleton: Skeleton;
  9932. /** defines the mesh attached to the skeleton */
  9933. mesh: AbstractMesh;
  9934. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  9935. autoUpdateBonesMatrices: boolean;
  9936. /** defines the rendering group id to use with the viewer */
  9937. renderingGroupId: number;
  9938. /** Gets or sets the color used to render the skeleton */
  9939. color: Color3;
  9940. private _scene;
  9941. private _debugLines;
  9942. private _debugMesh;
  9943. private _isEnabled;
  9944. private _renderFunction;
  9945. private _utilityLayer;
  9946. /**
  9947. * Returns the mesh used to render the bones
  9948. */
  9949. readonly debugMesh: Nullable<LinesMesh>;
  9950. /**
  9951. * Creates a new SkeletonViewer
  9952. * @param skeleton defines the skeleton to render
  9953. * @param mesh defines the mesh attached to the skeleton
  9954. * @param scene defines the hosting scene
  9955. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  9956. * @param renderingGroupId defines the rendering group id to use with the viewer
  9957. */
  9958. constructor(
  9959. /** defines the skeleton to render */
  9960. skeleton: Skeleton,
  9961. /** defines the mesh attached to the skeleton */
  9962. mesh: AbstractMesh, scene: Scene,
  9963. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  9964. autoUpdateBonesMatrices?: boolean,
  9965. /** defines the rendering group id to use with the viewer */
  9966. renderingGroupId?: number);
  9967. /** Gets or sets a boolean indicating if the viewer is enabled */
  9968. isEnabled: boolean;
  9969. private _getBonePosition;
  9970. private _getLinesForBonesWithLength;
  9971. private _getLinesForBonesNoLength;
  9972. /** Update the viewer to sync with current skeleton state */
  9973. update(): void;
  9974. /** Release associated resources */
  9975. dispose(): void;
  9976. }
  9977. }
  9978. declare module BABYLON {
  9979. /**
  9980. * Interface for attribute information associated with buffer instanciation
  9981. */
  9982. class InstancingAttributeInfo {
  9983. /**
  9984. * Index/offset of the attribute in the vertex shader
  9985. */
  9986. index: number;
  9987. /**
  9988. * size of the attribute, 1, 2, 3 or 4
  9989. */
  9990. attributeSize: number;
  9991. /**
  9992. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  9993. * default is FLOAT
  9994. */
  9995. attribyteType: number;
  9996. /**
  9997. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  9998. */
  9999. normalized: boolean;
  10000. /**
  10001. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  10002. */
  10003. offset: number;
  10004. /**
  10005. * Name of the GLSL attribute, for debugging purpose only
  10006. */
  10007. attributeName: string;
  10008. }
  10009. /**
  10010. * Define options used to create a render target texture
  10011. */
  10012. class RenderTargetCreationOptions {
  10013. /**
  10014. * Specifies is mipmaps must be generated
  10015. */
  10016. generateMipMaps?: boolean;
  10017. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  10018. generateDepthBuffer?: boolean;
  10019. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  10020. generateStencilBuffer?: boolean;
  10021. /** Defines texture type (int by default) */
  10022. type?: number;
  10023. /** Defines sampling mode (trilinear by default) */
  10024. samplingMode?: number;
  10025. /** Defines format (RGBA by default) */
  10026. format?: number;
  10027. }
  10028. /**
  10029. * Define options used to create a depth texture
  10030. */
  10031. class DepthTextureCreationOptions {
  10032. /** Specifies whether or not a stencil should be allocated in the texture */
  10033. generateStencil?: boolean;
  10034. /** Specifies whether or not bilinear filtering is enable on the texture */
  10035. bilinearFiltering?: boolean;
  10036. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  10037. comparisonFunction?: number;
  10038. /** Specifies if the created texture is a cube texture */
  10039. isCube?: boolean;
  10040. }
  10041. /**
  10042. * Class used to describe the capabilities of the engine relatively to the current browser
  10043. */
  10044. class EngineCapabilities {
  10045. /** Maximum textures units per fragment shader */
  10046. maxTexturesImageUnits: number;
  10047. /** Maximum texture units per vertex shader */
  10048. maxVertexTextureImageUnits: number;
  10049. /** Maximum textures units in the entire pipeline */
  10050. maxCombinedTexturesImageUnits: number;
  10051. /** Maximum texture size */
  10052. maxTextureSize: number;
  10053. /** Maximum cube texture size */
  10054. maxCubemapTextureSize: number;
  10055. /** Maximum render texture size */
  10056. maxRenderTextureSize: number;
  10057. /** Maximum number of vertex attributes */
  10058. maxVertexAttribs: number;
  10059. /** Maximum number of varyings */
  10060. maxVaryingVectors: number;
  10061. /** Maximum number of uniforms per vertex shader */
  10062. maxVertexUniformVectors: number;
  10063. /** Maximum number of uniforms per fragment shader */
  10064. maxFragmentUniformVectors: number;
  10065. /** Defines if standard derivates (dx/dy) are supported */
  10066. standardDerivatives: boolean;
  10067. /** Defines if s3tc texture compression is supported */
  10068. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  10069. /** Defines if pvrtc texture compression is supported */
  10070. pvrtc: any;
  10071. /** Defines if etc1 texture compression is supported */
  10072. etc1: any;
  10073. /** Defines if etc2 texture compression is supported */
  10074. etc2: any;
  10075. /** Defines if astc texture compression is supported */
  10076. astc: any;
  10077. /** Defines if float textures are supported */
  10078. textureFloat: boolean;
  10079. /** Defines if vertex array objects are supported */
  10080. vertexArrayObject: boolean;
  10081. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  10082. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  10083. /** Gets the maximum level of anisotropy supported */
  10084. maxAnisotropy: number;
  10085. /** Defines if instancing is supported */
  10086. instancedArrays: boolean;
  10087. /** Defines if 32 bits indices are supported */
  10088. uintIndices: boolean;
  10089. /** Defines if high precision shaders are supported */
  10090. highPrecisionShaderSupported: boolean;
  10091. /** Defines if depth reading in the fragment shader is supported */
  10092. fragmentDepthSupported: boolean;
  10093. /** Defines if float texture linear filtering is supported*/
  10094. textureFloatLinearFiltering: boolean;
  10095. /** Defines if rendering to float textures is supported */
  10096. textureFloatRender: boolean;
  10097. /** Defines if half float textures are supported*/
  10098. textureHalfFloat: boolean;
  10099. /** Defines if half float texture linear filtering is supported*/
  10100. textureHalfFloatLinearFiltering: boolean;
  10101. /** Defines if rendering to half float textures is supported */
  10102. textureHalfFloatRender: boolean;
  10103. /** Defines if textureLOD shader command is supported */
  10104. textureLOD: boolean;
  10105. /** Defines if draw buffers extension is supported */
  10106. drawBuffersExtension: boolean;
  10107. /** Defines if depth textures are supported */
  10108. depthTextureExtension: boolean;
  10109. /** Defines if float color buffer are supported */
  10110. colorBufferFloat: boolean;
  10111. /** Gets disjoint timer query extension (null if not supported) */
  10112. timerQuery: EXT_disjoint_timer_query;
  10113. /** Defines if timestamp can be used with timer query */
  10114. canUseTimestampForTimerQuery: boolean;
  10115. /** Function used to let the system compiles shaders in background */
  10116. parallelShaderCompile: {
  10117. MAX_SHADER_COMPILER_THREADS_KHR: number;
  10118. maxShaderCompilerThreadsKHR: (thread: number) => void;
  10119. COMPLETION_STATUS_KHR: number;
  10120. };
  10121. }
  10122. /** Interface defining initialization parameters for Engine class */
  10123. interface EngineOptions extends WebGLContextAttributes {
  10124. /**
  10125. * Defines if the engine should no exceed a specified device ratio
  10126. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  10127. */
  10128. limitDeviceRatio?: number;
  10129. /**
  10130. * Defines if webvr should be enabled automatically
  10131. * @see http://doc.babylonjs.com/how_to/webvr_camera
  10132. */
  10133. autoEnableWebVR?: boolean;
  10134. /**
  10135. * Defines if webgl2 should be turned off even if supported
  10136. * @see http://doc.babylonjs.com/features/webgl2
  10137. */
  10138. disableWebGL2Support?: boolean;
  10139. /**
  10140. * Defines if webaudio should be initialized as well
  10141. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  10142. */
  10143. audioEngine?: boolean;
  10144. /**
  10145. * Defines if animations should run using a deterministic lock step
  10146. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  10147. */
  10148. deterministicLockstep?: boolean;
  10149. /** Defines the maximum steps to use with deterministic lock step mode */
  10150. lockstepMaxSteps?: number;
  10151. /**
  10152. * Defines that engine should ignore context lost events
  10153. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  10154. */
  10155. doNotHandleContextLost?: boolean;
  10156. }
  10157. /**
  10158. * Defines the interface used by display changed events
  10159. */
  10160. interface IDisplayChangedEventArgs {
  10161. /** Gets the vrDisplay object (if any) */
  10162. vrDisplay: Nullable<any>;
  10163. /** Gets a boolean indicating if webVR is supported */
  10164. vrSupported: boolean;
  10165. }
  10166. /**
  10167. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  10168. */
  10169. class Engine {
  10170. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  10171. static ExceptionList: ({
  10172. key: string;
  10173. capture: string;
  10174. captureConstraint: number;
  10175. targets: string[];
  10176. } | {
  10177. key: string;
  10178. capture: null;
  10179. captureConstraint: null;
  10180. targets: string[];
  10181. })[];
  10182. /** Gets the list of created engines */
  10183. static Instances: Engine[];
  10184. /**
  10185. * Gets the latest created engine
  10186. */
  10187. static readonly LastCreatedEngine: Nullable<Engine>;
  10188. /**
  10189. * Gets the latest created scene
  10190. */
  10191. static readonly LastCreatedScene: Nullable<Scene>;
  10192. /**
  10193. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  10194. * @param flag defines which part of the materials must be marked as dirty
  10195. * @param predicate defines a predicate used to filter which materials should be affected
  10196. */
  10197. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  10198. /**
  10199. * Hidden
  10200. */
  10201. static _TextureLoaders: IInternalTextureLoader[];
  10202. /** Defines that alpha blending is disabled */
  10203. static readonly ALPHA_DISABLE: number;
  10204. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  10205. static readonly ALPHA_ADD: number;
  10206. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  10207. static readonly ALPHA_COMBINE: number;
  10208. /** Defines that alpha blending to DEST - SRC * DEST */
  10209. static readonly ALPHA_SUBTRACT: number;
  10210. /** Defines that alpha blending to SRC * DEST */
  10211. static readonly ALPHA_MULTIPLY: number;
  10212. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  10213. static readonly ALPHA_MAXIMIZED: number;
  10214. /** Defines that alpha blending to SRC + DEST */
  10215. static readonly ALPHA_ONEONE: number;
  10216. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  10217. static readonly ALPHA_PREMULTIPLIED: number;
  10218. /**
  10219. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  10220. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  10221. */
  10222. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  10223. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  10224. static readonly ALPHA_INTERPOLATE: number;
  10225. /**
  10226. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  10227. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  10228. */
  10229. static readonly ALPHA_SCREENMODE: number;
  10230. /** Defines that the ressource is not delayed*/
  10231. static readonly DELAYLOADSTATE_NONE: number;
  10232. /** Defines that the ressource was successfully delay loaded */
  10233. static readonly DELAYLOADSTATE_LOADED: number;
  10234. /** Defines that the ressource is currently delay loading */
  10235. static readonly DELAYLOADSTATE_LOADING: number;
  10236. /** Defines that the ressource is delayed and has not started loading */
  10237. static readonly DELAYLOADSTATE_NOTLOADED: number;
  10238. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  10239. static readonly NEVER: number;
  10240. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  10241. static readonly ALWAYS: number;
  10242. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  10243. static readonly LESS: number;
  10244. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  10245. static readonly EQUAL: number;
  10246. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  10247. static readonly LEQUAL: number;
  10248. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  10249. static readonly GREATER: number;
  10250. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  10251. static readonly GEQUAL: number;
  10252. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  10253. static readonly NOTEQUAL: number;
  10254. /** Passed to stencilOperation to specify that stencil value must be kept */
  10255. static readonly KEEP: number;
  10256. /** Passed to stencilOperation to specify that stencil value must be replaced */
  10257. static readonly REPLACE: number;
  10258. /** Passed to stencilOperation to specify that stencil value must be incremented */
  10259. static readonly INCR: number;
  10260. /** Passed to stencilOperation to specify that stencil value must be decremented */
  10261. static readonly DECR: number;
  10262. /** Passed to stencilOperation to specify that stencil value must be inverted */
  10263. static readonly INVERT: number;
  10264. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  10265. static readonly INCR_WRAP: number;
  10266. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  10267. static readonly DECR_WRAP: number;
  10268. /** Texture is not repeating outside of 0..1 UVs */
  10269. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  10270. /** Texture is repeating outside of 0..1 UVs */
  10271. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  10272. /** Texture is repeating and mirrored */
  10273. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  10274. /** ALPHA */
  10275. static readonly TEXTUREFORMAT_ALPHA: number;
  10276. /** LUMINANCE */
  10277. static readonly TEXTUREFORMAT_LUMINANCE: number;
  10278. /** LUMINANCE_ALPHA */
  10279. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  10280. /** RGB */
  10281. static readonly TEXTUREFORMAT_RGB: number;
  10282. /** RGBA */
  10283. static readonly TEXTUREFORMAT_RGBA: number;
  10284. /** RED */
  10285. static readonly TEXTUREFORMAT_RED: number;
  10286. /** RED (2nd reference) */
  10287. static readonly TEXTUREFORMAT_R: number;
  10288. /** RG */
  10289. static readonly TEXTUREFORMAT_RG: number;
  10290. /** RED_INTEGER */
  10291. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  10292. /** RED_INTEGER (2nd reference) */
  10293. static readonly TEXTUREFORMAT_R_INTEGER: number;
  10294. /** RG_INTEGER */
  10295. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  10296. /** RGB_INTEGER */
  10297. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  10298. /** RGBA_INTEGER */
  10299. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  10300. /** UNSIGNED_BYTE */
  10301. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  10302. /** UNSIGNED_BYTE (2nd reference) */
  10303. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  10304. /** FLOAT */
  10305. static readonly TEXTURETYPE_FLOAT: number;
  10306. /** HALF_FLOAT */
  10307. static readonly TEXTURETYPE_HALF_FLOAT: number;
  10308. /** BYTE */
  10309. static readonly TEXTURETYPE_BYTE: number;
  10310. /** SHORT */
  10311. static readonly TEXTURETYPE_SHORT: number;
  10312. /** UNSIGNED_SHORT */
  10313. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  10314. /** INT */
  10315. static readonly TEXTURETYPE_INT: number;
  10316. /** UNSIGNED_INT */
  10317. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  10318. /** UNSIGNED_SHORT_4_4_4_4 */
  10319. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  10320. /** UNSIGNED_SHORT_5_5_5_1 */
  10321. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  10322. /** UNSIGNED_SHORT_5_6_5 */
  10323. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  10324. /** UNSIGNED_INT_2_10_10_10_REV */
  10325. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  10326. /** UNSIGNED_INT_24_8 */
  10327. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  10328. /** UNSIGNED_INT_10F_11F_11F_REV */
  10329. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  10330. /** UNSIGNED_INT_5_9_9_9_REV */
  10331. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  10332. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  10333. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  10334. /** nearest is mag = nearest and min = nearest and mip = linear */
  10335. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  10336. /** Bilinear is mag = linear and min = linear and mip = nearest */
  10337. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  10338. /** Trilinear is mag = linear and min = linear and mip = linear */
  10339. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  10340. /** nearest is mag = nearest and min = nearest and mip = linear */
  10341. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  10342. /** Bilinear is mag = linear and min = linear and mip = nearest */
  10343. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  10344. /** Trilinear is mag = linear and min = linear and mip = linear */
  10345. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  10346. /** mag = nearest and min = nearest and mip = nearest */
  10347. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  10348. /** mag = nearest and min = linear and mip = nearest */
  10349. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  10350. /** mag = nearest and min = linear and mip = linear */
  10351. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  10352. /** mag = nearest and min = linear and mip = none */
  10353. static readonly TEXTURE_NEAREST_LINEAR: number;
  10354. /** mag = nearest and min = nearest and mip = none */
  10355. static readonly TEXTURE_NEAREST_NEAREST: number;
  10356. /** mag = linear and min = nearest and mip = nearest */
  10357. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  10358. /** mag = linear and min = nearest and mip = linear */
  10359. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  10360. /** mag = linear and min = linear and mip = none */
  10361. static readonly TEXTURE_LINEAR_LINEAR: number;
  10362. /** mag = linear and min = nearest and mip = none */
  10363. static readonly TEXTURE_LINEAR_NEAREST: number;
  10364. /** Explicit coordinates mode */
  10365. static readonly TEXTURE_EXPLICIT_MODE: number;
  10366. /** Spherical coordinates mode */
  10367. static readonly TEXTURE_SPHERICAL_MODE: number;
  10368. /** Planar coordinates mode */
  10369. static readonly TEXTURE_PLANAR_MODE: number;
  10370. /** Cubic coordinates mode */
  10371. static readonly TEXTURE_CUBIC_MODE: number;
  10372. /** Projection coordinates mode */
  10373. static readonly TEXTURE_PROJECTION_MODE: number;
  10374. /** Skybox coordinates mode */
  10375. static readonly TEXTURE_SKYBOX_MODE: number;
  10376. /** Inverse Cubic coordinates mode */
  10377. static readonly TEXTURE_INVCUBIC_MODE: number;
  10378. /** Equirectangular coordinates mode */
  10379. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  10380. /** Equirectangular Fixed coordinates mode */
  10381. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  10382. /** Equirectangular Fixed Mirrored coordinates mode */
  10383. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  10384. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  10385. static readonly SCALEMODE_FLOOR: number;
  10386. /** Defines that texture rescaling will look for the nearest power of 2 size */
  10387. static readonly SCALEMODE_NEAREST: number;
  10388. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  10389. static readonly SCALEMODE_CEILING: number;
  10390. /**
  10391. * Returns the current version of the framework
  10392. */
  10393. static readonly Version: string;
  10394. /**
  10395. * Returns a string describing the current engine
  10396. */
  10397. readonly description: string;
  10398. /**
  10399. * Gets or sets the epsilon value used by collision engine
  10400. */
  10401. static CollisionsEpsilon: number;
  10402. /**
  10403. * Gets or sets the relative url used to load code if using the engine in non-minified mode
  10404. */
  10405. static CodeRepository: string;
  10406. /**
  10407. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  10408. */
  10409. static ShadersRepository: string;
  10410. /**
  10411. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  10412. */
  10413. forcePOTTextures: boolean;
  10414. /**
  10415. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  10416. */
  10417. isFullscreen: boolean;
  10418. /**
  10419. * Gets a boolean indicating if the pointer is currently locked
  10420. */
  10421. isPointerLock: boolean;
  10422. /**
  10423. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  10424. */
  10425. cullBackFaces: boolean;
  10426. /**
  10427. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  10428. */
  10429. renderEvenInBackground: boolean;
  10430. /**
  10431. * Gets or sets a boolean indicating that cache can be kept between frames
  10432. */
  10433. preventCacheWipeBetweenFrames: boolean;
  10434. /**
  10435. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  10436. **/
  10437. enableOfflineSupport: boolean;
  10438. /**
  10439. * Gets or sets a boolean to enable/disable checking manifest if IndexedDB support is enabled (Babylon.js will always consider the database is up to date)
  10440. **/
  10441. disableManifestCheck: boolean;
  10442. /**
  10443. * Gets the list of created scenes
  10444. */
  10445. scenes: Scene[];
  10446. /**
  10447. * Event raised when a new scene is created
  10448. */
  10449. onNewSceneAddedObservable: Observable<Scene>;
  10450. /**
  10451. * Gets the list of created postprocesses
  10452. */
  10453. postProcesses: PostProcess[];
  10454. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  10455. validateShaderPrograms: boolean;
  10456. /**
  10457. * Observable event triggered each time the rendering canvas is resized
  10458. */
  10459. onResizeObservable: Observable<Engine>;
  10460. /**
  10461. * Observable event triggered each time the canvas loses focus
  10462. */
  10463. onCanvasBlurObservable: Observable<Engine>;
  10464. /**
  10465. * Observable event triggered each time the canvas gains focus
  10466. */
  10467. onCanvasFocusObservable: Observable<Engine>;
  10468. /**
  10469. * Observable event triggered each time the canvas receives pointerout event
  10470. */
  10471. onCanvasPointerOutObservable: Observable<PointerEvent>;
  10472. /**
  10473. * Observable event triggered before each texture is initialized
  10474. */
  10475. onBeforeTextureInitObservable: Observable<Texture>;
  10476. private _vrDisplay;
  10477. private _vrSupported;
  10478. private _oldSize;
  10479. private _oldHardwareScaleFactor;
  10480. private _vrExclusivePointerMode;
  10481. private _webVRInitPromise;
  10482. /**
  10483. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  10484. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  10485. */
  10486. readonly isInVRExclusivePointerMode: boolean;
  10487. /**
  10488. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  10489. */
  10490. disableUniformBuffers: boolean;
  10491. /** @hidden */
  10492. _uniformBuffers: UniformBuffer[];
  10493. /**
  10494. * Gets a boolean indicating that the engine supports uniform buffers
  10495. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  10496. */
  10497. readonly supportsUniformBuffers: boolean;
  10498. /**
  10499. * Observable raised when the engine begins a new frame
  10500. */
  10501. onBeginFrameObservable: Observable<Engine>;
  10502. /**
  10503. * If set, will be used to request the next animation frame for the render loop
  10504. */
  10505. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  10506. /**
  10507. * Observable raised when the engine ends the current frame
  10508. */
  10509. onEndFrameObservable: Observable<Engine>;
  10510. /**
  10511. * Observable raised when the engine is about to compile a shader
  10512. */
  10513. onBeforeShaderCompilationObservable: Observable<Engine>;
  10514. /**
  10515. * Observable raised when the engine has jsut compiled a shader
  10516. */
  10517. onAfterShaderCompilationObservable: Observable<Engine>;
  10518. /** @hidden */
  10519. _gl: WebGLRenderingContext;
  10520. private _renderingCanvas;
  10521. private _windowIsBackground;
  10522. private _webGLVersion;
  10523. /**
  10524. * Gets a boolean indicating that only power of 2 textures are supported
  10525. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  10526. */
  10527. readonly needPOTTextures: boolean;
  10528. /** @hidden */
  10529. _badOS: boolean;
  10530. /** @hidden */
  10531. _badDesktopOS: boolean;
  10532. /**
  10533. * Gets or sets a value indicating if we want to disable texture binding optimization.
  10534. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  10535. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  10536. */
  10537. disableTextureBindingOptimization: boolean;
  10538. /**
  10539. * Gets the audio engine
  10540. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  10541. * @ignorenaming
  10542. */
  10543. static audioEngine: IAudioEngine;
  10544. /**
  10545. * Default AudioEngine factory responsible of creating the Audio Engine.
  10546. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  10547. */
  10548. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  10549. /**
  10550. * Default offline support factory responsible of creating a tool used to store data locally.
  10551. * By default, this will create a Database object if the workload has been embedded.
  10552. */
  10553. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  10554. private _onFocus;
  10555. private _onBlur;
  10556. private _onCanvasPointerOut;
  10557. private _onCanvasBlur;
  10558. private _onCanvasFocus;
  10559. private _onFullscreenChange;
  10560. private _onPointerLockChange;
  10561. private _onVRDisplayPointerRestricted;
  10562. private _onVRDisplayPointerUnrestricted;
  10563. private _onVrDisplayConnect;
  10564. private _onVrDisplayDisconnect;
  10565. private _onVrDisplayPresentChange;
  10566. /**
  10567. * Observable signaled when VR display mode changes
  10568. */
  10569. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  10570. /**
  10571. * Observable signaled when VR request present is complete
  10572. */
  10573. onVRRequestPresentComplete: Observable<boolean>;
  10574. /**
  10575. * Observable signaled when VR request present starts
  10576. */
  10577. onVRRequestPresentStart: Observable<Engine>;
  10578. private _hardwareScalingLevel;
  10579. /** @hidden */
  10580. protected _caps: EngineCapabilities;
  10581. private _pointerLockRequested;
  10582. private _isStencilEnable;
  10583. private _colorWrite;
  10584. private _loadingScreen;
  10585. /** @hidden */
  10586. _drawCalls: PerfCounter;
  10587. /** @hidden */
  10588. _textureCollisions: PerfCounter;
  10589. private _glVersion;
  10590. private _glRenderer;
  10591. private _glVendor;
  10592. private _videoTextureSupported;
  10593. private _renderingQueueLaunched;
  10594. private _activeRenderLoops;
  10595. private _deterministicLockstep;
  10596. private _lockstepMaxSteps;
  10597. /**
  10598. * Observable signaled when a context lost event is raised
  10599. */
  10600. onContextLostObservable: Observable<Engine>;
  10601. /**
  10602. * Observable signaled when a context restored event is raised
  10603. */
  10604. onContextRestoredObservable: Observable<Engine>;
  10605. private _onContextLost;
  10606. private _onContextRestored;
  10607. private _contextWasLost;
  10608. private _doNotHandleContextLost;
  10609. /**
  10610. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  10611. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  10612. */
  10613. doNotHandleContextLost: boolean;
  10614. private _performanceMonitor;
  10615. private _fps;
  10616. private _deltaTime;
  10617. /**
  10618. * Turn this value on if you want to pause FPS computation when in background
  10619. */
  10620. disablePerformanceMonitorInBackground: boolean;
  10621. /**
  10622. * Gets the performance monitor attached to this engine
  10623. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  10624. */
  10625. readonly performanceMonitor: PerformanceMonitor;
  10626. /** @hidden */
  10627. protected _depthCullingState: _DepthCullingState;
  10628. /** @hidden */
  10629. protected _stencilState: _StencilState;
  10630. /** @hidden */
  10631. protected _alphaState: _AlphaState;
  10632. /** @hidden */
  10633. protected _alphaMode: number;
  10634. protected _internalTexturesCache: InternalTexture[];
  10635. /** @hidden */
  10636. protected _activeChannel: number;
  10637. private _currentTextureChannel;
  10638. /** @hidden */
  10639. protected _boundTexturesCache: {
  10640. [key: string]: Nullable<InternalTexture>;
  10641. };
  10642. /** @hidden */
  10643. protected _currentEffect: Nullable<Effect>;
  10644. /** @hidden */
  10645. protected _currentProgram: Nullable<WebGLProgram>;
  10646. private _compiledEffects;
  10647. private _vertexAttribArraysEnabled;
  10648. /** @hidden */
  10649. protected _cachedViewport: Nullable<Viewport>;
  10650. private _cachedVertexArrayObject;
  10651. /** @hidden */
  10652. protected _cachedVertexBuffers: any;
  10653. /** @hidden */
  10654. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  10655. /** @hidden */
  10656. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  10657. /** @hidden */
  10658. protected _currentRenderTarget: Nullable<InternalTexture>;
  10659. private _uintIndicesCurrentlySet;
  10660. private _currentBoundBuffer;
  10661. /** @hidden */
  10662. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  10663. private _currentBufferPointers;
  10664. private _currentInstanceLocations;
  10665. private _currentInstanceBuffers;
  10666. private _textureUnits;
  10667. private _firstBoundInternalTextureTracker;
  10668. private _lastBoundInternalTextureTracker;
  10669. private _workingCanvas;
  10670. private _workingContext;
  10671. private _rescalePostProcess;
  10672. private _dummyFramebuffer;
  10673. private _externalData;
  10674. private _bindedRenderFunction;
  10675. private _vaoRecordInProgress;
  10676. private _mustWipeVertexAttributes;
  10677. private _emptyTexture;
  10678. private _emptyCubeTexture;
  10679. private _emptyTexture3D;
  10680. /** @hidden */
  10681. _frameHandler: number;
  10682. private _nextFreeTextureSlots;
  10683. private _maxSimultaneousTextures;
  10684. private _activeRequests;
  10685. private _texturesSupported;
  10686. private _textureFormatInUse;
  10687. /**
  10688. * Gets the list of texture formats supported
  10689. */
  10690. readonly texturesSupported: Array<string>;
  10691. /**
  10692. * Gets the list of texture formats in use
  10693. */
  10694. readonly textureFormatInUse: Nullable<string>;
  10695. /**
  10696. * Gets the current viewport
  10697. */
  10698. readonly currentViewport: Nullable<Viewport>;
  10699. /**
  10700. * Gets the default empty texture
  10701. */
  10702. readonly emptyTexture: InternalTexture;
  10703. /**
  10704. * Gets the default empty 3D texture
  10705. */
  10706. readonly emptyTexture3D: InternalTexture;
  10707. /**
  10708. * Gets the default empty cube texture
  10709. */
  10710. readonly emptyCubeTexture: InternalTexture;
  10711. /**
  10712. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  10713. */
  10714. readonly premultipliedAlpha: boolean;
  10715. /**
  10716. * Creates a new engine
  10717. * @param canvasOrContext defines the canvas or WebGL context to use for rendering. If you provide a WebGL context, Babylon.js will not hook events on the canvas (like pointers, keyboards, etc...) so no event observables will be available. This is mostly used when Babylon.js is used as a plugin on a system which alreay used the WebGL context
  10718. * @param antialias defines enable antialiasing (default: false)
  10719. * @param options defines further options to be sent to the getContext() function
  10720. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  10721. */
  10722. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  10723. private _rebuildInternalTextures;
  10724. private _rebuildEffects;
  10725. /**
  10726. * Gets a boolean indicating if all created effects are ready
  10727. * @returns true if all effects are ready
  10728. */
  10729. areAllEffectsReady(): boolean;
  10730. private _rebuildBuffers;
  10731. private _initGLContext;
  10732. /**
  10733. * Gets version of the current webGL context
  10734. */
  10735. readonly webGLVersion: number;
  10736. /**
  10737. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  10738. */
  10739. readonly isStencilEnable: boolean;
  10740. private _prepareWorkingCanvas;
  10741. /**
  10742. * Reset the texture cache to empty state
  10743. */
  10744. resetTextureCache(): void;
  10745. /**
  10746. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  10747. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  10748. * @returns true if engine is in deterministic lock step mode
  10749. */
  10750. isDeterministicLockStep(): boolean;
  10751. /**
  10752. * Gets the max steps when engine is running in deterministic lock step
  10753. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  10754. * @returns the max steps
  10755. */
  10756. getLockstepMaxSteps(): number;
  10757. /**
  10758. * Gets an object containing information about the current webGL context
  10759. * @returns an object containing the vender, the renderer and the version of the current webGL context
  10760. */
  10761. getGlInfo(): {
  10762. vendor: string;
  10763. renderer: string;
  10764. version: string;
  10765. };
  10766. /**
  10767. * Gets current aspect ratio
  10768. * @param camera defines the camera to use to get the aspect ratio
  10769. * @param useScreen defines if screen size must be used (or the current render target if any)
  10770. * @returns a number defining the aspect ratio
  10771. */
  10772. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  10773. /**
  10774. * Gets current screen aspect ratio
  10775. * @returns a number defining the aspect ratio
  10776. */
  10777. getScreenAspectRatio(): number;
  10778. /**
  10779. * Gets the current render width
  10780. * @param useScreen defines if screen size must be used (or the current render target if any)
  10781. * @returns a number defining the current render width
  10782. */
  10783. getRenderWidth(useScreen?: boolean): number;
  10784. /**
  10785. * Gets the current render height
  10786. * @param useScreen defines if screen size must be used (or the current render target if any)
  10787. * @returns a number defining the current render height
  10788. */
  10789. getRenderHeight(useScreen?: boolean): number;
  10790. /**
  10791. * Gets the HTML canvas attached with the current webGL context
  10792. * @returns a HTML canvas
  10793. */
  10794. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  10795. /**
  10796. * Gets the client rect of the HTML canvas attached with the current webGL context
  10797. * @returns a client rectanglee
  10798. */
  10799. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  10800. /**
  10801. * Defines the hardware scaling level.
  10802. * By default the hardware scaling level is computed from the window device ratio.
  10803. * if level = 1 then the engine will render at the exact resolution of the canvas. If level = 0.5 then the engine will render at twice the size of the canvas.
  10804. * @param level defines the level to use
  10805. */
  10806. setHardwareScalingLevel(level: number): void;
  10807. /**
  10808. * Gets the current hardware scaling level.
  10809. * By default the hardware scaling level is computed from the window device ratio.
  10810. * if level = 1 then the engine will render at the exact resolution of the canvas. If level = 0.5 then the engine will render at twice the size of the canvas.
  10811. * @returns a number indicating the current hardware scaling level
  10812. */
  10813. getHardwareScalingLevel(): number;
  10814. /**
  10815. * Gets the list of loaded textures
  10816. * @returns an array containing all loaded textures
  10817. */
  10818. getLoadedTexturesCache(): InternalTexture[];
  10819. /**
  10820. * Gets the object containing all engine capabilities
  10821. * @returns the EngineCapabilities object
  10822. */
  10823. getCaps(): EngineCapabilities;
  10824. /**
  10825. * Gets the current depth function
  10826. * @returns a number defining the depth function
  10827. */
  10828. getDepthFunction(): Nullable<number>;
  10829. /**
  10830. * Sets the current depth function
  10831. * @param depthFunc defines the function to use
  10832. */
  10833. setDepthFunction(depthFunc: number): void;
  10834. /**
  10835. * Sets the current depth function to GREATER
  10836. */
  10837. setDepthFunctionToGreater(): void;
  10838. /**
  10839. * Sets the current depth function to GEQUAL
  10840. */
  10841. setDepthFunctionToGreaterOrEqual(): void;
  10842. /**
  10843. * Sets the current depth function to LESS
  10844. */
  10845. setDepthFunctionToLess(): void;
  10846. /**
  10847. * Sets the current depth function to LEQUAL
  10848. */
  10849. setDepthFunctionToLessOrEqual(): void;
  10850. /**
  10851. * Gets a boolean indicating if stencil buffer is enabled
  10852. * @returns the current stencil buffer state
  10853. */
  10854. getStencilBuffer(): boolean;
  10855. /**
  10856. * Enable or disable the stencil buffer
  10857. * @param enable defines if the stencil buffer must be enabled or disabled
  10858. */
  10859. setStencilBuffer(enable: boolean): void;
  10860. /**
  10861. * Gets the current stencil mask
  10862. * @returns a number defining the new stencil mask to use
  10863. */
  10864. getStencilMask(): number;
  10865. /**
  10866. * Sets the current stencil mask
  10867. * @param mask defines the new stencil mask to use
  10868. */
  10869. setStencilMask(mask: number): void;
  10870. /**
  10871. * Gets the current stencil function
  10872. * @returns a number defining the stencil function to use
  10873. */
  10874. getStencilFunction(): number;
  10875. /**
  10876. * Gets the current stencil reference value
  10877. * @returns a number defining the stencil reference value to use
  10878. */
  10879. getStencilFunctionReference(): number;
  10880. /**
  10881. * Gets the current stencil mask
  10882. * @returns a number defining the stencil mask to use
  10883. */
  10884. getStencilFunctionMask(): number;
  10885. /**
  10886. * Sets the current stencil function
  10887. * @param stencilFunc defines the new stencil function to use
  10888. */
  10889. setStencilFunction(stencilFunc: number): void;
  10890. /**
  10891. * Sets the current stencil reference
  10892. * @param reference defines the new stencil reference to use
  10893. */
  10894. setStencilFunctionReference(reference: number): void;
  10895. /**
  10896. * Sets the current stencil mask
  10897. * @param mask defines the new stencil mask to use
  10898. */
  10899. setStencilFunctionMask(mask: number): void;
  10900. /**
  10901. * Gets the current stencil operation when stencil fails
  10902. * @returns a number defining stencil operation to use when stencil fails
  10903. */
  10904. getStencilOperationFail(): number;
  10905. /**
  10906. * Gets the current stencil operation when depth fails
  10907. * @returns a number defining stencil operation to use when depth fails
  10908. */
  10909. getStencilOperationDepthFail(): number;
  10910. /**
  10911. * Gets the current stencil operation when stencil passes
  10912. * @returns a number defining stencil operation to use when stencil passes
  10913. */
  10914. getStencilOperationPass(): number;
  10915. /**
  10916. * Sets the stencil operation to use when stencil fails
  10917. * @param operation defines the stencil operation to use when stencil fails
  10918. */
  10919. setStencilOperationFail(operation: number): void;
  10920. /**
  10921. * Sets the stencil operation to use when depth fails
  10922. * @param operation defines the stencil operation to use when depth fails
  10923. */
  10924. setStencilOperationDepthFail(operation: number): void;
  10925. /**
  10926. * Sets the stencil operation to use when stencil passes
  10927. * @param operation defines the stencil operation to use when stencil passes
  10928. */
  10929. setStencilOperationPass(operation: number): void;
  10930. /**
  10931. * Sets a boolean indicating if the dithering state is enabled or disabled
  10932. * @param value defines the dithering state
  10933. */
  10934. setDitheringState(value: boolean): void;
  10935. /**
  10936. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  10937. * @param value defines the rasterizer state
  10938. */
  10939. setRasterizerState(value: boolean): void;
  10940. /**
  10941. * stop executing a render loop function and remove it from the execution array
  10942. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  10943. */
  10944. stopRenderLoop(renderFunction?: () => void): void;
  10945. /** @hidden */
  10946. _renderLoop(): void;
  10947. /**
  10948. * Register and execute a render loop. The engine can have more than one render function
  10949. * @param renderFunction defines the function to continuously execute
  10950. */
  10951. runRenderLoop(renderFunction: () => void): void;
  10952. /**
  10953. * Toggle full screen mode
  10954. * @param requestPointerLock defines if a pointer lock should be requested from the user
  10955. */
  10956. switchFullscreen(requestPointerLock: boolean): void;
  10957. /**
  10958. * Clear the current render buffer or the current render target (if any is set up)
  10959. * @param color defines the color to use
  10960. * @param backBuffer defines if the back buffer must be cleared
  10961. * @param depth defines if the depth buffer must be cleared
  10962. * @param stencil defines if the stencil buffer must be cleared
  10963. */
  10964. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  10965. /**
  10966. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  10967. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  10968. * @param y defines the y-coordinate of the corner of the clear rectangle
  10969. * @param width defines the width of the clear rectangle
  10970. * @param height defines the height of the clear rectangle
  10971. * @param clearColor defines the clear color
  10972. */
  10973. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  10974. /**
  10975. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  10976. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  10977. * @param y defines the y-coordinate of the corner of the clear rectangle
  10978. * @param width defines the width of the clear rectangle
  10979. * @param height defines the height of the clear rectangle
  10980. */
  10981. enableScissor(x: number, y: number, width: number, height: number): void;
  10982. /**
  10983. * Disable previously set scissor test rectangle
  10984. */
  10985. disableScissor(): void;
  10986. private _viewportCached;
  10987. /** @hidden */
  10988. _viewport(x: number, y: number, width: number, height: number): void;
  10989. /**
  10990. * Set the WebGL's viewport
  10991. * @param viewport defines the viewport element to be used
  10992. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  10993. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  10994. */
  10995. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  10996. /**
  10997. * Directly set the WebGL Viewport
  10998. * @param x defines the x coordinate of the viewport (in screen space)
  10999. * @param y defines the y coordinate of the viewport (in screen space)
  11000. * @param width defines the width of the viewport (in screen space)
  11001. * @param height defines the height of the viewport (in screen space)
  11002. * @return the current viewport Object (if any) that is being replaced by this call. You can restore this viewport later on to go back to the original state
  11003. */
  11004. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  11005. /**
  11006. * Begin a new frame
  11007. */
  11008. beginFrame(): void;
  11009. /**
  11010. * Enf the current frame
  11011. */
  11012. endFrame(): void;
  11013. /**
  11014. * Resize the view according to the canvas' size
  11015. */
  11016. resize(): void;
  11017. /**
  11018. * Force a specific size of the canvas
  11019. * @param width defines the new canvas' width
  11020. * @param height defines the new canvas' height
  11021. */
  11022. setSize(width: number, height: number): void;
  11023. /**
  11024. * Gets a boolean indicating if a webVR device was detected
  11025. * @returns true if a webVR device was detected
  11026. */
  11027. isVRDevicePresent(): boolean;
  11028. /**
  11029. * Gets the current webVR device
  11030. * @returns the current webVR device (or null)
  11031. */
  11032. getVRDevice(): any;
  11033. /**
  11034. * Initializes a webVR display and starts listening to display change events
  11035. * The onVRDisplayChangedObservable will be notified upon these changes
  11036. * @returns The onVRDisplayChangedObservable
  11037. */
  11038. initWebVR(): Observable<IDisplayChangedEventArgs>;
  11039. /**
  11040. * Initializes a webVR display and starts listening to display change events
  11041. * The onVRDisplayChangedObservable will be notified upon these changes
  11042. * @returns A promise containing a VRDisplay and if vr is supported
  11043. */
  11044. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  11045. /**
  11046. * Call this function to switch to webVR mode
  11047. * Will do nothing if webVR is not supported or if there is no webVR device
  11048. * @see http://doc.babylonjs.com/how_to/webvr_camera
  11049. */
  11050. enableVR(): void;
  11051. /**
  11052. * Call this function to leave webVR mode
  11053. * Will do nothing if webVR is not supported or if there is no webVR device
  11054. * @see http://doc.babylonjs.com/how_to/webvr_camera
  11055. */
  11056. disableVR(): void;
  11057. private _onVRFullScreenTriggered;
  11058. private _getVRDisplaysAsync;
  11059. /**
  11060. * Binds the frame buffer to the specified texture.
  11061. * @param texture The texture to render to or null for the default canvas
  11062. * @param faceIndex The face of the texture to render to in case of cube texture
  11063. * @param requiredWidth The width of the target to render to
  11064. * @param requiredHeight The height of the target to render to
  11065. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  11066. * @param depthStencilTexture The depth stencil texture to use to render
  11067. * @param lodLevel defines le lod level to bind to the frame buffer
  11068. */
  11069. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  11070. private bindUnboundFramebuffer;
  11071. /**
  11072. * Unbind the current render target texture from the webGL context
  11073. * @param texture defines the render target texture to unbind
  11074. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  11075. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  11076. */
  11077. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  11078. /**
  11079. * Unbind a list of render target textures from the webGL context
  11080. * This is used only when drawBuffer extension or webGL2 are active
  11081. * @param textures defines the render target textures to unbind
  11082. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  11083. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  11084. */
  11085. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  11086. /**
  11087. * Force the mipmap generation for the given render target texture
  11088. * @param texture defines the render target texture to use
  11089. */
  11090. generateMipMapsForCubemap(texture: InternalTexture): void;
  11091. /**
  11092. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  11093. */
  11094. flushFramebuffer(): void;
  11095. /**
  11096. * Unbind the current render target and bind the default framebuffer
  11097. */
  11098. restoreDefaultFramebuffer(): void;
  11099. /**
  11100. * Create an uniform buffer
  11101. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  11102. * @param elements defines the content of the uniform buffer
  11103. * @returns the webGL uniform buffer
  11104. */
  11105. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  11106. /**
  11107. * Create a dynamic uniform buffer
  11108. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  11109. * @param elements defines the content of the uniform buffer
  11110. * @returns the webGL uniform buffer
  11111. */
  11112. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  11113. /**
  11114. * Update an existing uniform buffer
  11115. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  11116. * @param uniformBuffer defines the target uniform buffer
  11117. * @param elements defines the content to update
  11118. * @param offset defines the offset in the uniform buffer where update should start
  11119. * @param count defines the size of the data to update
  11120. */
  11121. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  11122. private _resetVertexBufferBinding;
  11123. /**
  11124. * Creates a vertex buffer
  11125. * @param data the data for the vertex buffer
  11126. * @returns the new WebGL static buffer
  11127. */
  11128. createVertexBuffer(data: DataArray): WebGLBuffer;
  11129. /**
  11130. * Creates a dynamic vertex buffer
  11131. * @param data the data for the dynamic vertex buffer
  11132. * @returns the new WebGL dynamic buffer
  11133. */
  11134. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  11135. /**
  11136. * Update a dynamic index buffer
  11137. * @param indexBuffer defines the target index buffer
  11138. * @param indices defines the data to update
  11139. * @param offset defines the offset in the target index buffer where update should start
  11140. */
  11141. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  11142. /**
  11143. * Updates a dynamic vertex buffer.
  11144. * @param vertexBuffer the vertex buffer to update
  11145. * @param data the data used to update the vertex buffer
  11146. * @param byteOffset the byte offset of the data
  11147. * @param byteLength the byte length of the data
  11148. */
  11149. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  11150. private _resetIndexBufferBinding;
  11151. /**
  11152. * Creates a new index buffer
  11153. * @param indices defines the content of the index buffer
  11154. * @param updatable defines if the index buffer must be updatable
  11155. * @returns a new webGL buffer
  11156. */
  11157. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  11158. /**
  11159. * Bind a webGL buffer to the webGL context
  11160. * @param buffer defines the buffer to bind
  11161. */
  11162. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  11163. /**
  11164. * Bind an uniform buffer to the current webGL context
  11165. * @param buffer defines the buffer to bind
  11166. */
  11167. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  11168. /**
  11169. * Bind a buffer to the current webGL context at a given location
  11170. * @param buffer defines the buffer to bind
  11171. * @param location defines the index where to bind the buffer
  11172. */
  11173. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  11174. /**
  11175. * Bind a specific block at a given index in a specific shader program
  11176. * @param shaderProgram defines the shader program
  11177. * @param blockName defines the block name
  11178. * @param index defines the index where to bind the block
  11179. */
  11180. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  11181. private bindIndexBuffer;
  11182. private bindBuffer;
  11183. /**
  11184. * update the bound buffer with the given data
  11185. * @param data defines the data to update
  11186. */
  11187. updateArrayBuffer(data: Float32Array): void;
  11188. private _vertexAttribPointer;
  11189. private _bindIndexBufferWithCache;
  11190. private _bindVertexBuffersAttributes;
  11191. /**
  11192. * Records a vertex array object
  11193. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  11194. * @param vertexBuffers defines the list of vertex buffers to store
  11195. * @param indexBuffer defines the index buffer to store
  11196. * @param effect defines the effect to store
  11197. * @returns the new vertex array object
  11198. */
  11199. recordVertexArrayObject(vertexBuffers: {
  11200. [key: string]: VertexBuffer;
  11201. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  11202. /**
  11203. * Bind a specific vertex array object
  11204. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  11205. * @param vertexArrayObject defines the vertex array object to bind
  11206. * @param indexBuffer defines the index buffer to bind
  11207. */
  11208. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  11209. /**
  11210. * Bind webGl buffers directly to the webGL context
  11211. * @param vertexBuffer defines the vertex buffer to bind
  11212. * @param indexBuffer defines the index buffer to bind
  11213. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  11214. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  11215. * @param effect defines the effect associated with the vertex buffer
  11216. */
  11217. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  11218. private _unbindVertexArrayObject;
  11219. /**
  11220. * Bind a list of vertex buffers to the webGL context
  11221. * @param vertexBuffers defines the list of vertex buffers to bind
  11222. * @param indexBuffer defines the index buffer to bind
  11223. * @param effect defines the effect associated with the vertex buffers
  11224. */
  11225. bindBuffers(vertexBuffers: {
  11226. [key: string]: Nullable<VertexBuffer>;
  11227. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  11228. /**
  11229. * Unbind all instance attributes
  11230. */
  11231. unbindInstanceAttributes(): void;
  11232. /**
  11233. * Release and free the memory of a vertex array object
  11234. * @param vao defines the vertex array object to delete
  11235. */
  11236. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  11237. /** @hidden */
  11238. _releaseBuffer(buffer: WebGLBuffer): boolean;
  11239. /**
  11240. * Creates a webGL buffer to use with instanciation
  11241. * @param capacity defines the size of the buffer
  11242. * @returns the webGL buffer
  11243. */
  11244. createInstancesBuffer(capacity: number): WebGLBuffer;
  11245. /**
  11246. * Delete a webGL buffer used with instanciation
  11247. * @param buffer defines the webGL buffer to delete
  11248. */
  11249. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  11250. /**
  11251. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  11252. * @param instancesBuffer defines the webGL buffer to update and bind
  11253. * @param data defines the data to store in the buffer
  11254. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  11255. */
  11256. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  11257. /**
  11258. * Apply all cached states (depth, culling, stencil and alpha)
  11259. */
  11260. applyStates(): void;
  11261. /**
  11262. * Send a draw order
  11263. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  11264. * @param indexStart defines the starting index
  11265. * @param indexCount defines the number of index to draw
  11266. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11267. */
  11268. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  11269. /**
  11270. * Draw a list of points
  11271. * @param verticesStart defines the index of first vertex to draw
  11272. * @param verticesCount defines the count of vertices to draw
  11273. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11274. */
  11275. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  11276. /**
  11277. * Draw a list of unindexed primitives
  11278. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  11279. * @param verticesStart defines the index of first vertex to draw
  11280. * @param verticesCount defines the count of vertices to draw
  11281. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11282. */
  11283. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  11284. /**
  11285. * Draw a list of indexed primitives
  11286. * @param fillMode defines the primitive to use
  11287. * @param indexStart defines the starting index
  11288. * @param indexCount defines the number of index to draw
  11289. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11290. */
  11291. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  11292. /**
  11293. * Draw a list of unindexed primitives
  11294. * @param fillMode defines the primitive to use
  11295. * @param verticesStart defines the index of first vertex to draw
  11296. * @param verticesCount defines the count of vertices to draw
  11297. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11298. */
  11299. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  11300. private _drawMode;
  11301. /** @hidden */
  11302. _releaseEffect(effect: Effect): void;
  11303. /** @hidden */
  11304. _deleteProgram(program: WebGLProgram): void;
  11305. /**
  11306. * Create a new effect (used to store vertex/fragment shaders)
  11307. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  11308. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  11309. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  11310. * @param samplers defines an array of string used to represent textures
  11311. * @param defines defines the string containing the defines to use to compile the shaders
  11312. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  11313. * @param onCompiled defines a function to call when the effect creation is successful
  11314. * @param onError defines a function to call when the effect creation has failed
  11315. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  11316. * @returns the new Effect
  11317. */
  11318. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, indexParameters?: any): Effect;
  11319. private _compileShader;
  11320. private _compileRawShader;
  11321. /**
  11322. * Directly creates a webGL program
  11323. * @param vertexCode defines the vertex shader code to use
  11324. * @param fragmentCode defines the fragment shader code to use
  11325. * @param context defines the webGL context to use (if not set, the current one will be used)
  11326. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  11327. * @returns the new webGL program
  11328. */
  11329. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  11330. /**
  11331. * Creates a webGL program
  11332. * @param vertexCode defines the vertex shader code to use
  11333. * @param fragmentCode defines the fragment shader code to use
  11334. * @param defines defines the string containing the defines to use to compile the shaders
  11335. * @param context defines the webGL context to use (if not set, the current one will be used)
  11336. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  11337. * @returns the new webGL program
  11338. */
  11339. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  11340. private _createShaderProgram;
  11341. private _finalizeProgram;
  11342. /** @hidden */
  11343. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  11344. /** @hidden */
  11345. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  11346. /**
  11347. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  11348. * @param shaderProgram defines the webGL program to use
  11349. * @param uniformsNames defines the list of uniform names
  11350. * @returns an array of webGL uniform locations
  11351. */
  11352. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  11353. /**
  11354. * Gets the lsit of active attributes for a given webGL program
  11355. * @param shaderProgram defines the webGL program to use
  11356. * @param attributesNames defines the list of attribute names to get
  11357. * @returns an array of indices indicating the offset of each attribute
  11358. */
  11359. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  11360. /**
  11361. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  11362. * @param effect defines the effect to activate
  11363. */
  11364. enableEffect(effect: Nullable<Effect>): void;
  11365. /**
  11366. * Set the value of an uniform to an array of int32
  11367. * @param uniform defines the webGL uniform location where to store the value
  11368. * @param array defines the array of int32 to store
  11369. */
  11370. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  11371. /**
  11372. * Set the value of an uniform to an array of int32 (stored as vec2)
  11373. * @param uniform defines the webGL uniform location where to store the value
  11374. * @param array defines the array of int32 to store
  11375. */
  11376. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  11377. /**
  11378. * Set the value of an uniform to an array of int32 (stored as vec3)
  11379. * @param uniform defines the webGL uniform location where to store the value
  11380. * @param array defines the array of int32 to store
  11381. */
  11382. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  11383. /**
  11384. * Set the value of an uniform to an array of int32 (stored as vec4)
  11385. * @param uniform defines the webGL uniform location where to store the value
  11386. * @param array defines the array of int32 to store
  11387. */
  11388. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  11389. /**
  11390. * Set the value of an uniform to an array of float32
  11391. * @param uniform defines the webGL uniform location where to store the value
  11392. * @param array defines the array of float32 to store
  11393. */
  11394. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  11395. /**
  11396. * Set the value of an uniform to an array of float32 (stored as vec2)
  11397. * @param uniform defines the webGL uniform location where to store the value
  11398. * @param array defines the array of float32 to store
  11399. */
  11400. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  11401. /**
  11402. * Set the value of an uniform to an array of float32 (stored as vec3)
  11403. * @param uniform defines the webGL uniform location where to store the value
  11404. * @param array defines the array of float32 to store
  11405. */
  11406. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  11407. /**
  11408. * Set the value of an uniform to an array of float32 (stored as vec4)
  11409. * @param uniform defines the webGL uniform location where to store the value
  11410. * @param array defines the array of float32 to store
  11411. */
  11412. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  11413. /**
  11414. * Set the value of an uniform to an array of number
  11415. * @param uniform defines the webGL uniform location where to store the value
  11416. * @param array defines the array of number to store
  11417. */
  11418. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  11419. /**
  11420. * Set the value of an uniform to an array of number (stored as vec2)
  11421. * @param uniform defines the webGL uniform location where to store the value
  11422. * @param array defines the array of number to store
  11423. */
  11424. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  11425. /**
  11426. * Set the value of an uniform to an array of number (stored as vec3)
  11427. * @param uniform defines the webGL uniform location where to store the value
  11428. * @param array defines the array of number to store
  11429. */
  11430. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  11431. /**
  11432. * Set the value of an uniform to an array of number (stored as vec4)
  11433. * @param uniform defines the webGL uniform location where to store the value
  11434. * @param array defines the array of number to store
  11435. */
  11436. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  11437. /**
  11438. * Set the value of an uniform to an array of float32 (stored as matrices)
  11439. * @param uniform defines the webGL uniform location where to store the value
  11440. * @param matrices defines the array of float32 to store
  11441. */
  11442. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  11443. /**
  11444. * Set the value of an uniform to a matrix
  11445. * @param uniform defines the webGL uniform location where to store the value
  11446. * @param matrix defines the matrix to store
  11447. */
  11448. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  11449. /**
  11450. * Set the value of an uniform to a matrix (3x3)
  11451. * @param uniform defines the webGL uniform location where to store the value
  11452. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  11453. */
  11454. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  11455. /**
  11456. * Set the value of an uniform to a matrix (2x2)
  11457. * @param uniform defines the webGL uniform location where to store the value
  11458. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  11459. */
  11460. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  11461. /**
  11462. * Set the value of an uniform to a number (int)
  11463. * @param uniform defines the webGL uniform location where to store the value
  11464. * @param value defines the int number to store
  11465. */
  11466. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  11467. /**
  11468. * Set the value of an uniform to a number (float)
  11469. * @param uniform defines the webGL uniform location where to store the value
  11470. * @param value defines the float number to store
  11471. */
  11472. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  11473. /**
  11474. * Set the value of an uniform to a vec2
  11475. * @param uniform defines the webGL uniform location where to store the value
  11476. * @param x defines the 1st component of the value
  11477. * @param y defines the 2nd component of the value
  11478. */
  11479. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  11480. /**
  11481. * Set the value of an uniform to a vec3
  11482. * @param uniform defines the webGL uniform location where to store the value
  11483. * @param x defines the 1st component of the value
  11484. * @param y defines the 2nd component of the value
  11485. * @param z defines the 3rd component of the value
  11486. */
  11487. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  11488. /**
  11489. * Set the value of an uniform to a boolean
  11490. * @param uniform defines the webGL uniform location where to store the value
  11491. * @param bool defines the boolean to store
  11492. */
  11493. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  11494. /**
  11495. * Set the value of an uniform to a vec4
  11496. * @param uniform defines the webGL uniform location where to store the value
  11497. * @param x defines the 1st component of the value
  11498. * @param y defines the 2nd component of the value
  11499. * @param z defines the 3rd component of the value
  11500. * @param w defines the 4th component of the value
  11501. */
  11502. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  11503. /**
  11504. * Set the value of an uniform to a Color3
  11505. * @param uniform defines the webGL uniform location where to store the value
  11506. * @param color3 defines the color to store
  11507. */
  11508. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  11509. /**
  11510. * Set the value of an uniform to a Color3 and an alpha value
  11511. * @param uniform defines the webGL uniform location where to store the value
  11512. * @param color3 defines the color to store
  11513. * @param alpha defines the alpha component to store
  11514. */
  11515. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  11516. /**
  11517. * Sets a Color4 on a uniform variable
  11518. * @param uniform defines the uniform location
  11519. * @param color4 defines the value to be set
  11520. */
  11521. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  11522. /**
  11523. * Set various states to the webGL context
  11524. * @param culling defines backface culling state
  11525. * @param zOffset defines the value to apply to zOffset (0 by default)
  11526. * @param force defines if states must be applied even if cache is up to date
  11527. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  11528. */
  11529. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  11530. /**
  11531. * Set the z offset to apply to current rendering
  11532. * @param value defines the offset to apply
  11533. */
  11534. setZOffset(value: number): void;
  11535. /**
  11536. * Gets the current value of the zOffset
  11537. * @returns the current zOffset state
  11538. */
  11539. getZOffset(): number;
  11540. /**
  11541. * Enable or disable depth buffering
  11542. * @param enable defines the state to set
  11543. */
  11544. setDepthBuffer(enable: boolean): void;
  11545. /**
  11546. * Gets a boolean indicating if depth writing is enabled
  11547. * @returns the current depth writing state
  11548. */
  11549. getDepthWrite(): boolean;
  11550. /**
  11551. * Enable or disable depth writing
  11552. * @param enable defines the state to set
  11553. */
  11554. setDepthWrite(enable: boolean): void;
  11555. /**
  11556. * Enable or disable color writing
  11557. * @param enable defines the state to set
  11558. */
  11559. setColorWrite(enable: boolean): void;
  11560. /**
  11561. * Gets a boolean indicating if color writing is enabled
  11562. * @returns the current color writing state
  11563. */
  11564. getColorWrite(): boolean;
  11565. /**
  11566. * Sets alpha constants used by some alpha blending modes
  11567. * @param r defines the red component
  11568. * @param g defines the green component
  11569. * @param b defines the blue component
  11570. * @param a defines the alpha component
  11571. */
  11572. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  11573. /**
  11574. * Sets the current alpha mode
  11575. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  11576. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  11577. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  11578. */
  11579. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  11580. /**
  11581. * Gets the current alpha mode
  11582. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  11583. * @returns the current alpha mode
  11584. */
  11585. getAlphaMode(): number;
  11586. /**
  11587. * Clears the list of texture accessible through engine.
  11588. * This can help preventing texture load conflict due to name collision.
  11589. */
  11590. clearInternalTexturesCache(): void;
  11591. /**
  11592. * Force the entire cache to be cleared
  11593. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  11594. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  11595. */
  11596. wipeCaches(bruteForce?: boolean): void;
  11597. /**
  11598. * Set the compressed texture format to use, based on the formats you have, and the formats
  11599. * supported by the hardware / browser.
  11600. *
  11601. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  11602. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  11603. * to API arguments needed to compressed textures. This puts the burden on the container
  11604. * generator to house the arcane code for determining these for current & future formats.
  11605. *
  11606. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  11607. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  11608. *
  11609. * Note: The result of this call is not taken into account when a texture is base64.
  11610. *
  11611. * @param formatsAvailable defines the list of those format families you have created
  11612. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  11613. *
  11614. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  11615. * @returns The extension selected.
  11616. */
  11617. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  11618. private _getSamplingParameters;
  11619. private _partialLoadImg;
  11620. private _cascadeLoadImgs;
  11621. /** @hidden */
  11622. _createTexture(): WebGLTexture;
  11623. /**
  11624. * Usually called from BABYLON.Texture.ts.
  11625. * Passed information to create a WebGLTexture
  11626. * @param urlArg defines a value which contains one of the following:
  11627. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  11628. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  11629. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  11630. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  11631. * @param invertY when true, image is flipped when loaded. You probably want true. Certain compressed textures may invert this if their default is inverted (eg. ktx)
  11632. * @param scene needed for loading to the correct scene
  11633. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  11634. * @param onLoad optional callback to be called upon successful completion
  11635. * @param onError optional callback to be called upon failure
  11636. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), HTMLImageElement (image format), or a Blob
  11637. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  11638. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  11639. * @param forcedExtension defines the extension to use to pick the right loader
  11640. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  11641. * @returns a InternalTexture for assignment back into BABYLON.Texture
  11642. */
  11643. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  11644. private _rescaleTexture;
  11645. /**
  11646. * Update a raw texture
  11647. * @param texture defines the texture to update
  11648. * @param data defines the data to store in the texture
  11649. * @param format defines the format of the data
  11650. * @param invertY defines if data must be stored with Y axis inverted
  11651. * @param compression defines the compression used (null by default)
  11652. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11653. */
  11654. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  11655. /**
  11656. * Creates a raw texture
  11657. * @param data defines the data to store in the texture
  11658. * @param width defines the width of the texture
  11659. * @param height defines the height of the texture
  11660. * @param format defines the format of the data
  11661. * @param generateMipMaps defines if the engine should generate the mip levels
  11662. * @param invertY defines if data must be stored with Y axis inverted
  11663. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  11664. * @param compression defines the compression used (null by default)
  11665. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11666. * @returns the raw texture inside an InternalTexture
  11667. */
  11668. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  11669. private _unpackFlipYCached;
  11670. /**
  11671. * In case you are sharing the context with other applications, it might
  11672. * be interested to not cache the unpack flip y state to ensure a consistent
  11673. * value would be set.
  11674. */
  11675. enableUnpackFlipYCached: boolean;
  11676. /** @hidden */
  11677. _unpackFlipY(value: boolean): void;
  11678. /** @hidden */
  11679. _getUnpackAlignement(): number;
  11680. /**
  11681. * Creates a dynamic texture
  11682. * @param width defines the width of the texture
  11683. * @param height defines the height of the texture
  11684. * @param generateMipMaps defines if the engine should generate the mip levels
  11685. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  11686. * @returns the dynamic texture inside an InternalTexture
  11687. */
  11688. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  11689. /**
  11690. * Update the sampling mode of a given texture
  11691. * @param samplingMode defines the required sampling mode
  11692. * @param texture defines the texture to update
  11693. */
  11694. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  11695. /**
  11696. * Update the content of a dynamic texture
  11697. * @param texture defines the texture to update
  11698. * @param canvas defines the canvas containing the source
  11699. * @param invertY defines if data must be stored with Y axis inverted
  11700. * @param premulAlpha defines if alpha is stored as premultiplied
  11701. * @param format defines the format of the data
  11702. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  11703. */
  11704. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  11705. /**
  11706. * Update a video texture
  11707. * @param texture defines the texture to update
  11708. * @param video defines the video element to use
  11709. * @param invertY defines if data must be stored with Y axis inverted
  11710. */
  11711. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  11712. /**
  11713. * Updates a depth texture Comparison Mode and Function.
  11714. * If the comparison Function is equal to 0, the mode will be set to none.
  11715. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  11716. * @param texture The texture to set the comparison function for
  11717. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  11718. */
  11719. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  11720. private _setupDepthStencilTexture;
  11721. /**
  11722. * Creates a depth stencil texture.
  11723. * This is only available in WebGL 2 or with the depth texture extension available.
  11724. * @param size The size of face edge in the texture.
  11725. * @param options The options defining the texture.
  11726. * @returns The texture
  11727. */
  11728. createDepthStencilTexture(size: number | {
  11729. width: number;
  11730. height: number;
  11731. }, options: DepthTextureCreationOptions): InternalTexture;
  11732. /**
  11733. * Creates a depth stencil texture.
  11734. * This is only available in WebGL 2 or with the depth texture extension available.
  11735. * @param size The size of face edge in the texture.
  11736. * @param options The options defining the texture.
  11737. * @returns The texture
  11738. */
  11739. private _createDepthStencilTexture;
  11740. /**
  11741. * Creates a depth stencil cube texture.
  11742. * This is only available in WebGL 2.
  11743. * @param size The size of face edge in the cube texture.
  11744. * @param options The options defining the cube texture.
  11745. * @returns The cube texture
  11746. */
  11747. private _createDepthStencilCubeTexture;
  11748. /**
  11749. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  11750. * @param renderTarget The render target to set the frame buffer for
  11751. */
  11752. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  11753. /**
  11754. * Creates a new render target texture
  11755. * @param size defines the size of the texture
  11756. * @param options defines the options used to create the texture
  11757. * @returns a new render target texture stored in an InternalTexture
  11758. */
  11759. createRenderTargetTexture(size: number | {
  11760. width: number;
  11761. height: number;
  11762. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  11763. /**
  11764. * Create a multi render target texture
  11765. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  11766. * @param size defines the size of the texture
  11767. * @param options defines the creation options
  11768. * @returns the cube texture as an InternalTexture
  11769. */
  11770. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  11771. private _setupFramebufferDepthAttachments;
  11772. /**
  11773. * Updates the sample count of a render target texture
  11774. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  11775. * @param texture defines the texture to update
  11776. * @param samples defines the sample count to set
  11777. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  11778. */
  11779. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  11780. /**
  11781. * Update the sample count for a given multiple render target texture
  11782. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  11783. * @param textures defines the textures to update
  11784. * @param samples defines the sample count to set
  11785. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  11786. */
  11787. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  11788. /** @hidden */
  11789. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  11790. /** @hidden */
  11791. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  11792. /** @hidden */
  11793. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  11794. /** @hidden */
  11795. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  11796. /**
  11797. * Creates a new render target cube texture
  11798. * @param size defines the size of the texture
  11799. * @param options defines the options used to create the texture
  11800. * @returns a new render target cube texture stored in an InternalTexture
  11801. */
  11802. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11803. /**
  11804. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  11805. * @param rootUrl defines the url where the file to load is located
  11806. * @param scene defines the current scene
  11807. * @param lodScale defines scale to apply to the mip map selection
  11808. * @param lodOffset defines offset to apply to the mip map selection
  11809. * @param onLoad defines an optional callback raised when the texture is loaded
  11810. * @param onError defines an optional callback raised if there is an issue to load the texture
  11811. * @param format defines the format of the data
  11812. * @param forcedExtension defines the extension to use to pick the right loader
  11813. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  11814. * @returns the cube texture as an InternalTexture
  11815. */
  11816. createPrefilteredCubeTexture(rootUrl: string, scene: Nullable<Scene>, lodScale: number, lodOffset: number, onLoad?: Nullable<(internalTexture: Nullable<InternalTexture>) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean): InternalTexture;
  11817. /**
  11818. * Creates a cube texture
  11819. * @param rootUrl defines the url where the files to load is located
  11820. * @param scene defines the current scene
  11821. * @param files defines the list of files to load (1 per face)
  11822. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  11823. * @param onLoad defines an optional callback raised when the texture is loaded
  11824. * @param onError defines an optional callback raised if there is an issue to load the texture
  11825. * @param format defines the format of the data
  11826. * @param forcedExtension defines the extension to use to pick the right loader
  11827. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  11828. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11829. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11830. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  11831. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  11832. * @returns the cube texture as an InternalTexture
  11833. */
  11834. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  11835. /**
  11836. * @hidden
  11837. */
  11838. _setCubeMapTextureParams(loadMipmap: boolean): void;
  11839. /**
  11840. * Update a raw cube texture
  11841. * @param texture defines the texture to udpdate
  11842. * @param data defines the data to store
  11843. * @param format defines the data format
  11844. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11845. * @param invertY defines if data must be stored with Y axis inverted
  11846. * @param compression defines the compression used (null by default)
  11847. * @param level defines which level of the texture to update
  11848. */
  11849. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  11850. /**
  11851. * Creates a new raw cube texture
  11852. * @param data defines the array of data to use to create each face
  11853. * @param size defines the size of the textures
  11854. * @param format defines the format of the data
  11855. * @param type defines the type of the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  11856. * @param generateMipMaps defines if the engine should generate the mip levels
  11857. * @param invertY defines if data must be stored with Y axis inverted
  11858. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  11859. * @param compression defines the compression used (null by default)
  11860. * @returns the cube texture as an InternalTexture
  11861. */
  11862. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  11863. /**
  11864. * Creates a new raw cube texture from a specified url
  11865. * @param url defines the url where the data is located
  11866. * @param scene defines the current scene
  11867. * @param size defines the size of the textures
  11868. * @param format defines the format of the data
  11869. * @param type defines the type fo the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  11870. * @param noMipmap defines if the engine should avoid generating the mip levels
  11871. * @param callback defines a callback used to extract texture data from loaded data
  11872. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11873. * @param onLoad defines a callback called when texture is loaded
  11874. * @param onError defines a callback called if there is an error
  11875. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  11876. * @param invertY defines if data must be stored with Y axis inverted
  11877. * @returns the cube texture as an InternalTexture
  11878. */
  11879. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, samplingMode?: number, invertY?: boolean): InternalTexture;
  11880. /**
  11881. * Update a raw 3D texture
  11882. * @param texture defines the texture to update
  11883. * @param data defines the data to store
  11884. * @param format defines the data format
  11885. * @param invertY defines if data must be stored with Y axis inverted
  11886. * @param compression defines the used compression (can be null)
  11887. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11888. */
  11889. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  11890. /**
  11891. * Creates a new raw 3D texture
  11892. * @param data defines the data used to create the texture
  11893. * @param width defines the width of the texture
  11894. * @param height defines the height of the texture
  11895. * @param depth defines the depth of the texture
  11896. * @param format defines the format of the texture
  11897. * @param generateMipMaps defines if the engine must generate mip levels
  11898. * @param invertY defines if data must be stored with Y axis inverted
  11899. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  11900. * @param compression defines the compressed used (can be null)
  11901. * @param textureType defines the compressed used (can be null)
  11902. * @returns a new raw 3D texture (stored in an InternalTexture)
  11903. */
  11904. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  11905. private _prepareWebGLTextureContinuation;
  11906. private _prepareWebGLTexture;
  11907. private _convertRGBtoRGBATextureData;
  11908. /** @hidden */
  11909. _releaseFramebufferObjects(texture: InternalTexture): void;
  11910. /** @hidden */
  11911. _releaseTexture(texture: InternalTexture): void;
  11912. private setProgram;
  11913. private _boundUniforms;
  11914. /**
  11915. * Binds an effect to the webGL context
  11916. * @param effect defines the effect to bind
  11917. */
  11918. bindSamplers(effect: Effect): void;
  11919. private _moveBoundTextureOnTop;
  11920. private _getCorrectTextureChannel;
  11921. private _linkTrackers;
  11922. private _removeDesignatedSlot;
  11923. private _activateCurrentTexture;
  11924. /** @hidden */
  11925. protected _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  11926. /** @hidden */
  11927. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  11928. /**
  11929. * Sets a texture to the webGL context from a postprocess
  11930. * @param channel defines the channel to use
  11931. * @param postProcess defines the source postprocess
  11932. */
  11933. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  11934. /**
  11935. * Binds the output of the passed in post process to the texture channel specified
  11936. * @param channel The channel the texture should be bound to
  11937. * @param postProcess The post process which's output should be bound
  11938. */
  11939. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  11940. /**
  11941. * Unbind all textures from the webGL context
  11942. */
  11943. unbindAllTextures(): void;
  11944. /**
  11945. * Sets a texture to the according uniform.
  11946. * @param channel The texture channel
  11947. * @param uniform The uniform to set
  11948. * @param texture The texture to apply
  11949. */
  11950. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  11951. /**
  11952. * Sets a depth stencil texture from a render target to the according uniform.
  11953. * @param channel The texture channel
  11954. * @param uniform The uniform to set
  11955. * @param texture The render target texture containing the depth stencil texture to apply
  11956. */
  11957. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  11958. private _bindSamplerUniformToChannel;
  11959. private _getTextureWrapMode;
  11960. private _setTexture;
  11961. /**
  11962. * Sets an array of texture to the webGL context
  11963. * @param channel defines the channel where the texture array must be set
  11964. * @param uniform defines the associated uniform location
  11965. * @param textures defines the array of textures to bind
  11966. */
  11967. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  11968. /** @hidden */
  11969. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  11970. private _setTextureParameterFloat;
  11971. private _setTextureParameterInteger;
  11972. /**
  11973. * Reads pixels from the current frame buffer. Please note that this function can be slow
  11974. * @param x defines the x coordinate of the rectangle where pixels must be read
  11975. * @param y defines the y coordinate of the rectangle where pixels must be read
  11976. * @param width defines the width of the rectangle where pixels must be read
  11977. * @param height defines the height of the rectangle where pixels must be read
  11978. * @returns a Uint8Array containing RGBA colors
  11979. */
  11980. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  11981. /**
  11982. * Add an externaly attached data from its key.
  11983. * This method call will fail and return false, if such key already exists.
  11984. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  11985. * @param key the unique key that identifies the data
  11986. * @param data the data object to associate to the key for this Engine instance
  11987. * @return true if no such key were already present and the data was added successfully, false otherwise
  11988. */
  11989. addExternalData<T>(key: string, data: T): boolean;
  11990. /**
  11991. * Get an externaly attached data from its key
  11992. * @param key the unique key that identifies the data
  11993. * @return the associated data, if present (can be null), or undefined if not present
  11994. */
  11995. getExternalData<T>(key: string): T;
  11996. /**
  11997. * Get an externaly attached data from its key, create it using a factory if it's not already present
  11998. * @param key the unique key that identifies the data
  11999. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  12000. * @return the associated data, can be null if the factory returned null.
  12001. */
  12002. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  12003. /**
  12004. * Remove an externaly attached data from the Engine instance
  12005. * @param key the unique key that identifies the data
  12006. * @return true if the data was successfully removed, false if it doesn't exist
  12007. */
  12008. removeExternalData(key: string): boolean;
  12009. /**
  12010. * Unbind all vertex attributes from the webGL context
  12011. */
  12012. unbindAllAttributes(): void;
  12013. /**
  12014. * Force the engine to release all cached effects. This means that next effect compilation will have to be done completely even if a similar effect was already compiled
  12015. */
  12016. releaseEffects(): void;
  12017. /**
  12018. * Dispose and release all associated resources
  12019. */
  12020. dispose(): void;
  12021. /**
  12022. * Display the loading screen
  12023. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  12024. */
  12025. displayLoadingUI(): void;
  12026. /**
  12027. * Hide the loading screen
  12028. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  12029. */
  12030. hideLoadingUI(): void;
  12031. /**
  12032. * Gets the current loading screen object
  12033. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  12034. */
  12035. /**
  12036. * Sets the current loading screen object
  12037. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  12038. */
  12039. loadingScreen: ILoadingScreen;
  12040. /**
  12041. * Sets the current loading screen text
  12042. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  12043. */
  12044. loadingUIText: string;
  12045. /**
  12046. * Sets the current loading screen background color
  12047. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  12048. */
  12049. loadingUIBackgroundColor: string;
  12050. /**
  12051. * Attach a new callback raised when context lost event is fired
  12052. * @param callback defines the callback to call
  12053. */
  12054. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  12055. /**
  12056. * Attach a new callback raised when context restored event is fired
  12057. * @param callback defines the callback to call
  12058. */
  12059. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  12060. /**
  12061. * Gets the source code of the vertex shader associated with a specific webGL program
  12062. * @param program defines the program to use
  12063. * @returns a string containing the source code of the vertex shader associated with the program
  12064. */
  12065. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  12066. /**
  12067. * Gets the source code of the fragment shader associated with a specific webGL program
  12068. * @param program defines the program to use
  12069. * @returns a string containing the source code of the fragment shader associated with the program
  12070. */
  12071. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  12072. /**
  12073. * Get the current error code of the webGL context
  12074. * @returns the error code
  12075. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  12076. */
  12077. getError(): number;
  12078. /**
  12079. * Gets the current framerate
  12080. * @returns a number representing the framerate
  12081. */
  12082. getFps(): number;
  12083. /**
  12084. * Gets the time spent between current and previous frame
  12085. * @returns a number representing the delta time in ms
  12086. */
  12087. getDeltaTime(): number;
  12088. private _measureFps;
  12089. /** @hidden */
  12090. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  12091. private _canRenderToFloatFramebuffer;
  12092. private _canRenderToHalfFloatFramebuffer;
  12093. private _canRenderToFramebuffer;
  12094. /** @hidden */
  12095. _getWebGLTextureType(type: number): number;
  12096. private _getInternalFormat;
  12097. /** @hidden */
  12098. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  12099. /** @hidden */
  12100. _getRGBAMultiSampleBufferFormat(type: number): number;
  12101. /** @hidden */
  12102. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  12103. /** @hidden */
  12104. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  12105. private _partialLoadFile;
  12106. private _cascadeLoadFiles;
  12107. /**
  12108. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  12109. * @returns true if the engine can be created
  12110. * @ignorenaming
  12111. */
  12112. static isSupported(): boolean;
  12113. }
  12114. }
  12115. declare module BABYLON {
  12116. /**
  12117. * Options to create the null engine
  12118. */
  12119. class NullEngineOptions {
  12120. /**
  12121. * Render width (Default: 512)
  12122. */
  12123. renderWidth: number;
  12124. /**
  12125. * Render height (Default: 256)
  12126. */
  12127. renderHeight: number;
  12128. /**
  12129. * Texture size (Default: 512)
  12130. */
  12131. textureSize: number;
  12132. /**
  12133. * If delta time between frames should be constant
  12134. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  12135. */
  12136. deterministicLockstep: boolean;
  12137. /**
  12138. * Maximum about of steps between frames (Default: 4)
  12139. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  12140. */
  12141. lockstepMaxSteps: number;
  12142. }
  12143. /**
  12144. * The null engine class provides support for headless version of babylon.js.
  12145. * This can be used in server side scenario or for testing purposes
  12146. */
  12147. class NullEngine extends Engine {
  12148. private _options;
  12149. /**
  12150. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  12151. */
  12152. isDeterministicLockStep(): boolean;
  12153. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  12154. getLockstepMaxSteps(): number;
  12155. /**
  12156. * Sets hardware scaling, used to save performance if needed
  12157. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  12158. */
  12159. getHardwareScalingLevel(): number;
  12160. constructor(options?: NullEngineOptions);
  12161. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  12162. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  12163. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  12164. getRenderWidth(useScreen?: boolean): number;
  12165. getRenderHeight(useScreen?: boolean): number;
  12166. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  12167. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  12168. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  12169. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  12170. bindSamplers(effect: Effect): void;
  12171. enableEffect(effect: Effect): void;
  12172. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  12173. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  12174. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  12175. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  12176. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  12177. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  12178. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  12179. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  12180. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  12181. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  12182. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  12183. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  12184. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  12185. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  12186. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  12187. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  12188. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  12189. setFloat(uniform: WebGLUniformLocation, value: number): void;
  12190. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  12191. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  12192. setBool(uniform: WebGLUniformLocation, bool: number): void;
  12193. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  12194. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  12195. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  12196. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  12197. bindBuffers(vertexBuffers: {
  12198. [key: string]: VertexBuffer;
  12199. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  12200. wipeCaches(bruteForce?: boolean): void;
  12201. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  12202. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  12203. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  12204. /** @hidden */
  12205. _createTexture(): WebGLTexture;
  12206. /** @hidden */
  12207. _releaseTexture(texture: InternalTexture): void;
  12208. createTexture(urlArg: string, noMipmap: boolean, invertY: boolean, scene: Scene, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<ArrayBuffer | HTMLImageElement>, fallBack?: InternalTexture, format?: number): InternalTexture;
  12209. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  12210. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  12211. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  12212. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  12213. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  12214. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  12215. areAllEffectsReady(): boolean;
  12216. /**
  12217. * @hidden
  12218. * Get the current error code of the webGL context
  12219. * @returns the error code
  12220. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  12221. */
  12222. getError(): number;
  12223. /** @hidden */
  12224. _getUnpackAlignement(): number;
  12225. /** @hidden */
  12226. _unpackFlipY(value: boolean): void;
  12227. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  12228. /**
  12229. * Updates a dynamic vertex buffer.
  12230. * @param vertexBuffer the vertex buffer to update
  12231. * @param data the data used to update the vertex buffer
  12232. * @param byteOffset the byte offset of the data (optional)
  12233. * @param byteLength the byte length of the data (optional)
  12234. */
  12235. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  12236. protected _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  12237. /** @hidden */
  12238. _bindTexture(channel: number, texture: InternalTexture): void;
  12239. /** @hidden */
  12240. _releaseBuffer(buffer: WebGLBuffer): boolean;
  12241. releaseEffects(): void;
  12242. displayLoadingUI(): void;
  12243. hideLoadingUI(): void;
  12244. /** @hidden */
  12245. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  12246. /** @hidden */
  12247. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  12248. /** @hidden */
  12249. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  12250. /** @hidden */
  12251. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  12252. }
  12253. }
  12254. interface WebGLRenderingContext {
  12255. readonly RASTERIZER_DISCARD: number;
  12256. readonly DEPTH_COMPONENT24: number;
  12257. readonly TEXTURE_3D: number;
  12258. readonly TEXTURE_2D_ARRAY: number;
  12259. readonly TEXTURE_COMPARE_FUNC: number;
  12260. readonly TEXTURE_COMPARE_MODE: number;
  12261. readonly COMPARE_REF_TO_TEXTURE: number;
  12262. readonly TEXTURE_WRAP_R: number;
  12263. readonly HALF_FLOAT: number;
  12264. readonly RGB8: number;
  12265. readonly RED_INTEGER: number;
  12266. readonly RG_INTEGER: number;
  12267. readonly RGB_INTEGER: number;
  12268. readonly RGBA_INTEGER: number;
  12269. readonly R8_SNORM: number;
  12270. readonly RG8_SNORM: number;
  12271. readonly RGB8_SNORM: number;
  12272. readonly RGBA8_SNORM: number;
  12273. readonly R8I: number;
  12274. readonly RG8I: number;
  12275. readonly RGB8I: number;
  12276. readonly RGBA8I: number;
  12277. readonly R8UI: number;
  12278. readonly RG8UI: number;
  12279. readonly RGB8UI: number;
  12280. readonly RGBA8UI: number;
  12281. readonly R16I: number;
  12282. readonly RG16I: number;
  12283. readonly RGB16I: number;
  12284. readonly RGBA16I: number;
  12285. readonly R16UI: number;
  12286. readonly RG16UI: number;
  12287. readonly RGB16UI: number;
  12288. readonly RGBA16UI: number;
  12289. readonly R32I: number;
  12290. readonly RG32I: number;
  12291. readonly RGB32I: number;
  12292. readonly RGBA32I: number;
  12293. readonly R32UI: number;
  12294. readonly RG32UI: number;
  12295. readonly RGB32UI: number;
  12296. readonly RGBA32UI: number;
  12297. readonly RGB10_A2UI: number;
  12298. readonly R11F_G11F_B10F: number;
  12299. readonly RGB9_E5: number;
  12300. readonly RGB10_A2: number;
  12301. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  12302. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  12303. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  12304. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  12305. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  12306. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  12307. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ImageBitmap | ImageData | HTMLVideoElement | HTMLImageElement | HTMLCanvasElement): void;
  12308. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  12309. readonly TRANSFORM_FEEDBACK: number;
  12310. readonly INTERLEAVED_ATTRIBS: number;
  12311. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  12312. createTransformFeedback(): WebGLTransformFeedback;
  12313. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  12314. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  12315. beginTransformFeedback(primitiveMode: number): void;
  12316. endTransformFeedback(): void;
  12317. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  12318. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  12319. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  12320. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  12321. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  12322. }
  12323. interface ImageBitmap {
  12324. readonly width: number;
  12325. readonly height: number;
  12326. close(): void;
  12327. }
  12328. interface WebGLQuery extends WebGLObject {
  12329. }
  12330. declare var WebGLQuery: {
  12331. prototype: WebGLQuery;
  12332. new (): WebGLQuery;
  12333. };
  12334. interface WebGLSampler extends WebGLObject {
  12335. }
  12336. declare var WebGLSampler: {
  12337. prototype: WebGLSampler;
  12338. new (): WebGLSampler;
  12339. };
  12340. interface WebGLSync extends WebGLObject {
  12341. }
  12342. declare var WebGLSync: {
  12343. prototype: WebGLSync;
  12344. new (): WebGLSync;
  12345. };
  12346. interface WebGLTransformFeedback extends WebGLObject {
  12347. }
  12348. declare var WebGLTransformFeedback: {
  12349. prototype: WebGLTransformFeedback;
  12350. new (): WebGLTransformFeedback;
  12351. };
  12352. interface WebGLVertexArrayObject extends WebGLObject {
  12353. }
  12354. declare var WebGLVertexArrayObject: {
  12355. prototype: WebGLVertexArrayObject;
  12356. new (): WebGLVertexArrayObject;
  12357. };
  12358. declare module BABYLON {
  12359. /**
  12360. * Gather the list of clipboard event types as constants.
  12361. */
  12362. class ClipboardEventTypes {
  12363. /**
  12364. * The clipboard event is fired when a copy command is active (pressed).
  12365. */
  12366. static readonly COPY: number;
  12367. /**
  12368. * The clipboard event is fired when a cut command is active (pressed).
  12369. */
  12370. static readonly CUT: number;
  12371. /**
  12372. * The clipboard event is fired when a paste command is active (pressed).
  12373. */
  12374. static readonly PASTE: number;
  12375. }
  12376. /**
  12377. * This class is used to store clipboard related info for the onClipboardObservable event.
  12378. */
  12379. class ClipboardInfo {
  12380. /**
  12381. * Defines the type of event (BABYLON.ClipboardEventTypes)
  12382. */
  12383. type: number;
  12384. /**
  12385. * Defines the related dom event
  12386. */
  12387. event: ClipboardEvent;
  12388. /**
  12389. *Creates an instance of ClipboardInfo.
  12390. * @param {number} type
  12391. * @param {ClipboardEvent} event
  12392. */
  12393. constructor(
  12394. /**
  12395. * Defines the type of event (BABYLON.ClipboardEventTypes)
  12396. */
  12397. type: number,
  12398. /**
  12399. * Defines the related dom event
  12400. */
  12401. event: ClipboardEvent);
  12402. /**
  12403. * Get the clipboard event's type from the keycode.
  12404. * @param keyCode Defines the keyCode for the current keyboard event.
  12405. * @return {number}
  12406. */
  12407. static GetTypeFromCharacter(keyCode: number): number;
  12408. }
  12409. }
  12410. declare module BABYLON {
  12411. /**
  12412. * Gather the list of keyboard event types as constants.
  12413. */
  12414. class KeyboardEventTypes {
  12415. /**
  12416. * The keydown event is fired when a key becomes active (pressed).
  12417. */
  12418. static readonly KEYDOWN: number;
  12419. /**
  12420. * The keyup event is fired when a key has been released.
  12421. */
  12422. static readonly KEYUP: number;
  12423. }
  12424. /**
  12425. * This class is used to store keyboard related info for the onKeyboardObservable event.
  12426. */
  12427. class KeyboardInfo {
  12428. /**
  12429. * Defines the type of event (BABYLON.KeyboardEventTypes)
  12430. */
  12431. type: number;
  12432. /**
  12433. * Defines the related dom event
  12434. */
  12435. event: KeyboardEvent;
  12436. /**
  12437. * Instantiates a new keyboard info.
  12438. * This class is used to store keyboard related info for the onKeyboardObservable event.
  12439. * @param type Defines the type of event (BABYLON.KeyboardEventTypes)
  12440. * @param event Defines the related dom event
  12441. */
  12442. constructor(
  12443. /**
  12444. * Defines the type of event (BABYLON.KeyboardEventTypes)
  12445. */
  12446. type: number,
  12447. /**
  12448. * Defines the related dom event
  12449. */
  12450. event: KeyboardEvent);
  12451. }
  12452. /**
  12453. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  12454. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  12455. */
  12456. class KeyboardInfoPre extends KeyboardInfo {
  12457. /**
  12458. * Defines the type of event (BABYLON.KeyboardEventTypes)
  12459. */
  12460. type: number;
  12461. /**
  12462. * Defines the related dom event
  12463. */
  12464. event: KeyboardEvent;
  12465. /**
  12466. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  12467. */
  12468. skipOnPointerObservable: boolean;
  12469. /**
  12470. * Instantiates a new keyboard pre info.
  12471. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  12472. * @param type Defines the type of event (BABYLON.KeyboardEventTypes)
  12473. * @param event Defines the related dom event
  12474. */
  12475. constructor(
  12476. /**
  12477. * Defines the type of event (BABYLON.KeyboardEventTypes)
  12478. */
  12479. type: number,
  12480. /**
  12481. * Defines the related dom event
  12482. */
  12483. event: KeyboardEvent);
  12484. }
  12485. }
  12486. declare module BABYLON {
  12487. /**
  12488. * Gather the list of pointer event types as constants.
  12489. */
  12490. class PointerEventTypes {
  12491. /**
  12492. * The pointerdown event is fired when a pointer becomes active. For mouse, it is fired when the device transitions from no buttons depressed to at least one button depressed. For touch, it is fired when physical contact is made with the digitizer. For pen, it is fired when the stylus makes physical contact with the digitizer.
  12493. */
  12494. static readonly POINTERDOWN: number;
  12495. /**
  12496. * The pointerup event is fired when a pointer is no longer active.
  12497. */
  12498. static readonly POINTERUP: number;
  12499. /**
  12500. * The pointermove event is fired when a pointer changes coordinates.
  12501. */
  12502. static readonly POINTERMOVE: number;
  12503. /**
  12504. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12505. */
  12506. static readonly POINTERWHEEL: number;
  12507. /**
  12508. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12509. */
  12510. static readonly POINTERPICK: number;
  12511. /**
  12512. * The pointertap event is fired when a the object has been touched and released without drag.
  12513. */
  12514. static readonly POINTERTAP: number;
  12515. /**
  12516. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12517. */
  12518. static readonly POINTERDOUBLETAP: number;
  12519. }
  12520. /**
  12521. * Base class of pointer info types.
  12522. */
  12523. class PointerInfoBase {
  12524. /**
  12525. * Defines the type of event (BABYLON.PointerEventTypes)
  12526. */
  12527. type: number;
  12528. /**
  12529. * Defines the related dom event
  12530. */
  12531. event: PointerEvent | MouseWheelEvent;
  12532. /**
  12533. * Instantiates the base class of pointers info.
  12534. * @param type Defines the type of event (BABYLON.PointerEventTypes)
  12535. * @param event Defines the related dom event
  12536. */
  12537. constructor(
  12538. /**
  12539. * Defines the type of event (BABYLON.PointerEventTypes)
  12540. */
  12541. type: number,
  12542. /**
  12543. * Defines the related dom event
  12544. */
  12545. event: PointerEvent | MouseWheelEvent);
  12546. }
  12547. /**
  12548. * This class is used to store pointer related info for the onPrePointerObservable event.
  12549. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12550. */
  12551. class PointerInfoPre extends PointerInfoBase {
  12552. /**
  12553. * Ray from a pointer if availible (eg. 6dof controller)
  12554. */
  12555. ray: Nullable<Ray>;
  12556. /**
  12557. * Defines the local position of the pointer on the canvas.
  12558. */
  12559. localPosition: Vector2;
  12560. /**
  12561. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12562. */
  12563. skipOnPointerObservable: boolean;
  12564. /**
  12565. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12566. * @param type Defines the type of event (BABYLON.PointerEventTypes)
  12567. * @param event Defines the related dom event
  12568. * @param localX Defines the local x coordinates of the pointer when the event occured
  12569. * @param localY Defines the local y coordinates of the pointer when the event occured
  12570. */
  12571. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12572. }
  12573. /**
  12574. * This type contains all the data related to a pointer event in Babylon.js.
  12575. * The event member is an instance of PointerEvent for all types except PointerWheel and is of type MouseWheelEvent when type equals PointerWheel. The different event types can be found in the PointerEventTypes class.
  12576. */
  12577. class PointerInfo extends PointerInfoBase {
  12578. /**
  12579. * Defines the picking info associated to the info (if any)\
  12580. */
  12581. pickInfo: Nullable<PickingInfo>;
  12582. /**
  12583. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12584. * @param type Defines the type of event (BABYLON.PointerEventTypes)
  12585. * @param event Defines the related dom event
  12586. * @param pickInfo Defines the picking info associated to the info (if any)\
  12587. */
  12588. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12589. /**
  12590. * Defines the picking info associated to the info (if any)\
  12591. */
  12592. pickInfo: Nullable<PickingInfo>);
  12593. }
  12594. }
  12595. declare module BABYLON {
  12596. /**
  12597. * Represents a gamepad control stick position
  12598. */
  12599. class StickValues {
  12600. /**
  12601. * The x component of the control stick
  12602. */
  12603. x: number;
  12604. /**
  12605. * The y component of the control stick
  12606. */
  12607. y: number;
  12608. /**
  12609. * Initializes the gamepad x and y control stick values
  12610. * @param x The x component of the gamepad control stick value
  12611. * @param y The y component of the gamepad control stick value
  12612. */
  12613. constructor(
  12614. /**
  12615. * The x component of the control stick
  12616. */
  12617. x: number,
  12618. /**
  12619. * The y component of the control stick
  12620. */
  12621. y: number);
  12622. }
  12623. /**
  12624. * An interface which manages callbacks for gamepad button changes
  12625. */
  12626. interface GamepadButtonChanges {
  12627. /**
  12628. * Called when a gamepad has been changed
  12629. */
  12630. changed: boolean;
  12631. /**
  12632. * Called when a gamepad press event has been triggered
  12633. */
  12634. pressChanged: boolean;
  12635. /**
  12636. * Called when a touch event has been triggered
  12637. */
  12638. touchChanged: boolean;
  12639. /**
  12640. * Called when a value has changed
  12641. */
  12642. valueChanged: boolean;
  12643. }
  12644. /**
  12645. * Represents a gamepad
  12646. */
  12647. class Gamepad {
  12648. /**
  12649. * The id of the gamepad
  12650. */
  12651. id: string;
  12652. /**
  12653. * The index of the gamepad
  12654. */
  12655. index: number;
  12656. /**
  12657. * The browser gamepad
  12658. */
  12659. browserGamepad: any;
  12660. /**
  12661. * Specifies what type of gamepad this represents
  12662. */
  12663. type: number;
  12664. private _leftStick;
  12665. private _rightStick;
  12666. /** @hidden */
  12667. _isConnected: boolean;
  12668. private _leftStickAxisX;
  12669. private _leftStickAxisY;
  12670. private _rightStickAxisX;
  12671. private _rightStickAxisY;
  12672. /**
  12673. * Triggered when the left control stick has been changed
  12674. */
  12675. private _onleftstickchanged;
  12676. /**
  12677. * Triggered when the right control stick has been changed
  12678. */
  12679. private _onrightstickchanged;
  12680. /**
  12681. * Represents a gamepad controller
  12682. */
  12683. static GAMEPAD: number;
  12684. /**
  12685. * Represents a generic controller
  12686. */
  12687. static GENERIC: number;
  12688. /**
  12689. * Represents an XBox controller
  12690. */
  12691. static XBOX: number;
  12692. /**
  12693. * Represents a pose-enabled controller
  12694. */
  12695. static POSE_ENABLED: number;
  12696. /**
  12697. * Specifies whether the left control stick should be Y-inverted
  12698. */
  12699. protected _invertLeftStickY: boolean;
  12700. /**
  12701. * Specifies if the gamepad has been connected
  12702. */
  12703. readonly isConnected: boolean;
  12704. /**
  12705. * Initializes the gamepad
  12706. * @param id The id of the gamepad
  12707. * @param index The index of the gamepad
  12708. * @param browserGamepad The browser gamepad
  12709. * @param leftStickX The x component of the left joystick
  12710. * @param leftStickY The y component of the left joystick
  12711. * @param rightStickX The x component of the right joystick
  12712. * @param rightStickY The y component of the right joystick
  12713. */
  12714. constructor(
  12715. /**
  12716. * The id of the gamepad
  12717. */
  12718. id: string,
  12719. /**
  12720. * The index of the gamepad
  12721. */
  12722. index: number,
  12723. /**
  12724. * The browser gamepad
  12725. */
  12726. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12727. /**
  12728. * Callback triggered when the left joystick has changed
  12729. * @param callback
  12730. */
  12731. onleftstickchanged(callback: (values: StickValues) => void): void;
  12732. /**
  12733. * Callback triggered when the right joystick has changed
  12734. * @param callback
  12735. */
  12736. onrightstickchanged(callback: (values: StickValues) => void): void;
  12737. /**
  12738. * Gets the left joystick
  12739. */
  12740. /**
  12741. * Sets the left joystick values
  12742. */
  12743. leftStick: StickValues;
  12744. /**
  12745. * Gets the right joystick
  12746. */
  12747. /**
  12748. * Sets the right joystick value
  12749. */
  12750. rightStick: StickValues;
  12751. /**
  12752. * Updates the gamepad joystick positions
  12753. */
  12754. update(): void;
  12755. /**
  12756. * Disposes the gamepad
  12757. */
  12758. dispose(): void;
  12759. }
  12760. /**
  12761. * Represents a generic gamepad
  12762. */
  12763. class GenericPad extends Gamepad {
  12764. private _buttons;
  12765. private _onbuttondown;
  12766. private _onbuttonup;
  12767. /**
  12768. * Observable triggered when a button has been pressed
  12769. */
  12770. onButtonDownObservable: Observable<number>;
  12771. /**
  12772. * Observable triggered when a button has been released
  12773. */
  12774. onButtonUpObservable: Observable<number>;
  12775. /**
  12776. * Callback triggered when a button has been pressed
  12777. * @param callback Called when a button has been pressed
  12778. */
  12779. onbuttondown(callback: (buttonPressed: number) => void): void;
  12780. /**
  12781. * Callback triggered when a button has been released
  12782. * @param callback Called when a button has been released
  12783. */
  12784. onbuttonup(callback: (buttonReleased: number) => void): void;
  12785. /**
  12786. * Initializes the generic gamepad
  12787. * @param id The id of the generic gamepad
  12788. * @param index The index of the generic gamepad
  12789. * @param browserGamepad The browser gamepad
  12790. */
  12791. constructor(id: string, index: number, browserGamepad: any);
  12792. private _setButtonValue;
  12793. /**
  12794. * Updates the generic gamepad
  12795. */
  12796. update(): void;
  12797. /**
  12798. * Disposes the generic gamepad
  12799. */
  12800. dispose(): void;
  12801. }
  12802. }
  12803. declare module BABYLON {
  12804. /**
  12805. * Manager for handling gamepads
  12806. */
  12807. class GamepadManager {
  12808. private _scene?;
  12809. private _babylonGamepads;
  12810. private _oneGamepadConnected;
  12811. /** @hidden */
  12812. _isMonitoring: boolean;
  12813. private _gamepadEventSupported;
  12814. private _gamepadSupport;
  12815. /**
  12816. * observable to be triggered when the gamepad controller has been connected
  12817. */
  12818. onGamepadConnectedObservable: Observable<Gamepad>;
  12819. /**
  12820. * observable to be triggered when the gamepad controller has been disconnected
  12821. */
  12822. onGamepadDisconnectedObservable: Observable<Gamepad>;
  12823. private _onGamepadConnectedEvent;
  12824. private _onGamepadDisconnectedEvent;
  12825. /**
  12826. * Initializes the gamepad manager
  12827. * @param _scene BabylonJS scene
  12828. */
  12829. constructor(_scene?: Scene | undefined);
  12830. /**
  12831. * The gamepads in the game pad manager
  12832. */
  12833. readonly gamepads: Gamepad[];
  12834. /**
  12835. * Get the gamepad controllers based on type
  12836. * @param type The type of gamepad controller
  12837. * @returns Nullable gamepad
  12838. */
  12839. getGamepadByType(type?: number): Nullable<Gamepad>;
  12840. /**
  12841. * Disposes the gamepad manager
  12842. */
  12843. dispose(): void;
  12844. private _addNewGamepad;
  12845. private _startMonitoringGamepads;
  12846. private _stopMonitoringGamepads;
  12847. /** @hidden */
  12848. _checkGamepadsStatus(): void;
  12849. private _updateGamepadObjects;
  12850. }
  12851. }
  12852. declare module BABYLON {
  12853. interface Scene {
  12854. /** @hidden */
  12855. _gamepadManager: Nullable<GamepadManager>;
  12856. /**
  12857. * Gets the gamepad manager associated with the scene
  12858. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  12859. */
  12860. gamepadManager: GamepadManager;
  12861. }
  12862. /**
  12863. * Interface representing a free camera inputs manager
  12864. */
  12865. interface FreeCameraInputsManager {
  12866. /**
  12867. * Adds gamepad input support to the FreeCameraInputsManager.
  12868. * @returns the FreeCameraInputsManager
  12869. */
  12870. addGamepad(): FreeCameraInputsManager;
  12871. }
  12872. /**
  12873. * Interface representing an arc rotate camera inputs manager
  12874. */
  12875. interface ArcRotateCameraInputsManager {
  12876. /**
  12877. * Adds gamepad input support to the ArcRotateCamera InputManager.
  12878. * @returns the camera inputs manager
  12879. */
  12880. addGamepad(): ArcRotateCameraInputsManager;
  12881. }
  12882. /**
  12883. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  12884. */
  12885. class GamepadSystemSceneComponent implements ISceneComponent {
  12886. /**
  12887. * The component name helpfull to identify the component in the list of scene components.
  12888. */
  12889. readonly name: string;
  12890. /**
  12891. * The scene the component belongs to.
  12892. */
  12893. scene: Scene;
  12894. /**
  12895. * Creates a new instance of the component for the given scene
  12896. * @param scene Defines the scene to register the component in
  12897. */
  12898. constructor(scene: Scene);
  12899. /**
  12900. * Registers the component in a given scene
  12901. */
  12902. register(): void;
  12903. /**
  12904. * Rebuilds the elements related to this component in case of
  12905. * context lost for instance.
  12906. */
  12907. rebuild(): void;
  12908. /**
  12909. * Disposes the component and the associated ressources
  12910. */
  12911. dispose(): void;
  12912. private _beforeCameraUpdate;
  12913. }
  12914. }
  12915. declare module BABYLON {
  12916. /**
  12917. * Defines supported buttons for XBox360 compatible gamepads
  12918. */
  12919. enum Xbox360Button {
  12920. /** A */
  12921. A = 0,
  12922. /** B */
  12923. B = 1,
  12924. /** X */
  12925. X = 2,
  12926. /** Y */
  12927. Y = 3,
  12928. /** Start */
  12929. Start = 4,
  12930. /** Back */
  12931. Back = 5,
  12932. /** Left button */
  12933. LB = 6,
  12934. /** Right button */
  12935. RB = 7,
  12936. /** Left stick */
  12937. LeftStick = 8,
  12938. /** Right stick */
  12939. RightStick = 9
  12940. }
  12941. /** Defines values for XBox360 DPad */
  12942. enum Xbox360Dpad {
  12943. /** Up */
  12944. Up = 0,
  12945. /** Down */
  12946. Down = 1,
  12947. /** Left */
  12948. Left = 2,
  12949. /** Right */
  12950. Right = 3
  12951. }
  12952. /**
  12953. * Defines a XBox360 gamepad
  12954. */
  12955. class Xbox360Pad extends Gamepad {
  12956. private _leftTrigger;
  12957. private _rightTrigger;
  12958. private _onlefttriggerchanged;
  12959. private _onrighttriggerchanged;
  12960. private _onbuttondown;
  12961. private _onbuttonup;
  12962. private _ondpaddown;
  12963. private _ondpadup;
  12964. /** Observable raised when a button is pressed */
  12965. onButtonDownObservable: Observable<Xbox360Button>;
  12966. /** Observable raised when a button is released */
  12967. onButtonUpObservable: Observable<Xbox360Button>;
  12968. /** Observable raised when a pad is pressed */
  12969. onPadDownObservable: Observable<Xbox360Dpad>;
  12970. /** Observable raised when a pad is released */
  12971. onPadUpObservable: Observable<Xbox360Dpad>;
  12972. private _buttonA;
  12973. private _buttonB;
  12974. private _buttonX;
  12975. private _buttonY;
  12976. private _buttonBack;
  12977. private _buttonStart;
  12978. private _buttonLB;
  12979. private _buttonRB;
  12980. private _buttonLeftStick;
  12981. private _buttonRightStick;
  12982. private _dPadUp;
  12983. private _dPadDown;
  12984. private _dPadLeft;
  12985. private _dPadRight;
  12986. private _isXboxOnePad;
  12987. /**
  12988. * Creates a new XBox360 gamepad object
  12989. * @param id defines the id of this gamepad
  12990. * @param index defines its index
  12991. * @param gamepad defines the internal HTML gamepad object
  12992. * @param xboxOne defines if it is a XBox One gamepad
  12993. */
  12994. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  12995. /**
  12996. * Defines the callback to call when left trigger is pressed
  12997. * @param callback defines the callback to use
  12998. */
  12999. onlefttriggerchanged(callback: (value: number) => void): void;
  13000. /**
  13001. * Defines the callback to call when right trigger is pressed
  13002. * @param callback defines the callback to use
  13003. */
  13004. onrighttriggerchanged(callback: (value: number) => void): void;
  13005. /**
  13006. * Gets the left trigger value
  13007. */
  13008. /**
  13009. * Sets the left trigger value
  13010. */
  13011. leftTrigger: number;
  13012. /**
  13013. * Gets the right trigger value
  13014. */
  13015. /**
  13016. * Sets the right trigger value
  13017. */
  13018. rightTrigger: number;
  13019. /**
  13020. * Defines the callback to call when a button is pressed
  13021. * @param callback defines the callback to use
  13022. */
  13023. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  13024. /**
  13025. * Defines the callback to call when a button is released
  13026. * @param callback defines the callback to use
  13027. */
  13028. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  13029. /**
  13030. * Defines the callback to call when a pad is pressed
  13031. * @param callback defines the callback to use
  13032. */
  13033. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  13034. /**
  13035. * Defines the callback to call when a pad is released
  13036. * @param callback defines the callback to use
  13037. */
  13038. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  13039. private _setButtonValue;
  13040. private _setDPadValue;
  13041. /**
  13042. * Gets the value of the `A` button
  13043. */
  13044. /**
  13045. * Sets the value of the `A` button
  13046. */
  13047. buttonA: number;
  13048. /**
  13049. * Gets the value of the `B` button
  13050. */
  13051. /**
  13052. * Sets the value of the `B` button
  13053. */
  13054. buttonB: number;
  13055. /**
  13056. * Gets the value of the `X` button
  13057. */
  13058. /**
  13059. * Sets the value of the `X` button
  13060. */
  13061. buttonX: number;
  13062. /**
  13063. * Gets the value of the `Y` button
  13064. */
  13065. /**
  13066. * Sets the value of the `Y` button
  13067. */
  13068. buttonY: number;
  13069. /**
  13070. * Gets the value of the `Start` button
  13071. */
  13072. /**
  13073. * Sets the value of the `Start` button
  13074. */
  13075. buttonStart: number;
  13076. /**
  13077. * Gets the value of the `Back` button
  13078. */
  13079. /**
  13080. * Sets the value of the `Back` button
  13081. */
  13082. buttonBack: number;
  13083. /**
  13084. * Gets the value of the `Left` button
  13085. */
  13086. /**
  13087. * Sets the value of the `Left` button
  13088. */
  13089. buttonLB: number;
  13090. /**
  13091. * Gets the value of the `Right` button
  13092. */
  13093. /**
  13094. * Sets the value of the `Right` button
  13095. */
  13096. buttonRB: number;
  13097. /**
  13098. * Gets the value of the Left joystick
  13099. */
  13100. /**
  13101. * Sets the value of the Left joystick
  13102. */
  13103. buttonLeftStick: number;
  13104. /**
  13105. * Gets the value of the Right joystick
  13106. */
  13107. /**
  13108. * Sets the value of the Right joystick
  13109. */
  13110. buttonRightStick: number;
  13111. /**
  13112. * Gets the value of D-pad up
  13113. */
  13114. /**
  13115. * Sets the value of D-pad up
  13116. */
  13117. dPadUp: number;
  13118. /**
  13119. * Gets the value of D-pad down
  13120. */
  13121. /**
  13122. * Sets the value of D-pad down
  13123. */
  13124. dPadDown: number;
  13125. /**
  13126. * Gets the value of D-pad left
  13127. */
  13128. /**
  13129. * Sets the value of D-pad left
  13130. */
  13131. dPadLeft: number;
  13132. /**
  13133. * Gets the value of D-pad right
  13134. */
  13135. /**
  13136. * Sets the value of D-pad right
  13137. */
  13138. dPadRight: number;
  13139. /**
  13140. * Force the gamepad to synchronize with device values
  13141. */
  13142. update(): void;
  13143. /**
  13144. * Disposes the gamepad
  13145. */
  13146. dispose(): void;
  13147. }
  13148. }
  13149. declare module BABYLON {
  13150. /**
  13151. * Single axis drag gizmo
  13152. */
  13153. class AxisDragGizmo extends Gizmo {
  13154. /**
  13155. * Drag behavior responsible for the gizmos dragging interactions
  13156. */
  13157. dragBehavior: PointerDragBehavior;
  13158. private _pointerObserver;
  13159. /**
  13160. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13161. */
  13162. snapDistance: number;
  13163. /**
  13164. * Event that fires each time the gizmo snaps to a new location.
  13165. * * snapDistance is the the change in distance
  13166. */
  13167. onSnapObservable: Observable<{
  13168. snapDistance: number;
  13169. }>;
  13170. /** @hidden */
  13171. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  13172. /** @hidden */
  13173. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  13174. /**
  13175. * Creates an AxisDragGizmo
  13176. * @param gizmoLayer The utility layer the gizmo will be added to
  13177. * @param dragAxis The axis which the gizmo will be able to drag on
  13178. * @param color The color of the gizmo
  13179. */
  13180. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  13181. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13182. /**
  13183. * Disposes of the gizmo
  13184. */
  13185. dispose(): void;
  13186. }
  13187. }
  13188. declare module BABYLON {
  13189. /**
  13190. * Single axis scale gizmo
  13191. */
  13192. class AxisScaleGizmo extends Gizmo {
  13193. private _coloredMaterial;
  13194. /**
  13195. * Drag behavior responsible for the gizmos dragging interactions
  13196. */
  13197. dragBehavior: PointerDragBehavior;
  13198. private _pointerObserver;
  13199. /**
  13200. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13201. */
  13202. snapDistance: number;
  13203. /**
  13204. * Event that fires each time the gizmo snaps to a new location.
  13205. * * snapDistance is the the change in distance
  13206. */
  13207. onSnapObservable: Observable<{
  13208. snapDistance: number;
  13209. }>;
  13210. /**
  13211. * If the scaling operation should be done on all axis (default: false)
  13212. */
  13213. uniformScaling: boolean;
  13214. /**
  13215. * Creates an AxisScaleGizmo
  13216. * @param gizmoLayer The utility layer the gizmo will be added to
  13217. * @param dragAxis The axis which the gizmo will be able to scale on
  13218. * @param color The color of the gizmo
  13219. */
  13220. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  13221. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13222. /**
  13223. * Disposes of the gizmo
  13224. */
  13225. dispose(): void;
  13226. /**
  13227. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  13228. * @param mesh The mesh to replace the default mesh of the gizmo
  13229. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  13230. */
  13231. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  13232. }
  13233. }
  13234. declare module BABYLON {
  13235. /**
  13236. * Bounding box gizmo
  13237. */
  13238. class BoundingBoxGizmo extends Gizmo {
  13239. private _lineBoundingBox;
  13240. private _rotateSpheresParent;
  13241. private _scaleBoxesParent;
  13242. private _boundingDimensions;
  13243. private _renderObserver;
  13244. private _pointerObserver;
  13245. private _scaleDragSpeed;
  13246. private _tmpQuaternion;
  13247. private _tmpVector;
  13248. private _tmpRotationMatrix;
  13249. /**
  13250. * If child meshes should be ignored when calculating the boudning box. This should be set to true to avoid perf hits with heavily nested meshes (Default: false)
  13251. */
  13252. ignoreChildren: boolean;
  13253. /**
  13254. * Returns true if a descendant should be included when computing the bounding box. When null, all descendants are included. If ignoreChildren is set this will be ignored. (Default: null)
  13255. */
  13256. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  13257. /**
  13258. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  13259. */
  13260. rotationSphereSize: number;
  13261. /**
  13262. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  13263. */
  13264. scaleBoxSize: number;
  13265. /**
  13266. * If set, the rotation spheres and scale boxes will increase in size based on the distance away from the camera to have a consistent screen size (Default: false)
  13267. */
  13268. fixedDragMeshScreenSize: boolean;
  13269. /**
  13270. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  13271. */
  13272. fixedDragMeshScreenSizeDistanceFactor: number;
  13273. /**
  13274. * Fired when a rotation sphere or scale box is dragged
  13275. */
  13276. onDragStartObservable: Observable<{}>;
  13277. /**
  13278. * Fired when a scale box is dragged
  13279. */
  13280. onScaleBoxDragObservable: Observable<{}>;
  13281. /**
  13282. * Fired when a scale box drag is ended
  13283. */
  13284. onScaleBoxDragEndObservable: Observable<{}>;
  13285. /**
  13286. * Fired when a rotation sphere is dragged
  13287. */
  13288. onRotationSphereDragObservable: Observable<{}>;
  13289. /**
  13290. * Fired when a rotation sphere drag is ended
  13291. */
  13292. onRotationSphereDragEndObservable: Observable<{}>;
  13293. /**
  13294. * Relative bounding box pivot used when scaling the attached mesh. When null object with scale from the opposite corner. 0.5,0.5,0.5 for center and 0.5,0,0.5 for bottom (Default: null)
  13295. */
  13296. scalePivot: Nullable<Vector3>;
  13297. private _anchorMesh;
  13298. private _existingMeshScale;
  13299. private _dragMesh;
  13300. private pointerDragBehavior;
  13301. private static _PivotCached;
  13302. private static _OldPivotPoint;
  13303. private static _PivotTranslation;
  13304. private static _PivotTmpVector;
  13305. /** @hidden */
  13306. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  13307. /** @hidden */
  13308. static _RestorePivotPoint(mesh: AbstractMesh): void;
  13309. /**
  13310. * Creates an BoundingBoxGizmo
  13311. * @param gizmoLayer The utility layer the gizmo will be added to
  13312. * @param color The color of the gizmo
  13313. */
  13314. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  13315. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13316. private _selectNode;
  13317. /**
  13318. * Updates the bounding box information for the Gizmo
  13319. */
  13320. updateBoundingBox(): void;
  13321. private _updateRotationSpheres;
  13322. private _updateScaleBoxes;
  13323. /**
  13324. * Enables rotation on the specified axis and disables rotation on the others
  13325. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  13326. */
  13327. setEnabledRotationAxis(axis: string): void;
  13328. private _updateDummy;
  13329. /**
  13330. * Enables a pointer drag behavior on the bounding box of the gizmo
  13331. */
  13332. enableDragBehavior(): void;
  13333. /**
  13334. * Disposes of the gizmo
  13335. */
  13336. dispose(): void;
  13337. /**
  13338. * Makes a mesh not pickable and wraps the mesh inside of a bounding box mesh that is pickable. (This is useful to avoid picking within complex geometry)
  13339. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  13340. * @returns the bounding box mesh with the passed in mesh as a child
  13341. */
  13342. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  13343. /**
  13344. * CustomMeshes are not supported by this gizmo
  13345. * @param mesh The mesh to replace the default mesh of the gizmo
  13346. */
  13347. setCustomMesh(mesh: Mesh): void;
  13348. }
  13349. }
  13350. declare module BABYLON {
  13351. /**
  13352. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  13353. */
  13354. class Gizmo implements IDisposable {
  13355. /** The utility layer the gizmo will be added to */
  13356. gizmoLayer: UtilityLayerRenderer;
  13357. /**
  13358. * The root mesh of the gizmo
  13359. */
  13360. protected _rootMesh: Mesh;
  13361. private _attachedMesh;
  13362. /**
  13363. * Ratio for the scale of the gizmo (Default: 1)
  13364. */
  13365. scaleRatio: number;
  13366. private _tmpMatrix;
  13367. /**
  13368. * If a custom mesh has been set (Default: false)
  13369. */
  13370. protected _customMeshSet: boolean;
  13371. /**
  13372. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  13373. * * When set, interactions will be enabled
  13374. */
  13375. attachedMesh: Nullable<AbstractMesh>;
  13376. /**
  13377. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  13378. * @param mesh The mesh to replace the default mesh of the gizmo
  13379. */
  13380. setCustomMesh(mesh: Mesh): void;
  13381. /**
  13382. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  13383. */
  13384. updateGizmoRotationToMatchAttachedMesh: boolean;
  13385. /**
  13386. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  13387. */
  13388. updateGizmoPositionToMatchAttachedMesh: boolean;
  13389. /**
  13390. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  13391. */
  13392. protected _updateScale: boolean;
  13393. protected _interactionsEnabled: boolean;
  13394. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13395. private _beforeRenderObserver;
  13396. /**
  13397. * Creates a gizmo
  13398. * @param gizmoLayer The utility layer the gizmo will be added to
  13399. */
  13400. constructor(
  13401. /** The utility layer the gizmo will be added to */
  13402. gizmoLayer?: UtilityLayerRenderer);
  13403. private _tempVector;
  13404. /**
  13405. * @hidden
  13406. * Updates the gizmo to match the attached mesh's position/rotation
  13407. */
  13408. protected _update(): void;
  13409. /**
  13410. * Disposes of the gizmo
  13411. */
  13412. dispose(): void;
  13413. }
  13414. }
  13415. declare module BABYLON {
  13416. /**
  13417. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  13418. */
  13419. class GizmoManager implements IDisposable {
  13420. private scene;
  13421. /**
  13422. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  13423. */
  13424. gizmos: {
  13425. positionGizmo: Nullable<PositionGizmo>;
  13426. rotationGizmo: Nullable<RotationGizmo>;
  13427. scaleGizmo: Nullable<ScaleGizmo>;
  13428. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  13429. };
  13430. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  13431. clearGizmoOnEmptyPointerEvent: boolean;
  13432. /** Fires an event when the manager is attached to a mesh */
  13433. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  13434. private _gizmosEnabled;
  13435. private _pointerObserver;
  13436. private _attachedMesh;
  13437. private _boundingBoxColor;
  13438. private _defaultUtilityLayer;
  13439. private _defaultKeepDepthUtilityLayer;
  13440. /**
  13441. * When bounding box gizmo is enabled, this can be used to track drag/end events
  13442. */
  13443. boundingBoxDragBehavior: SixDofDragBehavior;
  13444. /**
  13445. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  13446. */
  13447. attachableMeshes: Nullable<Array<AbstractMesh>>;
  13448. /**
  13449. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  13450. */
  13451. usePointerToAttachGizmos: boolean;
  13452. /**
  13453. * Instatiates a gizmo manager
  13454. * @param scene the scene to overlay the gizmos on top of
  13455. */
  13456. constructor(scene: Scene);
  13457. /**
  13458. * Attaches a set of gizmos to the specified mesh
  13459. * @param mesh The mesh the gizmo's should be attached to
  13460. */
  13461. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  13462. /**
  13463. * If the position gizmo is enabled
  13464. */
  13465. positionGizmoEnabled: boolean;
  13466. /**
  13467. * If the rotation gizmo is enabled
  13468. */
  13469. rotationGizmoEnabled: boolean;
  13470. /**
  13471. * If the scale gizmo is enabled
  13472. */
  13473. scaleGizmoEnabled: boolean;
  13474. /**
  13475. * If the boundingBox gizmo is enabled
  13476. */
  13477. boundingBoxGizmoEnabled: boolean;
  13478. /**
  13479. * Disposes of the gizmo manager
  13480. */
  13481. dispose(): void;
  13482. }
  13483. }
  13484. declare module BABYLON {
  13485. /**
  13486. * Single plane rotation gizmo
  13487. */
  13488. class PlaneRotationGizmo extends Gizmo {
  13489. /**
  13490. * Drag behavior responsible for the gizmos dragging interactions
  13491. */
  13492. dragBehavior: PointerDragBehavior;
  13493. private _pointerObserver;
  13494. /**
  13495. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  13496. */
  13497. snapDistance: number;
  13498. /**
  13499. * Event that fires each time the gizmo snaps to a new location.
  13500. * * snapDistance is the the change in distance
  13501. */
  13502. onSnapObservable: Observable<{
  13503. snapDistance: number;
  13504. }>;
  13505. /**
  13506. * Creates a PlaneRotationGizmo
  13507. * @param gizmoLayer The utility layer the gizmo will be added to
  13508. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  13509. * @param color The color of the gizmo
  13510. * @param tessellation Amount of tessellation to be used when creating rotation circles
  13511. */
  13512. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  13513. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13514. /**
  13515. * Disposes of the gizmo
  13516. */
  13517. dispose(): void;
  13518. }
  13519. }
  13520. declare module BABYLON {
  13521. /**
  13522. * Gizmo that enables dragging a mesh along 3 axis
  13523. */
  13524. class PositionGizmo extends Gizmo {
  13525. /**
  13526. * Internal gizmo used for interactions on the x axis
  13527. */
  13528. xGizmo: AxisDragGizmo;
  13529. /**
  13530. * Internal gizmo used for interactions on the y axis
  13531. */
  13532. yGizmo: AxisDragGizmo;
  13533. /**
  13534. * Internal gizmo used for interactions on the z axis
  13535. */
  13536. zGizmo: AxisDragGizmo;
  13537. /** Fires an event when any of it's sub gizmos are dragged */
  13538. onDragStartObservable: Observable<{}>;
  13539. /** Fires an event when any of it's sub gizmos are released from dragging */
  13540. onDragEndObservable: Observable<{}>;
  13541. attachedMesh: Nullable<AbstractMesh>;
  13542. /**
  13543. * Creates a PositionGizmo
  13544. * @param gizmoLayer The utility layer the gizmo will be added to
  13545. */
  13546. constructor(gizmoLayer?: UtilityLayerRenderer);
  13547. updateGizmoRotationToMatchAttachedMesh: boolean;
  13548. /**
  13549. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13550. */
  13551. snapDistance: number;
  13552. /**
  13553. * Ratio for the scale of the gizmo (Default: 1)
  13554. */
  13555. scaleRatio: number;
  13556. /**
  13557. * Disposes of the gizmo
  13558. */
  13559. dispose(): void;
  13560. /**
  13561. * CustomMeshes are not supported by this gizmo
  13562. * @param mesh The mesh to replace the default mesh of the gizmo
  13563. */
  13564. setCustomMesh(mesh: Mesh): void;
  13565. }
  13566. }
  13567. declare module BABYLON {
  13568. /**
  13569. * Gizmo that enables rotating a mesh along 3 axis
  13570. */
  13571. class RotationGizmo extends Gizmo {
  13572. /**
  13573. * Internal gizmo used for interactions on the x axis
  13574. */
  13575. xGizmo: PlaneRotationGizmo;
  13576. /**
  13577. * Internal gizmo used for interactions on the y axis
  13578. */
  13579. yGizmo: PlaneRotationGizmo;
  13580. /**
  13581. * Internal gizmo used for interactions on the z axis
  13582. */
  13583. zGizmo: PlaneRotationGizmo;
  13584. /** Fires an event when any of it's sub gizmos are dragged */
  13585. onDragStartObservable: Observable<{}>;
  13586. /** Fires an event when any of it's sub gizmos are released from dragging */
  13587. onDragEndObservable: Observable<{}>;
  13588. attachedMesh: Nullable<AbstractMesh>;
  13589. /**
  13590. * Creates a RotationGizmo
  13591. * @param gizmoLayer The utility layer the gizmo will be added to
  13592. * @param tessellation Amount of tessellation to be used when creating rotation circles
  13593. */
  13594. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  13595. updateGizmoRotationToMatchAttachedMesh: boolean;
  13596. /**
  13597. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13598. */
  13599. snapDistance: number;
  13600. /**
  13601. * Ratio for the scale of the gizmo (Default: 1)
  13602. */
  13603. scaleRatio: number;
  13604. /**
  13605. * Disposes of the gizmo
  13606. */
  13607. dispose(): void;
  13608. /**
  13609. * CustomMeshes are not supported by this gizmo
  13610. * @param mesh The mesh to replace the default mesh of the gizmo
  13611. */
  13612. setCustomMesh(mesh: Mesh): void;
  13613. }
  13614. }
  13615. declare module BABYLON {
  13616. /**
  13617. * Gizmo that enables scaling a mesh along 3 axis
  13618. */
  13619. class ScaleGizmo extends Gizmo {
  13620. /**
  13621. * Internal gizmo used for interactions on the x axis
  13622. */
  13623. xGizmo: AxisScaleGizmo;
  13624. /**
  13625. * Internal gizmo used for interactions on the y axis
  13626. */
  13627. yGizmo: AxisScaleGizmo;
  13628. /**
  13629. * Internal gizmo used for interactions on the z axis
  13630. */
  13631. zGizmo: AxisScaleGizmo;
  13632. /**
  13633. * Internal gizmo used to scale all axis equally
  13634. */
  13635. uniformScaleGizmo: AxisScaleGizmo;
  13636. /** Fires an event when any of it's sub gizmos are dragged */
  13637. onDragStartObservable: Observable<{}>;
  13638. /** Fires an event when any of it's sub gizmos are released from dragging */
  13639. onDragEndObservable: Observable<{}>;
  13640. attachedMesh: Nullable<AbstractMesh>;
  13641. /**
  13642. * Creates a ScaleGizmo
  13643. * @param gizmoLayer The utility layer the gizmo will be added to
  13644. */
  13645. constructor(gizmoLayer?: UtilityLayerRenderer);
  13646. updateGizmoRotationToMatchAttachedMesh: boolean;
  13647. /**
  13648. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13649. */
  13650. snapDistance: number;
  13651. /**
  13652. * Ratio for the scale of the gizmo (Default: 1)
  13653. */
  13654. scaleRatio: number;
  13655. /**
  13656. * Disposes of the gizmo
  13657. */
  13658. dispose(): void;
  13659. }
  13660. }
  13661. declare module BABYLON {
  13662. /**
  13663. * Represents the different options available during the creation of
  13664. * a Environment helper.
  13665. *
  13666. * This can control the default ground, skybox and image processing setup of your scene.
  13667. */
  13668. interface IEnvironmentHelperOptions {
  13669. /**
  13670. * Specifies wether or not to create a ground.
  13671. * True by default.
  13672. */
  13673. createGround: boolean;
  13674. /**
  13675. * Specifies the ground size.
  13676. * 15 by default.
  13677. */
  13678. groundSize: number;
  13679. /**
  13680. * The texture used on the ground for the main color.
  13681. * Comes from the BabylonJS CDN by default.
  13682. *
  13683. * Remarks: Can be either a texture or a url.
  13684. */
  13685. groundTexture: string | BaseTexture;
  13686. /**
  13687. * The color mixed in the ground texture by default.
  13688. * BabylonJS clearColor by default.
  13689. */
  13690. groundColor: Color3;
  13691. /**
  13692. * Specifies the ground opacity.
  13693. * 1 by default.
  13694. */
  13695. groundOpacity: number;
  13696. /**
  13697. * Enables the ground to receive shadows.
  13698. * True by default.
  13699. */
  13700. enableGroundShadow: boolean;
  13701. /**
  13702. * Helps preventing the shadow to be fully black on the ground.
  13703. * 0.5 by default.
  13704. */
  13705. groundShadowLevel: number;
  13706. /**
  13707. * Creates a mirror texture attach to the ground.
  13708. * false by default.
  13709. */
  13710. enableGroundMirror: boolean;
  13711. /**
  13712. * Specifies the ground mirror size ratio.
  13713. * 0.3 by default as the default kernel is 64.
  13714. */
  13715. groundMirrorSizeRatio: number;
  13716. /**
  13717. * Specifies the ground mirror blur kernel size.
  13718. * 64 by default.
  13719. */
  13720. groundMirrorBlurKernel: number;
  13721. /**
  13722. * Specifies the ground mirror visibility amount.
  13723. * 1 by default
  13724. */
  13725. groundMirrorAmount: number;
  13726. /**
  13727. * Specifies the ground mirror reflectance weight.
  13728. * This uses the standard weight of the background material to setup the fresnel effect
  13729. * of the mirror.
  13730. * 1 by default.
  13731. */
  13732. groundMirrorFresnelWeight: number;
  13733. /**
  13734. * Specifies the ground mirror Falloff distance.
  13735. * This can helps reducing the size of the reflection.
  13736. * 0 by Default.
  13737. */
  13738. groundMirrorFallOffDistance: number;
  13739. /**
  13740. * Specifies the ground mirror texture type.
  13741. * Unsigned Int by Default.
  13742. */
  13743. groundMirrorTextureType: number;
  13744. /**
  13745. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  13746. * the shown objects.
  13747. */
  13748. groundYBias: number;
  13749. /**
  13750. * Specifies wether or not to create a skybox.
  13751. * True by default.
  13752. */
  13753. createSkybox: boolean;
  13754. /**
  13755. * Specifies the skybox size.
  13756. * 20 by default.
  13757. */
  13758. skyboxSize: number;
  13759. /**
  13760. * The texture used on the skybox for the main color.
  13761. * Comes from the BabylonJS CDN by default.
  13762. *
  13763. * Remarks: Can be either a texture or a url.
  13764. */
  13765. skyboxTexture: string | BaseTexture;
  13766. /**
  13767. * The color mixed in the skybox texture by default.
  13768. * BabylonJS clearColor by default.
  13769. */
  13770. skyboxColor: Color3;
  13771. /**
  13772. * The background rotation around the Y axis of the scene.
  13773. * This helps aligning the key lights of your scene with the background.
  13774. * 0 by default.
  13775. */
  13776. backgroundYRotation: number;
  13777. /**
  13778. * Compute automatically the size of the elements to best fit with the scene.
  13779. */
  13780. sizeAuto: boolean;
  13781. /**
  13782. * Default position of the rootMesh if autoSize is not true.
  13783. */
  13784. rootPosition: Vector3;
  13785. /**
  13786. * Sets up the image processing in the scene.
  13787. * true by default.
  13788. */
  13789. setupImageProcessing: boolean;
  13790. /**
  13791. * The texture used as your environment texture in the scene.
  13792. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  13793. *
  13794. * Remarks: Can be either a texture or a url.
  13795. */
  13796. environmentTexture: string | BaseTexture;
  13797. /**
  13798. * The value of the exposure to apply to the scene.
  13799. * 0.6 by default if setupImageProcessing is true.
  13800. */
  13801. cameraExposure: number;
  13802. /**
  13803. * The value of the contrast to apply to the scene.
  13804. * 1.6 by default if setupImageProcessing is true.
  13805. */
  13806. cameraContrast: number;
  13807. /**
  13808. * Specifies wether or not tonemapping should be enabled in the scene.
  13809. * true by default if setupImageProcessing is true.
  13810. */
  13811. toneMappingEnabled: boolean;
  13812. }
  13813. /**
  13814. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  13815. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  13816. * It also helps with the default setup of your imageProcessing configuration.
  13817. */
  13818. class EnvironmentHelper {
  13819. /**
  13820. * Default ground texture URL.
  13821. */
  13822. private static _groundTextureCDNUrl;
  13823. /**
  13824. * Default skybox texture URL.
  13825. */
  13826. private static _skyboxTextureCDNUrl;
  13827. /**
  13828. * Default environment texture URL.
  13829. */
  13830. private static _environmentTextureCDNUrl;
  13831. /**
  13832. * Creates the default options for the helper.
  13833. */
  13834. private static _getDefaultOptions;
  13835. private _rootMesh;
  13836. /**
  13837. * Gets the root mesh created by the helper.
  13838. */
  13839. readonly rootMesh: Mesh;
  13840. private _skybox;
  13841. /**
  13842. * Gets the skybox created by the helper.
  13843. */
  13844. readonly skybox: Nullable<Mesh>;
  13845. private _skyboxTexture;
  13846. /**
  13847. * Gets the skybox texture created by the helper.
  13848. */
  13849. readonly skyboxTexture: Nullable<BaseTexture>;
  13850. private _skyboxMaterial;
  13851. /**
  13852. * Gets the skybox material created by the helper.
  13853. */
  13854. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  13855. private _ground;
  13856. /**
  13857. * Gets the ground mesh created by the helper.
  13858. */
  13859. readonly ground: Nullable<Mesh>;
  13860. private _groundTexture;
  13861. /**
  13862. * Gets the ground texture created by the helper.
  13863. */
  13864. readonly groundTexture: Nullable<BaseTexture>;
  13865. private _groundMirror;
  13866. /**
  13867. * Gets the ground mirror created by the helper.
  13868. */
  13869. readonly groundMirror: Nullable<MirrorTexture>;
  13870. /**
  13871. * Gets the ground mirror render list to helps pushing the meshes
  13872. * you wish in the ground reflection.
  13873. */
  13874. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  13875. private _groundMaterial;
  13876. /**
  13877. * Gets the ground material created by the helper.
  13878. */
  13879. readonly groundMaterial: Nullable<BackgroundMaterial>;
  13880. /**
  13881. * Stores the creation options.
  13882. */
  13883. private readonly _scene;
  13884. private _options;
  13885. /**
  13886. * This observable will be notified with any error during the creation of the environment,
  13887. * mainly texture creation errors.
  13888. */
  13889. onErrorObservable: Observable<{
  13890. message?: string;
  13891. exception?: any;
  13892. }>;
  13893. /**
  13894. * constructor
  13895. * @param options
  13896. * @param scene The scene to add the material to
  13897. */
  13898. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  13899. /**
  13900. * Updates the background according to the new options
  13901. * @param options
  13902. */
  13903. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  13904. /**
  13905. * Sets the primary color of all the available elements.
  13906. * @param color the main color to affect to the ground and the background
  13907. */
  13908. setMainColor(color: Color3): void;
  13909. /**
  13910. * Setup the image processing according to the specified options.
  13911. */
  13912. private _setupImageProcessing;
  13913. /**
  13914. * Setup the environment texture according to the specified options.
  13915. */
  13916. private _setupEnvironmentTexture;
  13917. /**
  13918. * Setup the background according to the specified options.
  13919. */
  13920. private _setupBackground;
  13921. /**
  13922. * Get the scene sizes according to the setup.
  13923. */
  13924. private _getSceneSize;
  13925. /**
  13926. * Setup the ground according to the specified options.
  13927. */
  13928. private _setupGround;
  13929. /**
  13930. * Setup the ground material according to the specified options.
  13931. */
  13932. private _setupGroundMaterial;
  13933. /**
  13934. * Setup the ground diffuse texture according to the specified options.
  13935. */
  13936. private _setupGroundDiffuseTexture;
  13937. /**
  13938. * Setup the ground mirror texture according to the specified options.
  13939. */
  13940. private _setupGroundMirrorTexture;
  13941. /**
  13942. * Setup the ground to receive the mirror texture.
  13943. */
  13944. private _setupMirrorInGroundMaterial;
  13945. /**
  13946. * Setup the skybox according to the specified options.
  13947. */
  13948. private _setupSkybox;
  13949. /**
  13950. * Setup the skybox material according to the specified options.
  13951. */
  13952. private _setupSkyboxMaterial;
  13953. /**
  13954. * Setup the skybox reflection texture according to the specified options.
  13955. */
  13956. private _setupSkyboxReflectionTexture;
  13957. private _errorHandler;
  13958. /**
  13959. * Dispose all the elements created by the Helper.
  13960. */
  13961. dispose(): void;
  13962. }
  13963. }
  13964. declare module BABYLON {
  13965. /**
  13966. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  13967. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  13968. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  13969. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  13970. */
  13971. class PhotoDome extends TransformNode {
  13972. private _useDirectMapping;
  13973. /**
  13974. * The texture being displayed on the sphere
  13975. */
  13976. protected _photoTexture: Texture;
  13977. /**
  13978. * Gets or sets the texture being displayed on the sphere
  13979. */
  13980. photoTexture: Texture;
  13981. /**
  13982. * Observable raised when an error occured while loading the 360 image
  13983. */
  13984. onLoadErrorObservable: Observable<string>;
  13985. /**
  13986. * The skybox material
  13987. */
  13988. protected _material: BackgroundMaterial;
  13989. /**
  13990. * The surface used for the skybox
  13991. */
  13992. protected _mesh: Mesh;
  13993. /**
  13994. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  13995. * Also see the options.resolution property.
  13996. */
  13997. fovMultiplier: number;
  13998. /**
  13999. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  14000. * @param name Element's name, child elements will append suffixes for their own names.
  14001. * @param urlsOfPhoto defines the url of the photo to display
  14002. * @param options defines an object containing optional or exposed sub element properties
  14003. * @param onError defines a callback called when an error occured while loading the texture
  14004. */
  14005. constructor(name: string, urlOfPhoto: string, options: {
  14006. resolution?: number;
  14007. size?: number;
  14008. useDirectMapping?: boolean;
  14009. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  14010. /**
  14011. * Releases resources associated with this node.
  14012. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14013. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14014. */
  14015. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14016. }
  14017. }
  14018. declare module BABYLON {
  14019. interface Scene {
  14020. /**
  14021. * Creates a default light for the scene.
  14022. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  14023. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  14024. */
  14025. createDefaultLight(replace?: boolean): void;
  14026. /**
  14027. * Creates a default camera for the scene.
  14028. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  14029. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  14030. * @param replace has default false, when true replaces the active camera in the scene
  14031. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  14032. */
  14033. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  14034. /**
  14035. * Creates a default camera and a default light.
  14036. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  14037. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  14038. * @param replace has the default false, when true replaces the active camera/light in the scene
  14039. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  14040. */
  14041. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  14042. /**
  14043. * Creates a new sky box
  14044. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  14045. * @param environmentTexture defines the texture to use as environment texture
  14046. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  14047. * @param scale defines the overall scale of the skybox
  14048. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  14049. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  14050. * @returns a new mesh holding the sky box
  14051. */
  14052. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  14053. /**
  14054. * Creates a new environment
  14055. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  14056. * @param options defines the options you can use to configure the environment
  14057. * @returns the new EnvironmentHelper
  14058. */
  14059. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  14060. /**
  14061. * Creates a new VREXperienceHelper
  14062. * @see http://doc.babylonjs.com/how_to/webvr_helper
  14063. * @param webVROptions defines the options used to create the new VREXperienceHelper
  14064. * @returns a new VREXperienceHelper
  14065. */
  14066. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  14067. /**
  14068. * Creates a new XREXperienceHelper
  14069. * @see http://doc.babylonjs.com/how_to/webxr
  14070. * @returns a promise for a new XREXperienceHelper
  14071. */
  14072. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  14073. }
  14074. }
  14075. declare module BABYLON {
  14076. /**
  14077. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  14078. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  14079. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  14080. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  14081. */
  14082. class VideoDome extends TransformNode {
  14083. private _useDirectMapping;
  14084. /**
  14085. * The video texture being displayed on the sphere
  14086. */
  14087. protected _videoTexture: VideoTexture;
  14088. /**
  14089. * Gets the video texture being displayed on the sphere
  14090. */
  14091. readonly videoTexture: VideoTexture;
  14092. /**
  14093. * The skybox material
  14094. */
  14095. protected _material: BackgroundMaterial;
  14096. /**
  14097. * The surface used for the skybox
  14098. */
  14099. protected _mesh: Mesh;
  14100. /**
  14101. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  14102. * Also see the options.resolution property.
  14103. */
  14104. fovMultiplier: number;
  14105. /**
  14106. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  14107. * @param name Element's name, child elements will append suffixes for their own names.
  14108. * @param urlsOrVideo defines the url(s) or the video element to use
  14109. * @param options An object containing optional or exposed sub element properties
  14110. */
  14111. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  14112. resolution?: number;
  14113. clickToPlay?: boolean;
  14114. autoPlay?: boolean;
  14115. loop?: boolean;
  14116. size?: number;
  14117. poster?: string;
  14118. useDirectMapping?: boolean;
  14119. }, scene: Scene);
  14120. /**
  14121. * Releases resources associated with this node.
  14122. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14123. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14124. */
  14125. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14126. }
  14127. }
  14128. declare module BABYLON {
  14129. /**
  14130. * This class can be used to get instrumentation data from a Babylon engine
  14131. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  14132. */
  14133. class EngineInstrumentation implements IDisposable {
  14134. /**
  14135. * Define the instrumented engine.
  14136. */
  14137. engine: Engine;
  14138. private _captureGPUFrameTime;
  14139. private _gpuFrameTimeToken;
  14140. private _gpuFrameTime;
  14141. private _captureShaderCompilationTime;
  14142. private _shaderCompilationTime;
  14143. private _onBeginFrameObserver;
  14144. private _onEndFrameObserver;
  14145. private _onBeforeShaderCompilationObserver;
  14146. private _onAfterShaderCompilationObserver;
  14147. /**
  14148. * Gets the perf counter used for GPU frame time
  14149. */
  14150. readonly gpuFrameTimeCounter: PerfCounter;
  14151. /**
  14152. * Gets the GPU frame time capture status
  14153. */
  14154. /**
  14155. * Enable or disable the GPU frame time capture
  14156. */
  14157. captureGPUFrameTime: boolean;
  14158. /**
  14159. * Gets the perf counter used for shader compilation time
  14160. */
  14161. readonly shaderCompilationTimeCounter: PerfCounter;
  14162. /**
  14163. * Gets the shader compilation time capture status
  14164. */
  14165. /**
  14166. * Enable or disable the shader compilation time capture
  14167. */
  14168. captureShaderCompilationTime: boolean;
  14169. /**
  14170. * Instantiates a new engine instrumentation.
  14171. * This class can be used to get instrumentation data from a Babylon engine
  14172. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  14173. * @param engine Defines the engine to instrument
  14174. */
  14175. constructor(
  14176. /**
  14177. * Define the instrumented engine.
  14178. */
  14179. engine: Engine);
  14180. /**
  14181. * Dispose and release associated resources.
  14182. */
  14183. dispose(): void;
  14184. }
  14185. }
  14186. declare module BABYLON {
  14187. /**
  14188. * This class can be used to get instrumentation data from a Babylon engine
  14189. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  14190. */
  14191. class SceneInstrumentation implements IDisposable {
  14192. /**
  14193. * Defines the scene to instrument
  14194. */
  14195. scene: Scene;
  14196. private _captureActiveMeshesEvaluationTime;
  14197. private _activeMeshesEvaluationTime;
  14198. private _captureRenderTargetsRenderTime;
  14199. private _renderTargetsRenderTime;
  14200. private _captureFrameTime;
  14201. private _frameTime;
  14202. private _captureRenderTime;
  14203. private _renderTime;
  14204. private _captureInterFrameTime;
  14205. private _interFrameTime;
  14206. private _captureParticlesRenderTime;
  14207. private _particlesRenderTime;
  14208. private _captureSpritesRenderTime;
  14209. private _spritesRenderTime;
  14210. private _capturePhysicsTime;
  14211. private _physicsTime;
  14212. private _captureAnimationsTime;
  14213. private _animationsTime;
  14214. private _captureCameraRenderTime;
  14215. private _cameraRenderTime;
  14216. private _onBeforeActiveMeshesEvaluationObserver;
  14217. private _onAfterActiveMeshesEvaluationObserver;
  14218. private _onBeforeRenderTargetsRenderObserver;
  14219. private _onAfterRenderTargetsRenderObserver;
  14220. private _onAfterRenderObserver;
  14221. private _onBeforeDrawPhaseObserver;
  14222. private _onAfterDrawPhaseObserver;
  14223. private _onBeforeAnimationsObserver;
  14224. private _onBeforeParticlesRenderingObserver;
  14225. private _onAfterParticlesRenderingObserver;
  14226. private _onBeforeSpritesRenderingObserver;
  14227. private _onAfterSpritesRenderingObserver;
  14228. private _onBeforePhysicsObserver;
  14229. private _onAfterPhysicsObserver;
  14230. private _onAfterAnimationsObserver;
  14231. private _onBeforeCameraRenderObserver;
  14232. private _onAfterCameraRenderObserver;
  14233. /**
  14234. * Gets the perf counter used for active meshes evaluation time
  14235. */
  14236. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  14237. /**
  14238. * Gets the active meshes evaluation time capture status
  14239. */
  14240. /**
  14241. * Enable or disable the active meshes evaluation time capture
  14242. */
  14243. captureActiveMeshesEvaluationTime: boolean;
  14244. /**
  14245. * Gets the perf counter used for render targets render time
  14246. */
  14247. readonly renderTargetsRenderTimeCounter: PerfCounter;
  14248. /**
  14249. * Gets the render targets render time capture status
  14250. */
  14251. /**
  14252. * Enable or disable the render targets render time capture
  14253. */
  14254. captureRenderTargetsRenderTime: boolean;
  14255. /**
  14256. * Gets the perf counter used for particles render time
  14257. */
  14258. readonly particlesRenderTimeCounter: PerfCounter;
  14259. /**
  14260. * Gets the particles render time capture status
  14261. */
  14262. /**
  14263. * Enable or disable the particles render time capture
  14264. */
  14265. captureParticlesRenderTime: boolean;
  14266. /**
  14267. * Gets the perf counter used for sprites render time
  14268. */
  14269. readonly spritesRenderTimeCounter: PerfCounter;
  14270. /**
  14271. * Gets the sprites render time capture status
  14272. */
  14273. /**
  14274. * Enable or disable the sprites render time capture
  14275. */
  14276. captureSpritesRenderTime: boolean;
  14277. /**
  14278. * Gets the perf counter used for physics time
  14279. */
  14280. readonly physicsTimeCounter: PerfCounter;
  14281. /**
  14282. * Gets the physics time capture status
  14283. */
  14284. /**
  14285. * Enable or disable the physics time capture
  14286. */
  14287. capturePhysicsTime: boolean;
  14288. /**
  14289. * Gets the perf counter used for animations time
  14290. */
  14291. readonly animationsTimeCounter: PerfCounter;
  14292. /**
  14293. * Gets the animations time capture status
  14294. */
  14295. /**
  14296. * Enable or disable the animations time capture
  14297. */
  14298. captureAnimationsTime: boolean;
  14299. /**
  14300. * Gets the perf counter used for frame time capture
  14301. */
  14302. readonly frameTimeCounter: PerfCounter;
  14303. /**
  14304. * Gets the frame time capture status
  14305. */
  14306. /**
  14307. * Enable or disable the frame time capture
  14308. */
  14309. captureFrameTime: boolean;
  14310. /**
  14311. * Gets the perf counter used for inter-frames time capture
  14312. */
  14313. readonly interFrameTimeCounter: PerfCounter;
  14314. /**
  14315. * Gets the inter-frames time capture status
  14316. */
  14317. /**
  14318. * Enable or disable the inter-frames time capture
  14319. */
  14320. captureInterFrameTime: boolean;
  14321. /**
  14322. * Gets the perf counter used for render time capture
  14323. */
  14324. readonly renderTimeCounter: PerfCounter;
  14325. /**
  14326. * Gets the render time capture status
  14327. */
  14328. /**
  14329. * Enable or disable the render time capture
  14330. */
  14331. captureRenderTime: boolean;
  14332. /**
  14333. * Gets the perf counter used for camera render time capture
  14334. */
  14335. readonly cameraRenderTimeCounter: PerfCounter;
  14336. /**
  14337. * Gets the camera render time capture status
  14338. */
  14339. /**
  14340. * Enable or disable the camera render time capture
  14341. */
  14342. captureCameraRenderTime: boolean;
  14343. /**
  14344. * Gets the perf counter used for draw calls
  14345. */
  14346. readonly drawCallsCounter: PerfCounter;
  14347. /**
  14348. * Gets the perf counter used for texture collisions
  14349. */
  14350. readonly textureCollisionsCounter: PerfCounter;
  14351. /**
  14352. * Instantiates a new scene instrumentation.
  14353. * This class can be used to get instrumentation data from a Babylon engine
  14354. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  14355. * @param scene Defines the scene to instrument
  14356. */
  14357. constructor(
  14358. /**
  14359. * Defines the scene to instrument
  14360. */
  14361. scene: Scene);
  14362. /**
  14363. * Dispose and release associated resources.
  14364. */
  14365. dispose(): void;
  14366. }
  14367. }
  14368. declare module BABYLON {
  14369. /**
  14370. * @hidden
  14371. **/
  14372. class _TimeToken {
  14373. _startTimeQuery: Nullable<WebGLQuery>;
  14374. _endTimeQuery: Nullable<WebGLQuery>;
  14375. _timeElapsedQuery: Nullable<WebGLQuery>;
  14376. _timeElapsedQueryEnded: boolean;
  14377. }
  14378. }
  14379. declare module BABYLON {
  14380. /**
  14381. * Effect layer options. This helps customizing the behaviour
  14382. * of the effect layer.
  14383. */
  14384. interface IEffectLayerOptions {
  14385. /**
  14386. * Multiplication factor apply to the canvas size to compute the render target size
  14387. * used to generated the objects (the smaller the faster).
  14388. */
  14389. mainTextureRatio: number;
  14390. /**
  14391. * Enforces a fixed size texture to ensure effect stability across devices.
  14392. */
  14393. mainTextureFixedSize?: number;
  14394. /**
  14395. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  14396. */
  14397. alphaBlendingMode: number;
  14398. /**
  14399. * The camera attached to the layer.
  14400. */
  14401. camera: Nullable<Camera>;
  14402. /**
  14403. * The rendering group to draw the layer in.
  14404. */
  14405. renderingGroupId: number;
  14406. }
  14407. /**
  14408. * The effect layer Helps adding post process effect blended with the main pass.
  14409. *
  14410. * This can be for instance use to generate glow or higlight effects on the scene.
  14411. *
  14412. * The effect layer class can not be used directly and is intented to inherited from to be
  14413. * customized per effects.
  14414. */
  14415. abstract class EffectLayer {
  14416. private _vertexBuffers;
  14417. private _indexBuffer;
  14418. private _cachedDefines;
  14419. private _effectLayerMapGenerationEffect;
  14420. private _effectLayerOptions;
  14421. private _mergeEffect;
  14422. protected _scene: Scene;
  14423. protected _engine: Engine;
  14424. protected _maxSize: number;
  14425. protected _mainTextureDesiredSize: ISize;
  14426. protected _mainTexture: RenderTargetTexture;
  14427. protected _shouldRender: boolean;
  14428. protected _postProcesses: PostProcess[];
  14429. protected _textures: BaseTexture[];
  14430. protected _emissiveTextureAndColor: {
  14431. texture: Nullable<BaseTexture>;
  14432. color: Color4;
  14433. };
  14434. /**
  14435. * The name of the layer
  14436. */
  14437. name: string;
  14438. /**
  14439. * The clear color of the texture used to generate the glow map.
  14440. */
  14441. neutralColor: Color4;
  14442. /**
  14443. * Specifies wether the highlight layer is enabled or not.
  14444. */
  14445. isEnabled: boolean;
  14446. /**
  14447. * Gets the camera attached to the layer.
  14448. */
  14449. readonly camera: Nullable<Camera>;
  14450. /**
  14451. * Gets the rendering group id the layer should render in.
  14452. */
  14453. readonly renderingGroupId: number;
  14454. /**
  14455. * An event triggered when the effect layer has been disposed.
  14456. */
  14457. onDisposeObservable: Observable<EffectLayer>;
  14458. /**
  14459. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  14460. */
  14461. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  14462. /**
  14463. * An event triggered when the generated texture is being merged in the scene.
  14464. */
  14465. onBeforeComposeObservable: Observable<EffectLayer>;
  14466. /**
  14467. * An event triggered when the generated texture has been merged in the scene.
  14468. */
  14469. onAfterComposeObservable: Observable<EffectLayer>;
  14470. /**
  14471. * An event triggered when the efffect layer changes its size.
  14472. */
  14473. onSizeChangedObservable: Observable<EffectLayer>;
  14474. /**
  14475. * Instantiates a new effect Layer and references it in the scene.
  14476. * @param name The name of the layer
  14477. * @param scene The scene to use the layer in
  14478. */
  14479. constructor(
  14480. /** The Friendly of the effect in the scene */
  14481. name: string, scene: Scene);
  14482. /**
  14483. * Get the effect name of the layer.
  14484. * @return The effect name
  14485. */
  14486. abstract getEffectName(): string;
  14487. /**
  14488. * Checks for the readiness of the element composing the layer.
  14489. * @param subMesh the mesh to check for
  14490. * @param useInstances specify wether or not to use instances to render the mesh
  14491. * @return true if ready otherwise, false
  14492. */
  14493. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  14494. /**
  14495. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  14496. * @returns true if the effect requires stencil during the main canvas render pass.
  14497. */
  14498. abstract needStencil(): boolean;
  14499. /**
  14500. * Create the merge effect. This is the shader use to blit the information back
  14501. * to the main canvas at the end of the scene rendering.
  14502. * @returns The effect containing the shader used to merge the effect on the main canvas
  14503. */
  14504. protected abstract _createMergeEffect(): Effect;
  14505. /**
  14506. * Creates the render target textures and post processes used in the effect layer.
  14507. */
  14508. protected abstract _createTextureAndPostProcesses(): void;
  14509. /**
  14510. * Implementation specific of rendering the generating effect on the main canvas.
  14511. * @param effect The effect used to render through
  14512. */
  14513. protected abstract _internalRender(effect: Effect): void;
  14514. /**
  14515. * Sets the required values for both the emissive texture and and the main color.
  14516. */
  14517. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  14518. /**
  14519. * Free any resources and references associated to a mesh.
  14520. * Internal use
  14521. * @param mesh The mesh to free.
  14522. */
  14523. abstract _disposeMesh(mesh: Mesh): void;
  14524. /**
  14525. * Serializes this layer (Glow or Highlight for example)
  14526. * @returns a serialized layer object
  14527. */
  14528. abstract serialize?(): any;
  14529. /**
  14530. * Initializes the effect layer with the required options.
  14531. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  14532. */
  14533. protected _init(options: Partial<IEffectLayerOptions>): void;
  14534. /**
  14535. * Generates the index buffer of the full screen quad blending to the main canvas.
  14536. */
  14537. private _generateIndexBuffer;
  14538. /**
  14539. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  14540. */
  14541. private _genrateVertexBuffer;
  14542. /**
  14543. * Sets the main texture desired size which is the closest power of two
  14544. * of the engine canvas size.
  14545. */
  14546. private _setMainTextureSize;
  14547. /**
  14548. * Creates the main texture for the effect layer.
  14549. */
  14550. protected _createMainTexture(): void;
  14551. /**
  14552. * Checks for the readiness of the element composing the layer.
  14553. * @param subMesh the mesh to check for
  14554. * @param useInstances specify wether or not to use instances to render the mesh
  14555. * @param emissiveTexture the associated emissive texture used to generate the glow
  14556. * @return true if ready otherwise, false
  14557. */
  14558. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  14559. /**
  14560. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  14561. */
  14562. render(): void;
  14563. /**
  14564. * Determine if a given mesh will be used in the current effect.
  14565. * @param mesh mesh to test
  14566. * @returns true if the mesh will be used
  14567. */
  14568. hasMesh(mesh: AbstractMesh): boolean;
  14569. /**
  14570. * Returns true if the layer contains information to display, otherwise false.
  14571. * @returns true if the glow layer should be rendered
  14572. */
  14573. shouldRender(): boolean;
  14574. /**
  14575. * Returns true if the mesh should render, otherwise false.
  14576. * @param mesh The mesh to render
  14577. * @returns true if it should render otherwise false
  14578. */
  14579. protected _shouldRenderMesh(mesh: Mesh): boolean;
  14580. /**
  14581. * Returns true if the mesh should render, otherwise false.
  14582. * @param mesh The mesh to render
  14583. * @returns true if it should render otherwise false
  14584. */
  14585. protected _shouldRenderEmissiveTextureForMesh(mesh: Mesh): boolean;
  14586. /**
  14587. * Renders the submesh passed in parameter to the generation map.
  14588. */
  14589. protected _renderSubMesh(subMesh: SubMesh): void;
  14590. /**
  14591. * Rebuild the required buffers.
  14592. * @hidden Internal use only.
  14593. */
  14594. _rebuild(): void;
  14595. /**
  14596. * Dispose only the render target textures and post process.
  14597. */
  14598. private _disposeTextureAndPostProcesses;
  14599. /**
  14600. * Dispose the highlight layer and free resources.
  14601. */
  14602. dispose(): void;
  14603. /**
  14604. * Gets the class name of the effect layer
  14605. * @returns the string with the class name of the effect layer
  14606. */
  14607. getClassName(): string;
  14608. /**
  14609. * Creates an effect layer from parsed effect layer data
  14610. * @param parsedEffectLayer defines effect layer data
  14611. * @param scene defines the current scene
  14612. * @param rootUrl defines the root URL containing the effect layer information
  14613. * @returns a parsed effect Layer
  14614. */
  14615. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  14616. }
  14617. }
  14618. declare module BABYLON {
  14619. interface AbstractScene {
  14620. /**
  14621. * The list of effect layers (highlights/glow) added to the scene
  14622. * @see http://doc.babylonjs.com/how_to/highlight_layer
  14623. * @see http://doc.babylonjs.com/how_to/glow_layer
  14624. */
  14625. effectLayers: Array<EffectLayer>;
  14626. /**
  14627. * Removes the given effect layer from this scene.
  14628. * @param toRemove defines the effect layer to remove
  14629. * @returns the index of the removed effect layer
  14630. */
  14631. removeEffectLayer(toRemove: EffectLayer): number;
  14632. /**
  14633. * Adds the given effect layer to this scene
  14634. * @param newEffectLayer defines the effect layer to add
  14635. */
  14636. addEffectLayer(newEffectLayer: EffectLayer): void;
  14637. }
  14638. /**
  14639. * Defines the layer scene component responsible to manage any effect layers
  14640. * in a given scene.
  14641. */
  14642. class EffectLayerSceneComponent implements ISceneSerializableComponent {
  14643. /**
  14644. * The component name helpfull to identify the component in the list of scene components.
  14645. */
  14646. readonly name: string;
  14647. /**
  14648. * The scene the component belongs to.
  14649. */
  14650. scene: Scene;
  14651. private _engine;
  14652. private _renderEffects;
  14653. private _needStencil;
  14654. private _previousStencilState;
  14655. /**
  14656. * Creates a new instance of the component for the given scene
  14657. * @param scene Defines the scene to register the component in
  14658. */
  14659. constructor(scene: Scene);
  14660. /**
  14661. * Registers the component in a given scene
  14662. */
  14663. register(): void;
  14664. /**
  14665. * Rebuilds the elements related to this component in case of
  14666. * context lost for instance.
  14667. */
  14668. rebuild(): void;
  14669. /**
  14670. * Serializes the component data to the specified json object
  14671. * @param serializationObject The object to serialize to
  14672. */
  14673. serialize(serializationObject: any): void;
  14674. /**
  14675. * Adds all the element from the container to the scene
  14676. * @param container the container holding the elements
  14677. */
  14678. addFromContainer(container: AbstractScene): void;
  14679. /**
  14680. * Removes all the elements in the container from the scene
  14681. * @param container contains the elements to remove
  14682. */
  14683. removeFromContainer(container: AbstractScene): void;
  14684. /**
  14685. * Disposes the component and the associated ressources.
  14686. */
  14687. dispose(): void;
  14688. private _isReadyForMesh;
  14689. private _renderMainTexture;
  14690. private _setStencil;
  14691. private _setStencilBack;
  14692. private _draw;
  14693. private _drawCamera;
  14694. private _drawRenderingGroup;
  14695. }
  14696. }
  14697. declare module BABYLON {
  14698. interface AbstractScene {
  14699. /**
  14700. * Return a the first highlight layer of the scene with a given name.
  14701. * @param name The name of the highlight layer to look for.
  14702. * @return The highlight layer if found otherwise null.
  14703. */
  14704. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  14705. }
  14706. /**
  14707. * Glow layer options. This helps customizing the behaviour
  14708. * of the glow layer.
  14709. */
  14710. interface IGlowLayerOptions {
  14711. /**
  14712. * Multiplication factor apply to the canvas size to compute the render target size
  14713. * used to generated the glowing objects (the smaller the faster).
  14714. */
  14715. mainTextureRatio: number;
  14716. /**
  14717. * Enforces a fixed size texture to ensure resize independant blur.
  14718. */
  14719. mainTextureFixedSize?: number;
  14720. /**
  14721. * How big is the kernel of the blur texture.
  14722. */
  14723. blurKernelSize: number;
  14724. /**
  14725. * The camera attached to the layer.
  14726. */
  14727. camera: Nullable<Camera>;
  14728. /**
  14729. * Enable MSAA by chosing the number of samples.
  14730. */
  14731. mainTextureSamples?: number;
  14732. /**
  14733. * The rendering group to draw the layer in.
  14734. */
  14735. renderingGroupId: number;
  14736. }
  14737. /**
  14738. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  14739. *
  14740. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  14741. * glowy meshes to your scene.
  14742. *
  14743. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  14744. */
  14745. class GlowLayer extends EffectLayer {
  14746. /**
  14747. * Effect Name of the layer.
  14748. */
  14749. static readonly EffectName: string;
  14750. /**
  14751. * The default blur kernel size used for the glow.
  14752. */
  14753. static DefaultBlurKernelSize: number;
  14754. /**
  14755. * The default texture size ratio used for the glow.
  14756. */
  14757. static DefaultTextureRatio: number;
  14758. /**
  14759. * Sets the kernel size of the blur.
  14760. */
  14761. /**
  14762. * Gets the kernel size of the blur.
  14763. */
  14764. blurKernelSize: number;
  14765. /**
  14766. * Sets the glow intensity.
  14767. */
  14768. /**
  14769. * Gets the glow intensity.
  14770. */
  14771. intensity: number;
  14772. private _options;
  14773. private _intensity;
  14774. private _horizontalBlurPostprocess1;
  14775. private _verticalBlurPostprocess1;
  14776. private _horizontalBlurPostprocess2;
  14777. private _verticalBlurPostprocess2;
  14778. private _blurTexture1;
  14779. private _blurTexture2;
  14780. private _postProcesses1;
  14781. private _postProcesses2;
  14782. private _includedOnlyMeshes;
  14783. private _excludedMeshes;
  14784. /**
  14785. * Callback used to let the user override the color selection on a per mesh basis
  14786. */
  14787. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  14788. /**
  14789. * Callback used to let the user override the texture selection on a per mesh basis
  14790. */
  14791. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  14792. /**
  14793. * Instantiates a new glow Layer and references it to the scene.
  14794. * @param name The name of the layer
  14795. * @param scene The scene to use the layer in
  14796. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  14797. */
  14798. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  14799. /**
  14800. * Get the effect name of the layer.
  14801. * @return The effect name
  14802. */
  14803. getEffectName(): string;
  14804. /**
  14805. * Create the merge effect. This is the shader use to blit the information back
  14806. * to the main canvas at the end of the scene rendering.
  14807. */
  14808. protected _createMergeEffect(): Effect;
  14809. /**
  14810. * Creates the render target textures and post processes used in the glow layer.
  14811. */
  14812. protected _createTextureAndPostProcesses(): void;
  14813. /**
  14814. * Checks for the readiness of the element composing the layer.
  14815. * @param subMesh the mesh to check for
  14816. * @param useInstances specify wether or not to use instances to render the mesh
  14817. * @param emissiveTexture the associated emissive texture used to generate the glow
  14818. * @return true if ready otherwise, false
  14819. */
  14820. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  14821. /**
  14822. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  14823. */
  14824. needStencil(): boolean;
  14825. /**
  14826. * Implementation specific of rendering the generating effect on the main canvas.
  14827. * @param effect The effect used to render through
  14828. */
  14829. protected _internalRender(effect: Effect): void;
  14830. /**
  14831. * Sets the required values for both the emissive texture and and the main color.
  14832. */
  14833. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  14834. /**
  14835. * Returns true if the mesh should render, otherwise false.
  14836. * @param mesh The mesh to render
  14837. * @returns true if it should render otherwise false
  14838. */
  14839. protected _shouldRenderMesh(mesh: Mesh): boolean;
  14840. /**
  14841. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  14842. * @param mesh The mesh to exclude from the glow layer
  14843. */
  14844. addExcludedMesh(mesh: Mesh): void;
  14845. /**
  14846. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  14847. * @param mesh The mesh to remove
  14848. */
  14849. removeExcludedMesh(mesh: Mesh): void;
  14850. /**
  14851. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  14852. * @param mesh The mesh to include in the glow layer
  14853. */
  14854. addIncludedOnlyMesh(mesh: Mesh): void;
  14855. /**
  14856. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  14857. * @param mesh The mesh to remove
  14858. */
  14859. removeIncludedOnlyMesh(mesh: Mesh): void;
  14860. /**
  14861. * Determine if a given mesh will be used in the glow layer
  14862. * @param mesh The mesh to test
  14863. * @returns true if the mesh will be highlighted by the current glow layer
  14864. */
  14865. hasMesh(mesh: AbstractMesh): boolean;
  14866. /**
  14867. * Free any resources and references associated to a mesh.
  14868. * Internal use
  14869. * @param mesh The mesh to free.
  14870. * @hidden
  14871. */
  14872. _disposeMesh(mesh: Mesh): void;
  14873. /**
  14874. * Gets the class name of the effect layer
  14875. * @returns the string with the class name of the effect layer
  14876. */
  14877. getClassName(): string;
  14878. /**
  14879. * Serializes this glow layer
  14880. * @returns a serialized glow layer object
  14881. */
  14882. serialize(): any;
  14883. /**
  14884. * Creates a Glow Layer from parsed glow layer data
  14885. * @param parsedGlowLayer defines glow layer data
  14886. * @param scene defines the current scene
  14887. * @param rootUrl defines the root URL containing the glow layer information
  14888. * @returns a parsed Glow Layer
  14889. */
  14890. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  14891. }
  14892. }
  14893. declare module BABYLON {
  14894. interface AbstractScene {
  14895. /**
  14896. * Return a the first highlight layer of the scene with a given name.
  14897. * @param name The name of the highlight layer to look for.
  14898. * @return The highlight layer if found otherwise null.
  14899. */
  14900. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  14901. }
  14902. /**
  14903. * Highlight layer options. This helps customizing the behaviour
  14904. * of the highlight layer.
  14905. */
  14906. interface IHighlightLayerOptions {
  14907. /**
  14908. * Multiplication factor apply to the canvas size to compute the render target size
  14909. * used to generated the glowing objects (the smaller the faster).
  14910. */
  14911. mainTextureRatio: number;
  14912. /**
  14913. * Enforces a fixed size texture to ensure resize independant blur.
  14914. */
  14915. mainTextureFixedSize?: number;
  14916. /**
  14917. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  14918. * of the picture to blur (the smaller the faster).
  14919. */
  14920. blurTextureSizeRatio: number;
  14921. /**
  14922. * How big in texel of the blur texture is the vertical blur.
  14923. */
  14924. blurVerticalSize: number;
  14925. /**
  14926. * How big in texel of the blur texture is the horizontal blur.
  14927. */
  14928. blurHorizontalSize: number;
  14929. /**
  14930. * Alpha blending mode used to apply the blur. Default is combine.
  14931. */
  14932. alphaBlendingMode: number;
  14933. /**
  14934. * The camera attached to the layer.
  14935. */
  14936. camera: Nullable<Camera>;
  14937. /**
  14938. * Should we display highlight as a solid stroke?
  14939. */
  14940. isStroke?: boolean;
  14941. /**
  14942. * The rendering group to draw the layer in.
  14943. */
  14944. renderingGroupId: number;
  14945. }
  14946. /**
  14947. * The highlight layer Helps adding a glow effect around a mesh.
  14948. *
  14949. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  14950. * glowy meshes to your scene.
  14951. *
  14952. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  14953. */
  14954. class HighlightLayer extends EffectLayer {
  14955. name: string;
  14956. /**
  14957. * Effect Name of the highlight layer.
  14958. */
  14959. static readonly EffectName: string;
  14960. /**
  14961. * The neutral color used during the preparation of the glow effect.
  14962. * This is black by default as the blend operation is a blend operation.
  14963. */
  14964. static NeutralColor: Color4;
  14965. /**
  14966. * Stencil value used for glowing meshes.
  14967. */
  14968. static GlowingMeshStencilReference: number;
  14969. /**
  14970. * Stencil value used for the other meshes in the scene.
  14971. */
  14972. static NormalMeshStencilReference: number;
  14973. /**
  14974. * Specifies whether or not the inner glow is ACTIVE in the layer.
  14975. */
  14976. innerGlow: boolean;
  14977. /**
  14978. * Specifies whether or not the outer glow is ACTIVE in the layer.
  14979. */
  14980. outerGlow: boolean;
  14981. /**
  14982. * Specifies the horizontal size of the blur.
  14983. */
  14984. /**
  14985. * Gets the horizontal size of the blur.
  14986. */
  14987. blurHorizontalSize: number;
  14988. /**
  14989. * Specifies the vertical size of the blur.
  14990. */
  14991. /**
  14992. * Gets the vertical size of the blur.
  14993. */
  14994. blurVerticalSize: number;
  14995. /**
  14996. * An event triggered when the highlight layer is being blurred.
  14997. */
  14998. onBeforeBlurObservable: Observable<HighlightLayer>;
  14999. /**
  15000. * An event triggered when the highlight layer has been blurred.
  15001. */
  15002. onAfterBlurObservable: Observable<HighlightLayer>;
  15003. private _instanceGlowingMeshStencilReference;
  15004. private _options;
  15005. private _downSamplePostprocess;
  15006. private _horizontalBlurPostprocess;
  15007. private _verticalBlurPostprocess;
  15008. private _blurTexture;
  15009. private _meshes;
  15010. private _excludedMeshes;
  15011. /**
  15012. * Instantiates a new highlight Layer and references it to the scene..
  15013. * @param name The name of the layer
  15014. * @param scene The scene to use the layer in
  15015. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  15016. */
  15017. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  15018. /**
  15019. * Get the effect name of the layer.
  15020. * @return The effect name
  15021. */
  15022. getEffectName(): string;
  15023. /**
  15024. * Create the merge effect. This is the shader use to blit the information back
  15025. * to the main canvas at the end of the scene rendering.
  15026. */
  15027. protected _createMergeEffect(): Effect;
  15028. /**
  15029. * Creates the render target textures and post processes used in the highlight layer.
  15030. */
  15031. protected _createTextureAndPostProcesses(): void;
  15032. /**
  15033. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  15034. */
  15035. needStencil(): boolean;
  15036. /**
  15037. * Checks for the readiness of the element composing the layer.
  15038. * @param subMesh the mesh to check for
  15039. * @param useInstances specify wether or not to use instances to render the mesh
  15040. * @param emissiveTexture the associated emissive texture used to generate the glow
  15041. * @return true if ready otherwise, false
  15042. */
  15043. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  15044. /**
  15045. * Implementation specific of rendering the generating effect on the main canvas.
  15046. * @param effect The effect used to render through
  15047. */
  15048. protected _internalRender(effect: Effect): void;
  15049. /**
  15050. * Returns true if the layer contains information to display, otherwise false.
  15051. */
  15052. shouldRender(): boolean;
  15053. /**
  15054. * Returns true if the mesh should render, otherwise false.
  15055. * @param mesh The mesh to render
  15056. * @returns true if it should render otherwise false
  15057. */
  15058. protected _shouldRenderMesh(mesh: Mesh): boolean;
  15059. /**
  15060. * Sets the required values for both the emissive texture and and the main color.
  15061. */
  15062. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  15063. /**
  15064. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  15065. * @param mesh The mesh to exclude from the highlight layer
  15066. */
  15067. addExcludedMesh(mesh: Mesh): void;
  15068. /**
  15069. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  15070. * @param mesh The mesh to highlight
  15071. */
  15072. removeExcludedMesh(mesh: Mesh): void;
  15073. /**
  15074. * Determine if a given mesh will be highlighted by the current HighlightLayer
  15075. * @param mesh mesh to test
  15076. * @returns true if the mesh will be highlighted by the current HighlightLayer
  15077. */
  15078. hasMesh(mesh: AbstractMesh): boolean;
  15079. /**
  15080. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  15081. * @param mesh The mesh to highlight
  15082. * @param color The color of the highlight
  15083. * @param glowEmissiveOnly Extract the glow from the emissive texture
  15084. */
  15085. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  15086. /**
  15087. * Remove a mesh from the highlight layer in order to make it stop glowing.
  15088. * @param mesh The mesh to highlight
  15089. */
  15090. removeMesh(mesh: Mesh): void;
  15091. /**
  15092. * Force the stencil to the normal expected value for none glowing parts
  15093. */
  15094. private _defaultStencilReference;
  15095. /**
  15096. * Free any resources and references associated to a mesh.
  15097. * Internal use
  15098. * @param mesh The mesh to free.
  15099. * @hidden
  15100. */
  15101. _disposeMesh(mesh: Mesh): void;
  15102. /**
  15103. * Dispose the highlight layer and free resources.
  15104. */
  15105. dispose(): void;
  15106. /**
  15107. * Gets the class name of the effect layer
  15108. * @returns the string with the class name of the effect layer
  15109. */
  15110. getClassName(): string;
  15111. /**
  15112. * Serializes this Highlight layer
  15113. * @returns a serialized Highlight layer object
  15114. */
  15115. serialize(): any;
  15116. /**
  15117. * Creates a Highlight layer from parsed Highlight layer data
  15118. * @param parsedHightlightLayer defines the Highlight layer data
  15119. * @param scene defines the current scene
  15120. * @param rootUrl defines the root URL containing the Highlight layer information
  15121. * @returns a parsed Highlight layer
  15122. */
  15123. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  15124. }
  15125. }
  15126. declare module BABYLON {
  15127. /**
  15128. * This represents a full screen 2d layer.
  15129. * This can be useful to display a picture in the background of your scene for instance.
  15130. * @see https://www.babylonjs-playground.com/#08A2BS#1
  15131. */
  15132. class Layer {
  15133. /**
  15134. * Define the name of the layer.
  15135. */
  15136. name: string;
  15137. /**
  15138. * Define the texture the layer should display.
  15139. */
  15140. texture: Nullable<Texture>;
  15141. /**
  15142. * Is the layer in background or foreground.
  15143. */
  15144. isBackground: boolean;
  15145. /**
  15146. * Define the color of the layer (instead of texture).
  15147. */
  15148. color: Color4;
  15149. /**
  15150. * Define the scale of the layer in order to zoom in out of the texture.
  15151. */
  15152. scale: Vector2;
  15153. /**
  15154. * Define an offset for the layer in order to shift the texture.
  15155. */
  15156. offset: Vector2;
  15157. /**
  15158. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  15159. */
  15160. alphaBlendingMode: number;
  15161. /**
  15162. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  15163. * Alpha test will not mix with the background color in case of transparency.
  15164. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  15165. */
  15166. alphaTest: boolean;
  15167. /**
  15168. * Define a mask to restrict the layer to only some of the scene cameras.
  15169. */
  15170. layerMask: number;
  15171. /**
  15172. * Define the list of render target the layer is visible into.
  15173. */
  15174. renderTargetTextures: RenderTargetTexture[];
  15175. /**
  15176. * Define if the layer is only used in renderTarget or if it also
  15177. * renders in the main frame buffer of the canvas.
  15178. */
  15179. renderOnlyInRenderTargetTextures: boolean;
  15180. private _scene;
  15181. private _vertexBuffers;
  15182. private _indexBuffer;
  15183. private _effect;
  15184. private _alphaTestEffect;
  15185. /**
  15186. * An event triggered when the layer is disposed.
  15187. */
  15188. onDisposeObservable: Observable<Layer>;
  15189. private _onDisposeObserver;
  15190. /**
  15191. * Back compatibility with callback before the onDisposeObservable existed.
  15192. * The set callback will be triggered when the layer has been disposed.
  15193. */
  15194. onDispose: () => void;
  15195. /**
  15196. * An event triggered before rendering the scene
  15197. */
  15198. onBeforeRenderObservable: Observable<Layer>;
  15199. private _onBeforeRenderObserver;
  15200. /**
  15201. * Back compatibility with callback before the onBeforeRenderObservable existed.
  15202. * The set callback will be triggered just before rendering the layer.
  15203. */
  15204. onBeforeRender: () => void;
  15205. /**
  15206. * An event triggered after rendering the scene
  15207. */
  15208. onAfterRenderObservable: Observable<Layer>;
  15209. private _onAfterRenderObserver;
  15210. /**
  15211. * Back compatibility with callback before the onAfterRenderObservable existed.
  15212. * The set callback will be triggered just after rendering the layer.
  15213. */
  15214. onAfterRender: () => void;
  15215. /**
  15216. * Instantiates a new layer.
  15217. * This represents a full screen 2d layer.
  15218. * This can be useful to display a picture in the background of your scene for instance.
  15219. * @see https://www.babylonjs-playground.com/#08A2BS#1
  15220. * @param name Define the name of the layer in the scene
  15221. * @param imgUrl Define the url of the texture to display in the layer
  15222. * @param scene Define the scene the layer belongs to
  15223. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  15224. * @param color Defines a color for the layer
  15225. */
  15226. constructor(
  15227. /**
  15228. * Define the name of the layer.
  15229. */
  15230. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  15231. private _createIndexBuffer;
  15232. /** @hidden */
  15233. _rebuild(): void;
  15234. /**
  15235. * Renders the layer in the scene.
  15236. */
  15237. render(): void;
  15238. /**
  15239. * Disposes and releases the associated ressources.
  15240. */
  15241. dispose(): void;
  15242. }
  15243. }
  15244. declare module BABYLON {
  15245. interface AbstractScene {
  15246. /**
  15247. * The list of layers (background and foreground) of the scene
  15248. */
  15249. layers: Array<Layer>;
  15250. }
  15251. /**
  15252. * Defines the layer scene component responsible to manage any layers
  15253. * in a given scene.
  15254. */
  15255. class LayerSceneComponent implements ISceneComponent {
  15256. /**
  15257. * The component name helpfull to identify the component in the list of scene components.
  15258. */
  15259. readonly name: string;
  15260. /**
  15261. * The scene the component belongs to.
  15262. */
  15263. scene: Scene;
  15264. private _engine;
  15265. /**
  15266. * Creates a new instance of the component for the given scene
  15267. * @param scene Defines the scene to register the component in
  15268. */
  15269. constructor(scene: Scene);
  15270. /**
  15271. * Registers the component in a given scene
  15272. */
  15273. register(): void;
  15274. /**
  15275. * Rebuilds the elements related to this component in case of
  15276. * context lost for instance.
  15277. */
  15278. rebuild(): void;
  15279. /**
  15280. * Disposes the component and the associated ressources.
  15281. */
  15282. dispose(): void;
  15283. private _draw;
  15284. private _drawCameraPredicate;
  15285. private _drawCameraBackground;
  15286. private _drawCameraForeground;
  15287. private _drawRenderTargetPredicate;
  15288. private _drawRenderTargetBackground;
  15289. private _drawRenderTargetForeground;
  15290. }
  15291. }
  15292. declare module BABYLON {
  15293. /**
  15294. * This represents one of the lens effect in a `BABYLON.lensFlareSystem`.
  15295. * It controls one of the indiviual texture used in the effect.
  15296. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15297. */
  15298. class LensFlare {
  15299. /**
  15300. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  15301. */
  15302. size: number;
  15303. /**
  15304. * Define the position of the lens flare in the system. (a floating value between -1 and 1). A value of 0 is located on the emitter. A value greater than 0 is beyond the emitter and a value lesser than 0 is behind.
  15305. */
  15306. position: number;
  15307. /**
  15308. * Define the lens color.
  15309. */
  15310. color: Color3;
  15311. /**
  15312. * Define the lens texture.
  15313. */
  15314. texture: Nullable<Texture>;
  15315. /**
  15316. * Define the alpha mode to render this particular lens.
  15317. */
  15318. alphaMode: number;
  15319. private _system;
  15320. /**
  15321. * Creates a new Lens Flare.
  15322. * This represents one of the lens effect in a `BABYLON.lensFlareSystem`.
  15323. * It controls one of the indiviual texture used in the effect.
  15324. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15325. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  15326. * @param position Define the position of the lens flare in the system. (a floating value between -1 and 1). A value of 0 is located on the emitter. A value greater than 0 is beyond the emitter and a value lesser than 0 is behind.
  15327. * @param color Define the lens color
  15328. * @param imgUrl Define the lens texture url
  15329. * @param system Define the `lensFlareSystem` this flare is part of
  15330. * @returns The newly created Lens Flare
  15331. */
  15332. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  15333. /**
  15334. * Instantiates a new Lens Flare.
  15335. * This represents one of the lens effect in a `BABYLON.lensFlareSystem`.
  15336. * It controls one of the indiviual texture used in the effect.
  15337. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15338. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  15339. * @param position Define the position of the lens flare in the system. (a floating value between -1 and 1). A value of 0 is located on the emitter. A value greater than 0 is beyond the emitter and a value lesser than 0 is behind.
  15340. * @param color Define the lens color
  15341. * @param imgUrl Define the lens texture url
  15342. * @param system Define the `lensFlareSystem` this flare is part of
  15343. */
  15344. constructor(
  15345. /**
  15346. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  15347. */
  15348. size: number,
  15349. /**
  15350. * Define the position of the lens flare in the system. (a floating value between -1 and 1). A value of 0 is located on the emitter. A value greater than 0 is beyond the emitter and a value lesser than 0 is behind.
  15351. */
  15352. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  15353. /**
  15354. * Dispose and release the lens flare with its associated resources.
  15355. */
  15356. dispose(): void;
  15357. }
  15358. }
  15359. declare module BABYLON {
  15360. /**
  15361. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  15362. * It is usually composed of several `BABYLON.lensFlare`.
  15363. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15364. */
  15365. class LensFlareSystem {
  15366. /**
  15367. * Define the name of the lens flare system
  15368. */
  15369. name: string;
  15370. /**
  15371. * List of lens flares used in this system.
  15372. */
  15373. lensFlares: LensFlare[];
  15374. /**
  15375. * Define a limit from the border the lens flare can be visible.
  15376. */
  15377. borderLimit: number;
  15378. /**
  15379. * Define a viewport border we do not want to see the lens flare in.
  15380. */
  15381. viewportBorder: number;
  15382. /**
  15383. * Define a predicate which could limit the list of meshes able to occlude the effect.
  15384. */
  15385. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  15386. /**
  15387. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  15388. */
  15389. layerMask: number;
  15390. /**
  15391. * Define the id of the lens flare system in the scene.
  15392. * (equal to name by default)
  15393. */
  15394. id: string;
  15395. private _scene;
  15396. private _emitter;
  15397. private _vertexBuffers;
  15398. private _indexBuffer;
  15399. private _effect;
  15400. private _positionX;
  15401. private _positionY;
  15402. private _isEnabled;
  15403. /**
  15404. * Instantiates a lens flare system.
  15405. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  15406. * It is usually composed of several `BABYLON.lensFlare`.
  15407. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15408. * @param name Define the name of the lens flare system in the scene
  15409. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  15410. * @param scene Define the scene the lens flare system belongs to
  15411. */
  15412. constructor(
  15413. /**
  15414. * Define the name of the lens flare system
  15415. */
  15416. name: string, emitter: any, scene: Scene);
  15417. /**
  15418. * Define if the lens flare system is enabled.
  15419. */
  15420. isEnabled: boolean;
  15421. /**
  15422. * Get the scene the effects belongs to.
  15423. * @returns the scene holding the lens flare system
  15424. */
  15425. getScene(): Scene;
  15426. /**
  15427. * Get the emitter of the lens flare system.
  15428. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  15429. * @returns the emitter of the lens flare system
  15430. */
  15431. getEmitter(): any;
  15432. /**
  15433. * Set the emitter of the lens flare system.
  15434. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  15435. * @param newEmitter Define the new emitter of the system
  15436. */
  15437. setEmitter(newEmitter: any): void;
  15438. /**
  15439. * Get the lens flare system emitter position.
  15440. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  15441. * @returns the position
  15442. */
  15443. getEmitterPosition(): Vector3;
  15444. /**
  15445. * @hidden
  15446. */
  15447. computeEffectivePosition(globalViewport: Viewport): boolean;
  15448. /** @hidden */
  15449. _isVisible(): boolean;
  15450. /**
  15451. * @hidden
  15452. */
  15453. render(): boolean;
  15454. /**
  15455. * Dispose and release the lens flare with its associated resources.
  15456. */
  15457. dispose(): void;
  15458. /**
  15459. * Parse a lens flare system from a JSON repressentation
  15460. * @param parsedLensFlareSystem Define the JSON to parse
  15461. * @param scene Define the scene the parsed system should be instantiated in
  15462. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  15463. * @returns the parsed system
  15464. */
  15465. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  15466. /**
  15467. * Serialize the current Lens Flare System into a JSON representation.
  15468. * @returns the serialized JSON
  15469. */
  15470. serialize(): any;
  15471. }
  15472. }
  15473. declare module BABYLON {
  15474. interface AbstractScene {
  15475. /**
  15476. * The list of lens flare system added to the scene
  15477. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15478. */
  15479. lensFlareSystems: Array<LensFlareSystem>;
  15480. /**
  15481. * Removes the given lens flare system from this scene.
  15482. * @param toRemove The lens flare system to remove
  15483. * @returns The index of the removed lens flare system
  15484. */
  15485. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  15486. /**
  15487. * Adds the given lens flare system to this scene
  15488. * @param newLensFlareSystem The lens flare system to add
  15489. */
  15490. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  15491. /**
  15492. * Gets a lens flare system using its name
  15493. * @param name defines the name to look for
  15494. * @returns the lens flare system or null if not found
  15495. */
  15496. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  15497. /**
  15498. * Gets a lens flare system using its id
  15499. * @param id defines the id to look for
  15500. * @returns the lens flare system or null if not found
  15501. */
  15502. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  15503. }
  15504. /**
  15505. * Defines the lens flare scene component responsible to manage any lens flares
  15506. * in a given scene.
  15507. */
  15508. class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  15509. /**
  15510. * The component name helpfull to identify the component in the list of scene components.
  15511. */
  15512. readonly name: string;
  15513. /**
  15514. * The scene the component belongs to.
  15515. */
  15516. scene: Scene;
  15517. /**
  15518. * Creates a new instance of the component for the given scene
  15519. * @param scene Defines the scene to register the component in
  15520. */
  15521. constructor(scene: Scene);
  15522. /**
  15523. * Registers the component in a given scene
  15524. */
  15525. register(): void;
  15526. /**
  15527. * Rebuilds the elements related to this component in case of
  15528. * context lost for instance.
  15529. */
  15530. rebuild(): void;
  15531. /**
  15532. * Adds all the element from the container to the scene
  15533. * @param container the container holding the elements
  15534. */
  15535. addFromContainer(container: AbstractScene): void;
  15536. /**
  15537. * Removes all the elements in the container from the scene
  15538. * @param container contains the elements to remove
  15539. */
  15540. removeFromContainer(container: AbstractScene): void;
  15541. /**
  15542. * Serializes the component data to the specified json object
  15543. * @param serializationObject The object to serialize to
  15544. */
  15545. serialize(serializationObject: any): void;
  15546. /**
  15547. * Disposes the component and the associated ressources.
  15548. */
  15549. dispose(): void;
  15550. private _draw;
  15551. }
  15552. }
  15553. declare module BABYLON {
  15554. /**
  15555. * A directional light is defined by a direction (what a surprise!).
  15556. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  15557. * An example of a directional light is when a distance planet is lit by the apparently parallel lines of light from its sun. Light in a downward direction will light the top of an object.
  15558. * Documentation: https://doc.babylonjs.com/babylon101/lights
  15559. */
  15560. class DirectionalLight extends ShadowLight {
  15561. private _shadowFrustumSize;
  15562. /**
  15563. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  15564. */
  15565. /**
  15566. * Specifies a fix frustum size for the shadow generation.
  15567. */
  15568. shadowFrustumSize: number;
  15569. private _shadowOrthoScale;
  15570. /**
  15571. * Gets the shadow projection scale against the optimal computed one.
  15572. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  15573. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  15574. */
  15575. /**
  15576. * Sets the shadow projection scale against the optimal computed one.
  15577. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  15578. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  15579. */
  15580. shadowOrthoScale: number;
  15581. /**
  15582. * Automatically compute the projection matrix to best fit (including all the casters)
  15583. * on each frame.
  15584. */
  15585. autoUpdateExtends: boolean;
  15586. private _orthoLeft;
  15587. private _orthoRight;
  15588. private _orthoTop;
  15589. private _orthoBottom;
  15590. /**
  15591. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  15592. * The directional light is emitted from everywhere in the given direction.
  15593. * It can cast shadows.
  15594. * Documentation : https://doc.babylonjs.com/babylon101/lights
  15595. * @param name The friendly name of the light
  15596. * @param direction The direction of the light
  15597. * @param scene The scene the light belongs to
  15598. */
  15599. constructor(name: string, direction: Vector3, scene: Scene);
  15600. /**
  15601. * Returns the string "DirectionalLight".
  15602. * @return The class name
  15603. */
  15604. getClassName(): string;
  15605. /**
  15606. * Returns the integer 1.
  15607. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15608. */
  15609. getTypeID(): number;
  15610. /**
  15611. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  15612. * Returns the DirectionalLight Shadow projection matrix.
  15613. */
  15614. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  15615. /**
  15616. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  15617. * Returns the DirectionalLight Shadow projection matrix.
  15618. */
  15619. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix): void;
  15620. /**
  15621. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  15622. * Returns the DirectionalLight Shadow projection matrix.
  15623. */
  15624. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  15625. protected _buildUniformLayout(): void;
  15626. /**
  15627. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  15628. * @param effect The effect to update
  15629. * @param lightIndex The index of the light in the effect to update
  15630. * @returns The directional light
  15631. */
  15632. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  15633. /**
  15634. * Gets the minZ used for shadow according to both the scene and the light.
  15635. *
  15636. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  15637. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  15638. * @param activeCamera The camera we are returning the min for
  15639. * @returns the depth min z
  15640. */
  15641. getDepthMinZ(activeCamera: Camera): number;
  15642. /**
  15643. * Gets the maxZ used for shadow according to both the scene and the light.
  15644. *
  15645. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  15646. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  15647. * @param activeCamera The camera we are returning the max for
  15648. * @returns the depth max z
  15649. */
  15650. getDepthMaxZ(activeCamera: Camera): number;
  15651. /**
  15652. * Prepares the list of defines specific to the light type.
  15653. * @param defines the list of defines
  15654. * @param lightIndex defines the index of the light for the effect
  15655. */
  15656. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15657. }
  15658. }
  15659. declare module BABYLON {
  15660. /**
  15661. * The HemisphericLight simulates the ambient environment light,
  15662. * so the passed direction is the light reflection direction, not the incoming direction.
  15663. */
  15664. class HemisphericLight extends Light {
  15665. /**
  15666. * The groundColor is the light in the opposite direction to the one specified during creation.
  15667. * You can think of the diffuse and specular light as coming from the centre of the object in the given direction and the groundColor light in the opposite direction.
  15668. */
  15669. groundColor: Color3;
  15670. /**
  15671. * The light reflection direction, not the incoming direction.
  15672. */
  15673. direction: Vector3;
  15674. /**
  15675. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  15676. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  15677. * The HemisphericLight can't cast shadows.
  15678. * Documentation : https://doc.babylonjs.com/babylon101/lights
  15679. * @param name The friendly name of the light
  15680. * @param direction The direction of the light reflection
  15681. * @param scene The scene the light belongs to
  15682. */
  15683. constructor(name: string, direction: Vector3, scene: Scene);
  15684. protected _buildUniformLayout(): void;
  15685. /**
  15686. * Returns the string "HemisphericLight".
  15687. * @return The class name
  15688. */
  15689. getClassName(): string;
  15690. /**
  15691. * Sets the HemisphericLight direction towards the passed target (Vector3).
  15692. * Returns the updated direction.
  15693. * @param target The target the direction should point to
  15694. * @return The computed direction
  15695. */
  15696. setDirectionToTarget(target: Vector3): Vector3;
  15697. /**
  15698. * Returns the shadow generator associated to the light.
  15699. * @returns Always null for hemispheric lights because it does not support shadows.
  15700. */
  15701. getShadowGenerator(): Nullable<IShadowGenerator>;
  15702. /**
  15703. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  15704. * @param effect The effect to update
  15705. * @param lightIndex The index of the light in the effect to update
  15706. * @returns The hemispheric light
  15707. */
  15708. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  15709. /**
  15710. * Computes the world matrix of the node
  15711. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15712. * @param useWasUpdatedFlag defines a reserved property
  15713. * @returns the world matrix
  15714. */
  15715. computeWorldMatrix(force?: boolean, useWasUpdatedFlag?: boolean): Matrix;
  15716. /**
  15717. * Returns the integer 3.
  15718. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15719. */
  15720. getTypeID(): number;
  15721. /**
  15722. * Prepares the list of defines specific to the light type.
  15723. * @param defines the list of defines
  15724. * @param lightIndex defines the index of the light for the effect
  15725. */
  15726. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15727. }
  15728. }
  15729. declare module BABYLON {
  15730. /**
  15731. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  15732. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  15733. * All meshes allow light to pass through them unless shadow generation is activated. The default number of lights allowed is four but this can be increased.
  15734. */
  15735. abstract class Light extends Node {
  15736. /**
  15737. * Falloff Default: light is falling off following the material specification:
  15738. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  15739. */
  15740. static readonly FALLOFF_DEFAULT: number;
  15741. /**
  15742. * Falloff Physical: light is falling off following the inverse squared distance law.
  15743. */
  15744. static readonly FALLOFF_PHYSICAL: number;
  15745. /**
  15746. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  15747. * to enhance interoperability with other engines.
  15748. */
  15749. static readonly FALLOFF_GLTF: number;
  15750. /**
  15751. * Falloff Standard: light is falling off like in the standard material
  15752. * to enhance interoperability with other materials.
  15753. */
  15754. static readonly FALLOFF_STANDARD: number;
  15755. /**
  15756. * If every light affecting the material is in this lightmapMode,
  15757. * material.lightmapTexture adds or multiplies
  15758. * (depends on material.useLightmapAsShadowmap)
  15759. * after every other light calculations.
  15760. */
  15761. static readonly LIGHTMAP_DEFAULT: number;
  15762. /**
  15763. * material.lightmapTexture as only diffuse lighting from this light
  15764. * adds only specular lighting from this light
  15765. * adds dynamic shadows
  15766. */
  15767. static readonly LIGHTMAP_SPECULAR: number;
  15768. /**
  15769. * material.lightmapTexture as only lighting
  15770. * no light calculation from this light
  15771. * only adds dynamic shadows from this light
  15772. */
  15773. static readonly LIGHTMAP_SHADOWSONLY: number;
  15774. /**
  15775. * Each light type uses the default quantity according to its type:
  15776. * point/spot lights use luminous intensity
  15777. * directional lights use illuminance
  15778. */
  15779. static readonly INTENSITYMODE_AUTOMATIC: number;
  15780. /**
  15781. * lumen (lm)
  15782. */
  15783. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  15784. /**
  15785. * candela (lm/sr)
  15786. */
  15787. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  15788. /**
  15789. * lux (lm/m^2)
  15790. */
  15791. static readonly INTENSITYMODE_ILLUMINANCE: number;
  15792. /**
  15793. * nit (cd/m^2)
  15794. */
  15795. static readonly INTENSITYMODE_LUMINANCE: number;
  15796. /**
  15797. * Light type const id of the point light.
  15798. */
  15799. static readonly LIGHTTYPEID_POINTLIGHT: number;
  15800. /**
  15801. * Light type const id of the directional light.
  15802. */
  15803. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  15804. /**
  15805. * Light type const id of the spot light.
  15806. */
  15807. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  15808. /**
  15809. * Light type const id of the hemispheric light.
  15810. */
  15811. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  15812. /**
  15813. * Diffuse gives the basic color to an object.
  15814. */
  15815. diffuse: Color3;
  15816. /**
  15817. * Specular produces a highlight color on an object.
  15818. * Note: This is note affecting PBR materials.
  15819. */
  15820. specular: Color3;
  15821. /**
  15822. * Defines the falloff type for this light. This lets overrriding how punctual light are
  15823. * falling off base on range or angle.
  15824. * This can be set to any values in Light.FALLOFF_x.
  15825. *
  15826. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  15827. * other types of materials.
  15828. */
  15829. falloffType: number;
  15830. /**
  15831. * Strength of the light.
  15832. * Note: By default it is define in the framework own unit.
  15833. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  15834. */
  15835. intensity: number;
  15836. private _range;
  15837. protected _inverseSquaredRange: number;
  15838. /**
  15839. * Defines how far from the source the light is impacting in scene units.
  15840. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  15841. */
  15842. /**
  15843. * Defines how far from the source the light is impacting in scene units.
  15844. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  15845. */
  15846. range: number;
  15847. /**
  15848. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  15849. * of light.
  15850. */
  15851. private _photometricScale;
  15852. private _intensityMode;
  15853. /**
  15854. * Gets the photometric scale used to interpret the intensity.
  15855. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  15856. */
  15857. /**
  15858. * Sets the photometric scale used to interpret the intensity.
  15859. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  15860. */
  15861. intensityMode: number;
  15862. private _radius;
  15863. /**
  15864. * Gets the light radius used by PBR Materials to simulate soft area lights.
  15865. */
  15866. /**
  15867. * sets the light radius used by PBR Materials to simulate soft area lights.
  15868. */
  15869. radius: number;
  15870. private _renderPriority;
  15871. /**
  15872. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  15873. * exceeding the number allowed of the materials.
  15874. */
  15875. renderPriority: number;
  15876. private _shadowEnabled;
  15877. /**
  15878. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  15879. * the current shadow generator.
  15880. */
  15881. /**
  15882. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  15883. * the current shadow generator.
  15884. */
  15885. shadowEnabled: boolean;
  15886. private _includedOnlyMeshes;
  15887. /**
  15888. * Gets the only meshes impacted by this light.
  15889. */
  15890. /**
  15891. * Sets the only meshes impacted by this light.
  15892. */
  15893. includedOnlyMeshes: AbstractMesh[];
  15894. private _excludedMeshes;
  15895. /**
  15896. * Gets the meshes not impacted by this light.
  15897. */
  15898. /**
  15899. * Sets the meshes not impacted by this light.
  15900. */
  15901. excludedMeshes: AbstractMesh[];
  15902. private _excludeWithLayerMask;
  15903. /**
  15904. * Gets the layer id use to find what meshes are not impacted by the light.
  15905. * Inactive if 0
  15906. */
  15907. /**
  15908. * Sets the layer id use to find what meshes are not impacted by the light.
  15909. * Inactive if 0
  15910. */
  15911. excludeWithLayerMask: number;
  15912. private _includeOnlyWithLayerMask;
  15913. /**
  15914. * Gets the layer id use to find what meshes are impacted by the light.
  15915. * Inactive if 0
  15916. */
  15917. /**
  15918. * Sets the layer id use to find what meshes are impacted by the light.
  15919. * Inactive if 0
  15920. */
  15921. includeOnlyWithLayerMask: number;
  15922. private _lightmapMode;
  15923. /**
  15924. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  15925. */
  15926. /**
  15927. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  15928. */
  15929. lightmapMode: number;
  15930. /**
  15931. * Shadow generator associted to the light.
  15932. * @hidden Internal use only.
  15933. */
  15934. _shadowGenerator: Nullable<IShadowGenerator>;
  15935. /**
  15936. * @hidden Internal use only.
  15937. */
  15938. _excludedMeshesIds: string[];
  15939. /**
  15940. * @hidden Internal use only.
  15941. */
  15942. _includedOnlyMeshesIds: string[];
  15943. /**
  15944. * The current light unifom buffer.
  15945. * @hidden Internal use only.
  15946. */
  15947. _uniformBuffer: UniformBuffer;
  15948. /**
  15949. * Creates a Light object in the scene.
  15950. * Documentation : https://doc.babylonjs.com/babylon101/lights
  15951. * @param name The firendly name of the light
  15952. * @param scene The scene the light belongs too
  15953. */
  15954. constructor(name: string, scene: Scene);
  15955. protected abstract _buildUniformLayout(): void;
  15956. /**
  15957. * Sets the passed Effect "effect" with the Light information.
  15958. * @param effect The effect to update
  15959. * @param lightIndex The index of the light in the effect to update
  15960. * @returns The light
  15961. */
  15962. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  15963. /**
  15964. * Returns the string "Light".
  15965. * @returns the class name
  15966. */
  15967. getClassName(): string;
  15968. /**
  15969. * Converts the light information to a readable string for debug purpose.
  15970. * @param fullDetails Supports for multiple levels of logging within scene loading
  15971. * @returns the human readable light info
  15972. */
  15973. toString(fullDetails?: boolean): string;
  15974. /** @hidden */
  15975. protected _syncParentEnabledState(): void;
  15976. /**
  15977. * Set the enabled state of this node.
  15978. * @param value - the new enabled state
  15979. */
  15980. setEnabled(value: boolean): void;
  15981. /**
  15982. * Returns the Light associated shadow generator if any.
  15983. * @return the associated shadow generator.
  15984. */
  15985. getShadowGenerator(): Nullable<IShadowGenerator>;
  15986. /**
  15987. * Returns a Vector3, the absolute light position in the World.
  15988. * @returns the world space position of the light
  15989. */
  15990. getAbsolutePosition(): Vector3;
  15991. /**
  15992. * Specifies if the light will affect the passed mesh.
  15993. * @param mesh The mesh to test against the light
  15994. * @return true the mesh is affected otherwise, false.
  15995. */
  15996. canAffectMesh(mesh: AbstractMesh): boolean;
  15997. /**
  15998. * Sort function to order lights for rendering.
  15999. * @param a First Light object to compare to second.
  16000. * @param b Second Light object to compare first.
  16001. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  16002. */
  16003. static CompareLightsPriority(a: Light, b: Light): number;
  16004. /**
  16005. * Releases resources associated with this node.
  16006. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  16007. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  16008. */
  16009. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16010. /**
  16011. * Returns the light type ID (integer).
  16012. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  16013. */
  16014. getTypeID(): number;
  16015. /**
  16016. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  16017. * @returns the scaled intensity in intensity mode unit
  16018. */
  16019. getScaledIntensity(): number;
  16020. /**
  16021. * Returns a new Light object, named "name", from the current one.
  16022. * @param name The name of the cloned light
  16023. * @returns the new created light
  16024. */
  16025. clone(name: string): Nullable<Light>;
  16026. /**
  16027. * Serializes the current light into a Serialization object.
  16028. * @returns the serialized object.
  16029. */
  16030. serialize(): any;
  16031. /**
  16032. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  16033. * This new light is named "name" and added to the passed scene.
  16034. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  16035. * @param name The friendly name of the light
  16036. * @param scene The scene the new light will belong to
  16037. * @returns the constructor function
  16038. */
  16039. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  16040. /**
  16041. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  16042. * @param parsedLight The JSON representation of the light
  16043. * @param scene The scene to create the parsed light in
  16044. * @returns the created light after parsing
  16045. */
  16046. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  16047. private _hookArrayForExcluded;
  16048. private _hookArrayForIncludedOnly;
  16049. private _resyncMeshes;
  16050. /**
  16051. * Forces the meshes to update their light related information in their rendering used effects
  16052. * @hidden Internal Use Only
  16053. */
  16054. _markMeshesAsLightDirty(): void;
  16055. /**
  16056. * Recomputes the cached photometric scale if needed.
  16057. */
  16058. private _computePhotometricScale;
  16059. /**
  16060. * Returns the Photometric Scale according to the light type and intensity mode.
  16061. */
  16062. private _getPhotometricScale;
  16063. /**
  16064. * Reorder the light in the scene according to their defined priority.
  16065. * @hidden Internal Use Only
  16066. */
  16067. _reorderLightsInScene(): void;
  16068. /**
  16069. * Prepares the list of defines specific to the light type.
  16070. * @param defines the list of defines
  16071. * @param lightIndex defines the index of the light for the effect
  16072. */
  16073. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  16074. }
  16075. }
  16076. declare module BABYLON {
  16077. /**
  16078. * A point light is a light defined by an unique point in world space.
  16079. * The light is emitted in every direction from this point.
  16080. * A good example of a point light is a standard light bulb.
  16081. * Documentation: https://doc.babylonjs.com/babylon101/lights
  16082. */
  16083. class PointLight extends ShadowLight {
  16084. private _shadowAngle;
  16085. /**
  16086. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  16087. * This specifies what angle the shadow will use to be created.
  16088. *
  16089. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  16090. */
  16091. /**
  16092. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  16093. * This specifies what angle the shadow will use to be created.
  16094. *
  16095. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  16096. */
  16097. shadowAngle: number;
  16098. /**
  16099. * Gets the direction if it has been set.
  16100. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  16101. */
  16102. /**
  16103. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  16104. */
  16105. direction: Vector3;
  16106. /**
  16107. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  16108. * A PointLight emits the light in every direction.
  16109. * It can cast shadows.
  16110. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  16111. * ```javascript
  16112. * var pointLight = new BABYLON.PointLight("pl", camera.position, scene);
  16113. * ```
  16114. * Documentation : https://doc.babylonjs.com/babylon101/lights
  16115. * @param name The light friendly name
  16116. * @param position The position of the point light in the scene
  16117. * @param scene The scene the lights belongs to
  16118. */
  16119. constructor(name: string, position: Vector3, scene: Scene);
  16120. /**
  16121. * Returns the string "PointLight"
  16122. * @returns the class name
  16123. */
  16124. getClassName(): string;
  16125. /**
  16126. * Returns the integer 0.
  16127. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  16128. */
  16129. getTypeID(): number;
  16130. /**
  16131. * Specifies wether or not the shadowmap should be a cube texture.
  16132. * @returns true if the shadowmap needs to be a cube texture.
  16133. */
  16134. needCube(): boolean;
  16135. /**
  16136. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  16137. * @param faceIndex The index of the face we are computed the direction to generate shadow
  16138. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  16139. */
  16140. getShadowDirection(faceIndex?: number): Vector3;
  16141. /**
  16142. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  16143. * - fov = PI / 2
  16144. * - aspect ratio : 1.0
  16145. * - z-near and far equal to the active camera minZ and maxZ.
  16146. * Returns the PointLight.
  16147. */
  16148. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  16149. protected _buildUniformLayout(): void;
  16150. /**
  16151. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  16152. * @param effect The effect to update
  16153. * @param lightIndex The index of the light in the effect to update
  16154. * @returns The point light
  16155. */
  16156. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  16157. /**
  16158. * Prepares the list of defines specific to the light type.
  16159. * @param defines the list of defines
  16160. * @param lightIndex defines the index of the light for the effect
  16161. */
  16162. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  16163. }
  16164. }
  16165. declare module BABYLON {
  16166. /**
  16167. * Interface describing all the common properties and methods a shadow light needs to implement.
  16168. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  16169. * as well as binding the different shadow properties to the effects.
  16170. */
  16171. interface IShadowLight extends Light {
  16172. /**
  16173. * The light id in the scene (used in scene.findLighById for instance)
  16174. */
  16175. id: string;
  16176. /**
  16177. * The position the shdow will be casted from.
  16178. */
  16179. position: Vector3;
  16180. /**
  16181. * In 2d mode (needCube being false), the direction used to cast the shadow.
  16182. */
  16183. direction: Vector3;
  16184. /**
  16185. * The transformed position. Position of the light in world space taking parenting in account.
  16186. */
  16187. transformedPosition: Vector3;
  16188. /**
  16189. * The transformed direction. Direction of the light in world space taking parenting in account.
  16190. */
  16191. transformedDirection: Vector3;
  16192. /**
  16193. * The friendly name of the light in the scene.
  16194. */
  16195. name: string;
  16196. /**
  16197. * Defines the shadow projection clipping minimum z value.
  16198. */
  16199. shadowMinZ: number;
  16200. /**
  16201. * Defines the shadow projection clipping maximum z value.
  16202. */
  16203. shadowMaxZ: number;
  16204. /**
  16205. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  16206. * @returns true if the information has been computed, false if it does not need to (no parenting)
  16207. */
  16208. computeTransformedInformation(): boolean;
  16209. /**
  16210. * Gets the scene the light belongs to.
  16211. * @returns The scene
  16212. */
  16213. getScene(): Scene;
  16214. /**
  16215. * Callback defining a custom Projection Matrix Builder.
  16216. * This can be used to override the default projection matrix computation.
  16217. */
  16218. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  16219. /**
  16220. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  16221. * @param matrix The materix to updated with the projection information
  16222. * @param viewMatrix The transform matrix of the light
  16223. * @param renderList The list of mesh to render in the map
  16224. * @returns The current light
  16225. */
  16226. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  16227. /**
  16228. * Gets the current depth scale used in ESM.
  16229. * @returns The scale
  16230. */
  16231. getDepthScale(): number;
  16232. /**
  16233. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  16234. * @returns true if a cube texture needs to be use
  16235. */
  16236. needCube(): boolean;
  16237. /**
  16238. * Detects if the projection matrix requires to be recomputed this frame.
  16239. * @returns true if it requires to be recomputed otherwise, false.
  16240. */
  16241. needProjectionMatrixCompute(): boolean;
  16242. /**
  16243. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  16244. */
  16245. forceProjectionMatrixCompute(): void;
  16246. /**
  16247. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  16248. * @param faceIndex The index of the face we are computed the direction to generate shadow
  16249. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  16250. */
  16251. getShadowDirection(faceIndex?: number): Vector3;
  16252. /**
  16253. * Gets the minZ used for shadow according to both the scene and the light.
  16254. * @param activeCamera The camera we are returning the min for
  16255. * @returns the depth min z
  16256. */
  16257. getDepthMinZ(activeCamera: Camera): number;
  16258. /**
  16259. * Gets the maxZ used for shadow according to both the scene and the light.
  16260. * @param activeCamera The camera we are returning the max for
  16261. * @returns the depth max z
  16262. */
  16263. getDepthMaxZ(activeCamera: Camera): number;
  16264. }
  16265. /**
  16266. * Base implementation IShadowLight
  16267. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  16268. */
  16269. abstract class ShadowLight extends Light implements IShadowLight {
  16270. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  16271. protected _position: Vector3;
  16272. protected _setPosition(value: Vector3): void;
  16273. /**
  16274. * Sets the position the shadow will be casted from. Also use as the light position for both
  16275. * point and spot lights.
  16276. */
  16277. /**
  16278. * Sets the position the shadow will be casted from. Also use as the light position for both
  16279. * point and spot lights.
  16280. */
  16281. position: Vector3;
  16282. protected _direction: Vector3;
  16283. protected _setDirection(value: Vector3): void;
  16284. /**
  16285. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  16286. * Also use as the light direction on spot and directional lights.
  16287. */
  16288. /**
  16289. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  16290. * Also use as the light direction on spot and directional lights.
  16291. */
  16292. direction: Vector3;
  16293. private _shadowMinZ;
  16294. /**
  16295. * Gets the shadow projection clipping minimum z value.
  16296. */
  16297. /**
  16298. * Sets the shadow projection clipping minimum z value.
  16299. */
  16300. shadowMinZ: number;
  16301. private _shadowMaxZ;
  16302. /**
  16303. * Sets the shadow projection clipping maximum z value.
  16304. */
  16305. /**
  16306. * Gets the shadow projection clipping maximum z value.
  16307. */
  16308. shadowMaxZ: number;
  16309. /**
  16310. * Callback defining a custom Projection Matrix Builder.
  16311. * This can be used to override the default projection matrix computation.
  16312. */
  16313. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  16314. /**
  16315. * The transformed position. Position of the light in world space taking parenting in account.
  16316. */
  16317. transformedPosition: Vector3;
  16318. /**
  16319. * The transformed direction. Direction of the light in world space taking parenting in account.
  16320. */
  16321. transformedDirection: Vector3;
  16322. private _needProjectionMatrixCompute;
  16323. /**
  16324. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  16325. * @returns true if the information has been computed, false if it does not need to (no parenting)
  16326. */
  16327. computeTransformedInformation(): boolean;
  16328. /**
  16329. * Return the depth scale used for the shadow map.
  16330. * @returns the depth scale.
  16331. */
  16332. getDepthScale(): number;
  16333. /**
  16334. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  16335. * @param faceIndex The index of the face we are computed the direction to generate shadow
  16336. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  16337. */
  16338. getShadowDirection(faceIndex?: number): Vector3;
  16339. /**
  16340. * Returns the ShadowLight absolute position in the World.
  16341. * @returns the position vector in world space
  16342. */
  16343. getAbsolutePosition(): Vector3;
  16344. /**
  16345. * Sets the ShadowLight direction toward the passed target.
  16346. * @param target The point tot target in local space
  16347. * @returns the updated ShadowLight direction
  16348. */
  16349. setDirectionToTarget(target: Vector3): Vector3;
  16350. /**
  16351. * Returns the light rotation in euler definition.
  16352. * @returns the x y z rotation in local space.
  16353. */
  16354. getRotation(): Vector3;
  16355. /**
  16356. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  16357. * @returns true if a cube texture needs to be use
  16358. */
  16359. needCube(): boolean;
  16360. /**
  16361. * Detects if the projection matrix requires to be recomputed this frame.
  16362. * @returns true if it requires to be recomputed otherwise, false.
  16363. */
  16364. needProjectionMatrixCompute(): boolean;
  16365. /**
  16366. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  16367. */
  16368. forceProjectionMatrixCompute(): void;
  16369. /** @hidden */
  16370. _initCache(): void;
  16371. /** @hidden */
  16372. _isSynchronized(): boolean;
  16373. /**
  16374. * Computes the world matrix of the node
  16375. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  16376. * @returns the world matrix
  16377. */
  16378. computeWorldMatrix(force?: boolean): Matrix;
  16379. /**
  16380. * Gets the minZ used for shadow according to both the scene and the light.
  16381. * @param activeCamera The camera we are returning the min for
  16382. * @returns the depth min z
  16383. */
  16384. getDepthMinZ(activeCamera: Camera): number;
  16385. /**
  16386. * Gets the maxZ used for shadow according to both the scene and the light.
  16387. * @param activeCamera The camera we are returning the max for
  16388. * @returns the depth max z
  16389. */
  16390. getDepthMaxZ(activeCamera: Camera): number;
  16391. /**
  16392. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  16393. * @param matrix The materix to updated with the projection information
  16394. * @param viewMatrix The transform matrix of the light
  16395. * @param renderList The list of mesh to render in the map
  16396. * @returns The current light
  16397. */
  16398. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  16399. }
  16400. }
  16401. declare module BABYLON {
  16402. /**
  16403. * A spot light is defined by a position, a direction, an angle, and an exponent.
  16404. * These values define a cone of light starting from the position, emitting toward the direction.
  16405. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  16406. * and the exponent defines the speed of the decay of the light with distance (reach).
  16407. * Documentation: https://doc.babylonjs.com/babylon101/lights
  16408. */
  16409. class SpotLight extends ShadowLight {
  16410. private _angle;
  16411. private _innerAngle;
  16412. private _cosHalfAngle;
  16413. private _lightAngleScale;
  16414. private _lightAngleOffset;
  16415. /**
  16416. * Gets the cone angle of the spot light in Radians.
  16417. */
  16418. /**
  16419. * Sets the cone angle of the spot light in Radians.
  16420. */
  16421. angle: number;
  16422. /**
  16423. * Only used in gltf falloff mode, this defines the angle where
  16424. * the directional falloff will start before cutting at angle which could be seen
  16425. * as outer angle.
  16426. */
  16427. /**
  16428. * Only used in gltf falloff mode, this defines the angle where
  16429. * the directional falloff will start before cutting at angle which could be seen
  16430. * as outer angle.
  16431. */
  16432. innerAngle: number;
  16433. private _shadowAngleScale;
  16434. /**
  16435. * Allows scaling the angle of the light for shadow generation only.
  16436. */
  16437. /**
  16438. * Allows scaling the angle of the light for shadow generation only.
  16439. */
  16440. shadowAngleScale: number;
  16441. /**
  16442. * The light decay speed with the distance from the emission spot.
  16443. */
  16444. exponent: number;
  16445. private _projectionTextureMatrix;
  16446. /**
  16447. * Allows reading the projecton texture
  16448. */
  16449. readonly projectionTextureMatrix: Matrix;
  16450. protected _projectionTextureLightNear: number;
  16451. /**
  16452. * Gets the near clip of the Spotlight for texture projection.
  16453. */
  16454. /**
  16455. * Sets the near clip of the Spotlight for texture projection.
  16456. */
  16457. projectionTextureLightNear: number;
  16458. protected _projectionTextureLightFar: number;
  16459. /**
  16460. * Gets the far clip of the Spotlight for texture projection.
  16461. */
  16462. /**
  16463. * Sets the far clip of the Spotlight for texture projection.
  16464. */
  16465. projectionTextureLightFar: number;
  16466. protected _projectionTextureUpDirection: Vector3;
  16467. /**
  16468. * Gets the Up vector of the Spotlight for texture projection.
  16469. */
  16470. /**
  16471. * Sets the Up vector of the Spotlight for texture projection.
  16472. */
  16473. projectionTextureUpDirection: Vector3;
  16474. private _projectionTexture;
  16475. /**
  16476. * Gets the projection texture of the light.
  16477. */
  16478. /**
  16479. * Sets the projection texture of the light.
  16480. */
  16481. projectionTexture: Nullable<BaseTexture>;
  16482. private _projectionTextureViewLightDirty;
  16483. private _projectionTextureProjectionLightDirty;
  16484. private _projectionTextureDirty;
  16485. private _projectionTextureViewTargetVector;
  16486. private _projectionTextureViewLightMatrix;
  16487. private _projectionTextureProjectionLightMatrix;
  16488. private _projectionTextureScalingMatrix;
  16489. /**
  16490. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  16491. * It can cast shadows.
  16492. * Documentation : https://doc.babylonjs.com/babylon101/lights
  16493. * @param name The light friendly name
  16494. * @param position The position of the spot light in the scene
  16495. * @param direction The direction of the light in the scene
  16496. * @param angle The cone angle of the light in Radians
  16497. * @param exponent The light decay speed with the distance from the emission spot
  16498. * @param scene The scene the lights belongs to
  16499. */
  16500. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  16501. /**
  16502. * Returns the string "SpotLight".
  16503. * @returns the class name
  16504. */
  16505. getClassName(): string;
  16506. /**
  16507. * Returns the integer 2.
  16508. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  16509. */
  16510. getTypeID(): number;
  16511. /**
  16512. * Overrides the direction setter to recompute the projection texture view light Matrix.
  16513. */
  16514. protected _setDirection(value: Vector3): void;
  16515. /**
  16516. * Overrides the position setter to recompute the projection texture view light Matrix.
  16517. */
  16518. protected _setPosition(value: Vector3): void;
  16519. /**
  16520. * Sets the passed matrix "matrix" as perspective projection matrix for the shadows and the passed view matrix with the fov equal to the SpotLight angle and and aspect ratio of 1.0.
  16521. * Returns the SpotLight.
  16522. */
  16523. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  16524. protected _computeProjectionTextureViewLightMatrix(): void;
  16525. protected _computeProjectionTextureProjectionLightMatrix(): void;
  16526. /**
  16527. * Main function for light texture projection matrix computing.
  16528. */
  16529. protected _computeProjectionTextureMatrix(): void;
  16530. protected _buildUniformLayout(): void;
  16531. private _computeAngleValues;
  16532. /**
  16533. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  16534. * @param effect The effect to update
  16535. * @param lightIndex The index of the light in the effect to update
  16536. * @returns The spot light
  16537. */
  16538. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  16539. /**
  16540. * Disposes the light and the associated resources.
  16541. */
  16542. dispose(): void;
  16543. /**
  16544. * Prepares the list of defines specific to the light type.
  16545. * @param defines the list of defines
  16546. * @param lightIndex defines the index of the light for the effect
  16547. */
  16548. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  16549. }
  16550. }
  16551. declare module BABYLON {
  16552. /**
  16553. * 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. /**
  20159. * Creates a new Color3 from the string containing valid hexadecimal values
  20160. * @param hex defines a string containing valid hexadecimal values
  20161. * @returns a new Color3 object
  20162. */
  20163. static FromHexString(hex: string): Color3;
  20164. /**
  20165. * Creates a new Vector3 from the starting index of the given array
  20166. * @param array defines the source array
  20167. * @param offset defines an offset in the source array
  20168. * @returns a new Color3 object
  20169. */
  20170. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  20171. /**
  20172. * Creates a new Color3 from integer values (< 256)
  20173. * @param r defines the red component to read from (value between 0 and 255)
  20174. * @param g defines the green component to read from (value between 0 and 255)
  20175. * @param b defines the blue component to read from (value between 0 and 255)
  20176. * @returns a new Color3 object
  20177. */
  20178. static FromInts(r: number, g: number, b: number): Color3;
  20179. /**
  20180. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  20181. * @param start defines the start Color3 value
  20182. * @param end defines the end Color3 value
  20183. * @param amount defines the gradient value between start and end
  20184. * @returns a new Color3 object
  20185. */
  20186. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  20187. /**
  20188. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  20189. * @param left defines the start value
  20190. * @param right defines the end value
  20191. * @param amount defines the gradient factor
  20192. * @param result defines the Color3 object where to store the result
  20193. */
  20194. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  20195. /**
  20196. * Returns a Color3 value containing a red color
  20197. * @returns a new Color3 object
  20198. */
  20199. static Red(): Color3;
  20200. /**
  20201. * Returns a Color3 value containing a green color
  20202. * @returns a new Color3 object
  20203. */
  20204. static Green(): Color3;
  20205. /**
  20206. * Returns a Color3 value containing a blue color
  20207. * @returns a new Color3 object
  20208. */
  20209. static Blue(): Color3;
  20210. /**
  20211. * Returns a Color3 value containing a black color
  20212. * @returns a new Color3 object
  20213. */
  20214. static Black(): Color3;
  20215. /**
  20216. * Returns a Color3 value containing a white color
  20217. * @returns a new Color3 object
  20218. */
  20219. static White(): Color3;
  20220. /**
  20221. * Returns a Color3 value containing a purple color
  20222. * @returns a new Color3 object
  20223. */
  20224. static Purple(): Color3;
  20225. /**
  20226. * Returns a Color3 value containing a magenta color
  20227. * @returns a new Color3 object
  20228. */
  20229. static Magenta(): Color3;
  20230. /**
  20231. * Returns a Color3 value containing a yellow color
  20232. * @returns a new Color3 object
  20233. */
  20234. static Yellow(): Color3;
  20235. /**
  20236. * Returns a Color3 value containing a gray color
  20237. * @returns a new Color3 object
  20238. */
  20239. static Gray(): Color3;
  20240. /**
  20241. * Returns a Color3 value containing a teal color
  20242. * @returns a new Color3 object
  20243. */
  20244. static Teal(): Color3;
  20245. /**
  20246. * Returns a Color3 value containing a random color
  20247. * @returns a new Color3 object
  20248. */
  20249. static Random(): Color3;
  20250. }
  20251. /**
  20252. * Class used to hold a RBGA color
  20253. */
  20254. class Color4 {
  20255. /**
  20256. * Defines the red component (between 0 and 1, default is 0)
  20257. */
  20258. r: number;
  20259. /**
  20260. * Defines the green component (between 0 and 1, default is 0)
  20261. */
  20262. g: number;
  20263. /**
  20264. * Defines the blue component (between 0 and 1, default is 0)
  20265. */
  20266. b: number;
  20267. /**
  20268. * Defines the alpha component (between 0 and 1, default is 1)
  20269. */
  20270. a: number;
  20271. /**
  20272. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  20273. * @param r defines the red component (between 0 and 1, default is 0)
  20274. * @param g defines the green component (between 0 and 1, default is 0)
  20275. * @param b defines the blue component (between 0 and 1, default is 0)
  20276. * @param a defines the alpha component (between 0 and 1, default is 1)
  20277. */
  20278. constructor(
  20279. /**
  20280. * Defines the red component (between 0 and 1, default is 0)
  20281. */
  20282. r?: number,
  20283. /**
  20284. * Defines the green component (between 0 and 1, default is 0)
  20285. */
  20286. g?: number,
  20287. /**
  20288. * Defines the blue component (between 0 and 1, default is 0)
  20289. */
  20290. b?: number,
  20291. /**
  20292. * Defines the alpha component (between 0 and 1, default is 1)
  20293. */
  20294. a?: number);
  20295. /**
  20296. * Adds in place the given Color4 values to the current Color4 object
  20297. * @param right defines the second operand
  20298. * @returns the current updated Color4 object
  20299. */
  20300. addInPlace(right: DeepImmutable<Color4>): Color4;
  20301. /**
  20302. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  20303. * @returns the new array
  20304. */
  20305. asArray(): number[];
  20306. /**
  20307. * Stores from the starting index in the given array the Color4 successive values
  20308. * @param array defines the array where to store the r,g,b components
  20309. * @param index defines an optional index in the target array to define where to start storing values
  20310. * @returns the current Color4 object
  20311. */
  20312. toArray(array: number[], index?: number): Color4;
  20313. /**
  20314. * Determines equality between Color4 objects
  20315. * @param otherColor defines the second operand
  20316. * @returns true if the rgba values are equal to the given ones
  20317. */
  20318. equals(otherColor: DeepImmutable<Color4>): boolean;
  20319. /**
  20320. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  20321. * @param right defines the second operand
  20322. * @returns a new Color4 object
  20323. */
  20324. add(right: DeepImmutable<Color4>): Color4;
  20325. /**
  20326. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  20327. * @param right defines the second operand
  20328. * @returns a new Color4 object
  20329. */
  20330. subtract(right: DeepImmutable<Color4>): Color4;
  20331. /**
  20332. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  20333. * @param right defines the second operand
  20334. * @param result defines the Color4 object where to store the result
  20335. * @returns the current Color4 object
  20336. */
  20337. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  20338. /**
  20339. * Creates a new Color4 with the current Color4 values multiplied by scale
  20340. * @param scale defines the scaling factor to apply
  20341. * @returns a new Color4 object
  20342. */
  20343. scale(scale: number): Color4;
  20344. /**
  20345. * Multiplies the current Color4 values by scale and stores the result in "result"
  20346. * @param scale defines the scaling factor to apply
  20347. * @param result defines the Color4 object where to store the result
  20348. * @returns the current unmodified Color4
  20349. */
  20350. scaleToRef(scale: number, result: Color4): Color4;
  20351. /**
  20352. * Scale the current Color4 values by a factor and add the result to a given Color4
  20353. * @param scale defines the scale factor
  20354. * @param result defines the Color4 object where to store the result
  20355. * @returns the unmodified current Color4
  20356. */
  20357. scaleAndAddToRef(scale: number, result: Color4): Color4;
  20358. /**
  20359. * Clamps the rgb values by the min and max values and stores the result into "result"
  20360. * @param min defines minimum clamping value (default is 0)
  20361. * @param max defines maximum clamping value (default is 1)
  20362. * @param result defines color to store the result into.
  20363. * @returns the cuurent Color4
  20364. */
  20365. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  20366. /**
  20367. * Multipy an Color4 value by another and return a new Color4 object
  20368. * @param color defines the Color4 value to multiply by
  20369. * @returns a new Color4 object
  20370. */
  20371. multiply(color: Color4): Color4;
  20372. /**
  20373. * Multipy a Color4 value by another and push the result in a reference value
  20374. * @param color defines the Color4 value to multiply by
  20375. * @param result defines the Color4 to fill the result in
  20376. * @returns the result Color4
  20377. */
  20378. multiplyToRef(color: Color4, result: Color4): Color4;
  20379. /**
  20380. * Creates a string with the Color4 current values
  20381. * @returns the string representation of the Color4 object
  20382. */
  20383. toString(): string;
  20384. /**
  20385. * Returns the string "Color4"
  20386. * @returns "Color4"
  20387. */
  20388. getClassName(): string;
  20389. /**
  20390. * Compute the Color4 hash code
  20391. * @returns an unique number that can be used to hash Color4 objects
  20392. */
  20393. getHashCode(): number;
  20394. /**
  20395. * Creates a new Color4 copied from the current one
  20396. * @returns a new Color4 object
  20397. */
  20398. clone(): Color4;
  20399. /**
  20400. * Copies the given Color4 values into the current one
  20401. * @param source defines the source Color4 object
  20402. * @returns the current updated Color4 object
  20403. */
  20404. copyFrom(source: Color4): Color4;
  20405. /**
  20406. * Copies the given float values into the current one
  20407. * @param r defines the red component to read from
  20408. * @param g defines the green component to read from
  20409. * @param b defines the blue component to read from
  20410. * @param a defines the alpha component to read from
  20411. * @returns the current updated Color4 object
  20412. */
  20413. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  20414. /**
  20415. * Copies the given float values into the current one
  20416. * @param r defines the red component to read from
  20417. * @param g defines the green component to read from
  20418. * @param b defines the blue component to read from
  20419. * @param a defines the alpha component to read from
  20420. * @returns the current updated Color4 object
  20421. */
  20422. set(r: number, g: number, b: number, a: number): Color4;
  20423. /**
  20424. * Compute the Color4 hexadecimal code as a string
  20425. * @returns a string containing the hexadecimal representation of the Color4 object
  20426. */
  20427. toHexString(): string;
  20428. /**
  20429. * Computes a new Color4 converted from the current one to linear space
  20430. * @returns a new Color4 object
  20431. */
  20432. toLinearSpace(): Color4;
  20433. /**
  20434. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  20435. * @param convertedColor defines the Color4 object where to store the linear space version
  20436. * @returns the unmodified Color4
  20437. */
  20438. toLinearSpaceToRef(convertedColor: Color4): Color4;
  20439. /**
  20440. * Computes a new Color4 converted from the current one to gamma space
  20441. * @returns a new Color4 object
  20442. */
  20443. toGammaSpace(): Color4;
  20444. /**
  20445. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  20446. * @param convertedColor defines the Color4 object where to store the gamma space version
  20447. * @returns the unmodified Color4
  20448. */
  20449. toGammaSpaceToRef(convertedColor: Color4): Color4;
  20450. /**
  20451. * Creates a new Color4 from the string containing valid hexadecimal values
  20452. * @param hex defines a string containing valid hexadecimal values
  20453. * @returns a new Color4 object
  20454. */
  20455. static FromHexString(hex: string): Color4;
  20456. /**
  20457. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  20458. * @param left defines the start value
  20459. * @param right defines the end value
  20460. * @param amount defines the gradient factor
  20461. * @returns a new Color4 object
  20462. */
  20463. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  20464. /**
  20465. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  20466. * @param left defines the start value
  20467. * @param right defines the end value
  20468. * @param amount defines the gradient factor
  20469. * @param result defines the Color4 object where to store data
  20470. */
  20471. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  20472. /**
  20473. * Creates a new Color4 from a Color3 and an alpha value
  20474. * @param color3 defines the source Color3 to read from
  20475. * @param alpha defines the alpha component (1.0 by default)
  20476. * @returns a new Color4 object
  20477. */
  20478. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  20479. /**
  20480. * Creates a new Color4 from the starting index element of the given array
  20481. * @param array defines the source array to read from
  20482. * @param offset defines the offset in the source array
  20483. * @returns a new Color4 object
  20484. */
  20485. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  20486. /**
  20487. * Creates a new Color3 from integer values (< 256)
  20488. * @param r defines the red component to read from (value between 0 and 255)
  20489. * @param g defines the green component to read from (value between 0 and 255)
  20490. * @param b defines the blue component to read from (value between 0 and 255)
  20491. * @param a defines the alpha component to read from (value between 0 and 255)
  20492. * @returns a new Color3 object
  20493. */
  20494. static FromInts(r: number, g: number, b: number, a: number): Color4;
  20495. /**
  20496. * Check the content of a given array and convert it to an array containing RGBA data
  20497. * If the original array was already containing count * 4 values then it is returned directly
  20498. * @param colors defines the array to check
  20499. * @param count defines the number of RGBA data to expect
  20500. * @returns an array containing count * 4 values (RGBA)
  20501. */
  20502. static CheckColors4(colors: number[], count: number): number[];
  20503. }
  20504. /**
  20505. * Class representing a vector containing 2 coordinates
  20506. */
  20507. class Vector2 {
  20508. /** defines the first coordinate */
  20509. x: number;
  20510. /** defines the second coordinate */
  20511. y: number;
  20512. /**
  20513. * Creates a new Vector2 from the given x and y coordinates
  20514. * @param x defines the first coordinate
  20515. * @param y defines the second coordinate
  20516. */
  20517. constructor(
  20518. /** defines the first coordinate */
  20519. x?: number,
  20520. /** defines the second coordinate */
  20521. y?: number);
  20522. /**
  20523. * Gets a string with the Vector2 coordinates
  20524. * @returns a string with the Vector2 coordinates
  20525. */
  20526. toString(): string;
  20527. /**
  20528. * Gets class name
  20529. * @returns the string "Vector2"
  20530. */
  20531. getClassName(): string;
  20532. /**
  20533. * Gets current vector hash code
  20534. * @returns the Vector2 hash code as a number
  20535. */
  20536. getHashCode(): number;
  20537. /**
  20538. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  20539. * @param array defines the source array
  20540. * @param index defines the offset in source array
  20541. * @returns the current Vector2
  20542. */
  20543. toArray(array: FloatArray, index?: number): Vector2;
  20544. /**
  20545. * Copy the current vector to an array
  20546. * @returns a new array with 2 elements: the Vector2 coordinates.
  20547. */
  20548. asArray(): number[];
  20549. /**
  20550. * Sets the Vector2 coordinates with the given Vector2 coordinates
  20551. * @param source defines the source Vector2
  20552. * @returns the current updated Vector2
  20553. */
  20554. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  20555. /**
  20556. * Sets the Vector2 coordinates with the given floats
  20557. * @param x defines the first coordinate
  20558. * @param y defines the second coordinate
  20559. * @returns the current updated Vector2
  20560. */
  20561. copyFromFloats(x: number, y: number): Vector2;
  20562. /**
  20563. * Sets the Vector2 coordinates with the given floats
  20564. * @param x defines the first coordinate
  20565. * @param y defines the second coordinate
  20566. * @returns the current updated Vector2
  20567. */
  20568. set(x: number, y: number): Vector2;
  20569. /**
  20570. * Add another vector with the current one
  20571. * @param otherVector defines the other vector
  20572. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  20573. */
  20574. add(otherVector: DeepImmutable<Vector2>): Vector2;
  20575. /**
  20576. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  20577. * @param otherVector defines the other vector
  20578. * @param result defines the target vector
  20579. * @returns the unmodified current Vector2
  20580. */
  20581. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  20582. /**
  20583. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  20584. * @param otherVector defines the other vector
  20585. * @returns the current updated Vector2
  20586. */
  20587. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  20588. /**
  20589. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  20590. * @param otherVector defines the other vector
  20591. * @returns a new Vector2
  20592. */
  20593. addVector3(otherVector: Vector3): Vector2;
  20594. /**
  20595. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  20596. * @param otherVector defines the other vector
  20597. * @returns a new Vector2
  20598. */
  20599. subtract(otherVector: Vector2): Vector2;
  20600. /**
  20601. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  20602. * @param otherVector defines the other vector
  20603. * @param result defines the target vector
  20604. * @returns the unmodified current Vector2
  20605. */
  20606. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  20607. /**
  20608. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  20609. * @param otherVector defines the other vector
  20610. * @returns the current updated Vector2
  20611. */
  20612. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  20613. /**
  20614. * Multiplies in place the current Vector2 coordinates by the given ones
  20615. * @param otherVector defines the other vector
  20616. * @returns the current updated Vector2
  20617. */
  20618. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  20619. /**
  20620. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  20621. * @param otherVector defines the other vector
  20622. * @returns a new Vector2
  20623. */
  20624. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  20625. /**
  20626. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  20627. * @param otherVector defines the other vector
  20628. * @param result defines the target vector
  20629. * @returns the unmodified current Vector2
  20630. */
  20631. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  20632. /**
  20633. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  20634. * @param x defines the first coordinate
  20635. * @param y defines the second coordinate
  20636. * @returns a new Vector2
  20637. */
  20638. multiplyByFloats(x: number, y: number): Vector2;
  20639. /**
  20640. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  20641. * @param otherVector defines the other vector
  20642. * @returns a new Vector2
  20643. */
  20644. divide(otherVector: Vector2): Vector2;
  20645. /**
  20646. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  20647. * @param otherVector defines the other vector
  20648. * @param result defines the target vector
  20649. * @returns the unmodified current Vector2
  20650. */
  20651. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  20652. /**
  20653. * Divides the current Vector2 coordinates by the given ones
  20654. * @param otherVector defines the other vector
  20655. * @returns the current updated Vector2
  20656. */
  20657. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  20658. /**
  20659. * Gets a new Vector2 with current Vector2 negated coordinates
  20660. * @returns a new Vector2
  20661. */
  20662. negate(): Vector2;
  20663. /**
  20664. * Multiply the Vector2 coordinates by scale
  20665. * @param scale defines the scaling factor
  20666. * @returns the current updated Vector2
  20667. */
  20668. scaleInPlace(scale: number): Vector2;
  20669. /**
  20670. * Returns a new Vector2 scaled by "scale" from the current Vector2
  20671. * @param scale defines the scaling factor
  20672. * @returns a new Vector2
  20673. */
  20674. scale(scale: number): Vector2;
  20675. /**
  20676. * Scale the current Vector2 values by a factor to a given Vector2
  20677. * @param scale defines the scale factor
  20678. * @param result defines the Vector2 object where to store the result
  20679. * @returns the unmodified current Vector2
  20680. */
  20681. scaleToRef(scale: number, result: Vector2): Vector2;
  20682. /**
  20683. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  20684. * @param scale defines the scale factor
  20685. * @param result defines the Vector2 object where to store the result
  20686. * @returns the unmodified current Vector2
  20687. */
  20688. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  20689. /**
  20690. * Gets a boolean if two vectors are equals
  20691. * @param otherVector defines the other vector
  20692. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  20693. */
  20694. equals(otherVector: DeepImmutable<Vector2>): boolean;
  20695. /**
  20696. * Gets a boolean if two vectors are equals (using an epsilon value)
  20697. * @param otherVector defines the other vector
  20698. * @param epsilon defines the minimal distance to consider equality
  20699. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  20700. */
  20701. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  20702. /**
  20703. * Gets a new Vector2 from current Vector2 floored values
  20704. * @returns a new Vector2
  20705. */
  20706. floor(): Vector2;
  20707. /**
  20708. * Gets a new Vector2 from current Vector2 floored values
  20709. * @returns a new Vector2
  20710. */
  20711. fract(): Vector2;
  20712. /**
  20713. * Gets the length of the vector
  20714. * @returns the vector length (float)
  20715. */
  20716. length(): number;
  20717. /**
  20718. * Gets the vector squared length
  20719. * @returns the vector squared length (float)
  20720. */
  20721. lengthSquared(): number;
  20722. /**
  20723. * Normalize the vector
  20724. * @returns the current updated Vector2
  20725. */
  20726. normalize(): Vector2;
  20727. /**
  20728. * Gets a new Vector2 copied from the Vector2
  20729. * @returns a new Vector2
  20730. */
  20731. clone(): Vector2;
  20732. /**
  20733. * Gets a new Vector2(0, 0)
  20734. * @returns a new Vector2
  20735. */
  20736. static Zero(): Vector2;
  20737. /**
  20738. * Gets a new Vector2(1, 1)
  20739. * @returns a new Vector2
  20740. */
  20741. static One(): Vector2;
  20742. /**
  20743. * Gets a new Vector2 set from the given index element of the given array
  20744. * @param array defines the data source
  20745. * @param offset defines the offset in the data source
  20746. * @returns a new Vector2
  20747. */
  20748. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  20749. /**
  20750. * Sets "result" from the given index element of the given array
  20751. * @param array defines the data source
  20752. * @param offset defines the offset in the data source
  20753. * @param result defines the target vector
  20754. */
  20755. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  20756. /**
  20757. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  20758. * @param value1 defines 1st point of control
  20759. * @param value2 defines 2nd point of control
  20760. * @param value3 defines 3rd point of control
  20761. * @param value4 defines 4th point of control
  20762. * @param amount defines the interpolation factor
  20763. * @returns a new Vector2
  20764. */
  20765. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  20766. /**
  20767. * 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".
  20768. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  20769. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  20770. * @param value defines the value to clamp
  20771. * @param min defines the lower limit
  20772. * @param max defines the upper limit
  20773. * @returns a new Vector2
  20774. */
  20775. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  20776. /**
  20777. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  20778. * @param value1 defines the 1st control point
  20779. * @param tangent1 defines the outgoing tangent
  20780. * @param value2 defines the 2nd control point
  20781. * @param tangent2 defines the incoming tangent
  20782. * @param amount defines the interpolation factor
  20783. * @returns a new Vector2
  20784. */
  20785. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  20786. /**
  20787. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  20788. * @param start defines the start vector
  20789. * @param end defines the end vector
  20790. * @param amount defines the interpolation factor
  20791. * @returns a new Vector2
  20792. */
  20793. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  20794. /**
  20795. * Gets the dot product of the vector "left" and the vector "right"
  20796. * @param left defines first vector
  20797. * @param right defines second vector
  20798. * @returns the dot product (float)
  20799. */
  20800. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  20801. /**
  20802. * Returns a new Vector2 equal to the normalized given vector
  20803. * @param vector defines the vector to normalize
  20804. * @returns a new Vector2
  20805. */
  20806. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  20807. /**
  20808. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  20809. * @param left defines 1st vector
  20810. * @param right defines 2nd vector
  20811. * @returns a new Vector2
  20812. */
  20813. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  20814. /**
  20815. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  20816. * @param left defines 1st vector
  20817. * @param right defines 2nd vector
  20818. * @returns a new Vector2
  20819. */
  20820. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  20821. /**
  20822. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  20823. * @param vector defines the vector to transform
  20824. * @param transformation defines the matrix to apply
  20825. * @returns a new Vector2
  20826. */
  20827. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  20828. /**
  20829. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  20830. * @param vector defines the vector to transform
  20831. * @param transformation defines the matrix to apply
  20832. * @param result defines the target vector
  20833. */
  20834. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  20835. /**
  20836. * Determines if a given vector is included in a triangle
  20837. * @param p defines the vector to test
  20838. * @param p0 defines 1st triangle point
  20839. * @param p1 defines 2nd triangle point
  20840. * @param p2 defines 3rd triangle point
  20841. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  20842. */
  20843. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  20844. /**
  20845. * Gets the distance between the vectors "value1" and "value2"
  20846. * @param value1 defines first vector
  20847. * @param value2 defines second vector
  20848. * @returns the distance between vectors
  20849. */
  20850. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  20851. /**
  20852. * Returns the squared distance between the vectors "value1" and "value2"
  20853. * @param value1 defines first vector
  20854. * @param value2 defines second vector
  20855. * @returns the squared distance between vectors
  20856. */
  20857. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  20858. /**
  20859. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  20860. * @param value1 defines first vector
  20861. * @param value2 defines second vector
  20862. * @returns a new Vector2
  20863. */
  20864. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  20865. /**
  20866. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  20867. * @param p defines the middle point
  20868. * @param segA defines one point of the segment
  20869. * @param segB defines the other point of the segment
  20870. * @returns the shortest distance
  20871. */
  20872. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  20873. }
  20874. /**
  20875. * Classed used to store (x,y,z) vector representation
  20876. * A Vector3 is the main object used in 3D geometry
  20877. * It can represent etiher the coordinates of a point the space, either a direction
  20878. * Reminder: Babylon.js uses a left handed forward facing system
  20879. */
  20880. class Vector3 {
  20881. /**
  20882. * Defines the first coordinates (on X axis)
  20883. */
  20884. x: number;
  20885. /**
  20886. * Defines the second coordinates (on Y axis)
  20887. */
  20888. y: number;
  20889. /**
  20890. * Defines the third coordinates (on Z axis)
  20891. */
  20892. z: number;
  20893. private static _UpReadOnly;
  20894. /**
  20895. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  20896. * @param x defines the first coordinates (on X axis)
  20897. * @param y defines the second coordinates (on Y axis)
  20898. * @param z defines the third coordinates (on Z axis)
  20899. */
  20900. constructor(
  20901. /**
  20902. * Defines the first coordinates (on X axis)
  20903. */
  20904. x?: number,
  20905. /**
  20906. * Defines the second coordinates (on Y axis)
  20907. */
  20908. y?: number,
  20909. /**
  20910. * Defines the third coordinates (on Z axis)
  20911. */
  20912. z?: number);
  20913. /**
  20914. * Creates a string representation of the Vector3
  20915. * @returns a string with the Vector3 coordinates.
  20916. */
  20917. toString(): string;
  20918. /**
  20919. * Gets the class name
  20920. * @returns the string "Vector3"
  20921. */
  20922. getClassName(): string;
  20923. /**
  20924. * Creates the Vector3 hash code
  20925. * @returns a number which tends to be unique between Vector3 instances
  20926. */
  20927. getHashCode(): number;
  20928. /**
  20929. * Creates an array containing three elements : the coordinates of the Vector3
  20930. * @returns a new array of numbers
  20931. */
  20932. asArray(): number[];
  20933. /**
  20934. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  20935. * @param array defines the destination array
  20936. * @param index defines the offset in the destination array
  20937. * @returns the current Vector3
  20938. */
  20939. toArray(array: FloatArray, index?: number): Vector3;
  20940. /**
  20941. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  20942. * @returns a new Quaternion object, computed from the Vector3 coordinates
  20943. */
  20944. toQuaternion(): Quaternion;
  20945. /**
  20946. * Adds the given vector to the current Vector3
  20947. * @param otherVector defines the second operand
  20948. * @returns the current updated Vector3
  20949. */
  20950. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  20951. /**
  20952. * Adds the given coordinates to the current Vector3
  20953. * @param x defines the x coordinate of the operand
  20954. * @param y defines the y coordinate of the operand
  20955. * @param z defines the z coordinate of the operand
  20956. * @returns the current updated Vector3
  20957. */
  20958. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  20959. /**
  20960. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  20961. * @param otherVector defines the second operand
  20962. * @returns the resulting Vector3
  20963. */
  20964. add(otherVector: DeepImmutable<Vector3>): Vector3;
  20965. /**
  20966. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  20967. * @param otherVector defines the second operand
  20968. * @param result defines the Vector3 object where to store the result
  20969. * @returns the current Vector3
  20970. */
  20971. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  20972. /**
  20973. * Subtract the given vector from the current Vector3
  20974. * @param otherVector defines the second operand
  20975. * @returns the current updated Vector3
  20976. */
  20977. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  20978. /**
  20979. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  20980. * @param otherVector defines the second operand
  20981. * @returns the resulting Vector3
  20982. */
  20983. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  20984. /**
  20985. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  20986. * @param otherVector defines the second operand
  20987. * @param result defines the Vector3 object where to store the result
  20988. * @returns the current Vector3
  20989. */
  20990. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  20991. /**
  20992. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  20993. * @param x defines the x coordinate of the operand
  20994. * @param y defines the y coordinate of the operand
  20995. * @param z defines the z coordinate of the operand
  20996. * @returns the resulting Vector3
  20997. */
  20998. subtractFromFloats(x: number, y: number, z: number): Vector3;
  20999. /**
  21000. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  21001. * @param x defines the x coordinate of the operand
  21002. * @param y defines the y coordinate of the operand
  21003. * @param z defines the z coordinate of the operand
  21004. * @param result defines the Vector3 object where to store the result
  21005. * @returns the current Vector3
  21006. */
  21007. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  21008. /**
  21009. * Gets a new Vector3 set with the current Vector3 negated coordinates
  21010. * @returns a new Vector3
  21011. */
  21012. negate(): Vector3;
  21013. /**
  21014. * Multiplies the Vector3 coordinates by the float "scale"
  21015. * @param scale defines the multiplier factor
  21016. * @returns the current updated Vector3
  21017. */
  21018. scaleInPlace(scale: number): Vector3;
  21019. /**
  21020. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  21021. * @param scale defines the multiplier factor
  21022. * @returns a new Vector3
  21023. */
  21024. scale(scale: number): Vector3;
  21025. /**
  21026. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  21027. * @param scale defines the multiplier factor
  21028. * @param result defines the Vector3 object where to store the result
  21029. * @returns the current Vector3
  21030. */
  21031. scaleToRef(scale: number, result: Vector3): Vector3;
  21032. /**
  21033. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  21034. * @param scale defines the scale factor
  21035. * @param result defines the Vector3 object where to store the result
  21036. * @returns the unmodified current Vector3
  21037. */
  21038. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  21039. /**
  21040. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  21041. * @param otherVector defines the second operand
  21042. * @returns true if both vectors are equals
  21043. */
  21044. equals(otherVector: DeepImmutable<Vector3>): boolean;
  21045. /**
  21046. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  21047. * @param otherVector defines the second operand
  21048. * @param epsilon defines the minimal distance to define values as equals
  21049. * @returns true if both vectors are distant less than epsilon
  21050. */
  21051. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  21052. /**
  21053. * Returns true if the current Vector3 coordinates equals the given floats
  21054. * @param x defines the x coordinate of the operand
  21055. * @param y defines the y coordinate of the operand
  21056. * @param z defines the z coordinate of the operand
  21057. * @returns true if both vectors are equals
  21058. */
  21059. equalsToFloats(x: number, y: number, z: number): boolean;
  21060. /**
  21061. * Multiplies the current Vector3 coordinates by the given ones
  21062. * @param otherVector defines the second operand
  21063. * @returns the current updated Vector3
  21064. */
  21065. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  21066. /**
  21067. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  21068. * @param otherVector defines the second operand
  21069. * @returns the new Vector3
  21070. */
  21071. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  21072. /**
  21073. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  21074. * @param otherVector defines the second operand
  21075. * @param result defines the Vector3 object where to store the result
  21076. * @returns the current Vector3
  21077. */
  21078. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  21079. /**
  21080. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  21081. * @param x defines the x coordinate of the operand
  21082. * @param y defines the y coordinate of the operand
  21083. * @param z defines the z coordinate of the operand
  21084. * @returns the new Vector3
  21085. */
  21086. multiplyByFloats(x: number, y: number, z: number): Vector3;
  21087. /**
  21088. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  21089. * @param otherVector defines the second operand
  21090. * @returns the new Vector3
  21091. */
  21092. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  21093. /**
  21094. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  21095. * @param otherVector defines the second operand
  21096. * @param result defines the Vector3 object where to store the result
  21097. * @returns the current Vector3
  21098. */
  21099. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  21100. /**
  21101. * Divides the current Vector3 coordinates by the given ones.
  21102. * @param otherVector defines the second operand
  21103. * @returns the current updated Vector3
  21104. */
  21105. divideInPlace(otherVector: Vector3): Vector3;
  21106. /**
  21107. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  21108. * @param other defines the second operand
  21109. * @returns the current updated Vector3
  21110. */
  21111. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  21112. /**
  21113. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  21114. * @param other defines the second operand
  21115. * @returns the current updated Vector3
  21116. */
  21117. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  21118. /**
  21119. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  21120. * @param x defines the x coordinate of the operand
  21121. * @param y defines the y coordinate of the operand
  21122. * @param z defines the z coordinate of the operand
  21123. * @returns the current updated Vector3
  21124. */
  21125. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  21126. /**
  21127. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  21128. * @param x defines the x coordinate of the operand
  21129. * @param y defines the y coordinate of the operand
  21130. * @param z defines the z coordinate of the operand
  21131. * @returns the current updated Vector3
  21132. */
  21133. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  21134. /**
  21135. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  21136. */
  21137. readonly isNonUniform: boolean;
  21138. /**
  21139. * Gets a new Vector3 from current Vector3 floored values
  21140. * @returns a new Vector3
  21141. */
  21142. floor(): Vector3;
  21143. /**
  21144. * Gets a new Vector3 from current Vector3 floored values
  21145. * @returns a new Vector3
  21146. */
  21147. fract(): Vector3;
  21148. /**
  21149. * Gets the length of the Vector3
  21150. * @returns the length of the Vecto3
  21151. */
  21152. length(): number;
  21153. /**
  21154. * Gets the squared length of the Vector3
  21155. * @returns squared length of the Vector3
  21156. */
  21157. lengthSquared(): number;
  21158. /**
  21159. * Normalize the current Vector3.
  21160. * Please note that this is an in place operation.
  21161. * @returns the current updated Vector3
  21162. */
  21163. normalize(): Vector3;
  21164. /**
  21165. * Reorders the x y z properties of the vector in place
  21166. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  21167. * @returns the current updated vector
  21168. */
  21169. reorderInPlace(order: string): this;
  21170. /**
  21171. * Rotates the vector around 0,0,0 by a quaternion
  21172. * @param quaternion the rotation quaternion
  21173. * @param result vector to store the result
  21174. * @returns the resulting vector
  21175. */
  21176. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  21177. /**
  21178. * Rotates a vector around a given point
  21179. * @param quaternion the rotation quaternion
  21180. * @param point the point to rotate around
  21181. * @param result vector to store the result
  21182. * @returns the resulting vector
  21183. */
  21184. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  21185. /**
  21186. * Normalize the current Vector3 with the given input length.
  21187. * Please note that this is an in place operation.
  21188. * @param len the length of the vector
  21189. * @returns the current updated Vector3
  21190. */
  21191. normalizeFromLength(len: number): Vector3;
  21192. /**
  21193. * Normalize the current Vector3 to a new vector
  21194. * @returns the new Vector3
  21195. */
  21196. normalizeToNew(): Vector3;
  21197. /**
  21198. * Normalize the current Vector3 to the reference
  21199. * @param reference define the Vector3 to update
  21200. * @returns the updated Vector3
  21201. */
  21202. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  21203. /**
  21204. * Creates a new Vector3 copied from the current Vector3
  21205. * @returns the new Vector3
  21206. */
  21207. clone(): Vector3;
  21208. /**
  21209. * Copies the given vector coordinates to the current Vector3 ones
  21210. * @param source defines the source Vector3
  21211. * @returns the current updated Vector3
  21212. */
  21213. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  21214. /**
  21215. * Copies the given floats to the current Vector3 coordinates
  21216. * @param x defines the x coordinate of the operand
  21217. * @param y defines the y coordinate of the operand
  21218. * @param z defines the z coordinate of the operand
  21219. * @returns the current updated Vector3
  21220. */
  21221. copyFromFloats(x: number, y: number, z: number): Vector3;
  21222. /**
  21223. * Copies the given floats to the current Vector3 coordinates
  21224. * @param x defines the x coordinate of the operand
  21225. * @param y defines the y coordinate of the operand
  21226. * @param z defines the z coordinate of the operand
  21227. * @returns the current updated Vector3
  21228. */
  21229. set(x: number, y: number, z: number): Vector3;
  21230. /**
  21231. * Copies the given float to the current Vector3 coordinates
  21232. * @param v defines the x, y and z coordinates of the operand
  21233. * @returns the current updated Vector3
  21234. */
  21235. setAll(v: number): Vector3;
  21236. /**
  21237. * Get the clip factor between two vectors
  21238. * @param vector0 defines the first operand
  21239. * @param vector1 defines the second operand
  21240. * @param axis defines the axis to use
  21241. * @param size defines the size along the axis
  21242. * @returns the clip factor
  21243. */
  21244. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  21245. /**
  21246. * Get angle between two vectors
  21247. * @param vector0 angle between vector0 and vector1
  21248. * @param vector1 angle between vector0 and vector1
  21249. * @param normal direction of the normal
  21250. * @return the angle between vector0 and vector1
  21251. */
  21252. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  21253. /**
  21254. * Returns a new Vector3 set from the index "offset" of the given array
  21255. * @param array defines the source array
  21256. * @param offset defines the offset in the source array
  21257. * @returns the new Vector3
  21258. */
  21259. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  21260. /**
  21261. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  21262. * This function is deprecated. Use FromArray instead
  21263. * @param array defines the source array
  21264. * @param offset defines the offset in the source array
  21265. * @returns the new Vector3
  21266. */
  21267. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  21268. /**
  21269. * Sets the given vector "result" with the element values from the index "offset" of the given array
  21270. * @param array defines the source array
  21271. * @param offset defines the offset in the source array
  21272. * @param result defines the Vector3 where to store the result
  21273. */
  21274. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  21275. /**
  21276. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  21277. * This function is deprecated. Use FromArrayToRef instead.
  21278. * @param array defines the source array
  21279. * @param offset defines the offset in the source array
  21280. * @param result defines the Vector3 where to store the result
  21281. */
  21282. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  21283. /**
  21284. * Sets the given vector "result" with the given floats.
  21285. * @param x defines the x coordinate of the source
  21286. * @param y defines the y coordinate of the source
  21287. * @param z defines the z coordinate of the source
  21288. * @param result defines the Vector3 where to store the result
  21289. */
  21290. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  21291. /**
  21292. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  21293. * @returns a new empty Vector3
  21294. */
  21295. static Zero(): Vector3;
  21296. /**
  21297. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  21298. * @returns a new unit Vector3
  21299. */
  21300. static One(): Vector3;
  21301. /**
  21302. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  21303. * @returns a new up Vector3
  21304. */
  21305. static Up(): Vector3;
  21306. /**
  21307. * Gets a up Vector3 that must not be updated
  21308. */
  21309. static readonly UpReadOnly: DeepImmutable<Vector3>;
  21310. /**
  21311. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  21312. * @returns a new down Vector3
  21313. */
  21314. static Down(): Vector3;
  21315. /**
  21316. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  21317. * @returns a new forward Vector3
  21318. */
  21319. static Forward(): Vector3;
  21320. /**
  21321. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  21322. * @returns a new forward Vector3
  21323. */
  21324. static Backward(): Vector3;
  21325. /**
  21326. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  21327. * @returns a new right Vector3
  21328. */
  21329. static Right(): Vector3;
  21330. /**
  21331. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  21332. * @returns a new left Vector3
  21333. */
  21334. static Left(): Vector3;
  21335. /**
  21336. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  21337. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  21338. * @param vector defines the Vector3 to transform
  21339. * @param transformation defines the transformation matrix
  21340. * @returns the transformed Vector3
  21341. */
  21342. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  21343. /**
  21344. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  21345. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  21346. * @param vector defines the Vector3 to transform
  21347. * @param transformation defines the transformation matrix
  21348. * @param result defines the Vector3 where to store the result
  21349. */
  21350. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  21351. /**
  21352. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  21353. * This method computes tranformed coordinates only, not transformed direction vectors
  21354. * @param x define the x coordinate of the source vector
  21355. * @param y define the y coordinate of the source vector
  21356. * @param z define the z coordinate of the source vector
  21357. * @param transformation defines the transformation matrix
  21358. * @param result defines the Vector3 where to store the result
  21359. */
  21360. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  21361. /**
  21362. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  21363. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  21364. * @param vector defines the Vector3 to transform
  21365. * @param transformation defines the transformation matrix
  21366. * @returns the new Vector3
  21367. */
  21368. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  21369. /**
  21370. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  21371. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  21372. * @param vector defines the Vector3 to transform
  21373. * @param transformation defines the transformation matrix
  21374. * @param result defines the Vector3 where to store the result
  21375. */
  21376. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  21377. /**
  21378. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  21379. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  21380. * @param x define the x coordinate of the source vector
  21381. * @param y define the y coordinate of the source vector
  21382. * @param z define the z coordinate of the source vector
  21383. * @param transformation defines the transformation matrix
  21384. * @param result defines the Vector3 where to store the result
  21385. */
  21386. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  21387. /**
  21388. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  21389. * @param value1 defines the first control point
  21390. * @param value2 defines the second control point
  21391. * @param value3 defines the third control point
  21392. * @param value4 defines the fourth control point
  21393. * @param amount defines the amount on the spline to use
  21394. * @returns the new Vector3
  21395. */
  21396. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  21397. /**
  21398. * 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"
  21399. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  21400. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  21401. * @param value defines the current value
  21402. * @param min defines the lower range value
  21403. * @param max defines the upper range value
  21404. * @returns the new Vector3
  21405. */
  21406. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  21407. /**
  21408. * 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"
  21409. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  21410. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  21411. * @param value defines the current value
  21412. * @param min defines the lower range value
  21413. * @param max defines the upper range value
  21414. * @param result defines the Vector3 where to store the result
  21415. */
  21416. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  21417. /**
  21418. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  21419. * @param value1 defines the first control point
  21420. * @param tangent1 defines the first tangent vector
  21421. * @param value2 defines the second control point
  21422. * @param tangent2 defines the second tangent vector
  21423. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  21424. * @returns the new Vector3
  21425. */
  21426. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  21427. /**
  21428. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  21429. * @param start defines the start value
  21430. * @param end defines the end value
  21431. * @param amount max defines amount between both (between 0 and 1)
  21432. * @returns the new Vector3
  21433. */
  21434. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  21435. /**
  21436. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  21437. * @param start defines the start value
  21438. * @param end defines the end value
  21439. * @param amount max defines amount between both (between 0 and 1)
  21440. * @param result defines the Vector3 where to store the result
  21441. */
  21442. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  21443. /**
  21444. * Returns the dot product (float) between the vectors "left" and "right"
  21445. * @param left defines the left operand
  21446. * @param right defines the right operand
  21447. * @returns the dot product
  21448. */
  21449. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  21450. /**
  21451. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  21452. * The cross product is then orthogonal to both "left" and "right"
  21453. * @param left defines the left operand
  21454. * @param right defines the right operand
  21455. * @returns the cross product
  21456. */
  21457. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  21458. /**
  21459. * Sets the given vector "result" with the cross product of "left" and "right"
  21460. * The cross product is then orthogonal to both "left" and "right"
  21461. * @param left defines the left operand
  21462. * @param right defines the right operand
  21463. * @param result defines the Vector3 where to store the result
  21464. */
  21465. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  21466. /**
  21467. * Returns a new Vector3 as the normalization of the given vector
  21468. * @param vector defines the Vector3 to normalize
  21469. * @returns the new Vector3
  21470. */
  21471. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  21472. /**
  21473. * Sets the given vector "result" with the normalization of the given first vector
  21474. * @param vector defines the Vector3 to normalize
  21475. * @param result defines the Vector3 where to store the result
  21476. */
  21477. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  21478. /**
  21479. * Project a Vector3 onto screen space
  21480. * @param vector defines the Vector3 to project
  21481. * @param world defines the world matrix to use
  21482. * @param transform defines the transform (view x projection) matrix to use
  21483. * @param viewport defines the screen viewport to use
  21484. * @returns the new Vector3
  21485. */
  21486. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  21487. /** @hidden */
  21488. private static UnprojectFromInvertedMatrixToRef;
  21489. /**
  21490. * Unproject from screen space to object space
  21491. * @param source defines the screen space Vector3 to use
  21492. * @param viewportWidth defines the current width of the viewport
  21493. * @param viewportHeight defines the current height of the viewport
  21494. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21495. * @param transform defines the transform (view x projection) matrix to use
  21496. * @returns the new Vector3
  21497. */
  21498. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  21499. /**
  21500. * Unproject from screen space to object space
  21501. * @param source defines the screen space Vector3 to use
  21502. * @param viewportWidth defines the current width of the viewport
  21503. * @param viewportHeight defines the current height of the viewport
  21504. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21505. * @param view defines the view matrix to use
  21506. * @param projection defines the projection matrix to use
  21507. * @returns the new Vector3
  21508. */
  21509. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  21510. /**
  21511. * Unproject from screen space to object space
  21512. * @param source defines the screen space Vector3 to use
  21513. * @param viewportWidth defines the current width of the viewport
  21514. * @param viewportHeight defines the current height of the viewport
  21515. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21516. * @param view defines the view matrix to use
  21517. * @param projection defines the projection matrix to use
  21518. * @param result defines the Vector3 where to store the result
  21519. */
  21520. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  21521. /**
  21522. * Unproject from screen space to object space
  21523. * @param sourceX defines the screen space x coordinate to use
  21524. * @param sourceY defines the screen space y coordinate to use
  21525. * @param sourceZ defines the screen space z coordinate to use
  21526. * @param viewportWidth defines the current width of the viewport
  21527. * @param viewportHeight defines the current height of the viewport
  21528. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21529. * @param view defines the view matrix to use
  21530. * @param projection defines the projection matrix to use
  21531. * @param result defines the Vector3 where to store the result
  21532. */
  21533. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  21534. /**
  21535. * Unproject a ray from screen space to object space
  21536. * @param sourceX defines the screen space x coordinate to use
  21537. * @param sourceY defines the screen space y coordinate to use
  21538. * @param viewportWidth defines the current width of the viewport
  21539. * @param viewportHeight defines the current height of the viewport
  21540. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21541. * @param view defines the view matrix to use
  21542. * @param projection defines the projection matrix to use
  21543. * @param ray defines the Ray where to store the result
  21544. */
  21545. static UnprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, ray: Ray): void;
  21546. /**
  21547. * Gets the minimal coordinate values between two Vector3
  21548. * @param left defines the first operand
  21549. * @param right defines the second operand
  21550. * @returns the new Vector3
  21551. */
  21552. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  21553. /**
  21554. * Gets the maximal coordinate values between two Vector3
  21555. * @param left defines the first operand
  21556. * @param right defines the second operand
  21557. * @returns the new Vector3
  21558. */
  21559. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  21560. /**
  21561. * Returns the distance between the vectors "value1" and "value2"
  21562. * @param value1 defines the first operand
  21563. * @param value2 defines the second operand
  21564. * @returns the distance
  21565. */
  21566. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  21567. /**
  21568. * Returns the squared distance between the vectors "value1" and "value2"
  21569. * @param value1 defines the first operand
  21570. * @param value2 defines the second operand
  21571. * @returns the squared distance
  21572. */
  21573. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  21574. /**
  21575. * Returns a new Vector3 located at the center between "value1" and "value2"
  21576. * @param value1 defines the first operand
  21577. * @param value2 defines the second operand
  21578. * @returns the new Vector3
  21579. */
  21580. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  21581. /**
  21582. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  21583. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  21584. * to something in order to rotate it from its local system to the given target system
  21585. * Note: axis1, axis2 and axis3 are normalized during this operation
  21586. * @param axis1 defines the first axis
  21587. * @param axis2 defines the second axis
  21588. * @param axis3 defines the third axis
  21589. * @returns a new Vector3
  21590. */
  21591. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  21592. /**
  21593. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  21594. * @param axis1 defines the first axis
  21595. * @param axis2 defines the second axis
  21596. * @param axis3 defines the third axis
  21597. * @param ref defines the Vector3 where to store the result
  21598. */
  21599. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  21600. }
  21601. /**
  21602. * Vector4 class created for EulerAngle class conversion to Quaternion
  21603. */
  21604. class Vector4 {
  21605. /** x value of the vector */
  21606. x: number;
  21607. /** y value of the vector */
  21608. y: number;
  21609. /** z value of the vector */
  21610. z: number;
  21611. /** w value of the vector */
  21612. w: number;
  21613. /**
  21614. * Creates a Vector4 object from the given floats.
  21615. * @param x x value of the vector
  21616. * @param y y value of the vector
  21617. * @param z z value of the vector
  21618. * @param w w value of the vector
  21619. */
  21620. constructor(
  21621. /** x value of the vector */
  21622. x: number,
  21623. /** y value of the vector */
  21624. y: number,
  21625. /** z value of the vector */
  21626. z: number,
  21627. /** w value of the vector */
  21628. w: number);
  21629. /**
  21630. * Returns the string with the Vector4 coordinates.
  21631. * @returns a string containing all the vector values
  21632. */
  21633. toString(): string;
  21634. /**
  21635. * Returns the string "Vector4".
  21636. * @returns "Vector4"
  21637. */
  21638. getClassName(): string;
  21639. /**
  21640. * Returns the Vector4 hash code.
  21641. * @returns a unique hash code
  21642. */
  21643. getHashCode(): number;
  21644. /**
  21645. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  21646. * @returns the resulting array
  21647. */
  21648. asArray(): number[];
  21649. /**
  21650. * Populates the given array from the given index with the Vector4 coordinates.
  21651. * @param array array to populate
  21652. * @param index index of the array to start at (default: 0)
  21653. * @returns the Vector4.
  21654. */
  21655. toArray(array: FloatArray, index?: number): Vector4;
  21656. /**
  21657. * Adds the given vector to the current Vector4.
  21658. * @param otherVector the vector to add
  21659. * @returns the updated Vector4.
  21660. */
  21661. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  21662. /**
  21663. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  21664. * @param otherVector the vector to add
  21665. * @returns the resulting vector
  21666. */
  21667. add(otherVector: DeepImmutable<Vector4>): Vector4;
  21668. /**
  21669. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  21670. * @param otherVector the vector to add
  21671. * @param result the vector to store the result
  21672. * @returns the current Vector4.
  21673. */
  21674. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  21675. /**
  21676. * Subtract in place the given vector from the current Vector4.
  21677. * @param otherVector the vector to subtract
  21678. * @returns the updated Vector4.
  21679. */
  21680. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  21681. /**
  21682. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  21683. * @param otherVector the vector to add
  21684. * @returns the new vector with the result
  21685. */
  21686. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  21687. /**
  21688. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  21689. * @param otherVector the vector to subtract
  21690. * @param result the vector to store the result
  21691. * @returns the current Vector4.
  21692. */
  21693. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  21694. /**
  21695. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  21696. */
  21697. /**
  21698. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  21699. * @param x value to subtract
  21700. * @param y value to subtract
  21701. * @param z value to subtract
  21702. * @param w value to subtract
  21703. * @returns new vector containing the result
  21704. */
  21705. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  21706. /**
  21707. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  21708. * @param x value to subtract
  21709. * @param y value to subtract
  21710. * @param z value to subtract
  21711. * @param w value to subtract
  21712. * @param result the vector to store the result in
  21713. * @returns the current Vector4.
  21714. */
  21715. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  21716. /**
  21717. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  21718. * @returns a new vector with the negated values
  21719. */
  21720. negate(): Vector4;
  21721. /**
  21722. * Multiplies the current Vector4 coordinates by scale (float).
  21723. * @param scale the number to scale with
  21724. * @returns the updated Vector4.
  21725. */
  21726. scaleInPlace(scale: number): Vector4;
  21727. /**
  21728. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  21729. * @param scale the number to scale with
  21730. * @returns a new vector with the result
  21731. */
  21732. scale(scale: number): Vector4;
  21733. /**
  21734. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  21735. * @param scale the number to scale with
  21736. * @param result a vector to store the result in
  21737. * @returns the current Vector4.
  21738. */
  21739. scaleToRef(scale: number, result: Vector4): Vector4;
  21740. /**
  21741. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  21742. * @param scale defines the scale factor
  21743. * @param result defines the Vector4 object where to store the result
  21744. * @returns the unmodified current Vector4
  21745. */
  21746. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  21747. /**
  21748. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  21749. * @param otherVector the vector to compare against
  21750. * @returns true if they are equal
  21751. */
  21752. equals(otherVector: DeepImmutable<Vector4>): boolean;
  21753. /**
  21754. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  21755. * @param otherVector vector to compare against
  21756. * @param epsilon (Default: very small number)
  21757. * @returns true if they are equal
  21758. */
  21759. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  21760. /**
  21761. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  21762. * @param x x value to compare against
  21763. * @param y y value to compare against
  21764. * @param z z value to compare against
  21765. * @param w w value to compare against
  21766. * @returns true if equal
  21767. */
  21768. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  21769. /**
  21770. * Multiplies in place the current Vector4 by the given one.
  21771. * @param otherVector vector to multiple with
  21772. * @returns the updated Vector4.
  21773. */
  21774. multiplyInPlace(otherVector: Vector4): Vector4;
  21775. /**
  21776. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  21777. * @param otherVector vector to multiple with
  21778. * @returns resulting new vector
  21779. */
  21780. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  21781. /**
  21782. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  21783. * @param otherVector vector to multiple with
  21784. * @param result vector to store the result
  21785. * @returns the current Vector4.
  21786. */
  21787. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  21788. /**
  21789. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  21790. * @param x x value multiply with
  21791. * @param y y value multiply with
  21792. * @param z z value multiply with
  21793. * @param w w value multiply with
  21794. * @returns resulting new vector
  21795. */
  21796. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  21797. /**
  21798. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  21799. * @param otherVector vector to devide with
  21800. * @returns resulting new vector
  21801. */
  21802. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  21803. /**
  21804. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  21805. * @param otherVector vector to devide with
  21806. * @param result vector to store the result
  21807. * @returns the current Vector4.
  21808. */
  21809. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  21810. /**
  21811. * Divides the current Vector3 coordinates by the given ones.
  21812. * @param otherVector vector to devide with
  21813. * @returns the updated Vector3.
  21814. */
  21815. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  21816. /**
  21817. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  21818. * @param other defines the second operand
  21819. * @returns the current updated Vector4
  21820. */
  21821. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  21822. /**
  21823. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  21824. * @param other defines the second operand
  21825. * @returns the current updated Vector4
  21826. */
  21827. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  21828. /**
  21829. * Gets a new Vector4 from current Vector4 floored values
  21830. * @returns a new Vector4
  21831. */
  21832. floor(): Vector4;
  21833. /**
  21834. * Gets a new Vector4 from current Vector3 floored values
  21835. * @returns a new Vector4
  21836. */
  21837. fract(): Vector4;
  21838. /**
  21839. * Returns the Vector4 length (float).
  21840. * @returns the length
  21841. */
  21842. length(): number;
  21843. /**
  21844. * Returns the Vector4 squared length (float).
  21845. * @returns the length squared
  21846. */
  21847. lengthSquared(): number;
  21848. /**
  21849. * Normalizes in place the Vector4.
  21850. * @returns the updated Vector4.
  21851. */
  21852. normalize(): Vector4;
  21853. /**
  21854. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  21855. * @returns this converted to a new vector3
  21856. */
  21857. toVector3(): Vector3;
  21858. /**
  21859. * Returns a new Vector4 copied from the current one.
  21860. * @returns the new cloned vector
  21861. */
  21862. clone(): Vector4;
  21863. /**
  21864. * Updates the current Vector4 with the given one coordinates.
  21865. * @param source the source vector to copy from
  21866. * @returns the updated Vector4.
  21867. */
  21868. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  21869. /**
  21870. * Updates the current Vector4 coordinates with the given floats.
  21871. * @param x float to copy from
  21872. * @param y float to copy from
  21873. * @param z float to copy from
  21874. * @param w float to copy from
  21875. * @returns the updated Vector4.
  21876. */
  21877. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  21878. /**
  21879. * Updates the current Vector4 coordinates with the given floats.
  21880. * @param x float to set from
  21881. * @param y float to set from
  21882. * @param z float to set from
  21883. * @param w float to set from
  21884. * @returns the updated Vector4.
  21885. */
  21886. set(x: number, y: number, z: number, w: number): Vector4;
  21887. /**
  21888. * Copies the given float to the current Vector3 coordinates
  21889. * @param v defines the x, y, z and w coordinates of the operand
  21890. * @returns the current updated Vector3
  21891. */
  21892. setAll(v: number): Vector4;
  21893. /**
  21894. * Returns a new Vector4 set from the starting index of the given array.
  21895. * @param array the array to pull values from
  21896. * @param offset the offset into the array to start at
  21897. * @returns the new vector
  21898. */
  21899. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  21900. /**
  21901. * Updates the given vector "result" from the starting index of the given array.
  21902. * @param array the array to pull values from
  21903. * @param offset the offset into the array to start at
  21904. * @param result the vector to store the result in
  21905. */
  21906. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  21907. /**
  21908. * Updates the given vector "result" from the starting index of the given Float32Array.
  21909. * @param array the array to pull values from
  21910. * @param offset the offset into the array to start at
  21911. * @param result the vector to store the result in
  21912. */
  21913. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  21914. /**
  21915. * Updates the given vector "result" coordinates from the given floats.
  21916. * @param x float to set from
  21917. * @param y float to set from
  21918. * @param z float to set from
  21919. * @param w float to set from
  21920. * @param result the vector to the floats in
  21921. */
  21922. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  21923. /**
  21924. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  21925. * @returns the new vector
  21926. */
  21927. static Zero(): Vector4;
  21928. /**
  21929. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  21930. * @returns the new vector
  21931. */
  21932. static One(): Vector4;
  21933. /**
  21934. * Returns a new normalized Vector4 from the given one.
  21935. * @param vector the vector to normalize
  21936. * @returns the vector
  21937. */
  21938. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  21939. /**
  21940. * Updates the given vector "result" from the normalization of the given one.
  21941. * @param vector the vector to normalize
  21942. * @param result the vector to store the result in
  21943. */
  21944. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  21945. /**
  21946. * Returns a vector with the minimum values from the left and right vectors
  21947. * @param left left vector to minimize
  21948. * @param right right vector to minimize
  21949. * @returns a new vector with the minimum of the left and right vector values
  21950. */
  21951. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  21952. /**
  21953. * Returns a vector with the maximum values from the left and right vectors
  21954. * @param left left vector to maximize
  21955. * @param right right vector to maximize
  21956. * @returns a new vector with the maximum of the left and right vector values
  21957. */
  21958. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  21959. /**
  21960. * Returns the distance (float) between the vectors "value1" and "value2".
  21961. * @param value1 value to calulate the distance between
  21962. * @param value2 value to calulate the distance between
  21963. * @return the distance between the two vectors
  21964. */
  21965. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  21966. /**
  21967. * Returns the squared distance (float) between the vectors "value1" and "value2".
  21968. * @param value1 value to calulate the distance between
  21969. * @param value2 value to calulate the distance between
  21970. * @return the distance between the two vectors squared
  21971. */
  21972. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  21973. /**
  21974. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  21975. * @param value1 value to calulate the center between
  21976. * @param value2 value to calulate the center between
  21977. * @return the center between the two vectors
  21978. */
  21979. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  21980. /**
  21981. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  21982. * This methods computes transformed normalized direction vectors only.
  21983. * @param vector the vector to transform
  21984. * @param transformation the transformation matrix to apply
  21985. * @returns the new vector
  21986. */
  21987. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  21988. /**
  21989. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  21990. * This methods computes transformed normalized direction vectors only.
  21991. * @param vector the vector to transform
  21992. * @param transformation the transformation matrix to apply
  21993. * @param result the vector to store the result in
  21994. */
  21995. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  21996. /**
  21997. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  21998. * This methods computes transformed normalized direction vectors only.
  21999. * @param x value to transform
  22000. * @param y value to transform
  22001. * @param z value to transform
  22002. * @param w value to transform
  22003. * @param transformation the transformation matrix to apply
  22004. * @param result the vector to store the results in
  22005. */
  22006. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  22007. /**
  22008. * Creates a new Vector4 from a Vector3
  22009. * @param source defines the source data
  22010. * @param w defines the 4th component (default is 0)
  22011. * @returns a new Vector4
  22012. */
  22013. static FromVector3(source: Vector3, w?: number): Vector4;
  22014. }
  22015. /**
  22016. * Interface for the size containing width and height
  22017. */
  22018. interface ISize {
  22019. /**
  22020. * Width
  22021. */
  22022. width: number;
  22023. /**
  22024. * Heighht
  22025. */
  22026. height: number;
  22027. }
  22028. /**
  22029. * Size containing widht and height
  22030. */
  22031. class Size implements ISize {
  22032. /**
  22033. * Width
  22034. */
  22035. width: number;
  22036. /**
  22037. * Height
  22038. */
  22039. height: number;
  22040. /**
  22041. * Creates a Size object from the given width and height (floats).
  22042. * @param width width of the new size
  22043. * @param height height of the new size
  22044. */
  22045. constructor(width: number, height: number);
  22046. /**
  22047. * Returns a string with the Size width and height
  22048. * @returns a string with the Size width and height
  22049. */
  22050. toString(): string;
  22051. /**
  22052. * "Size"
  22053. * @returns the string "Size"
  22054. */
  22055. getClassName(): string;
  22056. /**
  22057. * Returns the Size hash code.
  22058. * @returns a hash code for a unique width and height
  22059. */
  22060. getHashCode(): number;
  22061. /**
  22062. * Updates the current size from the given one.
  22063. * @param src the given size
  22064. */
  22065. copyFrom(src: Size): void;
  22066. /**
  22067. * Updates in place the current Size from the given floats.
  22068. * @param width width of the new size
  22069. * @param height height of the new size
  22070. * @returns the updated Size.
  22071. */
  22072. copyFromFloats(width: number, height: number): Size;
  22073. /**
  22074. * Updates in place the current Size from the given floats.
  22075. * @param width width to set
  22076. * @param height height to set
  22077. * @returns the updated Size.
  22078. */
  22079. set(width: number, height: number): Size;
  22080. /**
  22081. * Multiplies the width and height by numbers
  22082. * @param w factor to multiple the width by
  22083. * @param h factor to multiple the height by
  22084. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  22085. */
  22086. multiplyByFloats(w: number, h: number): Size;
  22087. /**
  22088. * Clones the size
  22089. * @returns a new Size copied from the given one.
  22090. */
  22091. clone(): Size;
  22092. /**
  22093. * True if the current Size and the given one width and height are strictly equal.
  22094. * @param other the other size to compare against
  22095. * @returns True if the current Size and the given one width and height are strictly equal.
  22096. */
  22097. equals(other: Size): boolean;
  22098. /**
  22099. * The surface of the Size : width * height (float).
  22100. */
  22101. readonly surface: number;
  22102. /**
  22103. * Create a new size of zero
  22104. * @returns a new Size set to (0.0, 0.0)
  22105. */
  22106. static Zero(): Size;
  22107. /**
  22108. * Sums the width and height of two sizes
  22109. * @param otherSize size to add to this size
  22110. * @returns a new Size set as the addition result of the current Size and the given one.
  22111. */
  22112. add(otherSize: Size): Size;
  22113. /**
  22114. * Subtracts the width and height of two
  22115. * @param otherSize size to subtract to this size
  22116. * @returns a new Size set as the subtraction result of the given one from the current Size.
  22117. */
  22118. subtract(otherSize: Size): Size;
  22119. /**
  22120. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  22121. * @param start starting size to lerp between
  22122. * @param end end size to lerp between
  22123. * @param amount amount to lerp between the start and end values
  22124. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  22125. */
  22126. static Lerp(start: Size, end: Size, amount: number): Size;
  22127. }
  22128. /**
  22129. * Class used to store quaternion data
  22130. * @see https://en.wikipedia.org/wiki/Quaternion
  22131. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  22132. */
  22133. class Quaternion {
  22134. /** defines the first component (0 by default) */
  22135. x: number;
  22136. /** defines the second component (0 by default) */
  22137. y: number;
  22138. /** defines the third component (0 by default) */
  22139. z: number;
  22140. /** defines the fourth component (1.0 by default) */
  22141. w: number;
  22142. /**
  22143. * Creates a new Quaternion from the given floats
  22144. * @param x defines the first component (0 by default)
  22145. * @param y defines the second component (0 by default)
  22146. * @param z defines the third component (0 by default)
  22147. * @param w defines the fourth component (1.0 by default)
  22148. */
  22149. constructor(
  22150. /** defines the first component (0 by default) */
  22151. x?: number,
  22152. /** defines the second component (0 by default) */
  22153. y?: number,
  22154. /** defines the third component (0 by default) */
  22155. z?: number,
  22156. /** defines the fourth component (1.0 by default) */
  22157. w?: number);
  22158. /**
  22159. * Gets a string representation for the current quaternion
  22160. * @returns a string with the Quaternion coordinates
  22161. */
  22162. toString(): string;
  22163. /**
  22164. * Gets the class name of the quaternion
  22165. * @returns the string "Quaternion"
  22166. */
  22167. getClassName(): string;
  22168. /**
  22169. * Gets a hash code for this quaternion
  22170. * @returns the quaternion hash code
  22171. */
  22172. getHashCode(): number;
  22173. /**
  22174. * Copy the quaternion to an array
  22175. * @returns a new array populated with 4 elements from the quaternion coordinates
  22176. */
  22177. asArray(): number[];
  22178. /**
  22179. * Check if two quaternions are equals
  22180. * @param otherQuaternion defines the second operand
  22181. * @return true if the current quaternion and the given one coordinates are strictly equals
  22182. */
  22183. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  22184. /**
  22185. * Clone the current quaternion
  22186. * @returns a new quaternion copied from the current one
  22187. */
  22188. clone(): Quaternion;
  22189. /**
  22190. * Copy a quaternion to the current one
  22191. * @param other defines the other quaternion
  22192. * @returns the updated current quaternion
  22193. */
  22194. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  22195. /**
  22196. * Updates the current quaternion with the given float coordinates
  22197. * @param x defines the x coordinate
  22198. * @param y defines the y coordinate
  22199. * @param z defines the z coordinate
  22200. * @param w defines the w coordinate
  22201. * @returns the updated current quaternion
  22202. */
  22203. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  22204. /**
  22205. * Updates the current quaternion from the given float coordinates
  22206. * @param x defines the x coordinate
  22207. * @param y defines the y coordinate
  22208. * @param z defines the z coordinate
  22209. * @param w defines the w coordinate
  22210. * @returns the updated current quaternion
  22211. */
  22212. set(x: number, y: number, z: number, w: number): Quaternion;
  22213. /**
  22214. * Adds two quaternions
  22215. * @param other defines the second operand
  22216. * @returns a new quaternion as the addition result of the given one and the current quaternion
  22217. */
  22218. add(other: DeepImmutable<Quaternion>): Quaternion;
  22219. /**
  22220. * Add a quaternion to the current one
  22221. * @param other defines the quaternion to add
  22222. * @returns the current quaternion
  22223. */
  22224. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  22225. /**
  22226. * Subtract two quaternions
  22227. * @param other defines the second operand
  22228. * @returns a new quaternion as the subtraction result of the given one from the current one
  22229. */
  22230. subtract(other: Quaternion): Quaternion;
  22231. /**
  22232. * Multiplies the current quaternion by a scale factor
  22233. * @param value defines the scale factor
  22234. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  22235. */
  22236. scale(value: number): Quaternion;
  22237. /**
  22238. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  22239. * @param scale defines the scale factor
  22240. * @param result defines the Quaternion object where to store the result
  22241. * @returns the unmodified current quaternion
  22242. */
  22243. scaleToRef(scale: number, result: Quaternion): Quaternion;
  22244. /**
  22245. * Multiplies in place the current quaternion by a scale factor
  22246. * @param value defines the scale factor
  22247. * @returns the current modified quaternion
  22248. */
  22249. scaleInPlace(value: number): Quaternion;
  22250. /**
  22251. * Scale the current quaternion values by a factor and add the result to a given quaternion
  22252. * @param scale defines the scale factor
  22253. * @param result defines the Quaternion object where to store the result
  22254. * @returns the unmodified current quaternion
  22255. */
  22256. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  22257. /**
  22258. * Multiplies two quaternions
  22259. * @param q1 defines the second operand
  22260. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  22261. */
  22262. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  22263. /**
  22264. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  22265. * @param q1 defines the second operand
  22266. * @param result defines the target quaternion
  22267. * @returns the current quaternion
  22268. */
  22269. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  22270. /**
  22271. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  22272. * @param q1 defines the second operand
  22273. * @returns the currentupdated quaternion
  22274. */
  22275. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  22276. /**
  22277. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  22278. * @param ref defines the target quaternion
  22279. * @returns the current quaternion
  22280. */
  22281. conjugateToRef(ref: Quaternion): Quaternion;
  22282. /**
  22283. * Conjugates in place (1-q) the current quaternion
  22284. * @returns the current updated quaternion
  22285. */
  22286. conjugateInPlace(): Quaternion;
  22287. /**
  22288. * Conjugates in place (1-q) the current quaternion
  22289. * @returns a new quaternion
  22290. */
  22291. conjugate(): Quaternion;
  22292. /**
  22293. * Gets length of current quaternion
  22294. * @returns the quaternion length (float)
  22295. */
  22296. length(): number;
  22297. /**
  22298. * Normalize in place the current quaternion
  22299. * @returns the current updated quaternion
  22300. */
  22301. normalize(): Quaternion;
  22302. /**
  22303. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  22304. * @param order is a reserved parameter and is ignore for now
  22305. * @returns a new Vector3 containing the Euler angles
  22306. */
  22307. toEulerAngles(order?: string): Vector3;
  22308. /**
  22309. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  22310. * @param result defines the vector which will be filled with the Euler angles
  22311. * @param order is a reserved parameter and is ignore for now
  22312. * @returns the current unchanged quaternion
  22313. */
  22314. toEulerAnglesToRef(result: Vector3, order?: string): Quaternion;
  22315. /**
  22316. * Updates the given rotation matrix with the current quaternion values
  22317. * @param result defines the target matrix
  22318. * @returns the current unchanged quaternion
  22319. */
  22320. toRotationMatrix(result: Matrix): Quaternion;
  22321. /**
  22322. * Updates the current quaternion from the given rotation matrix values
  22323. * @param matrix defines the source matrix
  22324. * @returns the current updated quaternion
  22325. */
  22326. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  22327. /**
  22328. * Creates a new quaternion from a rotation matrix
  22329. * @param matrix defines the source matrix
  22330. * @returns a new quaternion created from the given rotation matrix values
  22331. */
  22332. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  22333. /**
  22334. * Updates the given quaternion with the given rotation matrix values
  22335. * @param matrix defines the source matrix
  22336. * @param result defines the target quaternion
  22337. */
  22338. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  22339. /**
  22340. * Returns the dot product (float) between the quaternions "left" and "right"
  22341. * @param left defines the left operand
  22342. * @param right defines the right operand
  22343. * @returns the dot product
  22344. */
  22345. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  22346. /**
  22347. * Checks if the two quaternions are close to each other
  22348. * @param quat0 defines the first quaternion to check
  22349. * @param quat1 defines the second quaternion to check
  22350. * @returns true if the two quaternions are close to each other
  22351. */
  22352. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  22353. /**
  22354. * Creates an empty quaternion
  22355. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  22356. */
  22357. static Zero(): Quaternion;
  22358. /**
  22359. * Inverse a given quaternion
  22360. * @param q defines the source quaternion
  22361. * @returns a new quaternion as the inverted current quaternion
  22362. */
  22363. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  22364. /**
  22365. * Inverse a given quaternion
  22366. * @param q defines the source quaternion
  22367. * @param result the quaternion the result will be stored in
  22368. * @returns the result quaternion
  22369. */
  22370. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  22371. /**
  22372. * Creates an identity quaternion
  22373. * @returns the identity quaternion
  22374. */
  22375. static Identity(): Quaternion;
  22376. /**
  22377. * Gets a boolean indicating if the given quaternion is identity
  22378. * @param quaternion defines the quaternion to check
  22379. * @returns true if the quaternion is identity
  22380. */
  22381. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  22382. /**
  22383. * Creates a quaternion from a rotation around an axis
  22384. * @param axis defines the axis to use
  22385. * @param angle defines the angle to use
  22386. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  22387. */
  22388. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  22389. /**
  22390. * Creates a rotation around an axis and stores it into the given quaternion
  22391. * @param axis defines the axis to use
  22392. * @param angle defines the angle to use
  22393. * @param result defines the target quaternion
  22394. * @returns the target quaternion
  22395. */
  22396. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  22397. /**
  22398. * Creates a new quaternion from data stored into an array
  22399. * @param array defines the data source
  22400. * @param offset defines the offset in the source array where the data starts
  22401. * @returns a new quaternion
  22402. */
  22403. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  22404. /**
  22405. * Create a quaternion from Euler rotation angles
  22406. * @param x Pitch
  22407. * @param y Yaw
  22408. * @param z Roll
  22409. * @returns the new Quaternion
  22410. */
  22411. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  22412. /**
  22413. * Updates a quaternion from Euler rotation angles
  22414. * @param x Pitch
  22415. * @param y Yaw
  22416. * @param z Roll
  22417. * @param result the quaternion to store the result
  22418. * @returns the updated quaternion
  22419. */
  22420. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  22421. /**
  22422. * Create a quaternion from Euler rotation vector
  22423. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  22424. * @returns the new Quaternion
  22425. */
  22426. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  22427. /**
  22428. * Updates a quaternion from Euler rotation vector
  22429. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  22430. * @param result the quaternion to store the result
  22431. * @returns the updated quaternion
  22432. */
  22433. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  22434. /**
  22435. * Creates a new quaternion from the given Euler float angles (y, x, z)
  22436. * @param yaw defines the rotation around Y axis
  22437. * @param pitch defines the rotation around X axis
  22438. * @param roll defines the rotation around Z axis
  22439. * @returns the new quaternion
  22440. */
  22441. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  22442. /**
  22443. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  22444. * @param yaw defines the rotation around Y axis
  22445. * @param pitch defines the rotation around X axis
  22446. * @param roll defines the rotation around Z axis
  22447. * @param result defines the target quaternion
  22448. */
  22449. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  22450. /**
  22451. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  22452. * @param alpha defines the rotation around first axis
  22453. * @param beta defines the rotation around second axis
  22454. * @param gamma defines the rotation around third axis
  22455. * @returns the new quaternion
  22456. */
  22457. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  22458. /**
  22459. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  22460. * @param alpha defines the rotation around first axis
  22461. * @param beta defines the rotation around second axis
  22462. * @param gamma defines the rotation around third axis
  22463. * @param result defines the target quaternion
  22464. */
  22465. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  22466. /**
  22467. * 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)
  22468. * @param axis1 defines the first axis
  22469. * @param axis2 defines the second axis
  22470. * @param axis3 defines the third axis
  22471. * @returns the new quaternion
  22472. */
  22473. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  22474. /**
  22475. * 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
  22476. * @param axis1 defines the first axis
  22477. * @param axis2 defines the second axis
  22478. * @param axis3 defines the third axis
  22479. * @param ref defines the target quaternion
  22480. */
  22481. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  22482. /**
  22483. * Interpolates between two quaternions
  22484. * @param left defines first quaternion
  22485. * @param right defines second quaternion
  22486. * @param amount defines the gradient to use
  22487. * @returns the new interpolated quaternion
  22488. */
  22489. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  22490. /**
  22491. * Interpolates between two quaternions and stores it into a target quaternion
  22492. * @param left defines first quaternion
  22493. * @param right defines second quaternion
  22494. * @param amount defines the gradient to use
  22495. * @param result defines the target quaternion
  22496. */
  22497. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  22498. /**
  22499. * Interpolate between two quaternions using Hermite interpolation
  22500. * @param value1 defines first quaternion
  22501. * @param tangent1 defines the incoming tangent
  22502. * @param value2 defines second quaternion
  22503. * @param tangent2 defines the outgoing tangent
  22504. * @param amount defines the target quaternion
  22505. * @returns the new interpolated quaternion
  22506. */
  22507. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  22508. }
  22509. /**
  22510. * Class used to store matrix data (4x4)
  22511. */
  22512. class Matrix {
  22513. private static _updateFlagSeed;
  22514. private static _identityReadOnly;
  22515. private _isIdentity;
  22516. private _isIdentityDirty;
  22517. private _isIdentity3x2;
  22518. private _isIdentity3x2Dirty;
  22519. /**
  22520. * Gets the update flag of the matrix which is an unique number for the matrix.
  22521. * It will be incremented every time the matrix data change.
  22522. * You can use it to speed the comparison between two versions of the same matrix.
  22523. */
  22524. updateFlag: number;
  22525. private readonly _m;
  22526. /**
  22527. * Gets the internal data of the matrix
  22528. */
  22529. readonly m: DeepImmutable<Float32Array>;
  22530. /** @hidden */
  22531. _markAsUpdated(): void;
  22532. /** @hidden */
  22533. private _updateIdentityStatus;
  22534. /**
  22535. * Creates an empty matrix (filled with zeros)
  22536. */
  22537. constructor();
  22538. /**
  22539. * Check if the current matrix is identity
  22540. * @returns true is the matrix is the identity matrix
  22541. */
  22542. isIdentity(): boolean;
  22543. /**
  22544. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  22545. * @returns true is the matrix is the identity matrix
  22546. */
  22547. isIdentityAs3x2(): boolean;
  22548. /**
  22549. * Gets the determinant of the matrix
  22550. * @returns the matrix determinant
  22551. */
  22552. determinant(): number;
  22553. /**
  22554. * Returns the matrix as a Float32Array
  22555. * @returns the matrix underlying array
  22556. */
  22557. toArray(): DeepImmutable<Float32Array>;
  22558. /**
  22559. * Returns the matrix as a Float32Array
  22560. * @returns the matrix underlying array.
  22561. */
  22562. asArray(): DeepImmutable<Float32Array>;
  22563. /**
  22564. * Inverts the current matrix in place
  22565. * @returns the current inverted matrix
  22566. */
  22567. invert(): Matrix;
  22568. /**
  22569. * Sets all the matrix elements to zero
  22570. * @returns the current matrix
  22571. */
  22572. reset(): Matrix;
  22573. /**
  22574. * Adds the current matrix with a second one
  22575. * @param other defines the matrix to add
  22576. * @returns a new matrix as the addition of the current matrix and the given one
  22577. */
  22578. add(other: DeepImmutable<Matrix>): Matrix;
  22579. /**
  22580. * Sets the given matrix "result" to the addition of the current matrix and the given one
  22581. * @param other defines the matrix to add
  22582. * @param result defines the target matrix
  22583. * @returns the current matrix
  22584. */
  22585. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  22586. /**
  22587. * Adds in place the given matrix to the current matrix
  22588. * @param other defines the second operand
  22589. * @returns the current updated matrix
  22590. */
  22591. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  22592. /**
  22593. * Sets the given matrix to the current inverted Matrix
  22594. * @param other defines the target matrix
  22595. * @returns the unmodified current matrix
  22596. */
  22597. invertToRef(other: Matrix): Matrix;
  22598. /**
  22599. * add a value at the specified position in the current Matrix
  22600. * @param index the index of the value within the matrix. between 0 and 15.
  22601. * @param value the value to be added
  22602. * @returns the current updated matrix
  22603. */
  22604. addAtIndex(index: number, value: number): Matrix;
  22605. /**
  22606. * mutiply the specified position in the current Matrix by a value
  22607. * @param index the index of the value within the matrix. between 0 and 15.
  22608. * @param value the value to be added
  22609. * @returns the current updated matrix
  22610. */
  22611. multiplyAtIndex(index: number, value: number): Matrix;
  22612. /**
  22613. * Inserts the translation vector (using 3 floats) in the current matrix
  22614. * @param x defines the 1st component of the translation
  22615. * @param y defines the 2nd component of the translation
  22616. * @param z defines the 3rd component of the translation
  22617. * @returns the current updated matrix
  22618. */
  22619. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  22620. /**
  22621. * Inserts the translation vector in the current matrix
  22622. * @param vector3 defines the translation to insert
  22623. * @returns the current updated matrix
  22624. */
  22625. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  22626. /**
  22627. * Gets the translation value of the current matrix
  22628. * @returns a new Vector3 as the extracted translation from the matrix
  22629. */
  22630. getTranslation(): Vector3;
  22631. /**
  22632. * Fill a Vector3 with the extracted translation from the matrix
  22633. * @param result defines the Vector3 where to store the translation
  22634. * @returns the current matrix
  22635. */
  22636. getTranslationToRef(result: Vector3): Matrix;
  22637. /**
  22638. * Remove rotation and scaling part from the matrix
  22639. * @returns the updated matrix
  22640. */
  22641. removeRotationAndScaling(): Matrix;
  22642. /**
  22643. * Multiply two matrices
  22644. * @param other defines the second operand
  22645. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  22646. */
  22647. multiply(other: DeepImmutable<Matrix>): Matrix;
  22648. /**
  22649. * Copy the current matrix from the given one
  22650. * @param other defines the source matrix
  22651. * @returns the current updated matrix
  22652. */
  22653. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  22654. /**
  22655. * Populates the given array from the starting index with the current matrix values
  22656. * @param array defines the target array
  22657. * @param offset defines the offset in the target array where to start storing values
  22658. * @returns the current matrix
  22659. */
  22660. copyToArray(array: Float32Array, offset?: number): Matrix;
  22661. /**
  22662. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  22663. * @param other defines the second operand
  22664. * @param result defines the matrix where to store the multiplication
  22665. * @returns the current matrix
  22666. */
  22667. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  22668. /**
  22669. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  22670. * @param other defines the second operand
  22671. * @param result defines the array where to store the multiplication
  22672. * @param offset defines the offset in the target array where to start storing values
  22673. * @returns the current matrix
  22674. */
  22675. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  22676. /**
  22677. * Check equality between this matrix and a second one
  22678. * @param value defines the second matrix to compare
  22679. * @returns true is the current matrix and the given one values are strictly equal
  22680. */
  22681. equals(value: DeepImmutable<Matrix>): boolean;
  22682. /**
  22683. * Clone the current matrix
  22684. * @returns a new matrix from the current matrix
  22685. */
  22686. clone(): Matrix;
  22687. /**
  22688. * Returns the name of the current matrix class
  22689. * @returns the string "Matrix"
  22690. */
  22691. getClassName(): string;
  22692. /**
  22693. * Gets the hash code of the current matrix
  22694. * @returns the hash code
  22695. */
  22696. getHashCode(): number;
  22697. /**
  22698. * Decomposes the current Matrix into a translation, rotation and scaling components
  22699. * @param scale defines the scale vector3 given as a reference to update
  22700. * @param rotation defines the rotation quaternion given as a reference to update
  22701. * @param translation defines the translation vector3 given as a reference to update
  22702. * @returns true if operation was successful
  22703. */
  22704. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  22705. /**
  22706. * Gets specific row of the matrix
  22707. * @param index defines the number of the row to get
  22708. * @returns the index-th row of the current matrix as a new Vector4
  22709. */
  22710. getRow(index: number): Nullable<Vector4>;
  22711. /**
  22712. * Sets the index-th row of the current matrix to the vector4 values
  22713. * @param index defines the number of the row to set
  22714. * @param row defines the target vector4
  22715. * @returns the updated current matrix
  22716. */
  22717. setRow(index: number, row: Vector4): Matrix;
  22718. /**
  22719. * Compute the transpose of the matrix
  22720. * @returns the new transposed matrix
  22721. */
  22722. transpose(): Matrix;
  22723. /**
  22724. * Compute the transpose of the matrix and store it in a given matrix
  22725. * @param result defines the target matrix
  22726. * @returns the current matrix
  22727. */
  22728. transposeToRef(result: Matrix): Matrix;
  22729. /**
  22730. * Sets the index-th row of the current matrix with the given 4 x float values
  22731. * @param index defines the row index
  22732. * @param x defines the x component to set
  22733. * @param y defines the y component to set
  22734. * @param z defines the z component to set
  22735. * @param w defines the w component to set
  22736. * @returns the updated current matrix
  22737. */
  22738. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  22739. /**
  22740. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  22741. * @param scale defines the scale factor
  22742. * @returns a new matrix
  22743. */
  22744. scale(scale: number): Matrix;
  22745. /**
  22746. * Scale the current matrix values by a factor to a given result matrix
  22747. * @param scale defines the scale factor
  22748. * @param result defines the matrix to store the result
  22749. * @returns the current matrix
  22750. */
  22751. scaleToRef(scale: number, result: Matrix): Matrix;
  22752. /**
  22753. * Scale the current matrix values by a factor and add the result to a given matrix
  22754. * @param scale defines the scale factor
  22755. * @param result defines the Matrix to store the result
  22756. * @returns the current matrix
  22757. */
  22758. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  22759. /**
  22760. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  22761. * @param ref matrix to store the result
  22762. */
  22763. toNormalMatrix(ref: Matrix): void;
  22764. /**
  22765. * Gets only rotation part of the current matrix
  22766. * @returns a new matrix sets to the extracted rotation matrix from the current one
  22767. */
  22768. getRotationMatrix(): Matrix;
  22769. /**
  22770. * Extracts the rotation matrix from the current one and sets it as the given "result"
  22771. * @param result defines the target matrix to store data to
  22772. * @returns the current matrix
  22773. */
  22774. getRotationMatrixToRef(result: Matrix): Matrix;
  22775. /**
  22776. * Toggles model matrix from being right handed to left handed in place and vice versa
  22777. */
  22778. toggleModelMatrixHandInPlace(): void;
  22779. /**
  22780. * Toggles projection matrix from being right handed to left handed in place and vice versa
  22781. */
  22782. toggleProjectionMatrixHandInPlace(): void;
  22783. /**
  22784. * Creates a matrix from an array
  22785. * @param array defines the source array
  22786. * @param offset defines an offset in the source array
  22787. * @returns a new Matrix set from the starting index of the given array
  22788. */
  22789. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  22790. /**
  22791. * Copy the content of an array into a given matrix
  22792. * @param array defines the source array
  22793. * @param offset defines an offset in the source array
  22794. * @param result defines the target matrix
  22795. */
  22796. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  22797. /**
  22798. * Stores an array into a matrix after having multiplied each component by a given factor
  22799. * @param array defines the source array
  22800. * @param offset defines the offset in the source array
  22801. * @param scale defines the scaling factor
  22802. * @param result defines the target matrix
  22803. */
  22804. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  22805. /**
  22806. * Gets an identity matrix that must not be updated
  22807. */
  22808. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  22809. /**
  22810. * Stores a list of values (16) inside a given matrix
  22811. * @param initialM11 defines 1st value of 1st row
  22812. * @param initialM12 defines 2nd value of 1st row
  22813. * @param initialM13 defines 3rd value of 1st row
  22814. * @param initialM14 defines 4th value of 1st row
  22815. * @param initialM21 defines 1st value of 2nd row
  22816. * @param initialM22 defines 2nd value of 2nd row
  22817. * @param initialM23 defines 3rd value of 2nd row
  22818. * @param initialM24 defines 4th value of 2nd row
  22819. * @param initialM31 defines 1st value of 3rd row
  22820. * @param initialM32 defines 2nd value of 3rd row
  22821. * @param initialM33 defines 3rd value of 3rd row
  22822. * @param initialM34 defines 4th value of 3rd row
  22823. * @param initialM41 defines 1st value of 4th row
  22824. * @param initialM42 defines 2nd value of 4th row
  22825. * @param initialM43 defines 3rd value of 4th row
  22826. * @param initialM44 defines 4th value of 4th row
  22827. * @param result defines the target matrix
  22828. */
  22829. 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;
  22830. /**
  22831. * Creates new matrix from a list of values (16)
  22832. * @param initialM11 defines 1st value of 1st row
  22833. * @param initialM12 defines 2nd value of 1st row
  22834. * @param initialM13 defines 3rd value of 1st row
  22835. * @param initialM14 defines 4th value of 1st row
  22836. * @param initialM21 defines 1st value of 2nd row
  22837. * @param initialM22 defines 2nd value of 2nd row
  22838. * @param initialM23 defines 3rd value of 2nd row
  22839. * @param initialM24 defines 4th value of 2nd row
  22840. * @param initialM31 defines 1st value of 3rd row
  22841. * @param initialM32 defines 2nd value of 3rd row
  22842. * @param initialM33 defines 3rd value of 3rd row
  22843. * @param initialM34 defines 4th value of 3rd row
  22844. * @param initialM41 defines 1st value of 4th row
  22845. * @param initialM42 defines 2nd value of 4th row
  22846. * @param initialM43 defines 3rd value of 4th row
  22847. * @param initialM44 defines 4th value of 4th row
  22848. * @returns the new matrix
  22849. */
  22850. 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;
  22851. /**
  22852. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  22853. * @param scale defines the scale vector3
  22854. * @param rotation defines the rotation quaternion
  22855. * @param translation defines the translation vector3
  22856. * @returns a new matrix
  22857. */
  22858. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  22859. /**
  22860. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  22861. * @param scale defines the scale vector3
  22862. * @param rotation defines the rotation quaternion
  22863. * @param translation defines the translation vector3
  22864. * @param result defines the target matrix
  22865. */
  22866. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  22867. /**
  22868. * Creates a new identity matrix
  22869. * @returns a new identity matrix
  22870. */
  22871. static Identity(): Matrix;
  22872. /**
  22873. * Creates a new identity matrix and stores the result in a given matrix
  22874. * @param result defines the target matrix
  22875. */
  22876. static IdentityToRef(result: Matrix): void;
  22877. /**
  22878. * Creates a new zero matrix
  22879. * @returns a new zero matrix
  22880. */
  22881. static Zero(): Matrix;
  22882. /**
  22883. * Creates a new rotation matrix for "angle" radians around the X axis
  22884. * @param angle defines the angle (in radians) to use
  22885. * @return the new matrix
  22886. */
  22887. static RotationX(angle: number): Matrix;
  22888. /**
  22889. * Creates a new matrix as the invert of a given matrix
  22890. * @param source defines the source matrix
  22891. * @returns the new matrix
  22892. */
  22893. static Invert(source: DeepImmutable<Matrix>): Matrix;
  22894. /**
  22895. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  22896. * @param angle defines the angle (in radians) to use
  22897. * @param result defines the target matrix
  22898. */
  22899. static RotationXToRef(angle: number, result: Matrix): void;
  22900. /**
  22901. * Creates a new rotation matrix for "angle" radians around the Y axis
  22902. * @param angle defines the angle (in radians) to use
  22903. * @return the new matrix
  22904. */
  22905. static RotationY(angle: number): Matrix;
  22906. /**
  22907. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  22908. * @param angle defines the angle (in radians) to use
  22909. * @param result defines the target matrix
  22910. */
  22911. static RotationYToRef(angle: number, result: Matrix): void;
  22912. /**
  22913. * Creates a new rotation matrix for "angle" radians around the Z axis
  22914. * @param angle defines the angle (in radians) to use
  22915. * @return the new matrix
  22916. */
  22917. static RotationZ(angle: number): Matrix;
  22918. /**
  22919. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  22920. * @param angle defines the angle (in radians) to use
  22921. * @param result defines the target matrix
  22922. */
  22923. static RotationZToRef(angle: number, result: Matrix): void;
  22924. /**
  22925. * Creates a new rotation matrix for "angle" radians around the given axis
  22926. * @param axis defines the axis to use
  22927. * @param angle defines the angle (in radians) to use
  22928. * @return the new matrix
  22929. */
  22930. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  22931. /**
  22932. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  22933. * @param axis defines the axis to use
  22934. * @param angle defines the angle (in radians) to use
  22935. * @param result defines the target matrix
  22936. */
  22937. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  22938. /**
  22939. * Creates a rotation matrix
  22940. * @param yaw defines the yaw angle in radians (Y axis)
  22941. * @param pitch defines the pitch angle in radians (X axis)
  22942. * @param roll defines the roll angle in radians (X axis)
  22943. * @returns the new rotation matrix
  22944. */
  22945. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  22946. /**
  22947. * Creates a rotation matrix and stores it in a given matrix
  22948. * @param yaw defines the yaw angle in radians (Y axis)
  22949. * @param pitch defines the pitch angle in radians (X axis)
  22950. * @param roll defines the roll angle in radians (X axis)
  22951. * @param result defines the target matrix
  22952. */
  22953. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  22954. /**
  22955. * Creates a scaling matrix
  22956. * @param x defines the scale factor on X axis
  22957. * @param y defines the scale factor on Y axis
  22958. * @param z defines the scale factor on Z axis
  22959. * @returns the new matrix
  22960. */
  22961. static Scaling(x: number, y: number, z: number): Matrix;
  22962. /**
  22963. * Creates a scaling matrix and stores it in a given matrix
  22964. * @param x defines the scale factor on X axis
  22965. * @param y defines the scale factor on Y axis
  22966. * @param z defines the scale factor on Z axis
  22967. * @param result defines the target matrix
  22968. */
  22969. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  22970. /**
  22971. * Creates a translation matrix
  22972. * @param x defines the translation on X axis
  22973. * @param y defines the translation on Y axis
  22974. * @param z defines the translationon Z axis
  22975. * @returns the new matrix
  22976. */
  22977. static Translation(x: number, y: number, z: number): Matrix;
  22978. /**
  22979. * Creates a translation matrix and stores it in a given matrix
  22980. * @param x defines the translation on X axis
  22981. * @param y defines the translation on Y axis
  22982. * @param z defines the translationon Z axis
  22983. * @param result defines the target matrix
  22984. */
  22985. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  22986. /**
  22987. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  22988. * @param startValue defines the start value
  22989. * @param endValue defines the end value
  22990. * @param gradient defines the gradient factor
  22991. * @returns the new matrix
  22992. */
  22993. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  22994. /**
  22995. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  22996. * @param startValue defines the start value
  22997. * @param endValue defines the end value
  22998. * @param gradient defines the gradient factor
  22999. * @param result defines the Matrix object where to store data
  23000. */
  23001. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  23002. /**
  23003. * Builds a new matrix whose values are computed by:
  23004. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  23005. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  23006. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  23007. * @param startValue defines the first matrix
  23008. * @param endValue defines the second matrix
  23009. * @param gradient defines the gradient between the two matrices
  23010. * @returns the new matrix
  23011. */
  23012. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  23013. /**
  23014. * Update a matrix to values which are computed by:
  23015. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  23016. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  23017. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  23018. * @param startValue defines the first matrix
  23019. * @param endValue defines the second matrix
  23020. * @param gradient defines the gradient between the two matrices
  23021. * @param result defines the target matrix
  23022. */
  23023. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  23024. /**
  23025. * 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"
  23026. * This function works in left handed mode
  23027. * @param eye defines the final position of the entity
  23028. * @param target defines where the entity should look at
  23029. * @param up defines the up vector for the entity
  23030. * @returns the new matrix
  23031. */
  23032. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  23033. /**
  23034. * 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".
  23035. * This function works in left handed mode
  23036. * @param eye defines the final position of the entity
  23037. * @param target defines where the entity should look at
  23038. * @param up defines the up vector for the entity
  23039. * @param result defines the target matrix
  23040. */
  23041. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  23042. /**
  23043. * 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"
  23044. * This function works in right handed mode
  23045. * @param eye defines the final position of the entity
  23046. * @param target defines where the entity should look at
  23047. * @param up defines the up vector for the entity
  23048. * @returns the new matrix
  23049. */
  23050. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  23051. /**
  23052. * 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".
  23053. * This function works in right handed mode
  23054. * @param eye defines the final position of the entity
  23055. * @param target defines where the entity should look at
  23056. * @param up defines the up vector for the entity
  23057. * @param result defines the target matrix
  23058. */
  23059. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  23060. /**
  23061. * Create a left-handed orthographic projection matrix
  23062. * @param width defines the viewport width
  23063. * @param height defines the viewport height
  23064. * @param znear defines the near clip plane
  23065. * @param zfar defines the far clip plane
  23066. * @returns a new matrix as a left-handed orthographic projection matrix
  23067. */
  23068. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  23069. /**
  23070. * Store a left-handed orthographic projection to a given matrix
  23071. * @param width defines the viewport width
  23072. * @param height defines the viewport height
  23073. * @param znear defines the near clip plane
  23074. * @param zfar defines the far clip plane
  23075. * @param result defines the target matrix
  23076. */
  23077. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  23078. /**
  23079. * Create a left-handed orthographic projection matrix
  23080. * @param left defines the viewport left coordinate
  23081. * @param right defines the viewport right coordinate
  23082. * @param bottom defines the viewport bottom coordinate
  23083. * @param top defines the viewport top coordinate
  23084. * @param znear defines the near clip plane
  23085. * @param zfar defines the far clip plane
  23086. * @returns a new matrix as a left-handed orthographic projection matrix
  23087. */
  23088. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  23089. /**
  23090. * Stores a left-handed orthographic projection into a given matrix
  23091. * @param left defines the viewport left coordinate
  23092. * @param right defines the viewport right coordinate
  23093. * @param bottom defines the viewport bottom coordinate
  23094. * @param top defines the viewport top coordinate
  23095. * @param znear defines the near clip plane
  23096. * @param zfar defines the far clip plane
  23097. * @param result defines the target matrix
  23098. */
  23099. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  23100. /**
  23101. * Creates a right-handed orthographic projection matrix
  23102. * @param left defines the viewport left coordinate
  23103. * @param right defines the viewport right coordinate
  23104. * @param bottom defines the viewport bottom coordinate
  23105. * @param top defines the viewport top coordinate
  23106. * @param znear defines the near clip plane
  23107. * @param zfar defines the far clip plane
  23108. * @returns a new matrix as a right-handed orthographic projection matrix
  23109. */
  23110. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  23111. /**
  23112. * Stores a right-handed orthographic projection into a given matrix
  23113. * @param left defines the viewport left coordinate
  23114. * @param right defines the viewport right coordinate
  23115. * @param bottom defines the viewport bottom coordinate
  23116. * @param top defines the viewport top coordinate
  23117. * @param znear defines the near clip plane
  23118. * @param zfar defines the far clip plane
  23119. * @param result defines the target matrix
  23120. */
  23121. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  23122. /**
  23123. * Creates a left-handed perspective projection matrix
  23124. * @param width defines the viewport width
  23125. * @param height defines the viewport height
  23126. * @param znear defines the near clip plane
  23127. * @param zfar defines the far clip plane
  23128. * @returns a new matrix as a left-handed perspective projection matrix
  23129. */
  23130. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  23131. /**
  23132. * Creates a left-handed perspective projection matrix
  23133. * @param fov defines the horizontal field of view
  23134. * @param aspect defines the aspect ratio
  23135. * @param znear defines the near clip plane
  23136. * @param zfar defines the far clip plane
  23137. * @returns a new matrix as a left-handed perspective projection matrix
  23138. */
  23139. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  23140. /**
  23141. * Stores a left-handed perspective projection into a given matrix
  23142. * @param fov defines the horizontal field of view
  23143. * @param aspect defines the aspect ratio
  23144. * @param znear defines the near clip plane
  23145. * @param zfar defines the far clip plane
  23146. * @param result defines the target matrix
  23147. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  23148. */
  23149. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  23150. /**
  23151. * Creates a right-handed perspective projection matrix
  23152. * @param fov defines the horizontal field of view
  23153. * @param aspect defines the aspect ratio
  23154. * @param znear defines the near clip plane
  23155. * @param zfar defines the far clip plane
  23156. * @returns a new matrix as a right-handed perspective projection matrix
  23157. */
  23158. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  23159. /**
  23160. * Stores a right-handed perspective projection into a given matrix
  23161. * @param fov defines the horizontal field of view
  23162. * @param aspect defines the aspect ratio
  23163. * @param znear defines the near clip plane
  23164. * @param zfar defines the far clip plane
  23165. * @param result defines the target matrix
  23166. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  23167. */
  23168. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  23169. /**
  23170. * Stores a perspective projection for WebVR info a given matrix
  23171. * @param fov defines the field of view
  23172. * @param znear defines the near clip plane
  23173. * @param zfar defines the far clip plane
  23174. * @param result defines the target matrix
  23175. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  23176. */
  23177. static PerspectiveFovWebVRToRef(fov: {
  23178. upDegrees: number;
  23179. downDegrees: number;
  23180. leftDegrees: number;
  23181. rightDegrees: number;
  23182. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  23183. /**
  23184. * Computes a complete transformation matrix
  23185. * @param viewport defines the viewport to use
  23186. * @param world defines the world matrix
  23187. * @param view defines the view matrix
  23188. * @param projection defines the projection matrix
  23189. * @param zmin defines the near clip plane
  23190. * @param zmax defines the far clip plane
  23191. * @returns the transformation matrix
  23192. */
  23193. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  23194. /**
  23195. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  23196. * @param matrix defines the matrix to use
  23197. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  23198. */
  23199. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  23200. /**
  23201. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  23202. * @param matrix defines the matrix to use
  23203. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  23204. */
  23205. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  23206. /**
  23207. * Compute the transpose of a given matrix
  23208. * @param matrix defines the matrix to transpose
  23209. * @returns the new matrix
  23210. */
  23211. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  23212. /**
  23213. * Compute the transpose of a matrix and store it in a target matrix
  23214. * @param matrix defines the matrix to transpose
  23215. * @param result defines the target matrix
  23216. */
  23217. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  23218. /**
  23219. * Computes a reflection matrix from a plane
  23220. * @param plane defines the reflection plane
  23221. * @returns a new matrix
  23222. */
  23223. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  23224. /**
  23225. * Computes a reflection matrix from a plane
  23226. * @param plane defines the reflection plane
  23227. * @param result defines the target matrix
  23228. */
  23229. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  23230. /**
  23231. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  23232. * @param xaxis defines the value of the 1st axis
  23233. * @param yaxis defines the value of the 2nd axis
  23234. * @param zaxis defines the value of the 3rd axis
  23235. * @param result defines the target matrix
  23236. */
  23237. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  23238. /**
  23239. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  23240. * @param quat defines the quaternion to use
  23241. * @param result defines the target matrix
  23242. */
  23243. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  23244. }
  23245. /**
  23246. * Represens a plane by the equation ax + by + cz + d = 0
  23247. */
  23248. class Plane {
  23249. /**
  23250. * Normal of the plane (a,b,c)
  23251. */
  23252. normal: Vector3;
  23253. /**
  23254. * d component of the plane
  23255. */
  23256. d: number;
  23257. /**
  23258. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  23259. * @param a a component of the plane
  23260. * @param b b component of the plane
  23261. * @param c c component of the plane
  23262. * @param d d component of the plane
  23263. */
  23264. constructor(a: number, b: number, c: number, d: number);
  23265. /**
  23266. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  23267. */
  23268. asArray(): number[];
  23269. /**
  23270. * @returns a new plane copied from the current Plane.
  23271. */
  23272. clone(): Plane;
  23273. /**
  23274. * @returns the string "Plane".
  23275. */
  23276. getClassName(): string;
  23277. /**
  23278. * @returns the Plane hash code.
  23279. */
  23280. getHashCode(): number;
  23281. /**
  23282. * Normalize the current Plane in place.
  23283. * @returns the updated Plane.
  23284. */
  23285. normalize(): Plane;
  23286. /**
  23287. * Applies a transformation the plane and returns the result
  23288. * @param transformation the transformation matrix to be applied to the plane
  23289. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  23290. */
  23291. transform(transformation: DeepImmutable<Matrix>): Plane;
  23292. /**
  23293. * Calcualtte the dot product between the point and the plane normal
  23294. * @param point point to calculate the dot product with
  23295. * @returns the dot product (float) of the point coordinates and the plane normal.
  23296. */
  23297. dotCoordinate(point: DeepImmutable<Vector3>): number;
  23298. /**
  23299. * Updates the current Plane from the plane defined by the three given points.
  23300. * @param point1 one of the points used to contruct the plane
  23301. * @param point2 one of the points used to contruct the plane
  23302. * @param point3 one of the points used to contruct the plane
  23303. * @returns the updated Plane.
  23304. */
  23305. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  23306. /**
  23307. * Checks if the plane is facing a given direction
  23308. * @param direction the direction to check if the plane is facing
  23309. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  23310. * @returns True is the vector "direction" is the same side than the plane normal.
  23311. */
  23312. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  23313. /**
  23314. * Calculates the distance to a point
  23315. * @param point point to calculate distance to
  23316. * @returns the signed distance (float) from the given point to the Plane.
  23317. */
  23318. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  23319. /**
  23320. * Creates a plane from an array
  23321. * @param array the array to create a plane from
  23322. * @returns a new Plane from the given array.
  23323. */
  23324. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  23325. /**
  23326. * Creates a plane from three points
  23327. * @param point1 point used to create the plane
  23328. * @param point2 point used to create the plane
  23329. * @param point3 point used to create the plane
  23330. * @returns a new Plane defined by the three given points.
  23331. */
  23332. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  23333. /**
  23334. * Creates a plane from an origin point and a normal
  23335. * @param origin origin of the plane to be constructed
  23336. * @param normal normal of the plane to be constructed
  23337. * @returns a new Plane the normal vector to this plane at the given origin point.
  23338. * Note : the vector "normal" is updated because normalized.
  23339. */
  23340. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  23341. /**
  23342. * Calculates the distance from a plane and a point
  23343. * @param origin origin of the plane to be constructed
  23344. * @param normal normal of the plane to be constructed
  23345. * @param point point to calculate distance to
  23346. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  23347. */
  23348. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  23349. }
  23350. /**
  23351. * Class used to represent a viewport on screen
  23352. */
  23353. class Viewport {
  23354. /** viewport left coordinate */
  23355. x: number;
  23356. /** viewport top coordinate */
  23357. y: number;
  23358. /**viewport width */
  23359. width: number;
  23360. /** viewport height */
  23361. height: number;
  23362. /**
  23363. * Creates a Viewport object located at (x, y) and sized (width, height)
  23364. * @param x defines viewport left coordinate
  23365. * @param y defines viewport top coordinate
  23366. * @param width defines the viewport width
  23367. * @param height defines the viewport height
  23368. */
  23369. constructor(
  23370. /** viewport left coordinate */
  23371. x: number,
  23372. /** viewport top coordinate */
  23373. y: number,
  23374. /**viewport width */
  23375. width: number,
  23376. /** viewport height */
  23377. height: number);
  23378. /**
  23379. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  23380. * @param renderWidthOrEngine defines either an engine or the rendering width
  23381. * @param renderHeight defines the rendering height
  23382. * @returns a new Viewport
  23383. */
  23384. toGlobal(renderWidthOrEngine: number | Engine, renderHeight: number): Viewport;
  23385. /**
  23386. * Returns a new Viewport copied from the current one
  23387. * @returns a new Viewport
  23388. */
  23389. clone(): Viewport;
  23390. }
  23391. /**
  23392. * Reprasents a camera frustum
  23393. */
  23394. class Frustum {
  23395. /**
  23396. * Gets the planes representing the frustum
  23397. * @param transform matrix to be applied to the returned planes
  23398. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  23399. */
  23400. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  23401. /**
  23402. * Gets the near frustum plane transformed by the transform matrix
  23403. * @param transform transformation matrix to be applied to the resulting frustum plane
  23404. * @param frustumPlane the resuling frustum plane
  23405. */
  23406. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  23407. /**
  23408. * Gets the far frustum plane transformed by the transform matrix
  23409. * @param transform transformation matrix to be applied to the resulting frustum plane
  23410. * @param frustumPlane the resuling frustum plane
  23411. */
  23412. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  23413. /**
  23414. * Gets the left frustum plane transformed by the transform matrix
  23415. * @param transform transformation matrix to be applied to the resulting frustum plane
  23416. * @param frustumPlane the resuling frustum plane
  23417. */
  23418. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  23419. /**
  23420. * Gets the right frustum plane transformed by the transform matrix
  23421. * @param transform transformation matrix to be applied to the resulting frustum plane
  23422. * @param frustumPlane the resuling frustum plane
  23423. */
  23424. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  23425. /**
  23426. * Gets the top frustum plane transformed by the transform matrix
  23427. * @param transform transformation matrix to be applied to the resulting frustum plane
  23428. * @param frustumPlane the resuling frustum plane
  23429. */
  23430. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  23431. /**
  23432. * Gets the bottom frustum plane transformed by the transform matrix
  23433. * @param transform transformation matrix to be applied to the resulting frustum plane
  23434. * @param frustumPlane the resuling frustum plane
  23435. */
  23436. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  23437. /**
  23438. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  23439. * @param transform transformation matrix to be applied to the resulting frustum planes
  23440. * @param frustumPlanes the resuling frustum planes
  23441. */
  23442. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  23443. }
  23444. /** Defines supported spaces */
  23445. enum Space {
  23446. /** Local (object) space */
  23447. LOCAL = 0,
  23448. /** World space */
  23449. WORLD = 1,
  23450. /** Bone space */
  23451. BONE = 2
  23452. }
  23453. /** Defines the 3 main axes */
  23454. class Axis {
  23455. /** X axis */
  23456. static X: Vector3;
  23457. /** Y axis */
  23458. static Y: Vector3;
  23459. /** Z axis */
  23460. static Z: Vector3;
  23461. }
  23462. /** Class used to represent a Bezier curve */
  23463. class BezierCurve {
  23464. /**
  23465. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  23466. * @param t defines the time
  23467. * @param x1 defines the left coordinate on X axis
  23468. * @param y1 defines the left coordinate on Y axis
  23469. * @param x2 defines the right coordinate on X axis
  23470. * @param y2 defines the right coordinate on Y axis
  23471. * @returns the interpolated value
  23472. */
  23473. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  23474. }
  23475. /**
  23476. * Defines potential orientation for back face culling
  23477. */
  23478. enum Orientation {
  23479. /**
  23480. * Clockwise
  23481. */
  23482. CW = 0,
  23483. /** Counter clockwise */
  23484. CCW = 1
  23485. }
  23486. /**
  23487. * Defines angle representation
  23488. */
  23489. class Angle {
  23490. private _radians;
  23491. /**
  23492. * Creates an Angle object of "radians" radians (float).
  23493. */
  23494. constructor(radians: number);
  23495. /**
  23496. * Get value in degrees
  23497. * @returns the Angle value in degrees (float)
  23498. */
  23499. degrees(): number;
  23500. /**
  23501. * Get value in radians
  23502. * @returns the Angle value in radians (float)
  23503. */
  23504. radians(): number;
  23505. /**
  23506. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  23507. * @param a defines first vector
  23508. * @param b defines second vector
  23509. * @returns a new Angle
  23510. */
  23511. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  23512. /**
  23513. * Gets a new Angle object from the given float in radians
  23514. * @param radians defines the angle value in radians
  23515. * @returns a new Angle
  23516. */
  23517. static FromRadians(radians: number): Angle;
  23518. /**
  23519. * Gets a new Angle object from the given float in degrees
  23520. * @param degrees defines the angle value in degrees
  23521. * @returns a new Angle
  23522. */
  23523. static FromDegrees(degrees: number): Angle;
  23524. }
  23525. /**
  23526. * This represents an arc in a 2d space.
  23527. */
  23528. class Arc2 {
  23529. /** Defines the start point of the arc */
  23530. startPoint: Vector2;
  23531. /** Defines the mid point of the arc */
  23532. midPoint: Vector2;
  23533. /** Defines the end point of the arc */
  23534. endPoint: Vector2;
  23535. /**
  23536. * Defines the center point of the arc.
  23537. */
  23538. centerPoint: Vector2;
  23539. /**
  23540. * Defines the radius of the arc.
  23541. */
  23542. radius: number;
  23543. /**
  23544. * Defines the angle of the arc (from mid point to end point).
  23545. */
  23546. angle: Angle;
  23547. /**
  23548. * Defines the start angle of the arc (from start point to middle point).
  23549. */
  23550. startAngle: Angle;
  23551. /**
  23552. * Defines the orientation of the arc (clock wise/counter clock wise).
  23553. */
  23554. orientation: Orientation;
  23555. /**
  23556. * Creates an Arc object from the three given points : start, middle and end.
  23557. * @param startPoint Defines the start point of the arc
  23558. * @param midPoint Defines the midlle point of the arc
  23559. * @param endPoint Defines the end point of the arc
  23560. */
  23561. constructor(
  23562. /** Defines the start point of the arc */
  23563. startPoint: Vector2,
  23564. /** Defines the mid point of the arc */
  23565. midPoint: Vector2,
  23566. /** Defines the end point of the arc */
  23567. endPoint: Vector2);
  23568. }
  23569. /**
  23570. * Represents a 2D path made up of multiple 2D points
  23571. */
  23572. class Path2 {
  23573. private _points;
  23574. private _length;
  23575. /**
  23576. * If the path start and end point are the same
  23577. */
  23578. closed: boolean;
  23579. /**
  23580. * Creates a Path2 object from the starting 2D coordinates x and y.
  23581. * @param x the starting points x value
  23582. * @param y the starting points y value
  23583. */
  23584. constructor(x: number, y: number);
  23585. /**
  23586. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  23587. * @param x the added points x value
  23588. * @param y the added points y value
  23589. * @returns the updated Path2.
  23590. */
  23591. addLineTo(x: number, y: number): Path2;
  23592. /**
  23593. * 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.
  23594. * @param midX middle point x value
  23595. * @param midY middle point y value
  23596. * @param endX end point x value
  23597. * @param endY end point y value
  23598. * @param numberOfSegments (default: 36)
  23599. * @returns the updated Path2.
  23600. */
  23601. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  23602. /**
  23603. * Closes the Path2.
  23604. * @returns the Path2.
  23605. */
  23606. close(): Path2;
  23607. /**
  23608. * Gets the sum of the distance between each sequential point in the path
  23609. * @returns the Path2 total length (float).
  23610. */
  23611. length(): number;
  23612. /**
  23613. * Gets the points which construct the path
  23614. * @returns the Path2 internal array of points.
  23615. */
  23616. getPoints(): Vector2[];
  23617. /**
  23618. * Retreives the point at the distance aways from the starting point
  23619. * @param normalizedLengthPosition the length along the path to retreive the point from
  23620. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  23621. */
  23622. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  23623. /**
  23624. * Creates a new path starting from an x and y position
  23625. * @param x starting x value
  23626. * @param y starting y value
  23627. * @returns a new Path2 starting at the coordinates (x, y).
  23628. */
  23629. static StartingAt(x: number, y: number): Path2;
  23630. }
  23631. /**
  23632. * Represents a 3D path made up of multiple 3D points
  23633. */
  23634. class Path3D {
  23635. /**
  23636. * an array of Vector3, the curve axis of the Path3D
  23637. */
  23638. path: Vector3[];
  23639. private _curve;
  23640. private _distances;
  23641. private _tangents;
  23642. private _normals;
  23643. private _binormals;
  23644. private _raw;
  23645. /**
  23646. * new Path3D(path, normal, raw)
  23647. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  23648. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  23649. * @param path an array of Vector3, the curve axis of the Path3D
  23650. * @param normal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  23651. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  23652. */
  23653. constructor(
  23654. /**
  23655. * an array of Vector3, the curve axis of the Path3D
  23656. */
  23657. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  23658. /**
  23659. * Returns the Path3D array of successive Vector3 designing its curve.
  23660. * @returns the Path3D array of successive Vector3 designing its curve.
  23661. */
  23662. getCurve(): Vector3[];
  23663. /**
  23664. * Returns an array populated with tangent vectors on each Path3D curve point.
  23665. * @returns an array populated with tangent vectors on each Path3D curve point.
  23666. */
  23667. getTangents(): Vector3[];
  23668. /**
  23669. * Returns an array populated with normal vectors on each Path3D curve point.
  23670. * @returns an array populated with normal vectors on each Path3D curve point.
  23671. */
  23672. getNormals(): Vector3[];
  23673. /**
  23674. * Returns an array populated with binormal vectors on each Path3D curve point.
  23675. * @returns an array populated with binormal vectors on each Path3D curve point.
  23676. */
  23677. getBinormals(): Vector3[];
  23678. /**
  23679. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  23680. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  23681. */
  23682. getDistances(): number[];
  23683. /**
  23684. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  23685. * @param path path which all values are copied into the curves points
  23686. * @param firstNormal which should be projected onto the curve
  23687. * @returns the same object updated.
  23688. */
  23689. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  23690. private _compute;
  23691. private _getFirstNonNullVector;
  23692. private _getLastNonNullVector;
  23693. private _normalVector;
  23694. }
  23695. /**
  23696. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  23697. * A Curve3 is designed from a series of successive Vector3.
  23698. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  23699. */
  23700. class Curve3 {
  23701. private _points;
  23702. private _length;
  23703. /**
  23704. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  23705. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  23706. * @param v1 (Vector3) the control point
  23707. * @param v2 (Vector3) the end point of the Quadratic Bezier
  23708. * @param nbPoints (integer) the wanted number of points in the curve
  23709. * @returns the created Curve3
  23710. */
  23711. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  23712. /**
  23713. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  23714. * @param v0 (Vector3) the origin point of the Cubic Bezier
  23715. * @param v1 (Vector3) the first control point
  23716. * @param v2 (Vector3) the second control point
  23717. * @param v3 (Vector3) the end point of the Cubic Bezier
  23718. * @param nbPoints (integer) the wanted number of points in the curve
  23719. * @returns the created Curve3
  23720. */
  23721. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  23722. /**
  23723. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  23724. * @param p1 (Vector3) the origin point of the Hermite Spline
  23725. * @param t1 (Vector3) the tangent vector at the origin point
  23726. * @param p2 (Vector3) the end point of the Hermite Spline
  23727. * @param t2 (Vector3) the tangent vector at the end point
  23728. * @param nbPoints (integer) the wanted number of points in the curve
  23729. * @returns the created Curve3
  23730. */
  23731. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  23732. /**
  23733. * Returns a Curve3 object along a CatmullRom Spline curve :
  23734. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  23735. * @param nbPoints (integer) the wanted number of points between each curve control points
  23736. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  23737. * @returns the created Curve3
  23738. */
  23739. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  23740. /**
  23741. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  23742. * A Curve3 is designed from a series of successive Vector3.
  23743. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  23744. * @param points points which make up the curve
  23745. */
  23746. constructor(points: Vector3[]);
  23747. /**
  23748. * @returns the Curve3 stored array of successive Vector3
  23749. */
  23750. getPoints(): Vector3[];
  23751. /**
  23752. * @returns the computed length (float) of the curve.
  23753. */
  23754. length(): number;
  23755. /**
  23756. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  23757. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  23758. * curveA and curveB keep unchanged.
  23759. * @param curve the curve to continue from this curve
  23760. * @returns the newly constructed curve
  23761. */
  23762. continue(curve: DeepImmutable<Curve3>): Curve3;
  23763. private _computeLength;
  23764. }
  23765. /**
  23766. * Contains position and normal vectors for a vertex
  23767. */
  23768. class PositionNormalVertex {
  23769. /** the position of the vertex (defaut: 0,0,0) */
  23770. position: Vector3;
  23771. /** the normal of the vertex (defaut: 0,1,0) */
  23772. normal: Vector3;
  23773. /**
  23774. * Creates a PositionNormalVertex
  23775. * @param position the position of the vertex (defaut: 0,0,0)
  23776. * @param normal the normal of the vertex (defaut: 0,1,0)
  23777. */
  23778. constructor(
  23779. /** the position of the vertex (defaut: 0,0,0) */
  23780. position?: Vector3,
  23781. /** the normal of the vertex (defaut: 0,1,0) */
  23782. normal?: Vector3);
  23783. /**
  23784. * Clones the PositionNormalVertex
  23785. * @returns the cloned PositionNormalVertex
  23786. */
  23787. clone(): PositionNormalVertex;
  23788. }
  23789. /**
  23790. * Contains position, normal and uv vectors for a vertex
  23791. */
  23792. class PositionNormalTextureVertex {
  23793. /** the position of the vertex (defaut: 0,0,0) */
  23794. position: Vector3;
  23795. /** the normal of the vertex (defaut: 0,1,0) */
  23796. normal: Vector3;
  23797. /** the uv of the vertex (default: 0,0) */
  23798. uv: Vector2;
  23799. /**
  23800. * Creates a PositionNormalTextureVertex
  23801. * @param position the position of the vertex (defaut: 0,0,0)
  23802. * @param normal the normal of the vertex (defaut: 0,1,0)
  23803. * @param uv the uv of the vertex (default: 0,0)
  23804. */
  23805. constructor(
  23806. /** the position of the vertex (defaut: 0,0,0) */
  23807. position?: Vector3,
  23808. /** the normal of the vertex (defaut: 0,1,0) */
  23809. normal?: Vector3,
  23810. /** the uv of the vertex (default: 0,0) */
  23811. uv?: Vector2);
  23812. /**
  23813. * Clones the PositionNormalTextureVertex
  23814. * @returns the cloned PositionNormalTextureVertex
  23815. */
  23816. clone(): PositionNormalTextureVertex;
  23817. }
  23818. /**
  23819. * @hidden
  23820. */
  23821. class Tmp {
  23822. static Color3: Color3[];
  23823. static Color4: Color4[];
  23824. static Vector2: Vector2[];
  23825. static Vector3: Vector3[];
  23826. static Vector4: Vector4[];
  23827. static Quaternion: Quaternion[];
  23828. static Matrix: Matrix[];
  23829. }
  23830. }
  23831. declare module BABYLON {
  23832. /**
  23833. * Class representing spherical polynomial coefficients to the 3rd degree
  23834. */
  23835. class SphericalPolynomial {
  23836. /**
  23837. * The x coefficients of the spherical polynomial
  23838. */
  23839. x: Vector3;
  23840. /**
  23841. * The y coefficients of the spherical polynomial
  23842. */
  23843. y: Vector3;
  23844. /**
  23845. * The z coefficients of the spherical polynomial
  23846. */
  23847. z: Vector3;
  23848. /**
  23849. * The xx coefficients of the spherical polynomial
  23850. */
  23851. xx: Vector3;
  23852. /**
  23853. * The yy coefficients of the spherical polynomial
  23854. */
  23855. yy: Vector3;
  23856. /**
  23857. * The zz coefficients of the spherical polynomial
  23858. */
  23859. zz: Vector3;
  23860. /**
  23861. * The xy coefficients of the spherical polynomial
  23862. */
  23863. xy: Vector3;
  23864. /**
  23865. * The yz coefficients of the spherical polynomial
  23866. */
  23867. yz: Vector3;
  23868. /**
  23869. * The zx coefficients of the spherical polynomial
  23870. */
  23871. zx: Vector3;
  23872. /**
  23873. * Adds an ambient color to the spherical polynomial
  23874. * @param color the color to add
  23875. */
  23876. addAmbient(color: Color3): void;
  23877. /**
  23878. * Scales the spherical polynomial by the given amount
  23879. * @param scale the amount to scale
  23880. */
  23881. scale(scale: number): void;
  23882. /**
  23883. * Gets the spherical polynomial from harmonics
  23884. * @param harmonics the spherical harmonics
  23885. * @returns the spherical polynomial
  23886. */
  23887. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  23888. /**
  23889. * Constructs a spherical polynomial from an array.
  23890. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  23891. * @returns the spherical polynomial
  23892. */
  23893. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  23894. }
  23895. /**
  23896. * Class representing spherical harmonics coefficients to the 3rd degree
  23897. */
  23898. class SphericalHarmonics {
  23899. /**
  23900. * The l0,0 coefficients of the spherical harmonics
  23901. */
  23902. l00: Vector3;
  23903. /**
  23904. * The l1,-1 coefficients of the spherical harmonics
  23905. */
  23906. l1_1: Vector3;
  23907. /**
  23908. * The l1,0 coefficients of the spherical harmonics
  23909. */
  23910. l10: Vector3;
  23911. /**
  23912. * The l1,1 coefficients of the spherical harmonics
  23913. */
  23914. l11: Vector3;
  23915. /**
  23916. * The l2,-2 coefficients of the spherical harmonics
  23917. */
  23918. l2_2: Vector3;
  23919. /**
  23920. * The l2,-1 coefficients of the spherical harmonics
  23921. */
  23922. l2_1: Vector3;
  23923. /**
  23924. * The l2,0 coefficients of the spherical harmonics
  23925. */
  23926. l20: Vector3;
  23927. /**
  23928. * The l2,1 coefficients of the spherical harmonics
  23929. */
  23930. l21: Vector3;
  23931. /**
  23932. * The l2,2 coefficients of the spherical harmonics
  23933. */
  23934. lL22: Vector3;
  23935. /**
  23936. * Adds a light to the spherical harmonics
  23937. * @param direction the direction of the light
  23938. * @param color the color of the light
  23939. * @param deltaSolidAngle the delta solid angle of the light
  23940. */
  23941. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  23942. /**
  23943. * Scales the spherical harmonics by the given amount
  23944. * @param scale the amount to scale
  23945. */
  23946. scale(scale: number): void;
  23947. /**
  23948. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  23949. *
  23950. * ```
  23951. * E_lm = A_l * L_lm
  23952. * ```
  23953. *
  23954. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  23955. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  23956. * the scaling factors are given in equation 9.
  23957. */
  23958. convertIncidentRadianceToIrradiance(): void;
  23959. /**
  23960. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  23961. *
  23962. * ```
  23963. * L = (1/pi) * E * rho
  23964. * ```
  23965. *
  23966. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  23967. */
  23968. convertIrradianceToLambertianRadiance(): void;
  23969. /**
  23970. * Gets the spherical harmonics from polynomial
  23971. * @param polynomial the spherical polynomial
  23972. * @returns the spherical harmonics
  23973. */
  23974. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  23975. /**
  23976. * Constructs a spherical harmonics from an array.
  23977. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  23978. * @returns the spherical harmonics
  23979. */
  23980. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  23981. }
  23982. }
  23983. declare module BABYLON {
  23984. /**
  23985. * Interface used to present a loading screen while loading a scene
  23986. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  23987. */
  23988. interface ILoadingScreen {
  23989. /**
  23990. * Function called to display the loading screen
  23991. */
  23992. displayLoadingUI: () => void;
  23993. /**
  23994. * Function called to hide the loading screen
  23995. */
  23996. hideLoadingUI: () => void;
  23997. /**
  23998. * Gets or sets the color to use for the background
  23999. */
  24000. loadingUIBackgroundColor: string;
  24001. /**
  24002. * Gets or sets the text to display while loading
  24003. */
  24004. loadingUIText: string;
  24005. }
  24006. /**
  24007. * Class used for the default loading screen
  24008. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  24009. */
  24010. class DefaultLoadingScreen implements ILoadingScreen {
  24011. private _renderingCanvas;
  24012. private _loadingText;
  24013. private _loadingDivBackgroundColor;
  24014. private _loadingDiv;
  24015. private _loadingTextDiv;
  24016. /**
  24017. * Creates a new default loading screen
  24018. * @param _renderingCanvas defines the canvas used to render the scene
  24019. * @param _loadingText defines the default text to display
  24020. * @param _loadingDivBackgroundColor defines the default background color
  24021. */
  24022. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  24023. /**
  24024. * Function called to display the loading screen
  24025. */
  24026. displayLoadingUI(): void;
  24027. /**
  24028. * Function called to hide the loading screen
  24029. */
  24030. hideLoadingUI(): void;
  24031. /**
  24032. * Gets or sets the text to display while loading
  24033. */
  24034. loadingUIText: string;
  24035. /**
  24036. * Gets or sets the color to use for the background
  24037. */
  24038. loadingUIBackgroundColor: string;
  24039. private _resizeLoadingUI;
  24040. }
  24041. }
  24042. declare module BABYLON {
  24043. /**
  24044. * Class used to represent data loading progression
  24045. */
  24046. class SceneLoaderProgressEvent {
  24047. /** defines if data length to load can be evaluated */
  24048. readonly lengthComputable: boolean;
  24049. /** defines the loaded data length */
  24050. readonly loaded: number;
  24051. /** defines the data length to load */
  24052. readonly total: number;
  24053. /**
  24054. * Create a new progress event
  24055. * @param lengthComputable defines if data length to load can be evaluated
  24056. * @param loaded defines the loaded data length
  24057. * @param total defines the data length to load
  24058. */
  24059. constructor(
  24060. /** defines if data length to load can be evaluated */
  24061. lengthComputable: boolean,
  24062. /** defines the loaded data length */
  24063. loaded: number,
  24064. /** defines the data length to load */
  24065. total: number);
  24066. /**
  24067. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  24068. * @param event defines the source event
  24069. * @returns a new SceneLoaderProgressEvent
  24070. */
  24071. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  24072. }
  24073. /**
  24074. * Interface used by SceneLoader plugins to define supported file extensions
  24075. */
  24076. interface ISceneLoaderPluginExtensions {
  24077. /**
  24078. * Defines the list of supported extensions
  24079. */
  24080. [extension: string]: {
  24081. isBinary: boolean;
  24082. };
  24083. }
  24084. /**
  24085. * Interface used by SceneLoader plugin factory
  24086. */
  24087. interface ISceneLoaderPluginFactory {
  24088. /**
  24089. * Defines the name of the factory
  24090. */
  24091. name: string;
  24092. /**
  24093. * Function called to create a new plugin
  24094. * @return the new plugin
  24095. */
  24096. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  24097. /**
  24098. * Boolean indicating if the plugin can direct load specific data
  24099. */
  24100. canDirectLoad?: (data: string) => boolean;
  24101. }
  24102. /**
  24103. * Interface used to define a SceneLoader plugin
  24104. */
  24105. interface ISceneLoaderPlugin {
  24106. /**
  24107. * The friendly name of this plugin.
  24108. */
  24109. name: string;
  24110. /**
  24111. * The file extensions supported by this plugin.
  24112. */
  24113. extensions: string | ISceneLoaderPluginExtensions;
  24114. /**
  24115. * Import meshes into a scene.
  24116. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  24117. * @param scene The scene to import into
  24118. * @param data The data to import
  24119. * @param rootUrl The root url for scene and resources
  24120. * @param meshes The meshes array to import into
  24121. * @param particleSystems The particle systems array to import into
  24122. * @param skeletons The skeletons array to import into
  24123. * @param onError The callback when import fails
  24124. * @returns True if successful or false otherwise
  24125. */
  24126. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  24127. /**
  24128. * Load into a scene.
  24129. * @param scene The scene to load into
  24130. * @param data The data to import
  24131. * @param rootUrl The root url for scene and resources
  24132. * @param onError The callback when import fails
  24133. * @returns true if successful or false otherwise
  24134. */
  24135. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  24136. /**
  24137. * The callback that returns true if the data can be directly loaded.
  24138. */
  24139. canDirectLoad?: (data: string) => boolean;
  24140. /**
  24141. * The callback that allows custom handling of the root url based on the response url.
  24142. */
  24143. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  24144. /**
  24145. * Load into an asset container.
  24146. * @param scene The scene to load into
  24147. * @param data The data to import
  24148. * @param rootUrl The root url for scene and resources
  24149. * @param onError The callback when import fails
  24150. * @returns The loaded asset container
  24151. */
  24152. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  24153. }
  24154. /**
  24155. * Interface used to define an async SceneLoader plugin
  24156. */
  24157. interface ISceneLoaderPluginAsync {
  24158. /**
  24159. * The friendly name of this plugin.
  24160. */
  24161. name: string;
  24162. /**
  24163. * The file extensions supported by this plugin.
  24164. */
  24165. extensions: string | ISceneLoaderPluginExtensions;
  24166. /**
  24167. * Import meshes into a scene.
  24168. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  24169. * @param scene The scene to import into
  24170. * @param data The data to import
  24171. * @param rootUrl The root url for scene and resources
  24172. * @param onProgress The callback when the load progresses
  24173. * @param fileName Defines the name of the file to load
  24174. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  24175. */
  24176. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  24177. meshes: AbstractMesh[];
  24178. particleSystems: IParticleSystem[];
  24179. skeletons: Skeleton[];
  24180. animationGroups: AnimationGroup[];
  24181. }>;
  24182. /**
  24183. * Load into a scene.
  24184. * @param scene The scene to load into
  24185. * @param data The data to import
  24186. * @param rootUrl The root url for scene and resources
  24187. * @param onProgress The callback when the load progresses
  24188. * @param fileName Defines the name of the file to load
  24189. * @returns Nothing
  24190. */
  24191. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  24192. /**
  24193. * The callback that returns true if the data can be directly loaded.
  24194. */
  24195. canDirectLoad?: (data: string) => boolean;
  24196. /**
  24197. * The callback that allows custom handling of the root url based on the response url.
  24198. */
  24199. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  24200. /**
  24201. * Load into an asset container.
  24202. * @param scene The scene to load into
  24203. * @param data The data to import
  24204. * @param rootUrl The root url for scene and resources
  24205. * @param onProgress The callback when the load progresses
  24206. * @param fileName Defines the name of the file to load
  24207. * @returns The loaded asset container
  24208. */
  24209. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  24210. }
  24211. /**
  24212. * Class used to load scene from various file formats using registered plugins
  24213. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  24214. */
  24215. class SceneLoader {
  24216. private static _ForceFullSceneLoadingForIncremental;
  24217. private static _ShowLoadingScreen;
  24218. private static _CleanBoneMatrixWeights;
  24219. /**
  24220. * No logging while loading
  24221. */
  24222. static readonly NO_LOGGING: number;
  24223. /**
  24224. * Minimal logging while loading
  24225. */
  24226. static readonly MINIMAL_LOGGING: number;
  24227. /**
  24228. * Summary logging while loading
  24229. */
  24230. static readonly SUMMARY_LOGGING: number;
  24231. /**
  24232. * Detailled logging while loading
  24233. */
  24234. static readonly DETAILED_LOGGING: number;
  24235. private static _loggingLevel;
  24236. /**
  24237. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  24238. */
  24239. static ForceFullSceneLoadingForIncremental: boolean;
  24240. /**
  24241. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  24242. */
  24243. static ShowLoadingScreen: boolean;
  24244. /**
  24245. * Defines the current logging level (while loading the scene)
  24246. * @ignorenaming
  24247. */
  24248. static loggingLevel: number;
  24249. /**
  24250. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  24251. */
  24252. static CleanBoneMatrixWeights: boolean;
  24253. /**
  24254. * Event raised when a plugin is used to load a scene
  24255. */
  24256. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  24257. private static _registeredPlugins;
  24258. private static _getDefaultPlugin;
  24259. private static _getPluginForExtension;
  24260. private static _getPluginForDirectLoad;
  24261. private static _getPluginForFilename;
  24262. private static _getDirectLoad;
  24263. private static _loadData;
  24264. private static _getFileInfo;
  24265. /**
  24266. * Gets a plugin that can load the given extension
  24267. * @param extension defines the extension to load
  24268. * @returns a plugin or null if none works
  24269. */
  24270. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  24271. /**
  24272. * Gets a boolean indicating that the given extension can be loaded
  24273. * @param extension defines the extension to load
  24274. * @returns true if the extension is supported
  24275. */
  24276. static IsPluginForExtensionAvailable(extension: string): boolean;
  24277. /**
  24278. * Adds a new plugin to the list of registered plugins
  24279. * @param plugin defines the plugin to add
  24280. */
  24281. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  24282. /**
  24283. * Import meshes into a scene
  24284. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  24285. * @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)
  24286. * @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)
  24287. * @param scene the instance of BABYLON.Scene to append to
  24288. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  24289. * @param onProgress a callback with a progress event for each file being loaded
  24290. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  24291. * @param pluginExtension the extension used to determine the plugin
  24292. * @returns The loaded plugin
  24293. */
  24294. 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>;
  24295. /**
  24296. * Import meshes into a scene
  24297. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  24298. * @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)
  24299. * @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)
  24300. * @param scene the instance of BABYLON.Scene to append to
  24301. * @param onProgress a callback with a progress event for each file being loaded
  24302. * @param pluginExtension the extension used to determine the plugin
  24303. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  24304. */
  24305. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  24306. meshes: AbstractMesh[];
  24307. particleSystems: IParticleSystem[];
  24308. skeletons: Skeleton[];
  24309. animationGroups: AnimationGroup[];
  24310. }>;
  24311. /**
  24312. * Load a scene
  24313. * @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)
  24314. * @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)
  24315. * @param engine is the instance of BABYLON.Engine to use to create the scene
  24316. * @param onSuccess a callback with the scene when import succeeds
  24317. * @param onProgress a callback with a progress event for each file being loaded
  24318. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  24319. * @param pluginExtension the extension used to determine the plugin
  24320. * @returns The loaded plugin
  24321. */
  24322. 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>;
  24323. /**
  24324. * Load a scene
  24325. * @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)
  24326. * @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)
  24327. * @param engine is the instance of BABYLON.Engine to use to create the scene
  24328. * @param onProgress a callback with a progress event for each file being loaded
  24329. * @param pluginExtension the extension used to determine the plugin
  24330. * @returns The loaded scene
  24331. */
  24332. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  24333. /**
  24334. * Append a scene
  24335. * @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)
  24336. * @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)
  24337. * @param scene is the instance of BABYLON.Scene to append to
  24338. * @param onSuccess a callback with the scene when import succeeds
  24339. * @param onProgress a callback with a progress event for each file being loaded
  24340. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  24341. * @param pluginExtension the extension used to determine the plugin
  24342. * @returns The loaded plugin
  24343. */
  24344. 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>;
  24345. /**
  24346. * Append a scene
  24347. * @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)
  24348. * @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)
  24349. * @param scene is the instance of BABYLON.Scene to append to
  24350. * @param onProgress a callback with a progress event for each file being loaded
  24351. * @param pluginExtension the extension used to determine the plugin
  24352. * @returns The given scene
  24353. */
  24354. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  24355. /**
  24356. * Load a scene into an asset container
  24357. * @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)
  24358. * @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)
  24359. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  24360. * @param onSuccess a callback with the scene when import succeeds
  24361. * @param onProgress a callback with a progress event for each file being loaded
  24362. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  24363. * @param pluginExtension the extension used to determine the plugin
  24364. * @returns The loaded plugin
  24365. */
  24366. 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>;
  24367. /**
  24368. * Load a scene into an asset container
  24369. * @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)
  24370. * @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)
  24371. * @param scene is the instance of BABYLON.Scene to append to
  24372. * @param onProgress a callback with a progress event for each file being loaded
  24373. * @param pluginExtension the extension used to determine the plugin
  24374. * @returns The loaded asset container
  24375. */
  24376. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  24377. }
  24378. }
  24379. declare module BABYLON {
  24380. /**
  24381. * Defines a target to use with MorphTargetManager
  24382. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24383. */
  24384. class MorphTarget implements IAnimatable {
  24385. /** defines the name of the target */
  24386. name: string;
  24387. /**
  24388. * Gets or sets the list of animations
  24389. */
  24390. animations: Animation[];
  24391. private _scene;
  24392. private _positions;
  24393. private _normals;
  24394. private _tangents;
  24395. private _influence;
  24396. /**
  24397. * Observable raised when the influence changes
  24398. */
  24399. onInfluenceChanged: Observable<boolean>;
  24400. /** @hidden */
  24401. _onDataLayoutChanged: Observable<void>;
  24402. /**
  24403. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  24404. */
  24405. influence: number;
  24406. /**
  24407. * Gets or sets the id of the morph Target
  24408. */
  24409. id: string;
  24410. private _animationPropertiesOverride;
  24411. /**
  24412. * Gets or sets the animation properties override
  24413. */
  24414. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  24415. /**
  24416. * Creates a new MorphTarget
  24417. * @param name defines the name of the target
  24418. * @param influence defines the influence to use
  24419. */
  24420. constructor(
  24421. /** defines the name of the target */
  24422. name: string, influence?: number, scene?: Nullable<Scene>);
  24423. /**
  24424. * Gets a boolean defining if the target contains position data
  24425. */
  24426. readonly hasPositions: boolean;
  24427. /**
  24428. * Gets a boolean defining if the target contains normal data
  24429. */
  24430. readonly hasNormals: boolean;
  24431. /**
  24432. * Gets a boolean defining if the target contains tangent data
  24433. */
  24434. readonly hasTangents: boolean;
  24435. /**
  24436. * Affects position data to this target
  24437. * @param data defines the position data to use
  24438. */
  24439. setPositions(data: Nullable<FloatArray>): void;
  24440. /**
  24441. * Gets the position data stored in this target
  24442. * @returns a FloatArray containing the position data (or null if not present)
  24443. */
  24444. getPositions(): Nullable<FloatArray>;
  24445. /**
  24446. * Affects normal data to this target
  24447. * @param data defines the normal data to use
  24448. */
  24449. setNormals(data: Nullable<FloatArray>): void;
  24450. /**
  24451. * Gets the normal data stored in this target
  24452. * @returns a FloatArray containing the normal data (or null if not present)
  24453. */
  24454. getNormals(): Nullable<FloatArray>;
  24455. /**
  24456. * Affects tangent data to this target
  24457. * @param data defines the tangent data to use
  24458. */
  24459. setTangents(data: Nullable<FloatArray>): void;
  24460. /**
  24461. * Gets the tangent data stored in this target
  24462. * @returns a FloatArray containing the tangent data (or null if not present)
  24463. */
  24464. getTangents(): Nullable<FloatArray>;
  24465. /**
  24466. * Serializes the current target into a Serialization object
  24467. * @returns the serialized object
  24468. */
  24469. serialize(): any;
  24470. /**
  24471. * Returns the string "MorphTarget"
  24472. * @returns "MorphTarget"
  24473. */
  24474. getClassName(): string;
  24475. /**
  24476. * Creates a new target from serialized data
  24477. * @param serializationObject defines the serialized data to use
  24478. * @returns a new MorphTarget
  24479. */
  24480. static Parse(serializationObject: any): MorphTarget;
  24481. /**
  24482. * Creates a MorphTarget from mesh data
  24483. * @param mesh defines the source mesh
  24484. * @param name defines the name to use for the new target
  24485. * @param influence defines the influence to attach to the target
  24486. * @returns a new MorphTarget
  24487. */
  24488. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  24489. }
  24490. }
  24491. declare module BABYLON {
  24492. /**
  24493. * This class is used to deform meshes using morphing between different targets
  24494. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24495. */
  24496. class MorphTargetManager {
  24497. private _targets;
  24498. private _targetInfluenceChangedObservers;
  24499. private _targetDataLayoutChangedObservers;
  24500. private _activeTargets;
  24501. private _scene;
  24502. private _influences;
  24503. private _supportsNormals;
  24504. private _supportsTangents;
  24505. private _vertexCount;
  24506. private _uniqueId;
  24507. private _tempInfluences;
  24508. /**
  24509. * Creates a new MorphTargetManager
  24510. * @param scene defines the current scene
  24511. */
  24512. constructor(scene?: Nullable<Scene>);
  24513. /**
  24514. * Gets the unique ID of this manager
  24515. */
  24516. readonly uniqueId: number;
  24517. /**
  24518. * Gets the number of vertices handled by this manager
  24519. */
  24520. readonly vertexCount: number;
  24521. /**
  24522. * Gets a boolean indicating if this manager supports morphing of normals
  24523. */
  24524. readonly supportsNormals: boolean;
  24525. /**
  24526. * Gets a boolean indicating if this manager supports morphing of tangents
  24527. */
  24528. readonly supportsTangents: boolean;
  24529. /**
  24530. * Gets the number of targets stored in this manager
  24531. */
  24532. readonly numTargets: number;
  24533. /**
  24534. * Gets the number of influencers (ie. the number of targets with influences > 0)
  24535. */
  24536. readonly numInfluencers: number;
  24537. /**
  24538. * Gets the list of influences (one per target)
  24539. */
  24540. readonly influences: Float32Array;
  24541. /**
  24542. * Gets the active target at specified index. An active target is a target with an influence > 0
  24543. * @param index defines the index to check
  24544. * @returns the requested target
  24545. */
  24546. getActiveTarget(index: number): MorphTarget;
  24547. /**
  24548. * Gets the target at specified index
  24549. * @param index defines the index to check
  24550. * @returns the requested target
  24551. */
  24552. getTarget(index: number): MorphTarget;
  24553. /**
  24554. * Add a new target to this manager
  24555. * @param target defines the target to add
  24556. */
  24557. addTarget(target: MorphTarget): void;
  24558. /**
  24559. * Removes a target from the manager
  24560. * @param target defines the target to remove
  24561. */
  24562. removeTarget(target: MorphTarget): void;
  24563. /**
  24564. * Serializes the current manager into a Serialization object
  24565. * @returns the serialized object
  24566. */
  24567. serialize(): any;
  24568. private _syncActiveTargets;
  24569. /**
  24570. * Syncrhonize the targets with all the meshes using this morph target manager
  24571. */
  24572. synchronize(): void;
  24573. /**
  24574. * Creates a new MorphTargetManager from serialized data
  24575. * @param serializationObject defines the serialized data
  24576. * @param scene defines the hosting scene
  24577. * @returns the new MorphTargetManager
  24578. */
  24579. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  24580. }
  24581. }
  24582. declare module BABYLON {
  24583. /**
  24584. * Class used to store all common mesh properties
  24585. */
  24586. class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  24587. /** No occlusion */
  24588. static OCCLUSION_TYPE_NONE: number;
  24589. /** Occlusion set to optimisitic */
  24590. static OCCLUSION_TYPE_OPTIMISTIC: number;
  24591. /** Occlusion set to strict */
  24592. static OCCLUSION_TYPE_STRICT: number;
  24593. /** Use an accurante occlusion algorithm */
  24594. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  24595. /** Use a conservative occlusion algorithm */
  24596. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  24597. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  24598. * Test order :
  24599. * Is the bounding sphere outside the frustum ?
  24600. * If not, are the bounding box vertices outside the frustum ?
  24601. * It not, then the cullable object is in the frustum.
  24602. */
  24603. static readonly CULLINGSTRATEGY_STANDARD: number;
  24604. /** Culling strategy : Bounding Sphere Only.
  24605. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  24606. * It's also less accurate than the standard because some not visible objects can still be selected.
  24607. * Test : is the bounding sphere outside the frustum ?
  24608. * If not, then the cullable object is in the frustum.
  24609. */
  24610. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  24611. /** Culling strategy : Optimistic Inclusion.
  24612. * This in an inclusion test first, then the standard exclusion test.
  24613. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  24614. * 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.
  24615. * Anyway, it's as accurate as the standard strategy.
  24616. * Test :
  24617. * Is the cullable object bounding sphere center in the frustum ?
  24618. * If not, apply the default culling strategy.
  24619. */
  24620. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  24621. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  24622. * This in an inclusion test first, then the bounding sphere only exclusion test.
  24623. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  24624. * 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.
  24625. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  24626. * Test :
  24627. * Is the cullable object bounding sphere center in the frustum ?
  24628. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  24629. */
  24630. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  24631. /**
  24632. * No billboard
  24633. */
  24634. static readonly BILLBOARDMODE_NONE: number;
  24635. /** Billboard on X axis */
  24636. static readonly BILLBOARDMODE_X: number;
  24637. /** Billboard on Y axis */
  24638. static readonly BILLBOARDMODE_Y: number;
  24639. /** Billboard on Z axis */
  24640. static readonly BILLBOARDMODE_Z: number;
  24641. /** Billboard on all axes */
  24642. static readonly BILLBOARDMODE_ALL: number;
  24643. private _facetData;
  24644. /**
  24645. * The culling strategy to use to check whether the mesh must be rendered or not.
  24646. * This value can be changed at any time and will be used on the next render mesh selection.
  24647. * The possible values are :
  24648. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24649. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24650. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24651. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24652. * Please read each static variable documentation to get details about the culling process.
  24653. * */
  24654. cullingStrategy: number;
  24655. /**
  24656. * Gets the number of facets in the mesh
  24657. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24658. */
  24659. readonly facetNb: number;
  24660. /**
  24661. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  24662. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24663. */
  24664. partitioningSubdivisions: number;
  24665. /**
  24666. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  24667. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  24668. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24669. */
  24670. partitioningBBoxRatio: number;
  24671. /**
  24672. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  24673. * Works only for updatable meshes.
  24674. * Doesn't work with multi-materials
  24675. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24676. */
  24677. mustDepthSortFacets: boolean;
  24678. /**
  24679. * The location (Vector3) where the facet depth sort must be computed from.
  24680. * By default, the active camera position.
  24681. * Used only when facet depth sort is enabled
  24682. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24683. */
  24684. facetDepthSortFrom: Vector3;
  24685. /**
  24686. * gets a boolean indicating if facetData is enabled
  24687. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24688. */
  24689. readonly isFacetDataEnabled: boolean;
  24690. /** @hidden */
  24691. _updateNonUniformScalingState(value: boolean): boolean;
  24692. /**
  24693. * An event triggered when this mesh collides with another one
  24694. */
  24695. onCollideObservable: Observable<AbstractMesh>;
  24696. private _onCollideObserver;
  24697. /** Set a function to call when this mesh collides with another one */
  24698. onCollide: () => void;
  24699. /**
  24700. * An event triggered when the collision's position changes
  24701. */
  24702. onCollisionPositionChangeObservable: Observable<Vector3>;
  24703. private _onCollisionPositionChangeObserver;
  24704. /** Set a function to call when the collision's position changes */
  24705. onCollisionPositionChange: () => void;
  24706. /**
  24707. * An event triggered when material is changed
  24708. */
  24709. onMaterialChangedObservable: Observable<AbstractMesh>;
  24710. /**
  24711. * Gets or sets the orientation for POV movement & rotation
  24712. */
  24713. definedFacingForward: boolean;
  24714. /** @hidden */
  24715. _occlusionQuery: Nullable<WebGLQuery>;
  24716. private _visibility;
  24717. /**
  24718. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24719. */
  24720. /**
  24721. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24722. */
  24723. visibility: number;
  24724. /** Gets or sets the alpha index used to sort transparent meshes
  24725. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  24726. */
  24727. alphaIndex: number;
  24728. /**
  24729. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  24730. */
  24731. isVisible: boolean;
  24732. /**
  24733. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24734. */
  24735. isPickable: boolean;
  24736. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  24737. showSubMeshesBoundingBox: boolean;
  24738. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  24739. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  24740. */
  24741. isBlocker: boolean;
  24742. /**
  24743. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  24744. */
  24745. enablePointerMoveEvents: boolean;
  24746. /**
  24747. * Specifies the rendering group id for this mesh (0 by default)
  24748. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24749. */
  24750. renderingGroupId: number;
  24751. private _material;
  24752. /** Gets or sets current material */
  24753. material: Nullable<Material>;
  24754. private _receiveShadows;
  24755. /**
  24756. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  24757. * @see http://doc.babylonjs.com/babylon101/shadows
  24758. */
  24759. receiveShadows: boolean;
  24760. /** Defines color to use when rendering outline */
  24761. outlineColor: Color3;
  24762. /** Define width to use when rendering outline */
  24763. outlineWidth: number;
  24764. /** Defines color to use when rendering overlay */
  24765. overlayColor: Color3;
  24766. /** Defines alpha to use when rendering overlay */
  24767. overlayAlpha: number;
  24768. private _hasVertexAlpha;
  24769. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  24770. hasVertexAlpha: boolean;
  24771. private _useVertexColors;
  24772. /** 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) */
  24773. useVertexColors: boolean;
  24774. private _computeBonesUsingShaders;
  24775. /**
  24776. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  24777. */
  24778. computeBonesUsingShaders: boolean;
  24779. private _numBoneInfluencers;
  24780. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  24781. numBoneInfluencers: number;
  24782. private _applyFog;
  24783. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24784. applyFog: boolean;
  24785. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24786. useOctreeForRenderingSelection: boolean;
  24787. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24788. useOctreeForPicking: boolean;
  24789. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24790. useOctreeForCollisions: boolean;
  24791. private _layerMask;
  24792. /**
  24793. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24794. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24795. */
  24796. layerMask: number;
  24797. /**
  24798. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24799. */
  24800. alwaysSelectAsActiveMesh: boolean;
  24801. /**
  24802. * Gets or sets the current action manager
  24803. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24804. */
  24805. actionManager: Nullable<ActionManager>;
  24806. private _checkCollisions;
  24807. private _collisionMask;
  24808. private _collisionGroup;
  24809. /**
  24810. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24811. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24812. */
  24813. ellipsoid: Vector3;
  24814. /**
  24815. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24816. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24817. */
  24818. ellipsoidOffset: Vector3;
  24819. private _collider;
  24820. private _oldPositionForCollisions;
  24821. private _diffPositionForCollisions;
  24822. /**
  24823. * Gets or sets a collision mask used to mask collisions (default is -1).
  24824. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24825. */
  24826. collisionMask: number;
  24827. /**
  24828. * Gets or sets the current collision group mask (-1 by default).
  24829. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24830. */
  24831. collisionGroup: number;
  24832. /**
  24833. * Defines edge width used when edgesRenderer is enabled
  24834. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24835. */
  24836. edgesWidth: number;
  24837. /**
  24838. * Defines edge color used when edgesRenderer is enabled
  24839. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24840. */
  24841. edgesColor: Color4;
  24842. /** @hidden */
  24843. _edgesRenderer: Nullable<IEdgesRenderer>;
  24844. /** @hidden */
  24845. _masterMesh: Nullable<AbstractMesh>;
  24846. /** @hidden */
  24847. _boundingInfo: Nullable<BoundingInfo>;
  24848. /** @hidden */
  24849. _renderId: number;
  24850. /**
  24851. * Gets or sets the list of subMeshes
  24852. * @see http://doc.babylonjs.com/how_to/multi_materials
  24853. */
  24854. subMeshes: SubMesh[];
  24855. /** @hidden */
  24856. _intersectionsInProgress: AbstractMesh[];
  24857. /** @hidden */
  24858. _unIndexed: boolean;
  24859. /** @hidden */
  24860. _lightSources: Light[];
  24861. /** @hidden */
  24862. readonly _positions: Nullable<Vector3[]>;
  24863. /** @hidden */
  24864. _waitingActions: any;
  24865. /** @hidden */
  24866. _waitingFreezeWorldMatrix: Nullable<boolean>;
  24867. private _skeleton;
  24868. /** @hidden */
  24869. _bonesTransformMatrices: Nullable<Float32Array>;
  24870. /**
  24871. * Gets or sets a skeleton to apply skining transformations
  24872. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24873. */
  24874. skeleton: Nullable<Skeleton>;
  24875. /**
  24876. * An event triggered when the mesh is rebuilt.
  24877. */
  24878. onRebuildObservable: Observable<AbstractMesh>;
  24879. /**
  24880. * Creates a new AbstractMesh
  24881. * @param name defines the name of the mesh
  24882. * @param scene defines the hosting scene
  24883. */
  24884. constructor(name: string, scene?: Nullable<Scene>);
  24885. /**
  24886. * Returns the string "AbstractMesh"
  24887. * @returns "AbstractMesh"
  24888. */
  24889. getClassName(): string;
  24890. /**
  24891. * Gets a string representation of the current mesh
  24892. * @param fullDetails defines a boolean indicating if full details must be included
  24893. * @returns a string representation of the current mesh
  24894. */
  24895. toString(fullDetails?: boolean): string;
  24896. /** @hidden */
  24897. _rebuild(): void;
  24898. /** @hidden */
  24899. _resyncLightSources(): void;
  24900. /** @hidden */
  24901. _resyncLighSource(light: Light): void;
  24902. /** @hidden */
  24903. _unBindEffect(): void;
  24904. /** @hidden */
  24905. _removeLightSource(light: Light): void;
  24906. private _markSubMeshesAsDirty;
  24907. /** @hidden */
  24908. _markSubMeshesAsLightDirty(): void;
  24909. /** @hidden */
  24910. _markSubMeshesAsAttributesDirty(): void;
  24911. /** @hidden */
  24912. _markSubMeshesAsMiscDirty(): void;
  24913. /**
  24914. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24915. */
  24916. scaling: Vector3;
  24917. /**
  24918. * Returns true if the mesh is blocked. Implemented by child classes
  24919. */
  24920. readonly isBlocked: boolean;
  24921. /**
  24922. * Returns the mesh itself by default. Implemented by child classes
  24923. * @param camera defines the camera to use to pick the right LOD level
  24924. * @returns the currentAbstractMesh
  24925. */
  24926. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24927. /**
  24928. * Returns 0 by default. Implemented by child classes
  24929. * @returns an integer
  24930. */
  24931. getTotalVertices(): number;
  24932. /**
  24933. * Returns a positive integer : the total number of indices in this mesh geometry.
  24934. * @returns the numner of indices or zero if the mesh has no geometry.
  24935. */
  24936. getTotalIndices(): number;
  24937. /**
  24938. * Returns null by default. Implemented by child classes
  24939. * @returns null
  24940. */
  24941. getIndices(): Nullable<IndicesArray>;
  24942. /**
  24943. * Returns the array of the requested vertex data kind. Implemented by child classes
  24944. * @param kind defines the vertex data kind to use
  24945. * @returns null
  24946. */
  24947. getVerticesData(kind: string): Nullable<FloatArray>;
  24948. /**
  24949. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24950. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24951. * Note that a new underlying VertexBuffer object is created each call.
  24952. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24953. * @param kind defines vertex data kind:
  24954. * * BABYLON.VertexBuffer.PositionKind
  24955. * * BABYLON.VertexBuffer.UVKind
  24956. * * BABYLON.VertexBuffer.UV2Kind
  24957. * * BABYLON.VertexBuffer.UV3Kind
  24958. * * BABYLON.VertexBuffer.UV4Kind
  24959. * * BABYLON.VertexBuffer.UV5Kind
  24960. * * BABYLON.VertexBuffer.UV6Kind
  24961. * * BABYLON.VertexBuffer.ColorKind
  24962. * * BABYLON.VertexBuffer.MatricesIndicesKind
  24963. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  24964. * * BABYLON.VertexBuffer.MatricesWeightsKind
  24965. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  24966. * @param data defines the data source
  24967. * @param updatable defines if the data must be flagged as updatable (or static)
  24968. * @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
  24969. * @returns the current mesh
  24970. */
  24971. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24972. /**
  24973. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24974. * If the mesh has no geometry, it is simply returned as it is.
  24975. * @param kind defines vertex data kind:
  24976. * * BABYLON.VertexBuffer.PositionKind
  24977. * * BABYLON.VertexBuffer.UVKind
  24978. * * BABYLON.VertexBuffer.UV2Kind
  24979. * * BABYLON.VertexBuffer.UV3Kind
  24980. * * BABYLON.VertexBuffer.UV4Kind
  24981. * * BABYLON.VertexBuffer.UV5Kind
  24982. * * BABYLON.VertexBuffer.UV6Kind
  24983. * * BABYLON.VertexBuffer.ColorKind
  24984. * * BABYLON.VertexBuffer.MatricesIndicesKind
  24985. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  24986. * * BABYLON.VertexBuffer.MatricesWeightsKind
  24987. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  24988. * @param data defines the data source
  24989. * @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
  24990. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24991. * @returns the current mesh
  24992. */
  24993. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24994. /**
  24995. * Sets the mesh indices,
  24996. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24997. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24998. * @param totalVertices Defines the total number of vertices
  24999. * @returns the current mesh
  25000. */
  25001. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  25002. /**
  25003. * Gets a boolean indicating if specific vertex data is present
  25004. * @param kind defines the vertex data kind to use
  25005. * @returns true is data kind is present
  25006. */
  25007. isVerticesDataPresent(kind: string): boolean;
  25008. /**
  25009. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  25010. * @returns a BoundingInfo
  25011. */
  25012. getBoundingInfo(): BoundingInfo;
  25013. /**
  25014. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  25015. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  25016. * @returns the current mesh
  25017. */
  25018. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  25019. /**
  25020. * Overwrite the current bounding info
  25021. * @param boundingInfo defines the new bounding info
  25022. * @returns the current mesh
  25023. */
  25024. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  25025. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  25026. readonly useBones: boolean;
  25027. /** @hidden */
  25028. _preActivate(): void;
  25029. /** @hidden */
  25030. _preActivateForIntermediateRendering(renderId: number): void;
  25031. /** @hidden */
  25032. _activate(renderId: number): void;
  25033. /**
  25034. * Gets the current world matrix
  25035. * @returns a Matrix
  25036. */
  25037. getWorldMatrix(): Matrix;
  25038. /** @hidden */
  25039. _getWorldMatrixDeterminant(): number;
  25040. /**
  25041. * Perform relative position change from the point of view of behind the front of the mesh.
  25042. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25043. * Supports definition of mesh facing forward or backward
  25044. * @param amountRight defines the distance on the right axis
  25045. * @param amountUp defines the distance on the up axis
  25046. * @param amountForward defines the distance on the forward axis
  25047. * @returns the current mesh
  25048. */
  25049. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  25050. /**
  25051. * Calculate relative position change from the point of view of behind the front of the mesh.
  25052. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25053. * Supports definition of mesh facing forward or backward
  25054. * @param amountRight defines the distance on the right axis
  25055. * @param amountUp defines the distance on the up axis
  25056. * @param amountForward defines the distance on the forward axis
  25057. * @returns the new displacement vector
  25058. */
  25059. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  25060. /**
  25061. * Perform relative rotation change from the point of view of behind the front of the mesh.
  25062. * Supports definition of mesh facing forward or backward
  25063. * @param flipBack defines the flip
  25064. * @param twirlClockwise defines the twirl
  25065. * @param tiltRight defines the tilt
  25066. * @returns the current mesh
  25067. */
  25068. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  25069. /**
  25070. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  25071. * Supports definition of mesh facing forward or backward.
  25072. * @param flipBack defines the flip
  25073. * @param twirlClockwise defines the twirl
  25074. * @param tiltRight defines the tilt
  25075. * @returns the new rotation vector
  25076. */
  25077. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  25078. /**
  25079. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  25080. * @param includeDescendants Include bounding info from descendants as well (true by default)
  25081. * @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
  25082. * @returns the new bounding vectors
  25083. */
  25084. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  25085. min: Vector3;
  25086. max: Vector3;
  25087. };
  25088. /**
  25089. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25090. * This means the mesh underlying bounding box and sphere are recomputed.
  25091. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25092. * @returns the current mesh
  25093. */
  25094. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  25095. /** @hidden */
  25096. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  25097. /** @hidden */
  25098. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  25099. /** @hidden */
  25100. _updateBoundingInfo(): AbstractMesh;
  25101. /** @hidden */
  25102. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  25103. /** @hidden */
  25104. protected _afterComputeWorldMatrix(): void;
  25105. /**
  25106. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25107. * A mesh is in the frustum if its bounding box intersects the frustum
  25108. * @param frustumPlanes defines the frustum to test
  25109. * @returns true if the mesh is in the frustum planes
  25110. */
  25111. isInFrustum(frustumPlanes: Plane[]): boolean;
  25112. /**
  25113. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  25114. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  25115. * @param frustumPlanes defines the frustum to test
  25116. * @returns true if the mesh is completely in the frustum planes
  25117. */
  25118. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25119. /**
  25120. * True if the mesh intersects another mesh or a SolidParticle object
  25121. * @param mesh defines a target mesh or SolidParticle to test
  25122. * @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)
  25123. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  25124. * @returns true if there is an intersection
  25125. */
  25126. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  25127. /**
  25128. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  25129. * @param point defines the point to test
  25130. * @returns true if there is an intersection
  25131. */
  25132. intersectsPoint(point: Vector3): boolean;
  25133. /**
  25134. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  25135. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25136. */
  25137. checkCollisions: boolean;
  25138. /**
  25139. * Gets Collider object used to compute collisions (not physics)
  25140. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25141. */
  25142. readonly collider: Collider;
  25143. /**
  25144. * Move the mesh using collision engine
  25145. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25146. * @param displacement defines the requested displacement vector
  25147. * @returns the current mesh
  25148. */
  25149. moveWithCollisions(displacement: Vector3): AbstractMesh;
  25150. private _onCollisionPositionChange;
  25151. /** @hidden */
  25152. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  25153. /** @hidden */
  25154. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  25155. /** @hidden */
  25156. _checkCollision(collider: Collider): AbstractMesh;
  25157. /** @hidden */
  25158. _generatePointsArray(): boolean;
  25159. /**
  25160. * Checks if the passed Ray intersects with the mesh
  25161. * @param ray defines the ray to use
  25162. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  25163. * @returns the picking info
  25164. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  25165. */
  25166. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  25167. /**
  25168. * Clones the current mesh
  25169. * @param name defines the mesh name
  25170. * @param newParent defines the new mesh parent
  25171. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  25172. * @returns the new mesh
  25173. */
  25174. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  25175. /**
  25176. * Disposes all the submeshes of the current meshnp
  25177. * @returns the current mesh
  25178. */
  25179. releaseSubMeshes(): AbstractMesh;
  25180. /**
  25181. * Releases resources associated with this abstract mesh.
  25182. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25183. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25184. */
  25185. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25186. /**
  25187. * Adds the passed mesh as a child to the current mesh
  25188. * @param mesh defines the child mesh
  25189. * @returns the current mesh
  25190. */
  25191. addChild(mesh: AbstractMesh): AbstractMesh;
  25192. /**
  25193. * Removes the passed mesh from the current mesh children list
  25194. * @param mesh defines the child mesh
  25195. * @returns the current mesh
  25196. */
  25197. removeChild(mesh: AbstractMesh): AbstractMesh;
  25198. /** @hidden */
  25199. private _initFacetData;
  25200. /**
  25201. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  25202. * This method can be called within the render loop.
  25203. * 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
  25204. * @returns the current mesh
  25205. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25206. */
  25207. updateFacetData(): AbstractMesh;
  25208. /**
  25209. * Returns the facetLocalNormals array.
  25210. * The normals are expressed in the mesh local spac
  25211. * @returns an array of Vector3
  25212. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25213. */
  25214. getFacetLocalNormals(): Vector3[];
  25215. /**
  25216. * Returns the facetLocalPositions array.
  25217. * The facet positions are expressed in the mesh local space
  25218. * @returns an array of Vector3
  25219. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25220. */
  25221. getFacetLocalPositions(): Vector3[];
  25222. /**
  25223. * Returns the facetLocalPartioning array
  25224. * @returns an array of array of numbers
  25225. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25226. */
  25227. getFacetLocalPartitioning(): number[][];
  25228. /**
  25229. * Returns the i-th facet position in the world system.
  25230. * This method allocates a new Vector3 per call
  25231. * @param i defines the facet index
  25232. * @returns a new Vector3
  25233. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25234. */
  25235. getFacetPosition(i: number): Vector3;
  25236. /**
  25237. * Sets the reference Vector3 with the i-th facet position in the world system
  25238. * @param i defines the facet index
  25239. * @param ref defines the target vector
  25240. * @returns the current mesh
  25241. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25242. */
  25243. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  25244. /**
  25245. * Returns the i-th facet normal in the world system.
  25246. * This method allocates a new Vector3 per call
  25247. * @param i defines the facet index
  25248. * @returns a new Vector3
  25249. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25250. */
  25251. getFacetNormal(i: number): Vector3;
  25252. /**
  25253. * Sets the reference Vector3 with the i-th facet normal in the world system
  25254. * @param i defines the facet index
  25255. * @param ref defines the target vector
  25256. * @returns the current mesh
  25257. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25258. */
  25259. getFacetNormalToRef(i: number, ref: Vector3): this;
  25260. /**
  25261. * 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)
  25262. * @param x defines x coordinate
  25263. * @param y defines y coordinate
  25264. * @param z defines z coordinate
  25265. * @returns the array of facet indexes
  25266. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25267. */
  25268. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  25269. /**
  25270. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  25271. * @param projected sets as the (x,y,z) world projection on the facet
  25272. * @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
  25273. * @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
  25274. * @param x defines x coordinate
  25275. * @param y defines y coordinate
  25276. * @param z defines z coordinate
  25277. * @returns the face index if found (or null instead)
  25278. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25279. */
  25280. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25281. /**
  25282. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  25283. * @param projected sets as the (x,y,z) local projection on the facet
  25284. * @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
  25285. * @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
  25286. * @param x defines x coordinate
  25287. * @param y defines y coordinate
  25288. * @param z defines z coordinate
  25289. * @returns the face index if found (or null instead)
  25290. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25291. */
  25292. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25293. /**
  25294. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  25295. * @returns the parameters
  25296. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25297. */
  25298. getFacetDataParameters(): any;
  25299. /**
  25300. * Disables the feature FacetData and frees the related memory
  25301. * @returns the current mesh
  25302. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25303. */
  25304. disableFacetData(): AbstractMesh;
  25305. /**
  25306. * Updates the AbstractMesh indices array
  25307. * @param indices defines the data source
  25308. * @returns the current mesh
  25309. */
  25310. updateIndices(indices: IndicesArray): AbstractMesh;
  25311. /**
  25312. * Creates new normals data for the mesh
  25313. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  25314. * @returns the current mesh
  25315. */
  25316. createNormals(updatable: boolean): AbstractMesh;
  25317. /**
  25318. * Align the mesh with a normal
  25319. * @param normal defines the normal to use
  25320. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  25321. * @returns the current mesh
  25322. */
  25323. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  25324. /** @hidden */
  25325. _checkOcclusionQuery(): boolean;
  25326. }
  25327. }
  25328. declare module BABYLON {
  25329. /**
  25330. * Class used to store data that will be store in GPU memory
  25331. */
  25332. class Buffer {
  25333. private _engine;
  25334. private _buffer;
  25335. /** @hidden */
  25336. _data: Nullable<DataArray>;
  25337. private _updatable;
  25338. private _instanced;
  25339. /**
  25340. * Gets the byte stride.
  25341. */
  25342. readonly byteStride: number;
  25343. /**
  25344. * Constructor
  25345. * @param engine the engine
  25346. * @param data the data to use for this buffer
  25347. * @param updatable whether the data is updatable
  25348. * @param stride the stride (optional)
  25349. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  25350. * @param instanced whether the buffer is instanced (optional)
  25351. * @param useBytes set to true if the stride in in bytes (optional)
  25352. */
  25353. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  25354. /**
  25355. * Create a new VertexBuffer based on the current buffer
  25356. * @param kind defines the vertex buffer kind (position, normal, etc.)
  25357. * @param offset defines offset in the buffer (0 by default)
  25358. * @param size defines the size in floats of attributes (position is 3 for instance)
  25359. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  25360. * @param instanced defines if the vertex buffer contains indexed data
  25361. * @param useBytes defines if the offset and stride are in bytes
  25362. * @returns the new vertex buffer
  25363. */
  25364. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  25365. /**
  25366. * Gets a boolean indicating if the Buffer is updatable?
  25367. * @returns true if the buffer is updatable
  25368. */
  25369. isUpdatable(): boolean;
  25370. /**
  25371. * Gets current buffer's data
  25372. * @returns a DataArray or null
  25373. */
  25374. getData(): Nullable<DataArray>;
  25375. /**
  25376. * Gets underlying native buffer
  25377. * @returns underlying native buffer
  25378. */
  25379. getBuffer(): Nullable<WebGLBuffer>;
  25380. /**
  25381. * Gets the stride in float32 units (i.e. byte stride / 4).
  25382. * May not be an integer if the byte stride is not divisible by 4.
  25383. * DEPRECATED. Use byteStride instead.
  25384. * @returns the stride in float32 units
  25385. */
  25386. getStrideSize(): number;
  25387. /**
  25388. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  25389. * @param data defines the data to store
  25390. */
  25391. create(data?: Nullable<DataArray>): void;
  25392. /** @hidden */
  25393. _rebuild(): void;
  25394. /**
  25395. * Update current buffer data
  25396. * @param data defines the data to store
  25397. */
  25398. update(data: DataArray): void;
  25399. /**
  25400. * Updates the data directly.
  25401. * @param data the new data
  25402. * @param offset the new offset
  25403. * @param vertexCount the vertex count (optional)
  25404. * @param useBytes set to true if the offset is in bytes
  25405. */
  25406. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  25407. /**
  25408. * Release all resources
  25409. */
  25410. dispose(): void;
  25411. }
  25412. }
  25413. declare module BABYLON {
  25414. /**
  25415. * Class for building Constructive Solid Geometry
  25416. */
  25417. class CSG {
  25418. private polygons;
  25419. /**
  25420. * The world matrix
  25421. */
  25422. matrix: Matrix;
  25423. /**
  25424. * Stores the position
  25425. */
  25426. position: Vector3;
  25427. /**
  25428. * Stores the rotation
  25429. */
  25430. rotation: Vector3;
  25431. /**
  25432. * Stores the rotation quaternion
  25433. */
  25434. rotationQuaternion: Nullable<Quaternion>;
  25435. /**
  25436. * Stores the scaling vector
  25437. */
  25438. scaling: Vector3;
  25439. /**
  25440. * Convert the BABYLON.Mesh to BABYLON.CSG
  25441. * @param mesh The BABYLON.Mesh to convert to BABYLON.CSG
  25442. * @returns A new BABYLON.CSG from the BABYLON.Mesh
  25443. */
  25444. static FromMesh(mesh: Mesh): CSG;
  25445. /**
  25446. * Construct a BABYLON.CSG solid from a list of `BABYLON.CSG.Polygon` instances.
  25447. * @param polygons Polygons used to construct a BABYLON.CSG solid
  25448. */
  25449. private static FromPolygons;
  25450. /**
  25451. * Clones, or makes a deep copy, of the BABYLON.CSG
  25452. * @returns A new BABYLON.CSG
  25453. */
  25454. clone(): CSG;
  25455. /**
  25456. * Unions this CSG with another CSG
  25457. * @param csg The CSG to union against this CSG
  25458. * @returns The unioned CSG
  25459. */
  25460. union(csg: CSG): CSG;
  25461. /**
  25462. * Unions this CSG with another CSG in place
  25463. * @param csg The CSG to union against this CSG
  25464. */
  25465. unionInPlace(csg: CSG): void;
  25466. /**
  25467. * Subtracts this CSG with another CSG
  25468. * @param csg The CSG to subtract against this CSG
  25469. * @returns A new BABYLON.CSG
  25470. */
  25471. subtract(csg: CSG): CSG;
  25472. /**
  25473. * Subtracts this CSG with another CSG in place
  25474. * @param csg The CSG to subtact against this CSG
  25475. */
  25476. subtractInPlace(csg: CSG): void;
  25477. /**
  25478. * Intersect this CSG with another CSG
  25479. * @param csg The CSG to intersect against this CSG
  25480. * @returns A new BABYLON.CSG
  25481. */
  25482. intersect(csg: CSG): CSG;
  25483. /**
  25484. * Intersects this CSG with another CSG in place
  25485. * @param csg The CSG to intersect against this CSG
  25486. */
  25487. intersectInPlace(csg: CSG): void;
  25488. /**
  25489. * Return a new BABYLON.CSG solid with solid and empty space switched. This solid is
  25490. * not modified.
  25491. * @returns A new BABYLON.CSG solid with solid and empty space switched
  25492. */
  25493. inverse(): CSG;
  25494. /**
  25495. * Inverses the BABYLON.CSG in place
  25496. */
  25497. inverseInPlace(): void;
  25498. /**
  25499. * This is used to keep meshes transformations so they can be restored
  25500. * when we build back a Babylon Mesh
  25501. * NB : All CSG operations are performed in world coordinates
  25502. * @param csg The BABYLON.CSG to copy the transform attributes from
  25503. * @returns This BABYLON.CSG
  25504. */
  25505. copyTransformAttributes(csg: CSG): CSG;
  25506. /**
  25507. * Build Raw mesh from CSG
  25508. * Coordinates here are in world space
  25509. * @param name The name of the mesh geometry
  25510. * @param scene The BABYLON.Scene
  25511. * @param keepSubMeshes Specifies if the submeshes should be kept
  25512. * @returns A new BABYLON.Mesh
  25513. */
  25514. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  25515. /**
  25516. * Build Mesh from CSG taking material and transforms into account
  25517. * @param name The name of the BABYLON.Mesh
  25518. * @param material The material of the BABYLON.Mesh
  25519. * @param scene The BABYLON.Scene
  25520. * @param keepSubMeshes Specifies if submeshes should be kept
  25521. * @returns The new BABYLON.Mesh
  25522. */
  25523. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  25524. }
  25525. }
  25526. declare module BABYLON {
  25527. /**
  25528. * Class used to store geometry data (vertex buffers + index buffer)
  25529. */
  25530. class Geometry implements IGetSetVerticesData {
  25531. /**
  25532. * Gets or sets the ID of the geometry
  25533. */
  25534. id: string;
  25535. /**
  25536. * Gets or sets the unique ID of the geometry
  25537. */
  25538. uniqueId: number;
  25539. /**
  25540. * Gets the delay loading state of the geometry (none by default which means not delayed)
  25541. */
  25542. delayLoadState: number;
  25543. /**
  25544. * Gets the file containing the data to load when running in delay load state
  25545. */
  25546. delayLoadingFile: Nullable<string>;
  25547. /**
  25548. * Callback called when the geometry is updated
  25549. */
  25550. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  25551. private _scene;
  25552. private _engine;
  25553. private _meshes;
  25554. private _totalVertices;
  25555. /** @hidden */
  25556. _indices: IndicesArray;
  25557. /** @hidden */
  25558. _vertexBuffers: {
  25559. [key: string]: VertexBuffer;
  25560. };
  25561. private _isDisposed;
  25562. private _extend;
  25563. private _boundingBias;
  25564. /** @hidden */
  25565. _delayInfo: Array<string>;
  25566. private _indexBuffer;
  25567. private _indexBufferIsUpdatable;
  25568. /** @hidden */
  25569. _boundingInfo: Nullable<BoundingInfo>;
  25570. /** @hidden */
  25571. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  25572. /** @hidden */
  25573. _softwareSkinningFrameId: number;
  25574. private _vertexArrayObjects;
  25575. private _updatable;
  25576. /** @hidden */
  25577. _positions: Nullable<Vector3[]>;
  25578. /**
  25579. * 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
  25580. */
  25581. /**
  25582. * 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
  25583. */
  25584. boundingBias: Vector2;
  25585. /**
  25586. * Static function used to attach a new empty geometry to a mesh
  25587. * @param mesh defines the mesh to attach the geometry to
  25588. * @returns the new Geometry
  25589. */
  25590. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  25591. /**
  25592. * Creates a new geometry
  25593. * @param id defines the unique ID
  25594. * @param scene defines the hosting scene
  25595. * @param vertexData defines the VertexData used to get geometry data
  25596. * @param updatable defines if geometry must be updatable (false by default)
  25597. * @param mesh defines the mesh that will be associated with the geometry
  25598. */
  25599. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  25600. /**
  25601. * Gets the current extend of the geometry
  25602. */
  25603. readonly extend: {
  25604. minimum: Vector3;
  25605. maximum: Vector3;
  25606. };
  25607. /**
  25608. * Gets the hosting scene
  25609. * @returns the hosting Scene
  25610. */
  25611. getScene(): Scene;
  25612. /**
  25613. * Gets the hosting engine
  25614. * @returns the hosting Engine
  25615. */
  25616. getEngine(): Engine;
  25617. /**
  25618. * Defines if the geometry is ready to use
  25619. * @returns true if the geometry is ready to be used
  25620. */
  25621. isReady(): boolean;
  25622. /**
  25623. * Gets a value indicating that the geometry should not be serialized
  25624. */
  25625. readonly doNotSerialize: boolean;
  25626. /** @hidden */
  25627. _rebuild(): void;
  25628. /**
  25629. * Affects all geometry data in one call
  25630. * @param vertexData defines the geometry data
  25631. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  25632. */
  25633. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  25634. /**
  25635. * Set specific vertex data
  25636. * @param kind defines the data kind (Position, normal, etc...)
  25637. * @param data defines the vertex data to use
  25638. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25639. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25640. */
  25641. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  25642. /**
  25643. * Removes a specific vertex data
  25644. * @param kind defines the data kind (Position, normal, etc...)
  25645. */
  25646. removeVerticesData(kind: string): void;
  25647. /**
  25648. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  25649. * @param buffer defines the vertex buffer to use
  25650. * @param totalVertices defines the total number of vertices for position kind (could be null)
  25651. */
  25652. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  25653. /**
  25654. * Update a specific vertex buffer
  25655. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  25656. * It will do nothing if the buffer is not updatable
  25657. * @param kind defines the data kind (Position, normal, etc...)
  25658. * @param data defines the data to use
  25659. * @param offset defines the offset in the target buffer where to store the data
  25660. * @param useBytes set to true if the offset is in bytes
  25661. */
  25662. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  25663. /**
  25664. * Update a specific vertex buffer
  25665. * This function will create a new buffer if the current one is not updatable
  25666. * @param kind defines the data kind (Position, normal, etc...)
  25667. * @param data defines the data to use
  25668. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  25669. */
  25670. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  25671. private _updateBoundingInfo;
  25672. /** @hidden */
  25673. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  25674. /**
  25675. * Gets total number of vertices
  25676. * @returns the total number of vertices
  25677. */
  25678. getTotalVertices(): number;
  25679. /**
  25680. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25681. * @param kind defines the data kind (Position, normal, etc...)
  25682. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25683. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25684. * @returns a float array containing vertex data
  25685. */
  25686. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25687. /**
  25688. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  25689. * @param kind defines the data kind (Position, normal, etc...)
  25690. * @returns true if the vertex buffer with the specified kind is updatable
  25691. */
  25692. isVertexBufferUpdatable(kind: string): boolean;
  25693. /**
  25694. * Gets a specific vertex buffer
  25695. * @param kind defines the data kind (Position, normal, etc...)
  25696. * @returns a VertexBuffer
  25697. */
  25698. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25699. /**
  25700. * Returns all vertex buffers
  25701. * @return an object holding all vertex buffers indexed by kind
  25702. */
  25703. getVertexBuffers(): Nullable<{
  25704. [key: string]: VertexBuffer;
  25705. }>;
  25706. /**
  25707. * Gets a boolean indicating if specific vertex buffer is present
  25708. * @param kind defines the data kind (Position, normal, etc...)
  25709. * @returns true if data is present
  25710. */
  25711. isVerticesDataPresent(kind: string): boolean;
  25712. /**
  25713. * Gets a list of all attached data kinds (Position, normal, etc...)
  25714. * @returns a list of string containing all kinds
  25715. */
  25716. getVerticesDataKinds(): string[];
  25717. /**
  25718. * Update index buffer
  25719. * @param indices defines the indices to store in the index buffer
  25720. * @param offset defines the offset in the target buffer where to store the data
  25721. */
  25722. updateIndices(indices: IndicesArray, offset?: number): void;
  25723. /**
  25724. * Creates a new index buffer
  25725. * @param indices defines the indices to store in the index buffer
  25726. * @param totalVertices defines the total number of vertices (could be null)
  25727. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25728. */
  25729. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  25730. /**
  25731. * Return the total number of indices
  25732. * @returns the total number of indices
  25733. */
  25734. getTotalIndices(): number;
  25735. /**
  25736. * Gets the index buffer array
  25737. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25738. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25739. * @returns the index buffer array
  25740. */
  25741. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25742. /**
  25743. * Gets the index buffer
  25744. * @return the index buffer
  25745. */
  25746. getIndexBuffer(): Nullable<WebGLBuffer>;
  25747. /** @hidden */
  25748. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  25749. /**
  25750. * Release the associated resources for a specific mesh
  25751. * @param mesh defines the source mesh
  25752. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  25753. */
  25754. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  25755. /**
  25756. * Apply current geometry to a given mesh
  25757. * @param mesh defines the mesh to apply geometry to
  25758. */
  25759. applyToMesh(mesh: Mesh): void;
  25760. private _updateExtend;
  25761. private _applyToMesh;
  25762. private notifyUpdate;
  25763. /**
  25764. * Load the geometry if it was flagged as delay loaded
  25765. * @param scene defines the hosting scene
  25766. * @param onLoaded defines a callback called when the geometry is loaded
  25767. */
  25768. load(scene: Scene, onLoaded?: () => void): void;
  25769. private _queueLoad;
  25770. /**
  25771. * Invert the geometry to move from a right handed system to a left handed one.
  25772. */
  25773. toLeftHanded(): void;
  25774. /** @hidden */
  25775. _resetPointsArrayCache(): void;
  25776. /** @hidden */
  25777. _generatePointsArray(): boolean;
  25778. /**
  25779. * Gets a value indicating if the geometry is disposed
  25780. * @returns true if the geometry was disposed
  25781. */
  25782. isDisposed(): boolean;
  25783. private _disposeVertexArrayObjects;
  25784. /**
  25785. * Free all associated resources
  25786. */
  25787. dispose(): void;
  25788. /**
  25789. * Clone the current geometry into a new geometry
  25790. * @param id defines the unique ID of the new geometry
  25791. * @returns a new geometry object
  25792. */
  25793. copy(id: string): Geometry;
  25794. /**
  25795. * Serialize the current geometry info (and not the vertices data) into a JSON object
  25796. * @return a JSON representation of the current geometry data (without the vertices data)
  25797. */
  25798. serialize(): any;
  25799. private toNumberArray;
  25800. /**
  25801. * Serialize all vertices data into a JSON oject
  25802. * @returns a JSON representation of the current geometry data
  25803. */
  25804. serializeVerticeData(): any;
  25805. /**
  25806. * Extracts a clone of a mesh geometry
  25807. * @param mesh defines the source mesh
  25808. * @param id defines the unique ID of the new geometry object
  25809. * @returns the new geometry object
  25810. */
  25811. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  25812. /**
  25813. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  25814. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  25815. * Be aware Math.random() could cause collisions, but:
  25816. * "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"
  25817. * @returns a string containing a new GUID
  25818. */
  25819. static RandomId(): string;
  25820. /** @hidden */
  25821. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  25822. private static _CleanMatricesWeights;
  25823. /**
  25824. * Create a new geometry from persisted data (Using .babylon file format)
  25825. * @param parsedVertexData defines the persisted data
  25826. * @param scene defines the hosting scene
  25827. * @param rootUrl defines the root url to use to load assets (like delayed data)
  25828. * @returns the new geometry object
  25829. */
  25830. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  25831. }
  25832. /**
  25833. * Abstract class used to provide common services for all typed geometries
  25834. * @hidden
  25835. */
  25836. class _PrimitiveGeometry extends Geometry {
  25837. private _canBeRegenerated;
  25838. private _beingRegenerated;
  25839. /**
  25840. * Creates a new typed geometry
  25841. * @param id defines the unique ID of the geometry
  25842. * @param scene defines the hosting scene
  25843. * @param _canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25844. * @param mesh defines the hosting mesh (can be null)
  25845. */
  25846. constructor(id: string, scene: Scene, _canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  25847. /**
  25848. * Gets a value indicating if the geometry supports being regenerated with new parameters (false by default)
  25849. * @returns true if the geometry can be regenerated
  25850. */
  25851. canBeRegenerated(): boolean;
  25852. /**
  25853. * If the geometry supports regeneration, the function will recreates the geometry with updated parameter values
  25854. */
  25855. regenerate(): void;
  25856. /**
  25857. * Clone the geometry
  25858. * @param id defines the unique ID of the new geometry
  25859. * @returns the new geometry
  25860. */
  25861. asNewGeometry(id: string): Geometry;
  25862. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  25863. setVerticesData(kind: string, data: FloatArray, updatable?: boolean): void;
  25864. /** @hidden */
  25865. _regenerateVertexData(): VertexData;
  25866. copy(id: string): Geometry;
  25867. serialize(): any;
  25868. }
  25869. /**
  25870. * Creates a ribbon geometry
  25871. * @description See http://doc.babylonjs.com/how_to/ribbon_tutorial, http://doc.babylonjs.com/resources/maths_make_ribbons
  25872. */
  25873. class RibbonGeometry extends _PrimitiveGeometry {
  25874. /**
  25875. * Defines the array of paths to use
  25876. */
  25877. pathArray: Vector3[][];
  25878. /**
  25879. * Defines if the last and first points of each path in your pathArray must be joined
  25880. */
  25881. closeArray: boolean;
  25882. /**
  25883. * Defines if the last and first points of each path in your pathArray must be joined
  25884. */
  25885. closePath: boolean;
  25886. /**
  25887. * Defines the offset between points
  25888. */
  25889. offset: number;
  25890. /**
  25891. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25892. */
  25893. side: number;
  25894. /**
  25895. * Creates a ribbon geometry
  25896. * @param id defines the unique ID of the geometry
  25897. * @param scene defines the hosting scene
  25898. * @param pathArray defines the array of paths to use
  25899. * @param closeArray defines if the last path and the first path must be joined
  25900. * @param closePath defines if the last and first points of each path in your pathArray must be joined
  25901. * @param offset defines the offset between points
  25902. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25903. * @param mesh defines the hosting mesh (can be null)
  25904. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25905. */
  25906. constructor(id: string, scene: Scene,
  25907. /**
  25908. * Defines the array of paths to use
  25909. */
  25910. pathArray: Vector3[][],
  25911. /**
  25912. * Defines if the last and first points of each path in your pathArray must be joined
  25913. */
  25914. closeArray: boolean,
  25915. /**
  25916. * Defines if the last and first points of each path in your pathArray must be joined
  25917. */
  25918. closePath: boolean,
  25919. /**
  25920. * Defines the offset between points
  25921. */
  25922. offset: number, canBeRegenerated?: boolean, mesh?: Mesh,
  25923. /**
  25924. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25925. */
  25926. side?: number);
  25927. /** @hidden */
  25928. _regenerateVertexData(): VertexData;
  25929. copy(id: string): Geometry;
  25930. }
  25931. /**
  25932. * Creates a box geometry
  25933. * @description see http://doc.babylonjs.com/how_to/set_shapes#box
  25934. */
  25935. class BoxGeometry extends _PrimitiveGeometry {
  25936. /**
  25937. * Defines the zise of the box (width, height and depth are the same)
  25938. */
  25939. size: number;
  25940. /**
  25941. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25942. */
  25943. side: number;
  25944. /**
  25945. * Creates a box geometry
  25946. * @param id defines the unique ID of the geometry
  25947. * @param scene defines the hosting scene
  25948. * @param size defines the zise of the box (width, height and depth are the same)
  25949. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25950. * @param mesh defines the hosting mesh (can be null)
  25951. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25952. */
  25953. constructor(id: string, scene: Scene,
  25954. /**
  25955. * Defines the zise of the box (width, height and depth are the same)
  25956. */
  25957. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25958. /**
  25959. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25960. */
  25961. side?: number);
  25962. /** @hidden */
  25963. _regenerateVertexData(): VertexData;
  25964. copy(id: string): Geometry;
  25965. serialize(): any;
  25966. static Parse(parsedBox: any, scene: Scene): Nullable<BoxGeometry>;
  25967. }
  25968. /**
  25969. * Creates a sphere geometry
  25970. * @description see http://doc.babylonjs.com/how_to/set_shapes#sphere
  25971. */
  25972. class SphereGeometry extends _PrimitiveGeometry {
  25973. /**
  25974. * Defines the number of segments to use to create the sphere
  25975. */
  25976. segments: number;
  25977. /**
  25978. * Defines the diameter of the sphere
  25979. */
  25980. diameter: number;
  25981. /**
  25982. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25983. */
  25984. side: number;
  25985. /**
  25986. * Create a new sphere geometry
  25987. * @param id defines the unique ID of the geometry
  25988. * @param scene defines the hosting scene
  25989. * @param segments defines the number of segments to use to create the sphere
  25990. * @param diameter defines the diameter of the sphere
  25991. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25992. * @param mesh defines the hosting mesh (can be null)
  25993. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25994. */
  25995. constructor(id: string, scene: Scene,
  25996. /**
  25997. * Defines the number of segments to use to create the sphere
  25998. */
  25999. segments: number,
  26000. /**
  26001. * Defines the diameter of the sphere
  26002. */
  26003. diameter: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  26004. /**
  26005. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26006. */
  26007. side?: number);
  26008. /** @hidden */
  26009. _regenerateVertexData(): VertexData;
  26010. copy(id: string): Geometry;
  26011. serialize(): any;
  26012. static Parse(parsedSphere: any, scene: Scene): Nullable<SphereGeometry>;
  26013. }
  26014. /**
  26015. * Creates a disc geometry
  26016. * @description see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26017. */
  26018. class DiscGeometry extends _PrimitiveGeometry {
  26019. /**
  26020. * Defines the radius of the disc
  26021. */
  26022. radius: number;
  26023. /**
  26024. * Defines the tesselation factor to apply to the disc
  26025. */
  26026. tessellation: number;
  26027. /**
  26028. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26029. */
  26030. side: number;
  26031. /**
  26032. * Creates a new disc geometry
  26033. * @param id defines the unique ID of the geometry
  26034. * @param scene defines the hosting scene
  26035. * @param radius defines the radius of the disc
  26036. * @param tessellation defines the tesselation factor to apply to the disc
  26037. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  26038. * @param mesh defines the hosting mesh (can be null)
  26039. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26040. */
  26041. constructor(id: string, scene: Scene,
  26042. /**
  26043. * Defines the radius of the disc
  26044. */
  26045. radius: number,
  26046. /**
  26047. * Defines the tesselation factor to apply to the disc
  26048. */
  26049. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  26050. /**
  26051. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26052. */
  26053. side?: number);
  26054. /** @hidden */
  26055. _regenerateVertexData(): VertexData;
  26056. copy(id: string): Geometry;
  26057. }
  26058. /**
  26059. * Creates a new cylinder geometry
  26060. * @description see http://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  26061. */
  26062. class CylinderGeometry extends _PrimitiveGeometry {
  26063. /**
  26064. * Defines the height of the cylinder
  26065. */
  26066. height: number;
  26067. /**
  26068. * Defines the diameter of the cylinder's top cap
  26069. */
  26070. diameterTop: number;
  26071. /**
  26072. * Defines the diameter of the cylinder's bottom cap
  26073. */
  26074. diameterBottom: number;
  26075. /**
  26076. * Defines the tessellation factor to apply to the cylinder
  26077. */
  26078. tessellation: number;
  26079. /**
  26080. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  26081. */
  26082. subdivisions: number;
  26083. /**
  26084. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26085. */
  26086. side: number;
  26087. /**
  26088. * Creates a new cylinder geometry
  26089. * @param id defines the unique ID of the geometry
  26090. * @param scene defines the hosting scene
  26091. * @param height defines the height of the cylinder
  26092. * @param diameterTop defines the diameter of the cylinder's top cap
  26093. * @param diameterBottom defines the diameter of the cylinder's bottom cap
  26094. * @param tessellation defines the tessellation factor to apply to the cylinder (number of radial sides)
  26095. * @param subdivisions defines the number of subdivisions to apply to the cylinder (number of rings) (1 by default)
  26096. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  26097. * @param mesh defines the hosting mesh (can be null)
  26098. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26099. */
  26100. constructor(id: string, scene: Scene,
  26101. /**
  26102. * Defines the height of the cylinder
  26103. */
  26104. height: number,
  26105. /**
  26106. * Defines the diameter of the cylinder's top cap
  26107. */
  26108. diameterTop: number,
  26109. /**
  26110. * Defines the diameter of the cylinder's bottom cap
  26111. */
  26112. diameterBottom: number,
  26113. /**
  26114. * Defines the tessellation factor to apply to the cylinder
  26115. */
  26116. tessellation: number,
  26117. /**
  26118. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  26119. */
  26120. subdivisions?: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  26121. /**
  26122. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26123. */
  26124. side?: number);
  26125. /** @hidden */
  26126. _regenerateVertexData(): VertexData;
  26127. copy(id: string): Geometry;
  26128. serialize(): any;
  26129. static Parse(parsedCylinder: any, scene: Scene): Nullable<CylinderGeometry>;
  26130. }
  26131. /**
  26132. * Creates a new torus geometry
  26133. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus
  26134. */
  26135. class TorusGeometry extends _PrimitiveGeometry {
  26136. /**
  26137. * Defines the diameter of the torus
  26138. */
  26139. diameter: number;
  26140. /**
  26141. * Defines the thickness of the torus (ie. internal diameter)
  26142. */
  26143. thickness: number;
  26144. /**
  26145. * Defines the tesselation factor to apply to the torus
  26146. */
  26147. tessellation: number;
  26148. /**
  26149. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26150. */
  26151. side: number;
  26152. /**
  26153. * Creates a new torus geometry
  26154. * @param id defines the unique ID of the geometry
  26155. * @param scene defines the hosting scene
  26156. * @param diameter defines the diameter of the torus
  26157. * @param thickness defines the thickness of the torus (ie. internal diameter)
  26158. * @param tessellation defines the tesselation factor to apply to the torus (number of segments along the circle)
  26159. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  26160. * @param mesh defines the hosting mesh (can be null)
  26161. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26162. */
  26163. constructor(id: string, scene: Scene,
  26164. /**
  26165. * Defines the diameter of the torus
  26166. */
  26167. diameter: number,
  26168. /**
  26169. * Defines the thickness of the torus (ie. internal diameter)
  26170. */
  26171. thickness: number,
  26172. /**
  26173. * Defines the tesselation factor to apply to the torus
  26174. */
  26175. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  26176. /**
  26177. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26178. */
  26179. side?: number);
  26180. /** @hidden */
  26181. _regenerateVertexData(): VertexData;
  26182. copy(id: string): Geometry;
  26183. serialize(): any;
  26184. static Parse(parsedTorus: any, scene: Scene): Nullable<TorusGeometry>;
  26185. }
  26186. /**
  26187. * Creates a new ground geometry
  26188. * @description see http://doc.babylonjs.com/how_to/set_shapes#ground
  26189. */
  26190. class GroundGeometry extends _PrimitiveGeometry {
  26191. /**
  26192. * Defines the width of the ground
  26193. */
  26194. width: number;
  26195. /**
  26196. * Defines the height of the ground
  26197. */
  26198. height: number;
  26199. /**
  26200. * Defines the subdivisions to apply to the ground
  26201. */
  26202. subdivisions: number;
  26203. /**
  26204. * Creates a new ground geometry
  26205. * @param id defines the unique ID of the geometry
  26206. * @param scene defines the hosting scene
  26207. * @param width defines the width of the ground
  26208. * @param height defines the height of the ground
  26209. * @param subdivisions defines the subdivisions to apply to the ground
  26210. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  26211. * @param mesh defines the hosting mesh (can be null)
  26212. */
  26213. constructor(id: string, scene: Scene,
  26214. /**
  26215. * Defines the width of the ground
  26216. */
  26217. width: number,
  26218. /**
  26219. * Defines the height of the ground
  26220. */
  26221. height: number,
  26222. /**
  26223. * Defines the subdivisions to apply to the ground
  26224. */
  26225. subdivisions: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  26226. /** @hidden */
  26227. _regenerateVertexData(): VertexData;
  26228. copy(id: string): Geometry;
  26229. serialize(): any;
  26230. static Parse(parsedGround: any, scene: Scene): Nullable<GroundGeometry>;
  26231. }
  26232. /**
  26233. * Creates a tiled ground geometry
  26234. * @description see http://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  26235. */
  26236. class TiledGroundGeometry extends _PrimitiveGeometry {
  26237. /**
  26238. * Defines the minimum value on X axis
  26239. */
  26240. xmin: number;
  26241. /**
  26242. * Defines the minimum value on Z axis
  26243. */
  26244. zmin: number;
  26245. /**
  26246. * Defines the maximum value on X axis
  26247. */
  26248. xmax: number;
  26249. /**
  26250. * Defines the maximum value on Z axis
  26251. */
  26252. zmax: number;
  26253. /**
  26254. * Defines the subdivisions to apply to the ground
  26255. */
  26256. subdivisions: {
  26257. w: number;
  26258. h: number;
  26259. };
  26260. /**
  26261. * Defines the precision to use when computing the tiles
  26262. */
  26263. precision: {
  26264. w: number;
  26265. h: number;
  26266. };
  26267. /**
  26268. * Creates a tiled ground geometry
  26269. * @param id defines the unique ID of the geometry
  26270. * @param scene defines the hosting scene
  26271. * @param xmin defines the minimum value on X axis
  26272. * @param zmin defines the minimum value on Z axis
  26273. * @param xmax defines the maximum value on X axis
  26274. * @param zmax defines the maximum value on Z axis
  26275. * @param subdivisions defines the subdivisions to apply to the ground (number of subdivisions (tiles) on the height and the width of the map)
  26276. * @param precision defines the precision to use when computing the tiles
  26277. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  26278. * @param mesh defines the hosting mesh (can be null)
  26279. */
  26280. constructor(id: string, scene: Scene,
  26281. /**
  26282. * Defines the minimum value on X axis
  26283. */
  26284. xmin: number,
  26285. /**
  26286. * Defines the minimum value on Z axis
  26287. */
  26288. zmin: number,
  26289. /**
  26290. * Defines the maximum value on X axis
  26291. */
  26292. xmax: number,
  26293. /**
  26294. * Defines the maximum value on Z axis
  26295. */
  26296. zmax: number,
  26297. /**
  26298. * Defines the subdivisions to apply to the ground
  26299. */
  26300. subdivisions: {
  26301. w: number;
  26302. h: number;
  26303. },
  26304. /**
  26305. * Defines the precision to use when computing the tiles
  26306. */
  26307. precision: {
  26308. w: number;
  26309. h: number;
  26310. }, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  26311. /** @hidden */
  26312. _regenerateVertexData(): VertexData;
  26313. copy(id: string): Geometry;
  26314. }
  26315. /**
  26316. * Creates a plane geometry
  26317. * @description see http://doc.babylonjs.com/how_to/set_shapes#plane
  26318. */
  26319. class PlaneGeometry extends _PrimitiveGeometry {
  26320. /**
  26321. * Defines the size of the plane (width === height)
  26322. */
  26323. size: number;
  26324. /**
  26325. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26326. */
  26327. side: number;
  26328. /**
  26329. * Creates a plane geometry
  26330. * @param id defines the unique ID of the geometry
  26331. * @param scene defines the hosting scene
  26332. * @param size defines the size of the plane (width === height)
  26333. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  26334. * @param mesh defines the hosting mesh (can be null)
  26335. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26336. */
  26337. constructor(id: string, scene: Scene,
  26338. /**
  26339. * Defines the size of the plane (width === height)
  26340. */
  26341. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  26342. /**
  26343. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26344. */
  26345. side?: number);
  26346. /** @hidden */
  26347. _regenerateVertexData(): VertexData;
  26348. copy(id: string): Geometry;
  26349. serialize(): any;
  26350. static Parse(parsedPlane: any, scene: Scene): Nullable<PlaneGeometry>;
  26351. }
  26352. /**
  26353. * Creates a torus knot geometry
  26354. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus-knot
  26355. */
  26356. class TorusKnotGeometry extends _PrimitiveGeometry {
  26357. /**
  26358. * Defines the radius of the torus knot
  26359. */
  26360. radius: number;
  26361. /**
  26362. * Defines the thickness of the torus knot tube
  26363. */
  26364. tube: number;
  26365. /**
  26366. * Defines the number of radial segments
  26367. */
  26368. radialSegments: number;
  26369. /**
  26370. * Defines the number of tubular segments
  26371. */
  26372. tubularSegments: number;
  26373. /**
  26374. * Defines the first number of windings
  26375. */
  26376. p: number;
  26377. /**
  26378. * Defines the second number of windings
  26379. */
  26380. q: number;
  26381. /**
  26382. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26383. */
  26384. side: number;
  26385. /**
  26386. * Creates a torus knot geometry
  26387. * @param id defines the unique ID of the geometry
  26388. * @param scene defines the hosting scene
  26389. * @param radius defines the radius of the torus knot
  26390. * @param tube defines the thickness of the torus knot tube
  26391. * @param radialSegments defines the number of radial segments
  26392. * @param tubularSegments defines the number of tubular segments
  26393. * @param p defines the first number of windings
  26394. * @param q defines the second number of windings
  26395. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  26396. * @param mesh defines the hosting mesh (can be null)
  26397. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26398. */
  26399. constructor(id: string, scene: Scene,
  26400. /**
  26401. * Defines the radius of the torus knot
  26402. */
  26403. radius: number,
  26404. /**
  26405. * Defines the thickness of the torus knot tube
  26406. */
  26407. tube: number,
  26408. /**
  26409. * Defines the number of radial segments
  26410. */
  26411. radialSegments: number,
  26412. /**
  26413. * Defines the number of tubular segments
  26414. */
  26415. tubularSegments: number,
  26416. /**
  26417. * Defines the first number of windings
  26418. */
  26419. p: number,
  26420. /**
  26421. * Defines the second number of windings
  26422. */
  26423. q: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  26424. /**
  26425. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26426. */
  26427. side?: number);
  26428. /** @hidden */
  26429. _regenerateVertexData(): VertexData;
  26430. copy(id: string): Geometry;
  26431. serialize(): any;
  26432. static Parse(parsedTorusKnot: any, scene: Scene): Nullable<TorusKnotGeometry>;
  26433. }
  26434. }
  26435. declare module BABYLON {
  26436. /**
  26437. * Mesh representing the gorund
  26438. */
  26439. class GroundMesh extends Mesh {
  26440. /** If octree should be generated */
  26441. generateOctree: boolean;
  26442. private _heightQuads;
  26443. /** @hidden */
  26444. _subdivisionsX: number;
  26445. /** @hidden */
  26446. _subdivisionsY: number;
  26447. /** @hidden */
  26448. _width: number;
  26449. /** @hidden */
  26450. _height: number;
  26451. /** @hidden */
  26452. _minX: number;
  26453. /** @hidden */
  26454. _maxX: number;
  26455. /** @hidden */
  26456. _minZ: number;
  26457. /** @hidden */
  26458. _maxZ: number;
  26459. constructor(name: string, scene: Scene);
  26460. /**
  26461. * "GroundMesh"
  26462. * @returns "GroundMesh"
  26463. */
  26464. getClassName(): string;
  26465. /**
  26466. * The minimum of x and y subdivisions
  26467. */
  26468. readonly subdivisions: number;
  26469. /**
  26470. * X subdivisions
  26471. */
  26472. readonly subdivisionsX: number;
  26473. /**
  26474. * Y subdivisions
  26475. */
  26476. readonly subdivisionsY: number;
  26477. /**
  26478. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  26479. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  26480. * @param chunksCount the number of subdivisions for x and y
  26481. * @param octreeBlocksSize (Default: 32)
  26482. */
  26483. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  26484. /**
  26485. * Returns a height (y) value in the Worl system :
  26486. * the ground altitude at the coordinates (x, z) expressed in the World system.
  26487. * @param x x coordinate
  26488. * @param z z coordinate
  26489. * @returns the ground y position if (x, z) are outside the ground surface.
  26490. */
  26491. getHeightAtCoordinates(x: number, z: number): number;
  26492. /**
  26493. * Returns a normalized vector (Vector3) orthogonal to the ground
  26494. * at the ground coordinates (x, z) expressed in the World system.
  26495. * @param x x coordinate
  26496. * @param z z coordinate
  26497. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  26498. */
  26499. getNormalAtCoordinates(x: number, z: number): Vector3;
  26500. /**
  26501. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  26502. * at the ground coordinates (x, z) expressed in the World system.
  26503. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  26504. * @param x x coordinate
  26505. * @param z z coordinate
  26506. * @param ref vector to store the result
  26507. * @returns the GroundMesh.
  26508. */
  26509. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  26510. /**
  26511. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  26512. * if the ground has been updated.
  26513. * This can be used in the render loop.
  26514. * @returns the GroundMesh.
  26515. */
  26516. updateCoordinateHeights(): GroundMesh;
  26517. private _getFacetAt;
  26518. private _initHeightQuads;
  26519. private _computeHeightQuads;
  26520. /**
  26521. * Serializes this ground mesh
  26522. * @param serializationObject object to write serialization to
  26523. */
  26524. serialize(serializationObject: any): void;
  26525. /**
  26526. * Parses a serialized ground mesh
  26527. * @param parsedMesh the serialized mesh
  26528. * @param scene the scene to create the ground mesh in
  26529. * @returns the created ground mesh
  26530. */
  26531. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  26532. }
  26533. }
  26534. declare module BABYLON {
  26535. /**
  26536. * Creates an instance based on a source mesh.
  26537. */
  26538. class InstancedMesh extends AbstractMesh {
  26539. private _sourceMesh;
  26540. private _currentLOD;
  26541. /** @hidden */
  26542. _indexInSourceMeshInstanceArray: number;
  26543. constructor(name: string, source: Mesh);
  26544. /**
  26545. * Returns the string "InstancedMesh".
  26546. */
  26547. getClassName(): string;
  26548. /**
  26549. * If the source mesh receives shadows
  26550. */
  26551. readonly receiveShadows: boolean;
  26552. /**
  26553. * The material of the source mesh
  26554. */
  26555. readonly material: Nullable<Material>;
  26556. /**
  26557. * Visibility of the source mesh
  26558. */
  26559. readonly visibility: number;
  26560. /**
  26561. * Skeleton of the source mesh
  26562. */
  26563. readonly skeleton: Nullable<Skeleton>;
  26564. /**
  26565. * Rendering ground id of the source mesh
  26566. */
  26567. renderingGroupId: number;
  26568. /**
  26569. * Returns the total number of vertices (integer).
  26570. */
  26571. getTotalVertices(): number;
  26572. /**
  26573. * Returns a positive integer : the total number of indices in this mesh geometry.
  26574. * @returns the numner of indices or zero if the mesh has no geometry.
  26575. */
  26576. getTotalIndices(): number;
  26577. /**
  26578. * The source mesh of the instance
  26579. */
  26580. readonly sourceMesh: Mesh;
  26581. /**
  26582. * Is this node ready to be used/rendered
  26583. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26584. * @return {boolean} is it ready
  26585. */
  26586. isReady(completeCheck?: boolean): boolean;
  26587. /**
  26588. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  26589. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  26590. * @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.
  26591. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  26592. */
  26593. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  26594. /**
  26595. * Sets the vertex data of the mesh geometry for the requested `kind`.
  26596. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  26597. * The `data` are either a numeric array either a Float32Array.
  26598. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  26599. * 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).
  26600. * Note that a new underlying VertexBuffer object is created each call.
  26601. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  26602. *
  26603. * Possible `kind` values :
  26604. * - BABYLON.VertexBuffer.PositionKind
  26605. * - BABYLON.VertexBuffer.UVKind
  26606. * - BABYLON.VertexBuffer.UV2Kind
  26607. * - BABYLON.VertexBuffer.UV3Kind
  26608. * - BABYLON.VertexBuffer.UV4Kind
  26609. * - BABYLON.VertexBuffer.UV5Kind
  26610. * - BABYLON.VertexBuffer.UV6Kind
  26611. * - BABYLON.VertexBuffer.ColorKind
  26612. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26613. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26614. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26615. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26616. *
  26617. * Returns the Mesh.
  26618. */
  26619. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  26620. /**
  26621. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  26622. * If the mesh has no geometry, it is simply returned as it is.
  26623. * The `data` are either a numeric array either a Float32Array.
  26624. * No new underlying VertexBuffer object is created.
  26625. * 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.
  26626. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  26627. *
  26628. * Possible `kind` values :
  26629. * - BABYLON.VertexBuffer.PositionKind
  26630. * - BABYLON.VertexBuffer.UVKind
  26631. * - BABYLON.VertexBuffer.UV2Kind
  26632. * - BABYLON.VertexBuffer.UV3Kind
  26633. * - BABYLON.VertexBuffer.UV4Kind
  26634. * - BABYLON.VertexBuffer.UV5Kind
  26635. * - BABYLON.VertexBuffer.UV6Kind
  26636. * - BABYLON.VertexBuffer.ColorKind
  26637. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26638. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26639. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26640. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26641. *
  26642. * Returns the Mesh.
  26643. */
  26644. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  26645. /**
  26646. * Sets the mesh indices.
  26647. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  26648. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  26649. * This method creates a new index buffer each call.
  26650. * Returns the Mesh.
  26651. */
  26652. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  26653. /**
  26654. * Boolean : True if the mesh owns the requested kind of data.
  26655. */
  26656. isVerticesDataPresent(kind: string): boolean;
  26657. /**
  26658. * Returns an array of indices (IndicesArray).
  26659. */
  26660. getIndices(): Nullable<IndicesArray>;
  26661. readonly _positions: Nullable<Vector3[]>;
  26662. /**
  26663. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26664. * This means the mesh underlying bounding box and sphere are recomputed.
  26665. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26666. * @returns the current mesh
  26667. */
  26668. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  26669. /** @hidden */
  26670. _preActivate(): InstancedMesh;
  26671. /** @hidden */
  26672. _activate(renderId: number): InstancedMesh;
  26673. /**
  26674. * Returns the current associated LOD AbstractMesh.
  26675. */
  26676. getLOD(camera: Camera): AbstractMesh;
  26677. /** @hidden */
  26678. _syncSubMeshes(): InstancedMesh;
  26679. /** @hidden */
  26680. _generatePointsArray(): boolean;
  26681. /**
  26682. * Creates a new InstancedMesh from the current mesh.
  26683. * - name (string) : the cloned mesh name
  26684. * - newParent (optional Node) : the optional Node to parent the clone to.
  26685. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  26686. *
  26687. * Returns the clone.
  26688. */
  26689. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  26690. /**
  26691. * Disposes the InstancedMesh.
  26692. * Returns nothing.
  26693. */
  26694. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26695. }
  26696. }
  26697. declare module BABYLON {
  26698. /**
  26699. * Line mesh
  26700. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  26701. */
  26702. class LinesMesh extends Mesh {
  26703. /**
  26704. * If vertex color should be applied to the mesh
  26705. */
  26706. useVertexColor?: boolean | undefined;
  26707. /**
  26708. * If vertex alpha should be applied to the mesh
  26709. */
  26710. useVertexAlpha?: boolean | undefined;
  26711. /**
  26712. * Color of the line (Default: White)
  26713. */
  26714. color: Color3;
  26715. /**
  26716. * Alpha of the line (Default: 1)
  26717. */
  26718. alpha: number;
  26719. /**
  26720. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  26721. * This margin is expressed in world space coordinates, so its value may vary.
  26722. * Default value is 0.1
  26723. */
  26724. intersectionThreshold: number;
  26725. private _colorShader;
  26726. /**
  26727. * Creates a new LinesMesh
  26728. * @param name defines the name
  26729. * @param scene defines the hosting scene
  26730. * @param parent defines the parent mesh if any
  26731. * @param source defines the optional source LinesMesh used to clone data from
  26732. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  26733. * When false, achieved by calling a clone(), also passing False.
  26734. * This will make creation of children, recursive.
  26735. * @param useVertexColor defines if this LinesMesh supports vertex color
  26736. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  26737. */
  26738. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  26739. /**
  26740. * If vertex color should be applied to the mesh
  26741. */
  26742. useVertexColor?: boolean | undefined,
  26743. /**
  26744. * If vertex alpha should be applied to the mesh
  26745. */
  26746. useVertexAlpha?: boolean | undefined);
  26747. /**
  26748. * Returns the string "LineMesh"
  26749. */
  26750. getClassName(): string;
  26751. /**
  26752. * @hidden
  26753. */
  26754. /**
  26755. * @hidden
  26756. */
  26757. material: Material;
  26758. /**
  26759. * @hidden
  26760. */
  26761. readonly checkCollisions: boolean;
  26762. /** @hidden */
  26763. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  26764. /** @hidden */
  26765. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  26766. /**
  26767. * Disposes of the line mesh
  26768. * @param doNotRecurse If children should be disposed
  26769. */
  26770. dispose(doNotRecurse?: boolean): void;
  26771. /**
  26772. * Returns a new LineMesh object cloned from the current one.
  26773. */
  26774. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  26775. /**
  26776. * Creates a new InstancedLinesMesh object from the mesh model.
  26777. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  26778. * @param name defines the name of the new instance
  26779. * @returns a new InstancedLinesMesh
  26780. */
  26781. createInstance(name: string): InstancedLinesMesh;
  26782. }
  26783. /**
  26784. * Creates an instance based on a source LinesMesh
  26785. */
  26786. class InstancedLinesMesh extends InstancedMesh {
  26787. /**
  26788. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  26789. * This margin is expressed in world space coordinates, so its value may vary.
  26790. * Initilized with the intersectionThreshold value of the source LinesMesh
  26791. */
  26792. intersectionThreshold: number;
  26793. constructor(name: string, source: LinesMesh);
  26794. /**
  26795. * Returns the string "InstancedLinesMesh".
  26796. */
  26797. getClassName(): string;
  26798. }
  26799. }
  26800. declare module BABYLON {
  26801. /**
  26802. * @hidden
  26803. **/
  26804. class _CreationDataStorage {
  26805. closePath?: boolean;
  26806. closeArray?: boolean;
  26807. idx: number[];
  26808. dashSize: number;
  26809. gapSize: number;
  26810. path3D: Path3D;
  26811. pathArray: Vector3[][];
  26812. arc: number;
  26813. radius: number;
  26814. cap: number;
  26815. tessellation: number;
  26816. }
  26817. /**
  26818. * @hidden
  26819. **/
  26820. class _InstanceDataStorage {
  26821. visibleInstances: any;
  26822. renderIdForInstances: number[];
  26823. batchCache: _InstancesBatch;
  26824. instancesBufferSize: number;
  26825. instancesBuffer: Nullable<Buffer>;
  26826. instancesData: Float32Array;
  26827. overridenInstanceCount: number;
  26828. }
  26829. /**
  26830. * @hidden
  26831. **/
  26832. class _InstancesBatch {
  26833. mustReturn: boolean;
  26834. visibleInstances: Nullable<InstancedMesh[]>[];
  26835. renderSelf: boolean[];
  26836. }
  26837. /**
  26838. * Class used to represent renderable models
  26839. */
  26840. class Mesh extends AbstractMesh implements IGetSetVerticesData {
  26841. /**
  26842. * Mesh side orientation : usually the external or front surface
  26843. */
  26844. static readonly FRONTSIDE: number;
  26845. /**
  26846. * Mesh side orientation : usually the internal or back surface
  26847. */
  26848. static readonly BACKSIDE: number;
  26849. /**
  26850. * Mesh side orientation : both internal and external or front and back surfaces
  26851. */
  26852. static readonly DOUBLESIDE: number;
  26853. /**
  26854. * Mesh side orientation : by default, `FRONTSIDE`
  26855. */
  26856. static readonly DEFAULTSIDE: number;
  26857. /**
  26858. * Mesh cap setting : no cap
  26859. */
  26860. static readonly NO_CAP: number;
  26861. /**
  26862. * Mesh cap setting : one cap at the beginning of the mesh
  26863. */
  26864. static readonly CAP_START: number;
  26865. /**
  26866. * Mesh cap setting : one cap at the end of the mesh
  26867. */
  26868. static readonly CAP_END: number;
  26869. /**
  26870. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  26871. */
  26872. static readonly CAP_ALL: number;
  26873. private _onBeforeRenderObservable;
  26874. private _onAfterRenderObservable;
  26875. private _onBeforeDrawObservable;
  26876. /**
  26877. * An event triggered before rendering the mesh
  26878. */
  26879. readonly onBeforeRenderObservable: Observable<Mesh>;
  26880. /**
  26881. * An event triggered after rendering the mesh
  26882. */
  26883. readonly onAfterRenderObservable: Observable<Mesh>;
  26884. /**
  26885. * An event triggered before drawing the mesh
  26886. */
  26887. readonly onBeforeDrawObservable: Observable<Mesh>;
  26888. private _onBeforeDrawObserver;
  26889. /**
  26890. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  26891. */
  26892. onBeforeDraw: () => void;
  26893. /**
  26894. * Gets the delay loading state of the mesh (when delay loading is turned on)
  26895. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  26896. */
  26897. delayLoadState: number;
  26898. /**
  26899. * Gets the list of instances created from this mesh
  26900. * it is not supposed to be modified manually.
  26901. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  26902. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  26903. */
  26904. instances: InstancedMesh[];
  26905. /**
  26906. * Gets the file containing delay loading data for this mesh
  26907. */
  26908. delayLoadingFile: string;
  26909. /** @hidden */
  26910. _binaryInfo: any;
  26911. private _LODLevels;
  26912. /**
  26913. * User defined function used to change how LOD level selection is done
  26914. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  26915. */
  26916. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  26917. private _morphTargetManager;
  26918. /**
  26919. * Gets or sets the morph target manager
  26920. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26921. */
  26922. morphTargetManager: Nullable<MorphTargetManager>;
  26923. /** @hidden */
  26924. _creationDataStorage: Nullable<_CreationDataStorage>;
  26925. /** @hidden */
  26926. _geometry: Nullable<Geometry>;
  26927. /** @hidden */
  26928. _delayInfo: Array<string>;
  26929. /** @hidden */
  26930. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  26931. /** @hidden */
  26932. _instanceDataStorage: _InstanceDataStorage;
  26933. private _effectiveMaterial;
  26934. /** @hidden */
  26935. _shouldGenerateFlatShading: boolean;
  26936. private _preActivateId;
  26937. /** @hidden */
  26938. _originalBuilderSideOrientation: number;
  26939. /**
  26940. * Use this property to change the original side orientation defined at construction time
  26941. */
  26942. overrideMaterialSideOrientation: Nullable<number>;
  26943. private _areNormalsFrozen;
  26944. private _sourcePositions;
  26945. private _sourceNormals;
  26946. private _source;
  26947. private meshMap;
  26948. /**
  26949. * Gets the source mesh (the one used to clone this one from)
  26950. */
  26951. readonly source: Nullable<Mesh>;
  26952. /**
  26953. * Gets or sets a boolean indicating that this mesh does not use index buffer
  26954. */
  26955. isUnIndexed: boolean;
  26956. /**
  26957. * @constructor
  26958. * @param name The value used by scene.getMeshByName() to do a lookup.
  26959. * @param scene The scene to add this mesh to.
  26960. * @param parent The parent of this mesh, if it has one
  26961. * @param source An optional Mesh from which geometry is shared, cloned.
  26962. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  26963. * When false, achieved by calling a clone(), also passing False.
  26964. * This will make creation of children, recursive.
  26965. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  26966. */
  26967. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  26968. /**
  26969. * Gets the class name
  26970. * @returns the string "Mesh".
  26971. */
  26972. getClassName(): string;
  26973. /**
  26974. * Returns a description of this mesh
  26975. * @param fullDetails define if full details about this mesh must be used
  26976. * @returns a descriptive string representing this mesh
  26977. */
  26978. toString(fullDetails?: boolean): string;
  26979. /** @hidden */
  26980. _unBindEffect(): void;
  26981. /**
  26982. * Gets a boolean indicating if this mesh has LOD
  26983. */
  26984. readonly hasLODLevels: boolean;
  26985. /**
  26986. * Gets the list of MeshLODLevel associated with the current mesh
  26987. * @returns an array of MeshLODLevel
  26988. */
  26989. getLODLevels(): MeshLODLevel[];
  26990. private _sortLODLevels;
  26991. /**
  26992. * Add a mesh as LOD level triggered at the given distance.
  26993. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26994. * @param distance The distance from the center of the object to show this level
  26995. * @param mesh The mesh to be added as LOD level (can be null)
  26996. * @return This mesh (for chaining)
  26997. */
  26998. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  26999. /**
  27000. * Returns the LOD level mesh at the passed distance or null if not found.
  27001. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27002. * @param distance The distance from the center of the object to show this level
  27003. * @returns a Mesh or `null`
  27004. */
  27005. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  27006. /**
  27007. * Remove a mesh from the LOD array
  27008. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27009. * @param mesh defines the mesh to be removed
  27010. * @return This mesh (for chaining)
  27011. */
  27012. removeLODLevel(mesh: Mesh): Mesh;
  27013. /**
  27014. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  27015. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27016. * @param camera defines the camera to use to compute distance
  27017. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  27018. * @return This mesh (for chaining)
  27019. */
  27020. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  27021. /**
  27022. * Gets the mesh internal Geometry object
  27023. */
  27024. readonly geometry: Nullable<Geometry>;
  27025. /**
  27026. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  27027. * @returns the total number of vertices
  27028. */
  27029. getTotalVertices(): number;
  27030. /**
  27031. * Returns the content of an associated vertex buffer
  27032. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  27033. * - BABYLON.VertexBuffer.PositionKind
  27034. * - BABYLON.VertexBuffer.UVKind
  27035. * - BABYLON.VertexBuffer.UV2Kind
  27036. * - BABYLON.VertexBuffer.UV3Kind
  27037. * - BABYLON.VertexBuffer.UV4Kind
  27038. * - BABYLON.VertexBuffer.UV5Kind
  27039. * - BABYLON.VertexBuffer.UV6Kind
  27040. * - BABYLON.VertexBuffer.ColorKind
  27041. * - BABYLON.VertexBuffer.MatricesIndicesKind
  27042. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  27043. * - BABYLON.VertexBuffer.MatricesWeightsKind
  27044. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  27045. * @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
  27046. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  27047. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  27048. */
  27049. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  27050. /**
  27051. * Returns the mesh VertexBuffer object from the requested `kind`
  27052. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  27053. * - BABYLON.VertexBuffer.PositionKind
  27054. * - BABYLON.VertexBuffer.UVKind
  27055. * - BABYLON.VertexBuffer.UV2Kind
  27056. * - BABYLON.VertexBuffer.UV3Kind
  27057. * - BABYLON.VertexBuffer.UV4Kind
  27058. * - BABYLON.VertexBuffer.UV5Kind
  27059. * - BABYLON.VertexBuffer.UV6Kind
  27060. * - BABYLON.VertexBuffer.ColorKind
  27061. * - BABYLON.VertexBuffer.MatricesIndicesKind
  27062. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  27063. * - BABYLON.VertexBuffer.MatricesWeightsKind
  27064. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  27065. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  27066. */
  27067. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  27068. /**
  27069. * Tests if a specific vertex buffer is associated with this mesh
  27070. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  27071. * - BABYLON.VertexBuffer.PositionKind
  27072. * - BABYLON.VertexBuffer.UVKind
  27073. * - BABYLON.VertexBuffer.UV2Kind
  27074. * - BABYLON.VertexBuffer.UV3Kind
  27075. * - BABYLON.VertexBuffer.UV4Kind
  27076. * - BABYLON.VertexBuffer.UV5Kind
  27077. * - BABYLON.VertexBuffer.UV6Kind
  27078. * - BABYLON.VertexBuffer.ColorKind
  27079. * - BABYLON.VertexBuffer.MatricesIndicesKind
  27080. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  27081. * - BABYLON.VertexBuffer.MatricesWeightsKind
  27082. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  27083. * @returns a boolean
  27084. */
  27085. isVerticesDataPresent(kind: string): boolean;
  27086. /**
  27087. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  27088. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  27089. * - BABYLON.VertexBuffer.PositionKind
  27090. * - BABYLON.VertexBuffer.UVKind
  27091. * - BABYLON.VertexBuffer.UV2Kind
  27092. * - BABYLON.VertexBuffer.UV3Kind
  27093. * - BABYLON.VertexBuffer.UV4Kind
  27094. * - BABYLON.VertexBuffer.UV5Kind
  27095. * - BABYLON.VertexBuffer.UV6Kind
  27096. * - BABYLON.VertexBuffer.ColorKind
  27097. * - BABYLON.VertexBuffer.MatricesIndicesKind
  27098. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  27099. * - BABYLON.VertexBuffer.MatricesWeightsKind
  27100. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  27101. * @returns a boolean
  27102. */
  27103. isVertexBufferUpdatable(kind: string): boolean;
  27104. /**
  27105. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  27106. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  27107. * - BABYLON.VertexBuffer.PositionKind
  27108. * - BABYLON.VertexBuffer.UVKind
  27109. * - BABYLON.VertexBuffer.UV2Kind
  27110. * - BABYLON.VertexBuffer.UV3Kind
  27111. * - BABYLON.VertexBuffer.UV4Kind
  27112. * - BABYLON.VertexBuffer.UV5Kind
  27113. * - BABYLON.VertexBuffer.UV6Kind
  27114. * - BABYLON.VertexBuffer.ColorKind
  27115. * - BABYLON.VertexBuffer.MatricesIndicesKind
  27116. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  27117. * - BABYLON.VertexBuffer.MatricesWeightsKind
  27118. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  27119. * @returns an array of strings
  27120. */
  27121. getVerticesDataKinds(): string[];
  27122. /**
  27123. * Returns a positive integer : the total number of indices in this mesh geometry.
  27124. * @returns the numner of indices or zero if the mesh has no geometry.
  27125. */
  27126. getTotalIndices(): number;
  27127. /**
  27128. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  27129. * @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.
  27130. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  27131. * @returns the indices array or an empty array if the mesh has no geometry
  27132. */
  27133. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  27134. readonly isBlocked: boolean;
  27135. /**
  27136. * Determine if the current mesh is ready to be rendered
  27137. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27138. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  27139. * @returns true if all associated assets are ready (material, textures, shaders)
  27140. */
  27141. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  27142. /**
  27143. * 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.
  27144. */
  27145. readonly areNormalsFrozen: boolean;
  27146. /**
  27147. * 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.
  27148. * @returns the current mesh
  27149. */
  27150. freezeNormals(): Mesh;
  27151. /**
  27152. * 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
  27153. * @returns the current mesh
  27154. */
  27155. unfreezeNormals(): Mesh;
  27156. /**
  27157. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  27158. */
  27159. overridenInstanceCount: number;
  27160. /** @hidden */
  27161. _preActivate(): Mesh;
  27162. /** @hidden */
  27163. _preActivateForIntermediateRendering(renderId: number): Mesh;
  27164. /** @hidden */
  27165. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  27166. /**
  27167. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  27168. * This means the mesh underlying bounding box and sphere are recomputed.
  27169. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  27170. * @returns the current mesh
  27171. */
  27172. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  27173. /** @hidden */
  27174. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  27175. /**
  27176. * This function will subdivide the mesh into multiple submeshes
  27177. * @param count defines the expected number of submeshes
  27178. */
  27179. subdivide(count: number): void;
  27180. /**
  27181. * Copy a FloatArray into a specific associated vertex buffer
  27182. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  27183. * - BABYLON.VertexBuffer.PositionKind
  27184. * - BABYLON.VertexBuffer.UVKind
  27185. * - BABYLON.VertexBuffer.UV2Kind
  27186. * - BABYLON.VertexBuffer.UV3Kind
  27187. * - BABYLON.VertexBuffer.UV4Kind
  27188. * - BABYLON.VertexBuffer.UV5Kind
  27189. * - BABYLON.VertexBuffer.UV6Kind
  27190. * - BABYLON.VertexBuffer.ColorKind
  27191. * - BABYLON.VertexBuffer.MatricesIndicesKind
  27192. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  27193. * - BABYLON.VertexBuffer.MatricesWeightsKind
  27194. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  27195. * @param data defines the data source
  27196. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  27197. * @param stride defines the data stride size (can be null)
  27198. * @returns the current mesh
  27199. */
  27200. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  27201. /**
  27202. * Flags an associated vertex buffer as updatable
  27203. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  27204. * - BABYLON.VertexBuffer.PositionKind
  27205. * - BABYLON.VertexBuffer.UVKind
  27206. * - BABYLON.VertexBuffer.UV2Kind
  27207. * - BABYLON.VertexBuffer.UV3Kind
  27208. * - BABYLON.VertexBuffer.UV4Kind
  27209. * - BABYLON.VertexBuffer.UV5Kind
  27210. * - BABYLON.VertexBuffer.UV6Kind
  27211. * - BABYLON.VertexBuffer.ColorKind
  27212. * - BABYLON.VertexBuffer.MatricesIndicesKind
  27213. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  27214. * - BABYLON.VertexBuffer.MatricesWeightsKind
  27215. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  27216. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  27217. */
  27218. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  27219. /**
  27220. * Sets the mesh global Vertex Buffer
  27221. * @param buffer defines the buffer to use
  27222. * @returns the current mesh
  27223. */
  27224. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  27225. /**
  27226. * Update a specific associated vertex buffer
  27227. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  27228. * - BABYLON.VertexBuffer.PositionKind
  27229. * - BABYLON.VertexBuffer.UVKind
  27230. * - BABYLON.VertexBuffer.UV2Kind
  27231. * - BABYLON.VertexBuffer.UV3Kind
  27232. * - BABYLON.VertexBuffer.UV4Kind
  27233. * - BABYLON.VertexBuffer.UV5Kind
  27234. * - BABYLON.VertexBuffer.UV6Kind
  27235. * - BABYLON.VertexBuffer.ColorKind
  27236. * - BABYLON.VertexBuffer.MatricesIndicesKind
  27237. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  27238. * - BABYLON.VertexBuffer.MatricesWeightsKind
  27239. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  27240. * @param data defines the data source
  27241. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  27242. * @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)
  27243. * @returns the current mesh
  27244. */
  27245. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  27246. /**
  27247. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  27248. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  27249. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  27250. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  27251. * @returns the current mesh
  27252. */
  27253. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  27254. /**
  27255. * Creates a un-shared specific occurence of the geometry for the mesh.
  27256. * @returns the current mesh
  27257. */
  27258. makeGeometryUnique(): Mesh;
  27259. /**
  27260. * Set the index buffer of this mesh
  27261. * @param indices defines the source data
  27262. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  27263. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  27264. * @returns the current mesh
  27265. */
  27266. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  27267. /**
  27268. * Update the current index buffer
  27269. * @param indices defines the source data
  27270. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27271. * @returns the current mesh
  27272. */
  27273. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  27274. /**
  27275. * Invert the geometry to move from a right handed system to a left handed one.
  27276. * @returns the current mesh
  27277. */
  27278. toLeftHanded(): Mesh;
  27279. /** @hidden */
  27280. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  27281. /** @hidden */
  27282. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  27283. /**
  27284. * Registers for this mesh a javascript function called just before the rendering process
  27285. * @param func defines the function to call before rendering this mesh
  27286. * @returns the current mesh
  27287. */
  27288. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  27289. /**
  27290. * Disposes a previously registered javascript function called before the rendering
  27291. * @param func defines the function to remove
  27292. * @returns the current mesh
  27293. */
  27294. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  27295. /**
  27296. * Registers for this mesh a javascript function called just after the rendering is complete
  27297. * @param func defines the function to call after rendering this mesh
  27298. * @returns the current mesh
  27299. */
  27300. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  27301. /**
  27302. * Disposes a previously registered javascript function called after the rendering.
  27303. * @param func defines the function to remove
  27304. * @returns the current mesh
  27305. */
  27306. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  27307. /** @hidden */
  27308. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  27309. /** @hidden */
  27310. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  27311. /** @hidden */
  27312. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  27313. /**
  27314. * 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
  27315. * @param subMesh defines the subMesh to render
  27316. * @param enableAlphaMode defines if alpha mode can be changed
  27317. * @returns the current mesh
  27318. */
  27319. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  27320. private _onBeforeDraw;
  27321. /**
  27322. * Renormalize the mesh and patch it up if there are no weights
  27323. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  27324. * However in the case of zero weights then we set just a single influence to 1.
  27325. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  27326. */
  27327. cleanMatrixWeights(): void;
  27328. private normalizeSkinFourWeights;
  27329. private normalizeSkinWeightsAndExtra;
  27330. /**
  27331. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  27332. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  27333. * the user know there was an issue with importing the mesh
  27334. * @returns a validation object with skinned, valid and report string
  27335. */
  27336. validateSkinning(): {
  27337. skinned: boolean;
  27338. valid: boolean;
  27339. report: string;
  27340. };
  27341. /** @hidden */
  27342. _checkDelayState(): Mesh;
  27343. private _queueLoad;
  27344. /**
  27345. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  27346. * A mesh is in the frustum if its bounding box intersects the frustum
  27347. * @param frustumPlanes defines the frustum to test
  27348. * @returns true if the mesh is in the frustum planes
  27349. */
  27350. isInFrustum(frustumPlanes: Plane[]): boolean;
  27351. /**
  27352. * Sets the mesh material by the material or multiMaterial `id` property
  27353. * @param id is a string identifying the material or the multiMaterial
  27354. * @returns the current mesh
  27355. */
  27356. setMaterialByID(id: string): Mesh;
  27357. /**
  27358. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  27359. * @returns an array of IAnimatable
  27360. */
  27361. getAnimatables(): IAnimatable[];
  27362. /**
  27363. * Modifies the mesh geometry according to the passed transformation matrix.
  27364. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  27365. * The mesh normals are modified using the same transformation.
  27366. * Note that, under the hood, this method sets a new VertexBuffer each call.
  27367. * @param transform defines the transform matrix to use
  27368. * @see http://doc.babylonjs.com/resources/baking_transformations
  27369. * @returns the current mesh
  27370. */
  27371. bakeTransformIntoVertices(transform: Matrix): Mesh;
  27372. /**
  27373. * Modifies the mesh geometry according to its own current World Matrix.
  27374. * The mesh World Matrix is then reset.
  27375. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  27376. * Note that, under the hood, this method sets a new VertexBuffer each call.
  27377. * @see http://doc.babylonjs.com/resources/baking_transformations
  27378. * @returns the current mesh
  27379. */
  27380. bakeCurrentTransformIntoVertices(): Mesh;
  27381. /** @hidden */
  27382. readonly _positions: Nullable<Vector3[]>;
  27383. /** @hidden */
  27384. _resetPointsArrayCache(): Mesh;
  27385. /** @hidden */
  27386. _generatePointsArray(): boolean;
  27387. /**
  27388. * Returns a new Mesh object generated from the current mesh properties.
  27389. * This method must not get confused with createInstance()
  27390. * @param name is a string, the name given to the new mesh
  27391. * @param newParent can be any Node object (default `null`)
  27392. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  27393. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  27394. * @returns a new mesh
  27395. */
  27396. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  27397. /**
  27398. * Releases resources associated with this mesh.
  27399. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27400. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27401. */
  27402. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27403. /**
  27404. * Modifies the mesh geometry according to a displacement map.
  27405. * 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.
  27406. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  27407. * @param url is a string, the URL from the image file is to be downloaded.
  27408. * @param minHeight is the lower limit of the displacement.
  27409. * @param maxHeight is the upper limit of the displacement.
  27410. * @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.
  27411. * @param uvOffset is an optional vector2 used to offset UV.
  27412. * @param uvScale is an optional vector2 used to scale UV.
  27413. * @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.
  27414. * @returns the Mesh.
  27415. */
  27416. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  27417. /**
  27418. * Modifies the mesh geometry according to a displacementMap buffer.
  27419. * 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.
  27420. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  27421. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  27422. * @param heightMapWidth is the width of the buffer image.
  27423. * @param heightMapHeight is the height of the buffer image.
  27424. * @param minHeight is the lower limit of the displacement.
  27425. * @param maxHeight is the upper limit of the displacement.
  27426. * @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.
  27427. * @param uvOffset is an optional vector2 used to offset UV.
  27428. * @param uvScale is an optional vector2 used to scale UV.
  27429. * @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.
  27430. * @returns the Mesh.
  27431. */
  27432. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  27433. /**
  27434. * Modify the mesh to get a flat shading rendering.
  27435. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  27436. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  27437. * @returns current mesh
  27438. */
  27439. convertToFlatShadedMesh(): Mesh;
  27440. /**
  27441. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  27442. * In other words, more vertices, no more indices and a single bigger VBO.
  27443. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  27444. * @returns current mesh
  27445. */
  27446. convertToUnIndexedMesh(): Mesh;
  27447. /**
  27448. * Inverses facet orientations.
  27449. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  27450. * @param flipNormals will also inverts the normals
  27451. * @returns current mesh
  27452. */
  27453. flipFaces(flipNormals?: boolean): Mesh;
  27454. /**
  27455. * Creates a new InstancedMesh object from the mesh model.
  27456. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  27457. * @param name defines the name of the new instance
  27458. * @returns a new InstancedMesh
  27459. */
  27460. createInstance(name: string): InstancedMesh;
  27461. /**
  27462. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  27463. * After this call, all the mesh instances have the same submeshes than the current mesh.
  27464. * @returns the current mesh
  27465. */
  27466. synchronizeInstances(): Mesh;
  27467. /**
  27468. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  27469. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  27470. * This should be used together with the simplification to avoid disappearing triangles.
  27471. * @param successCallback an optional success callback to be called after the optimization finished.
  27472. * @returns the current mesh
  27473. */
  27474. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  27475. /**
  27476. * Serialize current mesh
  27477. * @param serializationObject defines the object which will receive the serialization data
  27478. */
  27479. serialize(serializationObject: any): void;
  27480. /** @hidden */
  27481. _syncGeometryWithMorphTargetManager(): void;
  27482. /**
  27483. * Returns a new Mesh object parsed from the source provided.
  27484. * @param parsedMesh is the source
  27485. * @param scene defines the hosting scene
  27486. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  27487. * @returns a new Mesh
  27488. */
  27489. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  27490. /**
  27491. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  27492. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  27493. * @param name defines the name of the mesh to create
  27494. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  27495. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  27496. * @param closePath creates a seam between the first and the last points of each path of the path array
  27497. * @param offset is taken in account only if the `pathArray` is containing a single path
  27498. * @param scene defines the hosting scene
  27499. * @param updatable defines if the mesh must be flagged as updatable
  27500. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27501. * @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)
  27502. * @returns a new Mesh
  27503. */
  27504. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean | undefined, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  27505. /**
  27506. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  27507. * @param name defines the name of the mesh to create
  27508. * @param radius sets the radius size (float) of the polygon (default 0.5)
  27509. * @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
  27510. * @param scene defines the hosting scene
  27511. * @param updatable defines if the mesh must be flagged as updatable
  27512. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27513. * @returns a new Mesh
  27514. */
  27515. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  27516. /**
  27517. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  27518. * @param name defines the name of the mesh to create
  27519. * @param size sets the size (float) of each box side (default 1)
  27520. * @param scene defines the hosting scene
  27521. * @param updatable defines if the mesh must be flagged as updatable
  27522. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27523. * @returns a new Mesh
  27524. */
  27525. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  27526. /**
  27527. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  27528. * @param name defines the name of the mesh to create
  27529. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  27530. * @param diameter sets the diameter size (float) of the sphere (default 1)
  27531. * @param scene defines the hosting scene
  27532. * @param updatable defines if the mesh must be flagged as updatable
  27533. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27534. * @returns a new Mesh
  27535. */
  27536. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27537. /**
  27538. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  27539. * @param name defines the name of the mesh to create
  27540. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  27541. * @param diameterTop set the top cap diameter (floats, default 1)
  27542. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  27543. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  27544. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  27545. * @param scene defines the hosting scene
  27546. * @param updatable defines if the mesh must be flagged as updatable
  27547. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27548. * @returns a new Mesh
  27549. */
  27550. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  27551. /**
  27552. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  27553. * @param name defines the name of the mesh to create
  27554. * @param diameter sets the diameter size (float) of the torus (default 1)
  27555. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  27556. * @param tessellation sets the number of torus sides (postive integer, default 16)
  27557. * @param scene defines the hosting scene
  27558. * @param updatable defines if the mesh must be flagged as updatable
  27559. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27560. * @returns a new Mesh
  27561. */
  27562. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27563. /**
  27564. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  27565. * @param name defines the name of the mesh to create
  27566. * @param radius sets the global radius size (float) of the torus knot (default 2)
  27567. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  27568. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  27569. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  27570. * @param p the number of windings on X axis (positive integers, default 2)
  27571. * @param q the number of windings on Y axis (positive integers, default 3)
  27572. * @param scene defines the hosting scene
  27573. * @param updatable defines if the mesh must be flagged as updatable
  27574. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27575. * @returns a new Mesh
  27576. */
  27577. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27578. /**
  27579. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  27580. * @param name defines the name of the mesh to create
  27581. * @param points is an array successive Vector3
  27582. * @param scene defines the hosting scene
  27583. * @param updatable defines if the mesh must be flagged as updatable
  27584. * @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).
  27585. * @returns a new Mesh
  27586. */
  27587. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  27588. /**
  27589. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  27590. * @param name defines the name of the mesh to create
  27591. * @param points is an array successive Vector3
  27592. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  27593. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  27594. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  27595. * @param scene defines the hosting scene
  27596. * @param updatable defines if the mesh must be flagged as updatable
  27597. * @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)
  27598. * @returns a new Mesh
  27599. */
  27600. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  27601. /**
  27602. * Creates a polygon mesh.
  27603. * Please consider using the same method from the MeshBuilder class instead.
  27604. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  27605. * 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.
  27606. * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27607. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  27608. * Remember you can only change the shape positions, not their number when updating a polygon.
  27609. */
  27610. /**
  27611. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  27612. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  27613. * @param name defines the name of the mesh to create
  27614. * @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
  27615. * @param scene defines the hosting scene
  27616. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  27617. * @param updatable defines if the mesh must be flagged as updatable
  27618. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27619. * @returns a new Mesh
  27620. */
  27621. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  27622. /**
  27623. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  27624. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  27625. * @param name defines the name of the mesh to create
  27626. * @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
  27627. * @param depth defines the height of extrusion
  27628. * @param scene defines the hosting scene
  27629. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  27630. * @param updatable defines if the mesh must be flagged as updatable
  27631. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27632. * @returns a new Mesh
  27633. */
  27634. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  27635. /**
  27636. * Creates an extruded shape mesh.
  27637. * 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
  27638. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  27639. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  27640. * @param name defines the name of the mesh to create
  27641. * @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
  27642. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  27643. * @param scale is the value to scale the shape
  27644. * @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
  27645. * @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
  27646. * @param scene defines the hosting scene
  27647. * @param updatable defines if the mesh must be flagged as updatable
  27648. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27649. * @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)
  27650. * @returns a new Mesh
  27651. */
  27652. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  27653. /**
  27654. * Creates an custom extruded shape mesh.
  27655. * The custom extrusion is a parametric shape.
  27656. * It has no predefined shape. Its final shape will depend on the input parameters.
  27657. * Please consider using the same method from the MeshBuilder class instead
  27658. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  27659. * @param name defines the name of the mesh to create
  27660. * @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
  27661. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  27662. * @param scaleFunction is a custom Javascript function called on each path point
  27663. * @param rotationFunction is a custom Javascript function called on each path point
  27664. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  27665. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  27666. * @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
  27667. * @param scene defines the hosting scene
  27668. * @param updatable defines if the mesh must be flagged as updatable
  27669. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27670. * @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)
  27671. * @returns a new Mesh
  27672. */
  27673. 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;
  27674. /**
  27675. * Creates lathe mesh.
  27676. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  27677. * Please consider using the same method from the MeshBuilder class instead
  27678. * @param name defines the name of the mesh to create
  27679. * @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
  27680. * @param radius is the radius value of the lathe
  27681. * @param tessellation is the side number of the lathe.
  27682. * @param scene defines the hosting scene
  27683. * @param updatable defines if the mesh must be flagged as updatable
  27684. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27685. * @returns a new Mesh
  27686. */
  27687. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27688. /**
  27689. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  27690. * @param name defines the name of the mesh to create
  27691. * @param size sets the size (float) of both sides of the plane at once (default 1)
  27692. * @param scene defines the hosting scene
  27693. * @param updatable defines if the mesh must be flagged as updatable
  27694. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27695. * @returns a new Mesh
  27696. */
  27697. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27698. /**
  27699. * Creates a ground mesh.
  27700. * Please consider using the same method from the MeshBuilder class instead
  27701. * @param name defines the name of the mesh to create
  27702. * @param width set the width of the ground
  27703. * @param height set the height of the ground
  27704. * @param subdivisions sets the number of subdivisions per side
  27705. * @param scene defines the hosting scene
  27706. * @param updatable defines if the mesh must be flagged as updatable
  27707. * @returns a new Mesh
  27708. */
  27709. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  27710. /**
  27711. * Creates a tiled ground mesh.
  27712. * Please consider using the same method from the MeshBuilder class instead
  27713. * @param name defines the name of the mesh to create
  27714. * @param xmin set the ground minimum X coordinate
  27715. * @param zmin set the ground minimum Y coordinate
  27716. * @param xmax set the ground maximum X coordinate
  27717. * @param zmax set the ground maximum Z coordinate
  27718. * @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
  27719. * @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
  27720. * @param scene defines the hosting scene
  27721. * @param updatable defines if the mesh must be flagged as updatable
  27722. * @returns a new Mesh
  27723. */
  27724. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  27725. w: number;
  27726. h: number;
  27727. }, precision: {
  27728. w: number;
  27729. h: number;
  27730. }, scene: Scene, updatable?: boolean): Mesh;
  27731. /**
  27732. * Creates a ground mesh from a height map.
  27733. * Please consider using the same method from the MeshBuilder class instead
  27734. * @see http://doc.babylonjs.com/babylon101/height_map
  27735. * @param name defines the name of the mesh to create
  27736. * @param url sets the URL of the height map image resource
  27737. * @param width set the ground width size
  27738. * @param height set the ground height size
  27739. * @param subdivisions sets the number of subdivision per side
  27740. * @param minHeight is the minimum altitude on the ground
  27741. * @param maxHeight is the maximum altitude on the ground
  27742. * @param scene defines the hosting scene
  27743. * @param updatable defines if the mesh must be flagged as updatable
  27744. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  27745. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  27746. * @returns a new Mesh
  27747. */
  27748. 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;
  27749. /**
  27750. * Creates a tube mesh.
  27751. * The tube is a parametric shape.
  27752. * It has no predefined shape. Its final shape will depend on the input parameters.
  27753. * Please consider using the same method from the MeshBuilder class instead
  27754. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  27755. * @param name defines the name of the mesh to create
  27756. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  27757. * @param radius sets the tube radius size
  27758. * @param tessellation is the number of sides on the tubular surface
  27759. * @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
  27760. * @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
  27761. * @param scene defines the hosting scene
  27762. * @param updatable defines if the mesh must be flagged as updatable
  27763. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27764. * @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)
  27765. * @returns a new Mesh
  27766. */
  27767. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  27768. (i: number, distance: number): number;
  27769. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  27770. /**
  27771. * Creates a polyhedron mesh.
  27772. * Please consider using the same method from the MeshBuilder class instead.
  27773. * * 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
  27774. * * The parameter `size` (positive float, default 1) sets the polygon size
  27775. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  27776. * * 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`
  27777. * * 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
  27778. * * 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)`)
  27779. * * 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
  27780. * * 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
  27781. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27782. * * 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
  27783. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27784. * @param name defines the name of the mesh to create
  27785. * @param options defines the options used to create the mesh
  27786. * @param scene defines the hosting scene
  27787. * @returns a new Mesh
  27788. */
  27789. static CreatePolyhedron(name: string, options: {
  27790. type?: number;
  27791. size?: number;
  27792. sizeX?: number;
  27793. sizeY?: number;
  27794. sizeZ?: number;
  27795. custom?: any;
  27796. faceUV?: Vector4[];
  27797. faceColors?: Color4[];
  27798. updatable?: boolean;
  27799. sideOrientation?: number;
  27800. }, scene: Scene): Mesh;
  27801. /**
  27802. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  27803. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  27804. * * 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`)
  27805. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  27806. * * 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
  27807. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27808. * * 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
  27809. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27810. * @param name defines the name of the mesh
  27811. * @param options defines the options used to create the mesh
  27812. * @param scene defines the hosting scene
  27813. * @returns a new Mesh
  27814. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  27815. */
  27816. static CreateIcoSphere(name: string, options: {
  27817. radius?: number;
  27818. flat?: boolean;
  27819. subdivisions?: number;
  27820. sideOrientation?: number;
  27821. updatable?: boolean;
  27822. }, scene: Scene): Mesh;
  27823. /**
  27824. * Creates a decal mesh.
  27825. * Please consider using the same method from the MeshBuilder class instead.
  27826. * A decal is a mesh usually applied as a model onto the surface of another mesh
  27827. * @param name defines the name of the mesh
  27828. * @param sourceMesh defines the mesh receiving the decal
  27829. * @param position sets the position of the decal in world coordinates
  27830. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  27831. * @param size sets the decal scaling
  27832. * @param angle sets the angle to rotate the decal
  27833. * @returns a new Mesh
  27834. */
  27835. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  27836. /**
  27837. * Prepare internal position array for software CPU skinning
  27838. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  27839. */
  27840. setPositionsForCPUSkinning(): Float32Array;
  27841. /**
  27842. * Prepare internal normal array for software CPU skinning
  27843. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  27844. */
  27845. setNormalsForCPUSkinning(): Float32Array;
  27846. /**
  27847. * Updates the vertex buffer by applying transformation from the bones
  27848. * @param skeleton defines the skeleton to apply to current mesh
  27849. * @returns the current mesh
  27850. */
  27851. applySkeleton(skeleton: Skeleton): Mesh;
  27852. /**
  27853. * 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
  27854. * @param meshes defines the list of meshes to scan
  27855. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  27856. */
  27857. static MinMax(meshes: AbstractMesh[]): {
  27858. min: Vector3;
  27859. max: Vector3;
  27860. };
  27861. /**
  27862. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  27863. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  27864. * @returns a vector3
  27865. */
  27866. static Center(meshesOrMinMaxVector: {
  27867. min: Vector3;
  27868. max: Vector3;
  27869. } | AbstractMesh[]): Vector3;
  27870. /**
  27871. * Merge the array of meshes into a single mesh for performance reasons.
  27872. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  27873. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  27874. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  27875. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  27876. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  27877. * @returns a new mesh
  27878. */
  27879. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean): Nullable<Mesh>;
  27880. /** @hidden */
  27881. addInstance(instance: InstancedMesh): void;
  27882. /** @hidden */
  27883. removeInstance(instance: InstancedMesh): void;
  27884. }
  27885. }
  27886. declare module BABYLON {
  27887. /**
  27888. * Define an interface for all classes that will get and set the data on vertices
  27889. */
  27890. interface IGetSetVerticesData {
  27891. /**
  27892. * Gets a boolean indicating if specific vertex data is present
  27893. * @param kind defines the vertex data kind to use
  27894. * @returns true is data kind is present
  27895. */
  27896. isVerticesDataPresent(kind: string): boolean;
  27897. /**
  27898. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  27899. * @param kind defines the data kind (Position, normal, etc...)
  27900. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  27901. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  27902. * @returns a float array containing vertex data
  27903. */
  27904. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  27905. /**
  27906. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  27907. * @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.
  27908. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  27909. * @returns the indices array or an empty array if the mesh has no geometry
  27910. */
  27911. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  27912. /**
  27913. * Set specific vertex data
  27914. * @param kind defines the data kind (Position, normal, etc...)
  27915. * @param data defines the vertex data to use
  27916. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  27917. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  27918. */
  27919. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  27920. /**
  27921. * Update a specific associated vertex buffer
  27922. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  27923. * - BABYLON.VertexBuffer.PositionKind
  27924. * - BABYLON.VertexBuffer.UVKind
  27925. * - BABYLON.VertexBuffer.UV2Kind
  27926. * - BABYLON.VertexBuffer.UV3Kind
  27927. * - BABYLON.VertexBuffer.UV4Kind
  27928. * - BABYLON.VertexBuffer.UV5Kind
  27929. * - BABYLON.VertexBuffer.UV6Kind
  27930. * - BABYLON.VertexBuffer.ColorKind
  27931. * - BABYLON.VertexBuffer.MatricesIndicesKind
  27932. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  27933. * - BABYLON.VertexBuffer.MatricesWeightsKind
  27934. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  27935. * @param data defines the data source
  27936. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  27937. * @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)
  27938. */
  27939. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  27940. /**
  27941. * Creates a new index buffer
  27942. * @param indices defines the indices to store in the index buffer
  27943. * @param totalVertices defines the total number of vertices (could be null)
  27944. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  27945. */
  27946. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  27947. }
  27948. /**
  27949. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  27950. */
  27951. class VertexData {
  27952. /**
  27953. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  27954. */
  27955. positions: Nullable<FloatArray>;
  27956. /**
  27957. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  27958. */
  27959. normals: Nullable<FloatArray>;
  27960. /**
  27961. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  27962. */
  27963. tangents: Nullable<FloatArray>;
  27964. /**
  27965. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27966. */
  27967. uvs: Nullable<FloatArray>;
  27968. /**
  27969. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27970. */
  27971. uvs2: Nullable<FloatArray>;
  27972. /**
  27973. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27974. */
  27975. uvs3: Nullable<FloatArray>;
  27976. /**
  27977. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27978. */
  27979. uvs4: Nullable<FloatArray>;
  27980. /**
  27981. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27982. */
  27983. uvs5: Nullable<FloatArray>;
  27984. /**
  27985. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27986. */
  27987. uvs6: Nullable<FloatArray>;
  27988. /**
  27989. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  27990. */
  27991. colors: Nullable<FloatArray>;
  27992. /**
  27993. * 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).
  27994. */
  27995. matricesIndices: Nullable<FloatArray>;
  27996. /**
  27997. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  27998. */
  27999. matricesWeights: Nullable<FloatArray>;
  28000. /**
  28001. * An array extending the number of possible indices
  28002. */
  28003. matricesIndicesExtra: Nullable<FloatArray>;
  28004. /**
  28005. * An array extending the number of possible weights when the number of indices is extended
  28006. */
  28007. matricesWeightsExtra: Nullable<FloatArray>;
  28008. /**
  28009. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  28010. */
  28011. indices: Nullable<IndicesArray>;
  28012. /**
  28013. * Uses the passed data array to set the set the values for the specified kind of data
  28014. * @param data a linear array of floating numbers
  28015. * @param kind the type of data that is being set, eg positions, colors etc
  28016. */
  28017. set(data: FloatArray, kind: string): void;
  28018. /**
  28019. * Associates the vertexData to the passed Mesh.
  28020. * Sets it as updatable or not (default `false`)
  28021. * @param mesh the mesh the vertexData is applied to
  28022. * @param updatable when used and having the value true allows new data to update the vertexData
  28023. * @returns the VertexData
  28024. */
  28025. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  28026. /**
  28027. * Associates the vertexData to the passed Geometry.
  28028. * Sets it as updatable or not (default `false`)
  28029. * @param geometry the geometry the vertexData is applied to
  28030. * @param updatable when used and having the value true allows new data to update the vertexData
  28031. * @returns VertexData
  28032. */
  28033. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  28034. /**
  28035. * Updates the associated mesh
  28036. * @param mesh the mesh to be updated
  28037. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  28038. * @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
  28039. * @returns VertexData
  28040. */
  28041. updateMesh(mesh: Mesh, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  28042. /**
  28043. * Updates the associated geometry
  28044. * @param geometry the geometry to be updated
  28045. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  28046. * @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
  28047. * @returns VertexData.
  28048. */
  28049. updateGeometry(geometry: Geometry, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  28050. private _applyTo;
  28051. private _update;
  28052. /**
  28053. * Transforms each position and each normal of the vertexData according to the passed Matrix
  28054. * @param matrix the transforming matrix
  28055. * @returns the VertexData
  28056. */
  28057. transform(matrix: Matrix): VertexData;
  28058. /**
  28059. * Merges the passed VertexData into the current one
  28060. * @param other the VertexData to be merged into the current one
  28061. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  28062. * @returns the modified VertexData
  28063. */
  28064. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  28065. private _mergeElement;
  28066. private _validate;
  28067. /**
  28068. * Serializes the VertexData
  28069. * @returns a serialized object
  28070. */
  28071. serialize(): any;
  28072. /**
  28073. * Extracts the vertexData from a mesh
  28074. * @param mesh the mesh from which to extract the VertexData
  28075. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  28076. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  28077. * @returns the object VertexData associated to the passed mesh
  28078. */
  28079. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  28080. /**
  28081. * Extracts the vertexData from the geometry
  28082. * @param geometry the geometry from which to extract the VertexData
  28083. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  28084. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  28085. * @returns the object VertexData associated to the passed mesh
  28086. */
  28087. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  28088. private static _ExtractFrom;
  28089. /**
  28090. * Creates the VertexData for a Ribbon
  28091. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  28092. * * pathArray array of paths, each of which an array of successive Vector3
  28093. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  28094. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  28095. * * 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
  28096. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28097. * * 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)
  28098. * * 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)
  28099. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  28100. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  28101. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  28102. * @returns the VertexData of the ribbon
  28103. */
  28104. static CreateRibbon(options: {
  28105. pathArray: Vector3[][];
  28106. closeArray?: boolean;
  28107. closePath?: boolean;
  28108. offset?: number;
  28109. sideOrientation?: number;
  28110. frontUVs?: Vector4;
  28111. backUVs?: Vector4;
  28112. invertUV?: boolean;
  28113. uvs?: Vector2[];
  28114. colors?: Color4[];
  28115. }): VertexData;
  28116. /**
  28117. * Creates the VertexData for a box
  28118. * @param options an object used to set the following optional parameters for the box, required but can be empty
  28119. * * size sets the width, height and depth of the box to the value of size, optional default 1
  28120. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  28121. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  28122. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  28123. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  28124. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  28125. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28126. * * 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)
  28127. * * 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)
  28128. * @returns the VertexData of the box
  28129. */
  28130. static CreateBox(options: {
  28131. size?: number;
  28132. width?: number;
  28133. height?: number;
  28134. depth?: number;
  28135. faceUV?: Vector4[];
  28136. faceColors?: Color4[];
  28137. sideOrientation?: number;
  28138. frontUVs?: Vector4;
  28139. backUVs?: Vector4;
  28140. }): VertexData;
  28141. /**
  28142. * Creates the VertexData for an ellipsoid, defaults to a sphere
  28143. * @param options an object used to set the following optional parameters for the box, required but can be empty
  28144. * * segments sets the number of horizontal strips optional, default 32
  28145. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  28146. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  28147. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  28148. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  28149. * * 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
  28150. * * 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
  28151. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28152. * * 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)
  28153. * * 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)
  28154. * @returns the VertexData of the ellipsoid
  28155. */
  28156. static CreateSphere(options: {
  28157. segments?: number;
  28158. diameter?: number;
  28159. diameterX?: number;
  28160. diameterY?: number;
  28161. diameterZ?: number;
  28162. arc?: number;
  28163. slice?: number;
  28164. sideOrientation?: number;
  28165. frontUVs?: Vector4;
  28166. backUVs?: Vector4;
  28167. }): VertexData;
  28168. /**
  28169. * Creates the VertexData for a cylinder, cone or prism
  28170. * @param options an object used to set the following optional parameters for the box, required but can be empty
  28171. * * height sets the height (y direction) of the cylinder, optional, default 2
  28172. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  28173. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  28174. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  28175. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  28176. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  28177. * * 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
  28178. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  28179. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  28180. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  28181. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  28182. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28183. * * 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)
  28184. * * 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)
  28185. * @returns the VertexData of the cylinder, cone or prism
  28186. */
  28187. static CreateCylinder(options: {
  28188. height?: number;
  28189. diameterTop?: number;
  28190. diameterBottom?: number;
  28191. diameter?: number;
  28192. tessellation?: number;
  28193. subdivisions?: number;
  28194. arc?: number;
  28195. faceColors?: Color4[];
  28196. faceUV?: Vector4[];
  28197. hasRings?: boolean;
  28198. enclose?: boolean;
  28199. sideOrientation?: number;
  28200. frontUVs?: Vector4;
  28201. backUVs?: Vector4;
  28202. }): VertexData;
  28203. /**
  28204. * Creates the VertexData for a torus
  28205. * @param options an object used to set the following optional parameters for the box, required but can be empty
  28206. * * diameter the diameter of the torus, optional default 1
  28207. * * thickness the diameter of the tube forming the torus, optional default 0.5
  28208. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  28209. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28210. * * 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)
  28211. * * 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)
  28212. * @returns the VertexData of the torus
  28213. */
  28214. static CreateTorus(options: {
  28215. diameter?: number;
  28216. thickness?: number;
  28217. tessellation?: number;
  28218. sideOrientation?: number;
  28219. frontUVs?: Vector4;
  28220. backUVs?: Vector4;
  28221. }): VertexData;
  28222. /**
  28223. * Creates the VertexData of the LineSystem
  28224. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  28225. * - lines an array of lines, each line being an array of successive Vector3
  28226. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  28227. * @returns the VertexData of the LineSystem
  28228. */
  28229. static CreateLineSystem(options: {
  28230. lines: Vector3[][];
  28231. colors?: Nullable<Color4[][]>;
  28232. }): VertexData;
  28233. /**
  28234. * Create the VertexData for a DashedLines
  28235. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  28236. * - points an array successive Vector3
  28237. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  28238. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  28239. * - dashNb the intended total number of dashes, optional, default 200
  28240. * @returns the VertexData for the DashedLines
  28241. */
  28242. static CreateDashedLines(options: {
  28243. points: Vector3[];
  28244. dashSize?: number;
  28245. gapSize?: number;
  28246. dashNb?: number;
  28247. }): VertexData;
  28248. /**
  28249. * Creates the VertexData for a Ground
  28250. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  28251. * - width the width (x direction) of the ground, optional, default 1
  28252. * - height the height (z direction) of the ground, optional, default 1
  28253. * - subdivisions the number of subdivisions per side, optional, default 1
  28254. * @returns the VertexData of the Ground
  28255. */
  28256. static CreateGround(options: {
  28257. width?: number;
  28258. height?: number;
  28259. subdivisions?: number;
  28260. subdivisionsX?: number;
  28261. subdivisionsY?: number;
  28262. }): VertexData;
  28263. /**
  28264. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  28265. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  28266. * * xmin the ground minimum X coordinate, optional, default -1
  28267. * * zmin the ground minimum Z coordinate, optional, default -1
  28268. * * xmax the ground maximum X coordinate, optional, default 1
  28269. * * zmax the ground maximum Z coordinate, optional, default 1
  28270. * * 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}
  28271. * * 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}
  28272. * @returns the VertexData of the TiledGround
  28273. */
  28274. static CreateTiledGround(options: {
  28275. xmin: number;
  28276. zmin: number;
  28277. xmax: number;
  28278. zmax: number;
  28279. subdivisions?: {
  28280. w: number;
  28281. h: number;
  28282. };
  28283. precision?: {
  28284. w: number;
  28285. h: number;
  28286. };
  28287. }): VertexData;
  28288. /**
  28289. * Creates the VertexData of the Ground designed from a heightmap
  28290. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  28291. * * width the width (x direction) of the ground
  28292. * * height the height (z direction) of the ground
  28293. * * subdivisions the number of subdivisions per side
  28294. * * minHeight the minimum altitude on the ground, optional, default 0
  28295. * * maxHeight the maximum altitude on the ground, optional default 1
  28296. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  28297. * * buffer the array holding the image color data
  28298. * * bufferWidth the width of image
  28299. * * bufferHeight the height of image
  28300. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  28301. * @returns the VertexData of the Ground designed from a heightmap
  28302. */
  28303. static CreateGroundFromHeightMap(options: {
  28304. width: number;
  28305. height: number;
  28306. subdivisions: number;
  28307. minHeight: number;
  28308. maxHeight: number;
  28309. colorFilter: Color3;
  28310. buffer: Uint8Array;
  28311. bufferWidth: number;
  28312. bufferHeight: number;
  28313. alphaFilter: number;
  28314. }): VertexData;
  28315. /**
  28316. * Creates the VertexData for a Plane
  28317. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  28318. * * size sets the width and height of the plane to the value of size, optional default 1
  28319. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  28320. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  28321. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28322. * * 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)
  28323. * * 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)
  28324. * @returns the VertexData of the box
  28325. */
  28326. static CreatePlane(options: {
  28327. size?: number;
  28328. width?: number;
  28329. height?: number;
  28330. sideOrientation?: number;
  28331. frontUVs?: Vector4;
  28332. backUVs?: Vector4;
  28333. }): VertexData;
  28334. /**
  28335. * Creates the VertexData of the Disc or regular Polygon
  28336. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  28337. * * radius the radius of the disc, optional default 0.5
  28338. * * tessellation the number of polygon sides, optional, default 64
  28339. * * 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
  28340. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28341. * * 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)
  28342. * * 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)
  28343. * @returns the VertexData of the box
  28344. */
  28345. static CreateDisc(options: {
  28346. radius?: number;
  28347. tessellation?: number;
  28348. arc?: number;
  28349. sideOrientation?: number;
  28350. frontUVs?: Vector4;
  28351. backUVs?: Vector4;
  28352. }): VertexData;
  28353. /**
  28354. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  28355. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  28356. * @param polygon a mesh built from polygonTriangulation.build()
  28357. * @param sideOrientation takes the values BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28358. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  28359. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  28360. * @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)
  28361. * @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)
  28362. * @returns the VertexData of the Polygon
  28363. */
  28364. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  28365. /**
  28366. * Creates the VertexData of the IcoSphere
  28367. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  28368. * * radius the radius of the IcoSphere, optional default 1
  28369. * * radiusX allows stretching in the x direction, optional, default radius
  28370. * * radiusY allows stretching in the y direction, optional, default radius
  28371. * * radiusZ allows stretching in the z direction, optional, default radius
  28372. * * flat when true creates a flat shaded mesh, optional, default true
  28373. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  28374. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28375. * * 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)
  28376. * * 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)
  28377. * @returns the VertexData of the IcoSphere
  28378. */
  28379. static CreateIcoSphere(options: {
  28380. radius?: number;
  28381. radiusX?: number;
  28382. radiusY?: number;
  28383. radiusZ?: number;
  28384. flat?: boolean;
  28385. subdivisions?: number;
  28386. sideOrientation?: number;
  28387. frontUVs?: Vector4;
  28388. backUVs?: Vector4;
  28389. }): VertexData;
  28390. /**
  28391. * Creates the VertexData for a Polyhedron
  28392. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  28393. * * type provided types are:
  28394. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  28395. * * 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)
  28396. * * size the size of the IcoSphere, optional default 1
  28397. * * sizeX allows stretching in the x direction, optional, default size
  28398. * * sizeY allows stretching in the y direction, optional, default size
  28399. * * sizeZ allows stretching in the z direction, optional, default size
  28400. * * 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
  28401. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  28402. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  28403. * * flat when true creates a flat shaded mesh, optional, default true
  28404. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  28405. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28406. * * 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)
  28407. * * 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)
  28408. * @returns the VertexData of the Polyhedron
  28409. */
  28410. static CreatePolyhedron(options: {
  28411. type?: number;
  28412. size?: number;
  28413. sizeX?: number;
  28414. sizeY?: number;
  28415. sizeZ?: number;
  28416. custom?: any;
  28417. faceUV?: Vector4[];
  28418. faceColors?: Color4[];
  28419. flat?: boolean;
  28420. sideOrientation?: number;
  28421. frontUVs?: Vector4;
  28422. backUVs?: Vector4;
  28423. }): VertexData;
  28424. /**
  28425. * Creates the VertexData for a TorusKnot
  28426. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  28427. * * radius the radius of the torus knot, optional, default 2
  28428. * * tube the thickness of the tube, optional, default 0.5
  28429. * * radialSegments the number of sides on each tube segments, optional, default 32
  28430. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  28431. * * p the number of windings around the z axis, optional, default 2
  28432. * * q the number of windings around the x axis, optional, default 3
  28433. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28434. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  28435. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  28436. * @returns the VertexData of the Torus Knot
  28437. */
  28438. static CreateTorusKnot(options: {
  28439. radius?: number;
  28440. tube?: number;
  28441. radialSegments?: number;
  28442. tubularSegments?: number;
  28443. p?: number;
  28444. q?: number;
  28445. sideOrientation?: number;
  28446. frontUVs?: Vector4;
  28447. backUVs?: Vector4;
  28448. }): VertexData;
  28449. /**
  28450. * Compute normals for given positions and indices
  28451. * @param positions an array of vertex positions, [...., x, y, z, ......]
  28452. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  28453. * @param normals an array of vertex normals, [...., x, y, z, ......]
  28454. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  28455. * * facetNormals : optional array of facet normals (vector3)
  28456. * * facetPositions : optional array of facet positions (vector3)
  28457. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  28458. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  28459. * * bInfo : optional bounding info, required for facetPartitioning computation
  28460. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  28461. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  28462. * * useRightHandedSystem: optional boolean to for right handed system computation
  28463. * * depthSort : optional boolean to enable the facet depth sort computation
  28464. * * distanceTo : optional Vector3 to compute the facet depth from this location
  28465. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  28466. */
  28467. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  28468. facetNormals?: any;
  28469. facetPositions?: any;
  28470. facetPartitioning?: any;
  28471. ratio?: number;
  28472. bInfo?: any;
  28473. bbSize?: Vector3;
  28474. subDiv?: any;
  28475. useRightHandedSystem?: boolean;
  28476. depthSort?: boolean;
  28477. distanceTo?: Vector3;
  28478. depthSortedFacets?: any;
  28479. }): void;
  28480. private static _ComputeSides;
  28481. /**
  28482. * Applies VertexData created from the imported parameters to the geometry
  28483. * @param parsedVertexData the parsed data from an imported file
  28484. * @param geometry the geometry to apply the VertexData to
  28485. */
  28486. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  28487. }
  28488. }
  28489. declare module BABYLON {
  28490. /**
  28491. * Class containing static functions to help procedurally build meshes
  28492. */
  28493. class MeshBuilder {
  28494. private static _UpdateSideOrientation;
  28495. /**
  28496. * Creates a box mesh
  28497. * * The parameter `size` sets the size (float) of each box side (default 1)
  28498. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  28499. * * 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)
  28500. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  28501. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28502. * * 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
  28503. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28504. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  28505. * @param name defines the name of the mesh
  28506. * @param options defines the options used to create the mesh
  28507. * @param scene defines the hosting scene
  28508. * @returns the box mesh
  28509. */
  28510. static CreateBox(name: string, options: {
  28511. size?: number;
  28512. width?: number;
  28513. height?: number;
  28514. depth?: number;
  28515. faceUV?: Vector4[];
  28516. faceColors?: Color4[];
  28517. sideOrientation?: number;
  28518. frontUVs?: Vector4;
  28519. backUVs?: Vector4;
  28520. updatable?: boolean;
  28521. }, scene?: Nullable<Scene>): Mesh;
  28522. /**
  28523. * Creates a sphere mesh
  28524. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  28525. * * 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`)
  28526. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  28527. * * 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
  28528. * * 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)
  28529. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28530. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  28531. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28532. * @param name defines the name of the mesh
  28533. * @param options defines the options used to create the mesh
  28534. * @param scene defines the hosting scene
  28535. * @returns the sphere mesh
  28536. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  28537. */
  28538. static CreateSphere(name: string, options: {
  28539. segments?: number;
  28540. diameter?: number;
  28541. diameterX?: number;
  28542. diameterY?: number;
  28543. diameterZ?: number;
  28544. arc?: number;
  28545. slice?: number;
  28546. sideOrientation?: number;
  28547. frontUVs?: Vector4;
  28548. backUVs?: Vector4;
  28549. updatable?: boolean;
  28550. }, scene: any): Mesh;
  28551. /**
  28552. * Creates a plane polygonal mesh. By default, this is a disc
  28553. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  28554. * * 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
  28555. * * 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
  28556. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28557. * * 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
  28558. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28559. * @param name defines the name of the mesh
  28560. * @param options defines the options used to create the mesh
  28561. * @param scene defines the hosting scene
  28562. * @returns the plane polygonal mesh
  28563. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  28564. */
  28565. static CreateDisc(name: string, options: {
  28566. radius?: number;
  28567. tessellation?: number;
  28568. arc?: number;
  28569. updatable?: boolean;
  28570. sideOrientation?: number;
  28571. frontUVs?: Vector4;
  28572. backUVs?: Vector4;
  28573. }, scene?: Nullable<Scene>): Mesh;
  28574. /**
  28575. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  28576. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  28577. * * 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`)
  28578. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  28579. * * 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
  28580. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28581. * * 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
  28582. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28583. * @param name defines the name of the mesh
  28584. * @param options defines the options used to create the mesh
  28585. * @param scene defines the hosting scene
  28586. * @returns the icosahedron mesh
  28587. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  28588. */
  28589. static CreateIcoSphere(name: string, options: {
  28590. radius?: number;
  28591. radiusX?: number;
  28592. radiusY?: number;
  28593. radiusZ?: number;
  28594. flat?: boolean;
  28595. subdivisions?: number;
  28596. sideOrientation?: number;
  28597. frontUVs?: Vector4;
  28598. backUVs?: Vector4;
  28599. updatable?: boolean;
  28600. }, scene: Scene): Mesh;
  28601. /**
  28602. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  28603. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  28604. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  28605. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  28606. * * 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
  28607. * * 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
  28608. * * 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
  28609. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28610. * * 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
  28611. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  28612. * * 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
  28613. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  28614. * * 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
  28615. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  28616. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28617. * @param name defines the name of the mesh
  28618. * @param options defines the options used to create the mesh
  28619. * @param scene defines the hosting scene
  28620. * @returns the ribbon mesh
  28621. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  28622. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28623. */
  28624. static CreateRibbon(name: string, options: {
  28625. pathArray: Vector3[][];
  28626. closeArray?: boolean;
  28627. closePath?: boolean;
  28628. offset?: number;
  28629. updatable?: boolean;
  28630. sideOrientation?: number;
  28631. frontUVs?: Vector4;
  28632. backUVs?: Vector4;
  28633. instance?: Mesh;
  28634. invertUV?: boolean;
  28635. uvs?: Vector2[];
  28636. colors?: Color4[];
  28637. }, scene?: Nullable<Scene>): Mesh;
  28638. /**
  28639. * Creates a cylinder or a cone mesh
  28640. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  28641. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  28642. * * 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.
  28643. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  28644. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  28645. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  28646. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  28647. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  28648. * * 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).
  28649. * * 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
  28650. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  28651. * * 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
  28652. * * 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.
  28653. * * If `enclose` is false, a ring surface is one element.
  28654. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  28655. * * 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
  28656. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28657. * * 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
  28658. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28659. * @param name defines the name of the mesh
  28660. * @param options defines the options used to create the mesh
  28661. * @param scene defines the hosting scene
  28662. * @returns the cylinder mesh
  28663. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  28664. */
  28665. static CreateCylinder(name: string, options: {
  28666. height?: number;
  28667. diameterTop?: number;
  28668. diameterBottom?: number;
  28669. diameter?: number;
  28670. tessellation?: number;
  28671. subdivisions?: number;
  28672. arc?: number;
  28673. faceColors?: Color4[];
  28674. faceUV?: Vector4[];
  28675. updatable?: boolean;
  28676. hasRings?: boolean;
  28677. enclose?: boolean;
  28678. sideOrientation?: number;
  28679. frontUVs?: Vector4;
  28680. backUVs?: Vector4;
  28681. }, scene: any): Mesh;
  28682. /**
  28683. * Creates a torus mesh
  28684. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  28685. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  28686. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  28687. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28688. * * 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
  28689. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28690. * @param name defines the name of the mesh
  28691. * @param options defines the options used to create the mesh
  28692. * @param scene defines the hosting scene
  28693. * @returns the torus mesh
  28694. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  28695. */
  28696. static CreateTorus(name: string, options: {
  28697. diameter?: number;
  28698. thickness?: number;
  28699. tessellation?: number;
  28700. updatable?: boolean;
  28701. sideOrientation?: number;
  28702. frontUVs?: Vector4;
  28703. backUVs?: Vector4;
  28704. }, scene: any): Mesh;
  28705. /**
  28706. * Creates a torus knot mesh
  28707. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  28708. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  28709. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  28710. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  28711. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28712. * * 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
  28713. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28714. * @param name defines the name of the mesh
  28715. * @param options defines the options used to create the mesh
  28716. * @param scene defines the hosting scene
  28717. * @returns the torus knot mesh
  28718. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  28719. */
  28720. static CreateTorusKnot(name: string, options: {
  28721. radius?: number;
  28722. tube?: number;
  28723. radialSegments?: number;
  28724. tubularSegments?: number;
  28725. p?: number;
  28726. q?: number;
  28727. updatable?: boolean;
  28728. sideOrientation?: number;
  28729. frontUVs?: Vector4;
  28730. backUVs?: Vector4;
  28731. }, scene: any): Mesh;
  28732. /**
  28733. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  28734. * * 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
  28735. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  28736. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  28737. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  28738. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  28739. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  28740. * * 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
  28741. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  28742. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28743. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  28744. * @param name defines the name of the new line system
  28745. * @param options defines the options used to create the line system
  28746. * @param scene defines the hosting scene
  28747. * @returns a new line system mesh
  28748. */
  28749. static CreateLineSystem(name: string, options: {
  28750. lines: Vector3[][];
  28751. updatable?: boolean;
  28752. instance?: Nullable<LinesMesh>;
  28753. colors?: Nullable<Color4[][]>;
  28754. useVertexAlpha?: boolean;
  28755. }, scene: Nullable<Scene>): LinesMesh;
  28756. /**
  28757. * Creates a line mesh
  28758. * 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
  28759. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  28760. * * The parameter `points` is an array successive Vector3
  28761. * * 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
  28762. * * The optional parameter `colors` is an array of successive Color4, one per line point
  28763. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  28764. * * When updating an instance, remember that only point positions can change, not the number of points
  28765. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28766. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  28767. * @param name defines the name of the new line system
  28768. * @param options defines the options used to create the line system
  28769. * @param scene defines the hosting scene
  28770. * @returns a new line mesh
  28771. */
  28772. static CreateLines(name: string, options: {
  28773. points: Vector3[];
  28774. updatable?: boolean;
  28775. instance?: Nullable<LinesMesh>;
  28776. colors?: Color4[];
  28777. useVertexAlpha?: boolean;
  28778. }, scene?: Nullable<Scene>): LinesMesh;
  28779. /**
  28780. * Creates a dashed line mesh
  28781. * * 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
  28782. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  28783. * * The parameter `points` is an array successive Vector3
  28784. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  28785. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  28786. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  28787. * * 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
  28788. * * When updating an instance, remember that only point positions can change, not the number of points
  28789. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28790. * @param name defines the name of the mesh
  28791. * @param options defines the options used to create the mesh
  28792. * @param scene defines the hosting scene
  28793. * @returns the dashed line mesh
  28794. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  28795. */
  28796. static CreateDashedLines(name: string, options: {
  28797. points: Vector3[];
  28798. dashSize?: number;
  28799. gapSize?: number;
  28800. dashNb?: number;
  28801. updatable?: boolean;
  28802. instance?: LinesMesh;
  28803. }, scene?: Nullable<Scene>): LinesMesh;
  28804. /**
  28805. * 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.
  28806. * * 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.
  28807. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  28808. * * 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.
  28809. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  28810. * * 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
  28811. * * 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
  28812. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  28813. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28814. * * 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
  28815. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  28816. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28817. * @param name defines the name of the mesh
  28818. * @param options defines the options used to create the mesh
  28819. * @param scene defines the hosting scene
  28820. * @returns the extruded shape mesh
  28821. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28822. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28823. */
  28824. static ExtrudeShape(name: string, options: {
  28825. shape: Vector3[];
  28826. path: Vector3[];
  28827. scale?: number;
  28828. rotation?: number;
  28829. cap?: number;
  28830. updatable?: boolean;
  28831. sideOrientation?: number;
  28832. frontUVs?: Vector4;
  28833. backUVs?: Vector4;
  28834. instance?: Mesh;
  28835. invertUV?: boolean;
  28836. }, scene?: Nullable<Scene>): Mesh;
  28837. /**
  28838. * Creates an custom extruded shape mesh.
  28839. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  28840. * * 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.
  28841. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  28842. * * 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
  28843. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  28844. * * 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
  28845. * * It must returns a float value that will be the scale value applied to the shape on each path point
  28846. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  28847. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  28848. * * 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
  28849. * * 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
  28850. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  28851. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28852. * * 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
  28853. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  28854. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28855. * @param name defines the name of the mesh
  28856. * @param options defines the options used to create the mesh
  28857. * @param scene defines the hosting scene
  28858. * @returns the custom extruded shape mesh
  28859. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  28860. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28861. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28862. */
  28863. static ExtrudeShapeCustom(name: string, options: {
  28864. shape: Vector3[];
  28865. path: Vector3[];
  28866. scaleFunction?: any;
  28867. rotationFunction?: any;
  28868. ribbonCloseArray?: boolean;
  28869. ribbonClosePath?: boolean;
  28870. cap?: number;
  28871. updatable?: boolean;
  28872. sideOrientation?: number;
  28873. frontUVs?: Vector4;
  28874. backUVs?: Vector4;
  28875. instance?: Mesh;
  28876. invertUV?: boolean;
  28877. }, scene: Scene): Mesh;
  28878. /**
  28879. * Creates lathe mesh.
  28880. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  28881. * * 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
  28882. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  28883. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  28884. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  28885. * * 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
  28886. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  28887. * * 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
  28888. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28889. * * 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
  28890. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  28891. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28892. * @param name defines the name of the mesh
  28893. * @param options defines the options used to create the mesh
  28894. * @param scene defines the hosting scene
  28895. * @returns the lathe mesh
  28896. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  28897. */
  28898. static CreateLathe(name: string, options: {
  28899. shape: Vector3[];
  28900. radius?: number;
  28901. tessellation?: number;
  28902. clip?: number;
  28903. arc?: number;
  28904. closed?: boolean;
  28905. updatable?: boolean;
  28906. sideOrientation?: number;
  28907. frontUVs?: Vector4;
  28908. backUVs?: Vector4;
  28909. cap?: number;
  28910. invertUV?: boolean;
  28911. }, scene: Scene): Mesh;
  28912. /**
  28913. * Creates a plane mesh
  28914. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  28915. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  28916. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  28917. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28918. * * 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
  28919. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28920. * @param name defines the name of the mesh
  28921. * @param options defines the options used to create the mesh
  28922. * @param scene defines the hosting scene
  28923. * @returns the plane mesh
  28924. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  28925. */
  28926. static CreatePlane(name: string, options: {
  28927. size?: number;
  28928. width?: number;
  28929. height?: number;
  28930. sideOrientation?: number;
  28931. frontUVs?: Vector4;
  28932. backUVs?: Vector4;
  28933. updatable?: boolean;
  28934. sourcePlane?: Plane;
  28935. }, scene: Scene): Mesh;
  28936. /**
  28937. * Creates a ground mesh
  28938. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  28939. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  28940. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28941. * @param name defines the name of the mesh
  28942. * @param options defines the options used to create the mesh
  28943. * @param scene defines the hosting scene
  28944. * @returns the ground mesh
  28945. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  28946. */
  28947. static CreateGround(name: string, options: {
  28948. width?: number;
  28949. height?: number;
  28950. subdivisions?: number;
  28951. subdivisionsX?: number;
  28952. subdivisionsY?: number;
  28953. updatable?: boolean;
  28954. }, scene: any): Mesh;
  28955. /**
  28956. * Creates a tiled ground mesh
  28957. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  28958. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  28959. * * 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
  28960. * * 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
  28961. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28962. * @param name defines the name of the mesh
  28963. * @param options defines the options used to create the mesh
  28964. * @param scene defines the hosting scene
  28965. * @returns the tiled ground mesh
  28966. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  28967. */
  28968. static CreateTiledGround(name: string, options: {
  28969. xmin: number;
  28970. zmin: number;
  28971. xmax: number;
  28972. zmax: number;
  28973. subdivisions?: {
  28974. w: number;
  28975. h: number;
  28976. };
  28977. precision?: {
  28978. w: number;
  28979. h: number;
  28980. };
  28981. updatable?: boolean;
  28982. }, scene: Scene): Mesh;
  28983. /**
  28984. * Creates a ground mesh from a height map
  28985. * * The parameter `url` sets the URL of the height map image resource.
  28986. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  28987. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  28988. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  28989. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  28990. * * 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.
  28991. * * 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).
  28992. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  28993. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28994. * @param name defines the name of the mesh
  28995. * @param url defines the url to the height map
  28996. * @param options defines the options used to create the mesh
  28997. * @param scene defines the hosting scene
  28998. * @returns the ground mesh
  28999. * @see https://doc.babylonjs.com/babylon101/height_map
  29000. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  29001. */
  29002. static CreateGroundFromHeightMap(name: string, url: string, options: {
  29003. width?: number;
  29004. height?: number;
  29005. subdivisions?: number;
  29006. minHeight?: number;
  29007. maxHeight?: number;
  29008. colorFilter?: Color3;
  29009. alphaFilter?: number;
  29010. updatable?: boolean;
  29011. onReady?: (mesh: GroundMesh) => void;
  29012. }, scene: Scene): GroundMesh;
  29013. /**
  29014. * Creates a polygon mesh
  29015. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  29016. * * 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
  29017. * * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  29018. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29019. * * 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)
  29020. * * Remember you can only change the shape positions, not their number when updating a polygon
  29021. * @param name defines the name of the mesh
  29022. * @param options defines the options used to create the mesh
  29023. * @param scene defines the hosting scene
  29024. * @returns the polygon mesh
  29025. */
  29026. static CreatePolygon(name: string, options: {
  29027. shape: Vector3[];
  29028. holes?: Vector3[][];
  29029. depth?: number;
  29030. faceUV?: Vector4[];
  29031. faceColors?: Color4[];
  29032. updatable?: boolean;
  29033. sideOrientation?: number;
  29034. frontUVs?: Vector4;
  29035. backUVs?: Vector4;
  29036. }, scene: Scene): Mesh;
  29037. /**
  29038. * Creates an extruded polygon mesh, with depth in the Y direction.
  29039. * * 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)
  29040. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  29041. * @param name defines the name of the mesh
  29042. * @param options defines the options used to create the mesh
  29043. * @param scene defines the hosting scene
  29044. * @returns the polygon mesh
  29045. */
  29046. static ExtrudePolygon(name: string, options: {
  29047. shape: Vector3[];
  29048. holes?: Vector3[][];
  29049. depth?: number;
  29050. faceUV?: Vector4[];
  29051. faceColors?: Color4[];
  29052. updatable?: boolean;
  29053. sideOrientation?: number;
  29054. frontUVs?: Vector4;
  29055. backUVs?: Vector4;
  29056. }, scene: Scene): Mesh;
  29057. /**
  29058. * Creates a tube mesh.
  29059. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  29060. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  29061. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  29062. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  29063. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  29064. * * 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)
  29065. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  29066. * * 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
  29067. * * 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
  29068. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  29069. * * 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
  29070. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  29071. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29072. * @param name defines the name of the mesh
  29073. * @param options defines the options used to create the mesh
  29074. * @param scene defines the hosting scene
  29075. * @returns the tube mesh
  29076. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  29077. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  29078. */
  29079. static CreateTube(name: string, options: {
  29080. path: Vector3[];
  29081. radius?: number;
  29082. tessellation?: number;
  29083. radiusFunction?: {
  29084. (i: number, distance: number): number;
  29085. };
  29086. cap?: number;
  29087. arc?: number;
  29088. updatable?: boolean;
  29089. sideOrientation?: number;
  29090. frontUVs?: Vector4;
  29091. backUVs?: Vector4;
  29092. instance?: Mesh;
  29093. invertUV?: boolean;
  29094. }, scene: Scene): Mesh;
  29095. /**
  29096. * Creates a polyhedron mesh
  29097. * * 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
  29098. * * The parameter `size` (positive float, default 1) sets the polygon size
  29099. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  29100. * * 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`
  29101. * * 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
  29102. * * 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)`)
  29103. * * 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
  29104. * * 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
  29105. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  29106. * * 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
  29107. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29108. * @param name defines the name of the mesh
  29109. * @param options defines the options used to create the mesh
  29110. * @param scene defines the hosting scene
  29111. * @returns the polyhedron mesh
  29112. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  29113. */
  29114. static CreatePolyhedron(name: string, options: {
  29115. type?: number;
  29116. size?: number;
  29117. sizeX?: number;
  29118. sizeY?: number;
  29119. sizeZ?: number;
  29120. custom?: any;
  29121. faceUV?: Vector4[];
  29122. faceColors?: Color4[];
  29123. flat?: boolean;
  29124. updatable?: boolean;
  29125. sideOrientation?: number;
  29126. frontUVs?: Vector4;
  29127. backUVs?: Vector4;
  29128. }, scene: Scene): Mesh;
  29129. /**
  29130. * Creates a decal mesh.
  29131. * 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
  29132. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  29133. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  29134. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  29135. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  29136. * @param name defines the name of the mesh
  29137. * @param sourceMesh defines the mesh where the decal must be applied
  29138. * @param options defines the options used to create the mesh
  29139. * @param scene defines the hosting scene
  29140. * @returns the decal mesh
  29141. * @see https://doc.babylonjs.com/how_to/decals
  29142. */
  29143. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  29144. position?: Vector3;
  29145. normal?: Vector3;
  29146. size?: Vector3;
  29147. angle?: number;
  29148. }): Mesh;
  29149. private static _ExtrudeShapeGeneric;
  29150. }
  29151. }
  29152. declare module BABYLON {
  29153. /**
  29154. * Class used to represent a specific level of detail of a mesh
  29155. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  29156. */
  29157. class MeshLODLevel {
  29158. /** Defines the distance where this level should star being displayed */
  29159. distance: number;
  29160. /** Defines the mesh to use to render this level */
  29161. mesh: Nullable<Mesh>;
  29162. /**
  29163. * Creates a new LOD level
  29164. * @param distance defines the distance where this level should star being displayed
  29165. * @param mesh defines the mesh to use to render this level
  29166. */
  29167. constructor(
  29168. /** Defines the distance where this level should star being displayed */
  29169. distance: number,
  29170. /** Defines the mesh to use to render this level */
  29171. mesh: Nullable<Mesh>);
  29172. }
  29173. }
  29174. declare module BABYLON {
  29175. /**
  29176. * A simplifier interface for future simplification implementations
  29177. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  29178. */
  29179. interface ISimplifier {
  29180. /**
  29181. * Simplification of a given mesh according to the given settings.
  29182. * Since this requires computation, it is assumed that the function runs async.
  29183. * @param settings The settings of the simplification, including quality and distance
  29184. * @param successCallback A callback that will be called after the mesh was simplified.
  29185. * @param errorCallback in case of an error, this callback will be called. optional.
  29186. */
  29187. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  29188. }
  29189. /**
  29190. * Expected simplification settings.
  29191. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  29192. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  29193. */
  29194. interface ISimplificationSettings {
  29195. /**
  29196. * Gets or sets the expected quality
  29197. */
  29198. quality: number;
  29199. /**
  29200. * Gets or sets the distance when this optimized version should be used
  29201. */
  29202. distance: number;
  29203. /**
  29204. * Gets an already optimized mesh
  29205. */
  29206. optimizeMesh?: boolean;
  29207. }
  29208. /**
  29209. * Class used to specify simplification options
  29210. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  29211. */
  29212. class SimplificationSettings implements ISimplificationSettings {
  29213. /** expected quality */
  29214. quality: number;
  29215. /** distance when this optimized version should be used */
  29216. distance: number;
  29217. /** already optimized mesh */
  29218. optimizeMesh?: boolean | undefined;
  29219. /**
  29220. * Creates a SimplificationSettings
  29221. * @param quality expected quality
  29222. * @param distance distance when this optimized version should be used
  29223. * @param optimizeMesh already optimized mesh
  29224. */
  29225. constructor(
  29226. /** expected quality */
  29227. quality: number,
  29228. /** distance when this optimized version should be used */
  29229. distance: number,
  29230. /** already optimized mesh */
  29231. optimizeMesh?: boolean | undefined);
  29232. }
  29233. /**
  29234. * Interface used to define a simplification task
  29235. */
  29236. interface ISimplificationTask {
  29237. /**
  29238. * Array of settings
  29239. */
  29240. settings: Array<ISimplificationSettings>;
  29241. /**
  29242. * Simplification type
  29243. */
  29244. simplificationType: SimplificationType;
  29245. /**
  29246. * Mesh to simplify
  29247. */
  29248. mesh: Mesh;
  29249. /**
  29250. * Callback called on success
  29251. */
  29252. successCallback?: () => void;
  29253. /**
  29254. * Defines if parallel processing can be used
  29255. */
  29256. parallelProcessing: boolean;
  29257. }
  29258. /**
  29259. * Queue used to order the simplification tasks
  29260. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  29261. */
  29262. class SimplificationQueue {
  29263. private _simplificationArray;
  29264. /**
  29265. * Gets a boolean indicating that the process is still running
  29266. */
  29267. running: boolean;
  29268. /**
  29269. * Creates a new queue
  29270. */
  29271. constructor();
  29272. /**
  29273. * Adds a new simplification task
  29274. * @param task defines a task to add
  29275. */
  29276. addTask(task: ISimplificationTask): void;
  29277. /**
  29278. * Execute next task
  29279. */
  29280. executeNext(): void;
  29281. /**
  29282. * Execute a simplification task
  29283. * @param task defines the task to run
  29284. */
  29285. runSimplification(task: ISimplificationTask): void;
  29286. private getSimplifier;
  29287. }
  29288. /**
  29289. * The implemented types of simplification
  29290. * At the moment only Quadratic Error Decimation is implemented
  29291. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  29292. */
  29293. enum SimplificationType {
  29294. /** Quadratic error decimation */
  29295. QUADRATIC = 0
  29296. }
  29297. }
  29298. declare module BABYLON {
  29299. interface Scene {
  29300. /** @hidden (Backing field) */
  29301. _simplificationQueue: SimplificationQueue;
  29302. /**
  29303. * Gets or sets the simplification queue attached to the scene
  29304. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  29305. */
  29306. simplificationQueue: SimplificationQueue;
  29307. }
  29308. interface Mesh {
  29309. /**
  29310. * Simplify the mesh according to the given array of settings.
  29311. * Function will return immediately and will simplify async
  29312. * @param settings a collection of simplification settings
  29313. * @param parallelProcessing should all levels calculate parallel or one after the other
  29314. * @param simplificationType the type of simplification to run
  29315. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  29316. * @returns the current mesh
  29317. */
  29318. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  29319. }
  29320. /**
  29321. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  29322. * created in a scene
  29323. */
  29324. class SimplicationQueueSceneComponent implements ISceneComponent {
  29325. /**
  29326. * The component name helpfull to identify the component in the list of scene components.
  29327. */
  29328. readonly name: string;
  29329. /**
  29330. * The scene the component belongs to.
  29331. */
  29332. scene: Scene;
  29333. /**
  29334. * Creates a new instance of the component for the given scene
  29335. * @param scene Defines the scene to register the component in
  29336. */
  29337. constructor(scene: Scene);
  29338. /**
  29339. * Registers the component in a given scene
  29340. */
  29341. register(): void;
  29342. /**
  29343. * Rebuilds the elements related to this component in case of
  29344. * context lost for instance.
  29345. */
  29346. rebuild(): void;
  29347. /**
  29348. * Disposes the component and the associated ressources
  29349. */
  29350. dispose(): void;
  29351. private _beforeCameraUpdate;
  29352. }
  29353. }
  29354. declare module BABYLON {
  29355. /**
  29356. * Polygon
  29357. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  29358. */
  29359. class Polygon {
  29360. /**
  29361. * Creates a rectangle
  29362. * @param xmin bottom X coord
  29363. * @param ymin bottom Y coord
  29364. * @param xmax top X coord
  29365. * @param ymax top Y coord
  29366. * @returns points that make the resulting rectation
  29367. */
  29368. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  29369. /**
  29370. * Creates a circle
  29371. * @param radius radius of circle
  29372. * @param cx scale in x
  29373. * @param cy scale in y
  29374. * @param numberOfSides number of sides that make up the circle
  29375. * @returns points that make the resulting circle
  29376. */
  29377. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  29378. /**
  29379. * Creates a polygon from input string
  29380. * @param input Input polygon data
  29381. * @returns the parsed points
  29382. */
  29383. static Parse(input: string): Vector2[];
  29384. /**
  29385. * Starts building a polygon from x and y coordinates
  29386. * @param x x coordinate
  29387. * @param y y coordinate
  29388. * @returns the started path2
  29389. */
  29390. static StartingAt(x: number, y: number): Path2;
  29391. }
  29392. /**
  29393. * Builds a polygon
  29394. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  29395. */
  29396. class PolygonMeshBuilder {
  29397. private _points;
  29398. private _outlinepoints;
  29399. private _holes;
  29400. private _name;
  29401. private _scene;
  29402. private _epoints;
  29403. private _eholes;
  29404. private _addToepoint;
  29405. /**
  29406. * Creates a PolygonMeshBuilder
  29407. * @param name name of the builder
  29408. * @param contours Path of the polygon
  29409. * @param scene scene to add to
  29410. */
  29411. constructor(name: string, contours: Path2 | Vector2[] | any, scene: Scene);
  29412. /**
  29413. * Adds a whole within the polygon
  29414. * @param hole Array of points defining the hole
  29415. * @returns this
  29416. */
  29417. addHole(hole: Vector2[]): PolygonMeshBuilder;
  29418. /**
  29419. * Creates the polygon
  29420. * @param updatable If the mesh should be updatable
  29421. * @param depth The depth of the mesh created
  29422. * @returns the created mesh
  29423. */
  29424. build(updatable?: boolean, depth?: number): Mesh;
  29425. /**
  29426. * Adds a side to the polygon
  29427. * @param positions points that make the polygon
  29428. * @param normals normals of the polygon
  29429. * @param uvs uvs of the polygon
  29430. * @param indices indices of the polygon
  29431. * @param bounds bounds of the polygon
  29432. * @param points points of the polygon
  29433. * @param depth depth of the polygon
  29434. * @param flip flip of the polygon
  29435. */
  29436. private addSide;
  29437. }
  29438. }
  29439. declare module BABYLON {
  29440. /**
  29441. * Base class for submeshes
  29442. */
  29443. class BaseSubMesh {
  29444. /** @hidden */
  29445. _materialDefines: Nullable<MaterialDefines>;
  29446. /** @hidden */
  29447. _materialEffect: Nullable<Effect>;
  29448. /**
  29449. * Gets associated effect
  29450. */
  29451. readonly effect: Nullable<Effect>;
  29452. /**
  29453. * Sets associated effect (effect used to render this submesh)
  29454. * @param effect defines the effect to associate with
  29455. * @param defines defines the set of defines used to compile this effect
  29456. */
  29457. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  29458. }
  29459. /**
  29460. * Defines a subdivision inside a mesh
  29461. */
  29462. class SubMesh extends BaseSubMesh implements ICullable {
  29463. /** the material index to use */
  29464. materialIndex: number;
  29465. /** vertex index start */
  29466. verticesStart: number;
  29467. /** vertices count */
  29468. verticesCount: number;
  29469. /** index start */
  29470. indexStart: number;
  29471. /** indices count */
  29472. indexCount: number;
  29473. /** @hidden */
  29474. _linesIndexCount: number;
  29475. private _mesh;
  29476. private _renderingMesh;
  29477. private _boundingInfo;
  29478. private _linesIndexBuffer;
  29479. /** @hidden */
  29480. _lastColliderWorldVertices: Nullable<Vector3[]>;
  29481. /** @hidden */
  29482. _trianglePlanes: Plane[];
  29483. /** @hidden */
  29484. _lastColliderTransformMatrix: Matrix;
  29485. /** @hidden */
  29486. _renderId: number;
  29487. /** @hidden */
  29488. _alphaIndex: number;
  29489. /** @hidden */
  29490. _distanceToCamera: number;
  29491. /** @hidden */
  29492. _id: number;
  29493. private _currentMaterial;
  29494. /**
  29495. * Add a new submesh to a mesh
  29496. * @param materialIndex defines the material index to use
  29497. * @param verticesStart defines vertex index start
  29498. * @param verticesCount defines vertices count
  29499. * @param indexStart defines index start
  29500. * @param indexCount defines indices count
  29501. * @param mesh defines the parent mesh
  29502. * @param renderingMesh defines an optional rendering mesh
  29503. * @param createBoundingBox defines if bounding box should be created for this submesh
  29504. * @returns the new submesh
  29505. */
  29506. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  29507. /**
  29508. * Creates a new submesh
  29509. * @param materialIndex defines the material index to use
  29510. * @param verticesStart defines vertex index start
  29511. * @param verticesCount defines vertices count
  29512. * @param indexStart defines index start
  29513. * @param indexCount defines indices count
  29514. * @param mesh defines the parent mesh
  29515. * @param renderingMesh defines an optional rendering mesh
  29516. * @param createBoundingBox defines if bounding box should be created for this submesh
  29517. */
  29518. constructor(
  29519. /** the material index to use */
  29520. materialIndex: number,
  29521. /** vertex index start */
  29522. verticesStart: number,
  29523. /** vertices count */
  29524. verticesCount: number,
  29525. /** index start */
  29526. indexStart: number,
  29527. /** indices count */
  29528. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  29529. /**
  29530. * Returns true if this submesh covers the entire parent mesh
  29531. * @ignorenaming
  29532. */
  29533. readonly IsGlobal: boolean;
  29534. /**
  29535. * Returns the submesh BoudingInfo object
  29536. * @returns current bounding info (or mesh's one if the submesh is global)
  29537. */
  29538. getBoundingInfo(): BoundingInfo;
  29539. /**
  29540. * Sets the submesh BoundingInfo
  29541. * @param boundingInfo defines the new bounding info to use
  29542. * @returns the SubMesh
  29543. */
  29544. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  29545. /**
  29546. * Returns the mesh of the current submesh
  29547. * @return the parent mesh
  29548. */
  29549. getMesh(): AbstractMesh;
  29550. /**
  29551. * Returns the rendering mesh of the submesh
  29552. * @returns the rendering mesh (could be different from parent mesh)
  29553. */
  29554. getRenderingMesh(): Mesh;
  29555. /**
  29556. * Returns the submesh material
  29557. * @returns null or the current material
  29558. */
  29559. getMaterial(): Nullable<Material>;
  29560. /**
  29561. * Sets a new updated BoundingInfo object to the submesh
  29562. * @returns the SubMesh
  29563. */
  29564. refreshBoundingInfo(): SubMesh;
  29565. /** @hidden */
  29566. _checkCollision(collider: Collider): boolean;
  29567. /**
  29568. * Updates the submesh BoundingInfo
  29569. * @param world defines the world matrix to use to update the bounding info
  29570. * @returns the submesh
  29571. */
  29572. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  29573. /**
  29574. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  29575. * @param frustumPlanes defines the frustum planes
  29576. * @returns true if the submesh is intersecting with the frustum
  29577. */
  29578. isInFrustum(frustumPlanes: Plane[]): boolean;
  29579. /**
  29580. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  29581. * @param frustumPlanes defines the frustum planes
  29582. * @returns true if the submesh is inside the frustum
  29583. */
  29584. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  29585. /**
  29586. * Renders the submesh
  29587. * @param enableAlphaMode defines if alpha needs to be used
  29588. * @returns the submesh
  29589. */
  29590. render(enableAlphaMode: boolean): SubMesh;
  29591. /**
  29592. * @hidden
  29593. */
  29594. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  29595. /**
  29596. * Checks if the submesh intersects with a ray
  29597. * @param ray defines the ray to test
  29598. * @returns true is the passed ray intersects the submesh bounding box
  29599. */
  29600. canIntersects(ray: Ray): boolean;
  29601. /**
  29602. * Intersects current submesh with a ray
  29603. * @param ray defines the ray to test
  29604. * @param positions defines mesh's positions array
  29605. * @param indices defines mesh's indices array
  29606. * @param fastCheck defines if only bounding info should be used
  29607. * @returns intersection info or null if no intersection
  29608. */
  29609. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  29610. /** @hidden */
  29611. private _intersectLines;
  29612. /** @hidden */
  29613. private _intersectTriangles;
  29614. /** @hidden */
  29615. _rebuild(): void;
  29616. /**
  29617. * Creates a new submesh from the passed mesh
  29618. * @param newMesh defines the new hosting mesh
  29619. * @param newRenderingMesh defines an optional rendering mesh
  29620. * @returns the new submesh
  29621. */
  29622. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  29623. /**
  29624. * Release associated resources
  29625. */
  29626. dispose(): void;
  29627. /**
  29628. * Creates a new submesh from indices data
  29629. * @param materialIndex the index of the main mesh material
  29630. * @param startIndex the index where to start the copy in the mesh indices array
  29631. * @param indexCount the number of indices to copy then from the startIndex
  29632. * @param mesh the main mesh to create the submesh from
  29633. * @param renderingMesh the optional rendering mesh
  29634. * @returns a new submesh
  29635. */
  29636. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  29637. }
  29638. }
  29639. declare module BABYLON {
  29640. /**
  29641. * 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.
  29642. * @see https://doc.babylonjs.com/how_to/transformnode
  29643. */
  29644. class TransformNode extends Node {
  29645. /**
  29646. * Object will not rotate to face the camera
  29647. */
  29648. static BILLBOARDMODE_NONE: number;
  29649. /**
  29650. * Object will rotate to face the camera but only on the x axis
  29651. */
  29652. static BILLBOARDMODE_X: number;
  29653. /**
  29654. * Object will rotate to face the camera but only on the y axis
  29655. */
  29656. static BILLBOARDMODE_Y: number;
  29657. /**
  29658. * Object will rotate to face the camera but only on the z axis
  29659. */
  29660. static BILLBOARDMODE_Z: number;
  29661. /**
  29662. * Object will rotate to face the camera
  29663. */
  29664. static BILLBOARDMODE_ALL: number;
  29665. private _forward;
  29666. private _forwardInverted;
  29667. private _up;
  29668. private _right;
  29669. private _rightInverted;
  29670. private _position;
  29671. private _rotation;
  29672. private _rotationQuaternion;
  29673. protected _scaling: Vector3;
  29674. protected _isDirty: boolean;
  29675. private _transformToBoneReferal;
  29676. /**
  29677. * Set the billboard mode. Default is 0.
  29678. *
  29679. * | Value | Type | Description |
  29680. * | --- | --- | --- |
  29681. * | 0 | BILLBOARDMODE_NONE | |
  29682. * | 1 | BILLBOARDMODE_X | |
  29683. * | 2 | BILLBOARDMODE_Y | |
  29684. * | 4 | BILLBOARDMODE_Z | |
  29685. * | 7 | BILLBOARDMODE_ALL | |
  29686. *
  29687. */
  29688. billboardMode: number;
  29689. /**
  29690. * 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
  29691. */
  29692. scalingDeterminant: number;
  29693. /**
  29694. * Sets the distance of the object to max, often used by skybox
  29695. */
  29696. infiniteDistance: boolean;
  29697. /**
  29698. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  29699. * By default the system will update normals to compensate
  29700. */
  29701. ignoreNonUniformScaling: boolean;
  29702. /** @hidden */
  29703. _poseMatrix: Matrix;
  29704. /** @hidden */
  29705. _localMatrix: Matrix;
  29706. private _absolutePosition;
  29707. private _pivotMatrix;
  29708. private _pivotMatrixInverse;
  29709. protected _postMultiplyPivotMatrix: boolean;
  29710. protected _isWorldMatrixFrozen: boolean;
  29711. /** @hidden */
  29712. _indexInSceneTransformNodesArray: number;
  29713. /**
  29714. * An event triggered after the world matrix is updated
  29715. */
  29716. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  29717. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  29718. /**
  29719. * Gets a string identifying the name of the class
  29720. * @returns "TransformNode" string
  29721. */
  29722. getClassName(): string;
  29723. /**
  29724. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  29725. */
  29726. position: Vector3;
  29727. /**
  29728. * 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)).
  29729. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  29730. */
  29731. rotation: Vector3;
  29732. /**
  29733. * 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)).
  29734. */
  29735. scaling: Vector3;
  29736. /**
  29737. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (null by default).
  29738. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  29739. */
  29740. rotationQuaternion: Nullable<Quaternion>;
  29741. /**
  29742. * The forward direction of that transform in world space.
  29743. */
  29744. readonly forward: Vector3;
  29745. /**
  29746. * The up direction of that transform in world space.
  29747. */
  29748. readonly up: Vector3;
  29749. /**
  29750. * The right direction of that transform in world space.
  29751. */
  29752. readonly right: Vector3;
  29753. /**
  29754. * Copies the parameter passed Matrix into the mesh Pose matrix.
  29755. * @param matrix the matrix to copy the pose from
  29756. * @returns this TransformNode.
  29757. */
  29758. updatePoseMatrix(matrix: Matrix): TransformNode;
  29759. /**
  29760. * Returns the mesh Pose matrix.
  29761. * @returns the pose matrix
  29762. */
  29763. getPoseMatrix(): Matrix;
  29764. /** @hidden */
  29765. _isSynchronized(): boolean;
  29766. /** @hidden */
  29767. _initCache(): void;
  29768. /**
  29769. * Flag the transform node as dirty (Forcing it to update everything)
  29770. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  29771. * @returns this transform node
  29772. */
  29773. markAsDirty(property: string): TransformNode;
  29774. /**
  29775. * Returns the current mesh absolute position.
  29776. * Returns a Vector3.
  29777. */
  29778. readonly absolutePosition: Vector3;
  29779. /**
  29780. * Sets a new matrix to apply before all other transformation
  29781. * @param matrix defines the transform matrix
  29782. * @returns the current TransformNode
  29783. */
  29784. setPreTransformMatrix(matrix: Matrix): TransformNode;
  29785. /**
  29786. * Sets a new pivot matrix to the current node
  29787. * @param matrix defines the new pivot matrix to use
  29788. * @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
  29789. * @returns the current TransformNode
  29790. */
  29791. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  29792. /**
  29793. * Returns the mesh pivot matrix.
  29794. * Default : Identity.
  29795. * @returns the matrix
  29796. */
  29797. getPivotMatrix(): Matrix;
  29798. /**
  29799. * Prevents the World matrix to be computed any longer.
  29800. * @returns the TransformNode.
  29801. */
  29802. freezeWorldMatrix(): TransformNode;
  29803. /**
  29804. * Allows back the World matrix computation.
  29805. * @returns the TransformNode.
  29806. */
  29807. unfreezeWorldMatrix(): this;
  29808. /**
  29809. * True if the World matrix has been frozen.
  29810. */
  29811. readonly isWorldMatrixFrozen: boolean;
  29812. /**
  29813. * Retuns the mesh absolute position in the World.
  29814. * @returns a Vector3.
  29815. */
  29816. getAbsolutePosition(): Vector3;
  29817. /**
  29818. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  29819. * @param absolutePosition the absolute position to set
  29820. * @returns the TransformNode.
  29821. */
  29822. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  29823. /**
  29824. * Sets the mesh position in its local space.
  29825. * @param vector3 the position to set in localspace
  29826. * @returns the TransformNode.
  29827. */
  29828. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  29829. /**
  29830. * Returns the mesh position in the local space from the current World matrix values.
  29831. * @returns a new Vector3.
  29832. */
  29833. getPositionExpressedInLocalSpace(): Vector3;
  29834. /**
  29835. * Translates the mesh along the passed Vector3 in its local space.
  29836. * @param vector3 the distance to translate in localspace
  29837. * @returns the TransformNode.
  29838. */
  29839. locallyTranslate(vector3: Vector3): TransformNode;
  29840. private static _lookAtVectorCache;
  29841. /**
  29842. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  29843. * @param targetPoint the position (must be in same space as current mesh) to look at
  29844. * @param yawCor optional yaw (y-axis) correction in radians
  29845. * @param pitchCor optional pitch (x-axis) correction in radians
  29846. * @param rollCor optional roll (z-axis) correction in radians
  29847. * @param space the choosen space of the target
  29848. * @returns the TransformNode.
  29849. */
  29850. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  29851. /**
  29852. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  29853. * This Vector3 is expressed in the World space.
  29854. * @param localAxis axis to rotate
  29855. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  29856. */
  29857. getDirection(localAxis: Vector3): Vector3;
  29858. /**
  29859. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  29860. * localAxis is expressed in the mesh local space.
  29861. * result is computed in the Wordl space from the mesh World matrix.
  29862. * @param localAxis axis to rotate
  29863. * @param result the resulting transformnode
  29864. * @returns this TransformNode.
  29865. */
  29866. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  29867. /**
  29868. * Sets this transform node rotation to the given local axis.
  29869. * @param localAxis the axis in local space
  29870. * @param yawCor optional yaw (y-axis) correction in radians
  29871. * @param pitchCor optional pitch (x-axis) correction in radians
  29872. * @param rollCor optional roll (z-axis) correction in radians
  29873. * @returns this TransformNode
  29874. */
  29875. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  29876. /**
  29877. * Sets a new pivot point to the current node
  29878. * @param point defines the new pivot point to use
  29879. * @param space defines if the point is in world or local space (local by default)
  29880. * @returns the current TransformNode
  29881. */
  29882. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  29883. /**
  29884. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  29885. * @returns the pivot point
  29886. */
  29887. getPivotPoint(): Vector3;
  29888. /**
  29889. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  29890. * @param result the vector3 to store the result
  29891. * @returns this TransformNode.
  29892. */
  29893. getPivotPointToRef(result: Vector3): TransformNode;
  29894. /**
  29895. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  29896. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  29897. */
  29898. getAbsolutePivotPoint(): Vector3;
  29899. /**
  29900. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  29901. * @param result vector3 to store the result
  29902. * @returns this TransformNode.
  29903. */
  29904. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  29905. /**
  29906. * Defines the passed node as the parent of the current node.
  29907. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  29908. * @param node the node ot set as the parent
  29909. * @returns this TransformNode.
  29910. */
  29911. setParent(node: Nullable<Node>): TransformNode;
  29912. private _nonUniformScaling;
  29913. /**
  29914. * True if the scaling property of this object is non uniform eg. (1,2,1)
  29915. */
  29916. readonly nonUniformScaling: boolean;
  29917. /** @hidden */
  29918. _updateNonUniformScalingState(value: boolean): boolean;
  29919. /**
  29920. * Attach the current TransformNode to another TransformNode associated with a bone
  29921. * @param bone Bone affecting the TransformNode
  29922. * @param affectedTransformNode TransformNode associated with the bone
  29923. * @returns this object
  29924. */
  29925. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  29926. /**
  29927. * Detach the transform node if its associated with a bone
  29928. * @returns this object
  29929. */
  29930. detachFromBone(): TransformNode;
  29931. private static _rotationAxisCache;
  29932. /**
  29933. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  29934. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  29935. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  29936. * The passed axis is also normalized.
  29937. * @param axis the axis to rotate around
  29938. * @param amount the amount to rotate in radians
  29939. * @param space Space to rotate in (Default: local)
  29940. * @returns the TransformNode.
  29941. */
  29942. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  29943. /**
  29944. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  29945. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  29946. * The passed axis is also normalized. .
  29947. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  29948. * @param point the point to rotate around
  29949. * @param axis the axis to rotate around
  29950. * @param amount the amount to rotate in radians
  29951. * @returns the TransformNode
  29952. */
  29953. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  29954. /**
  29955. * Translates the mesh along the axis vector for the passed distance in the given space.
  29956. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  29957. * @param axis the axis to translate in
  29958. * @param distance the distance to translate
  29959. * @param space Space to rotate in (Default: local)
  29960. * @returns the TransformNode.
  29961. */
  29962. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  29963. /**
  29964. * Adds a rotation step to the mesh current rotation.
  29965. * x, y, z are Euler angles expressed in radians.
  29966. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  29967. * This means this rotation is made in the mesh local space only.
  29968. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  29969. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  29970. * ```javascript
  29971. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  29972. * ```
  29973. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  29974. * 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.
  29975. * @param x Rotation to add
  29976. * @param y Rotation to add
  29977. * @param z Rotation to add
  29978. * @returns the TransformNode.
  29979. */
  29980. addRotation(x: number, y: number, z: number): TransformNode;
  29981. /**
  29982. * Computes the world matrix of the node
  29983. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29984. * @returns the world matrix
  29985. */
  29986. computeWorldMatrix(force?: boolean): Matrix;
  29987. protected _afterComputeWorldMatrix(): void;
  29988. /**
  29989. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  29990. * @param func callback function to add
  29991. *
  29992. * @returns the TransformNode.
  29993. */
  29994. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  29995. /**
  29996. * Removes a registered callback function.
  29997. * @param func callback function to remove
  29998. * @returns the TransformNode.
  29999. */
  30000. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  30001. /**
  30002. * Gets the position of the current mesh in camera space
  30003. * @param camera defines the camera to use
  30004. * @returns a position
  30005. */
  30006. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  30007. /**
  30008. * Returns the distance from the mesh to the active camera
  30009. * @param camera defines the camera to use
  30010. * @returns the distance
  30011. */
  30012. getDistanceToCamera(camera?: Nullable<Camera>): number;
  30013. /**
  30014. * Clone the current transform node
  30015. * @param name Name of the new clone
  30016. * @param newParent New parent for the clone
  30017. * @param doNotCloneChildren Do not clone children hierarchy
  30018. * @returns the new transform node
  30019. */
  30020. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  30021. /**
  30022. * Serializes the objects information.
  30023. * @param currentSerializationObject defines the object to serialize in
  30024. * @returns the serialized object
  30025. */
  30026. serialize(currentSerializationObject?: any): any;
  30027. /**
  30028. * Returns a new TransformNode object parsed from the source provided.
  30029. * @param parsedTransformNode is the source.
  30030. * @param scene the scne the object belongs to
  30031. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  30032. * @returns a new TransformNode object parsed from the source provided.
  30033. */
  30034. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  30035. /**
  30036. * Releases resources associated with this transform node.
  30037. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30038. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30039. */
  30040. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30041. }
  30042. }
  30043. declare module BABYLON {
  30044. /**
  30045. * Specialized buffer used to store vertex data
  30046. */
  30047. class VertexBuffer {
  30048. /** @hidden */
  30049. _buffer: Buffer;
  30050. private _kind;
  30051. private _size;
  30052. private _ownsBuffer;
  30053. private _instanced;
  30054. private _instanceDivisor;
  30055. /**
  30056. * The byte type.
  30057. */
  30058. static readonly BYTE: number;
  30059. /**
  30060. * The unsigned byte type.
  30061. */
  30062. static readonly UNSIGNED_BYTE: number;
  30063. /**
  30064. * The short type.
  30065. */
  30066. static readonly SHORT: number;
  30067. /**
  30068. * The unsigned short type.
  30069. */
  30070. static readonly UNSIGNED_SHORT: number;
  30071. /**
  30072. * The integer type.
  30073. */
  30074. static readonly INT: number;
  30075. /**
  30076. * The unsigned integer type.
  30077. */
  30078. static readonly UNSIGNED_INT: number;
  30079. /**
  30080. * The float type.
  30081. */
  30082. static readonly FLOAT: number;
  30083. /**
  30084. * Gets or sets the instance divisor when in instanced mode
  30085. */
  30086. instanceDivisor: number;
  30087. /**
  30088. * Gets the byte stride.
  30089. */
  30090. readonly byteStride: number;
  30091. /**
  30092. * Gets the byte offset.
  30093. */
  30094. readonly byteOffset: number;
  30095. /**
  30096. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  30097. */
  30098. readonly normalized: boolean;
  30099. /**
  30100. * Gets the data type of each component in the array.
  30101. */
  30102. readonly type: number;
  30103. /**
  30104. * Constructor
  30105. * @param engine the engine
  30106. * @param data the data to use for this vertex buffer
  30107. * @param kind the vertex buffer kind
  30108. * @param updatable whether the data is updatable
  30109. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  30110. * @param stride the stride (optional)
  30111. * @param instanced whether the buffer is instanced (optional)
  30112. * @param offset the offset of the data (optional)
  30113. * @param size the number of components (optional)
  30114. * @param type the type of the component (optional)
  30115. * @param normalized whether the data contains normalized data (optional)
  30116. * @param useBytes set to true if stride and offset are in bytes (optional)
  30117. */
  30118. 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);
  30119. /** @hidden */
  30120. _rebuild(): void;
  30121. /**
  30122. * Returns the kind of the VertexBuffer (string)
  30123. * @returns a string
  30124. */
  30125. getKind(): string;
  30126. /**
  30127. * Gets a boolean indicating if the VertexBuffer is updatable?
  30128. * @returns true if the buffer is updatable
  30129. */
  30130. isUpdatable(): boolean;
  30131. /**
  30132. * Gets current buffer's data
  30133. * @returns a DataArray or null
  30134. */
  30135. getData(): Nullable<DataArray>;
  30136. /**
  30137. * Gets underlying native buffer
  30138. * @returns underlying native buffer
  30139. */
  30140. getBuffer(): Nullable<WebGLBuffer>;
  30141. /**
  30142. * Gets the stride in float32 units (i.e. byte stride / 4).
  30143. * May not be an integer if the byte stride is not divisible by 4.
  30144. * DEPRECATED. Use byteStride instead.
  30145. * @returns the stride in float32 units
  30146. */
  30147. getStrideSize(): number;
  30148. /**
  30149. * Returns the offset as a multiple of the type byte length.
  30150. * DEPRECATED. Use byteOffset instead.
  30151. * @returns the offset in bytes
  30152. */
  30153. getOffset(): number;
  30154. /**
  30155. * Returns the number of components per vertex attribute (integer)
  30156. * @returns the size in float
  30157. */
  30158. getSize(): number;
  30159. /**
  30160. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  30161. * @returns true if this buffer is instanced
  30162. */
  30163. getIsInstanced(): boolean;
  30164. /**
  30165. * Returns the instancing divisor, zero for non-instanced (integer).
  30166. * @returns a number
  30167. */
  30168. getInstanceDivisor(): number;
  30169. /**
  30170. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  30171. * @param data defines the data to store
  30172. */
  30173. create(data?: DataArray): void;
  30174. /**
  30175. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  30176. * This function will create a new buffer if the current one is not updatable
  30177. * @param data defines the data to store
  30178. */
  30179. update(data: DataArray): void;
  30180. /**
  30181. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  30182. * Returns the directly updated WebGLBuffer.
  30183. * @param data the new data
  30184. * @param offset the new offset
  30185. * @param useBytes set to true if the offset is in bytes
  30186. */
  30187. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  30188. /**
  30189. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  30190. */
  30191. dispose(): void;
  30192. /**
  30193. * Enumerates each value of this vertex buffer as numbers.
  30194. * @param count the number of values to enumerate
  30195. * @param callback the callback function called for each value
  30196. */
  30197. forEach(count: number, callback: (value: number, index: number) => void): void;
  30198. /**
  30199. * Positions
  30200. */
  30201. static readonly PositionKind: string;
  30202. /**
  30203. * Normals
  30204. */
  30205. static readonly NormalKind: string;
  30206. /**
  30207. * Tangents
  30208. */
  30209. static readonly TangentKind: string;
  30210. /**
  30211. * Texture coordinates
  30212. */
  30213. static readonly UVKind: string;
  30214. /**
  30215. * Texture coordinates 2
  30216. */
  30217. static readonly UV2Kind: string;
  30218. /**
  30219. * Texture coordinates 3
  30220. */
  30221. static readonly UV3Kind: string;
  30222. /**
  30223. * Texture coordinates 4
  30224. */
  30225. static readonly UV4Kind: string;
  30226. /**
  30227. * Texture coordinates 5
  30228. */
  30229. static readonly UV5Kind: string;
  30230. /**
  30231. * Texture coordinates 6
  30232. */
  30233. static readonly UV6Kind: string;
  30234. /**
  30235. * Colors
  30236. */
  30237. static readonly ColorKind: string;
  30238. /**
  30239. * Matrix indices (for bones)
  30240. */
  30241. static readonly MatricesIndicesKind: string;
  30242. /**
  30243. * Matrix weights (for bones)
  30244. */
  30245. static readonly MatricesWeightsKind: string;
  30246. /**
  30247. * Additional matrix indices (for bones)
  30248. */
  30249. static readonly MatricesIndicesExtraKind: string;
  30250. /**
  30251. * Additional matrix weights (for bones)
  30252. */
  30253. static readonly MatricesWeightsExtraKind: string;
  30254. /**
  30255. * Deduces the stride given a kind.
  30256. * @param kind The kind string to deduce
  30257. * @returns The deduced stride
  30258. */
  30259. static DeduceStride(kind: string): number;
  30260. /**
  30261. * Gets the byte length of the given type.
  30262. * @param type the type
  30263. * @returns the number of bytes
  30264. */
  30265. static GetTypeByteLength(type: number): number;
  30266. /**
  30267. * Enumerates each value of the given parameters as numbers.
  30268. * @param data the data to enumerate
  30269. * @param byteOffset the byte offset of the data
  30270. * @param byteStride the byte stride of the data
  30271. * @param componentCount the number of components per element
  30272. * @param componentType the type of the component
  30273. * @param count the total number of components
  30274. * @param normalized whether the data is normalized
  30275. * @param callback the callback function called for each value
  30276. */
  30277. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  30278. private static _GetFloatValue;
  30279. }
  30280. }
  30281. declare module BABYLON {
  30282. /**
  30283. * Class used to enable access to IndexedDB
  30284. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  30285. */
  30286. class Database implements IOfflineProvider {
  30287. private _callbackManifestChecked;
  30288. private _currentSceneUrl;
  30289. private _db;
  30290. private _enableSceneOffline;
  30291. private _enableTexturesOffline;
  30292. private _manifestVersionFound;
  30293. private _mustUpdateRessources;
  30294. private _hasReachedQuota;
  30295. private _isSupported;
  30296. private _idbFactory;
  30297. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  30298. private static IsUASupportingBlobStorage;
  30299. /**
  30300. * Gets a boolean indicating if Database storate is enabled (off by default)
  30301. */
  30302. static IDBStorageEnabled: boolean;
  30303. /**
  30304. * Gets a boolean indicating if scene must be saved in the database
  30305. */
  30306. readonly enableSceneOffline: boolean;
  30307. /**
  30308. * Gets a boolean indicating if textures must be saved in the database
  30309. */
  30310. readonly enableTexturesOffline: boolean;
  30311. /**
  30312. * Creates a new Database
  30313. * @param urlToScene defines the url to load the scene
  30314. * @param callbackManifestChecked defines the callback to use when manifest is checked
  30315. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  30316. */
  30317. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  30318. private static _ParseURL;
  30319. private static _ReturnFullUrlLocation;
  30320. private _checkManifestFile;
  30321. /**
  30322. * Open the database and make it available
  30323. * @param successCallback defines the callback to call on success
  30324. * @param errorCallback defines the callback to call on error
  30325. */
  30326. open(successCallback: () => void, errorCallback: () => void): void;
  30327. /**
  30328. * Loads an image from the database
  30329. * @param url defines the url to load from
  30330. * @param image defines the target DOM image
  30331. */
  30332. loadImage(url: string, image: HTMLImageElement): void;
  30333. private _loadImageFromDBAsync;
  30334. private _saveImageIntoDBAsync;
  30335. private _checkVersionFromDB;
  30336. private _loadVersionFromDBAsync;
  30337. private _saveVersionIntoDBAsync;
  30338. /**
  30339. * Loads a file from database
  30340. * @param url defines the URL to load from
  30341. * @param sceneLoaded defines a callback to call on success
  30342. * @param progressCallBack defines a callback to call when progress changed
  30343. * @param errorCallback defines a callback to call on error
  30344. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  30345. */
  30346. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  30347. private _loadFileAsync;
  30348. private _saveFileAsync;
  30349. }
  30350. }
  30351. declare module BABYLON {
  30352. /**
  30353. * Class used to enable access to offline support
  30354. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  30355. */
  30356. interface IOfflineProvider {
  30357. /**
  30358. * Gets a boolean indicating if scene must be saved in the database
  30359. */
  30360. enableSceneOffline: boolean;
  30361. /**
  30362. * Gets a boolean indicating if textures must be saved in the database
  30363. */
  30364. enableTexturesOffline: boolean;
  30365. /**
  30366. * Open the offline support and make it available
  30367. * @param successCallback defines the callback to call on success
  30368. * @param errorCallback defines the callback to call on error
  30369. */
  30370. open(successCallback: () => void, errorCallback: () => void): void;
  30371. /**
  30372. * Loads an image from the offline support
  30373. * @param url defines the url to load from
  30374. * @param image defines the target DOM image
  30375. */
  30376. loadImage(url: string, image: HTMLImageElement): void;
  30377. /**
  30378. * Loads a file from offline support
  30379. * @param url defines the URL to load from
  30380. * @param sceneLoaded defines a callback to call on success
  30381. * @param progressCallBack defines a callback to call when progress changed
  30382. * @param errorCallback defines a callback to call on error
  30383. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  30384. */
  30385. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  30386. }
  30387. }
  30388. declare module BABYLON {
  30389. /**
  30390. * This represents the base class for particle system in Babylon.
  30391. * 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.
  30392. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  30393. * @example https://doc.babylonjs.com/babylon101/particles
  30394. */
  30395. class BaseParticleSystem {
  30396. /**
  30397. * Source color is added to the destination color without alpha affecting the result
  30398. */
  30399. static BLENDMODE_ONEONE: number;
  30400. /**
  30401. * Blend current color and particle color using particle’s alpha
  30402. */
  30403. static BLENDMODE_STANDARD: number;
  30404. /**
  30405. * Add current color and particle color multiplied by particle’s alpha
  30406. */
  30407. static BLENDMODE_ADD: number;
  30408. /**
  30409. * Multiply current color with particle color
  30410. */
  30411. static BLENDMODE_MULTIPLY: number;
  30412. /**
  30413. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  30414. */
  30415. static BLENDMODE_MULTIPLYADD: number;
  30416. /**
  30417. * List of animations used by the particle system.
  30418. */
  30419. animations: Animation[];
  30420. /**
  30421. * The id of the Particle system.
  30422. */
  30423. id: string;
  30424. /**
  30425. * The friendly name of the Particle system.
  30426. */
  30427. name: string;
  30428. /**
  30429. * The rendering group used by the Particle system to chose when to render.
  30430. */
  30431. renderingGroupId: number;
  30432. /**
  30433. * The emitter represents the Mesh or position we are attaching the particle system to.
  30434. */
  30435. emitter: Nullable<AbstractMesh | Vector3>;
  30436. /**
  30437. * The maximum number of particles to emit per frame
  30438. */
  30439. emitRate: number;
  30440. /**
  30441. * If you want to launch only a few particles at once, that can be done, as well.
  30442. */
  30443. manualEmitCount: number;
  30444. /**
  30445. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  30446. */
  30447. updateSpeed: number;
  30448. /**
  30449. * The amount of time the particle system is running (depends of the overall update speed).
  30450. */
  30451. targetStopDuration: number;
  30452. /**
  30453. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  30454. */
  30455. disposeOnStop: boolean;
  30456. /**
  30457. * Minimum power of emitting particles.
  30458. */
  30459. minEmitPower: number;
  30460. /**
  30461. * Maximum power of emitting particles.
  30462. */
  30463. maxEmitPower: number;
  30464. /**
  30465. * Minimum life time of emitting particles.
  30466. */
  30467. minLifeTime: number;
  30468. /**
  30469. * Maximum life time of emitting particles.
  30470. */
  30471. maxLifeTime: number;
  30472. /**
  30473. * Minimum Size of emitting particles.
  30474. */
  30475. minSize: number;
  30476. /**
  30477. * Maximum Size of emitting particles.
  30478. */
  30479. maxSize: number;
  30480. /**
  30481. * Minimum scale of emitting particles on X axis.
  30482. */
  30483. minScaleX: number;
  30484. /**
  30485. * Maximum scale of emitting particles on X axis.
  30486. */
  30487. maxScaleX: number;
  30488. /**
  30489. * Minimum scale of emitting particles on Y axis.
  30490. */
  30491. minScaleY: number;
  30492. /**
  30493. * Maximum scale of emitting particles on Y axis.
  30494. */
  30495. maxScaleY: number;
  30496. /**
  30497. * Gets or sets the minimal initial rotation in radians.
  30498. */
  30499. minInitialRotation: number;
  30500. /**
  30501. * Gets or sets the maximal initial rotation in radians.
  30502. */
  30503. maxInitialRotation: number;
  30504. /**
  30505. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  30506. */
  30507. minAngularSpeed: number;
  30508. /**
  30509. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  30510. */
  30511. maxAngularSpeed: number;
  30512. /**
  30513. * The texture used to render each particle. (this can be a spritesheet)
  30514. */
  30515. particleTexture: Nullable<Texture>;
  30516. /**
  30517. * The layer mask we are rendering the particles through.
  30518. */
  30519. layerMask: number;
  30520. /**
  30521. * This can help using your own shader to render the particle system.
  30522. * The according effect will be created
  30523. */
  30524. customShader: any;
  30525. /**
  30526. * By default particle system starts as soon as they are created. This prevents the
  30527. * automatic start to happen and let you decide when to start emitting particles.
  30528. */
  30529. preventAutoStart: boolean;
  30530. private _noiseTexture;
  30531. /**
  30532. * Gets or sets a texture used to add random noise to particle positions
  30533. */
  30534. noiseTexture: Nullable<ProceduralTexture>;
  30535. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  30536. noiseStrength: Vector3;
  30537. /**
  30538. * Callback triggered when the particle animation is ending.
  30539. */
  30540. onAnimationEnd: Nullable<() => void>;
  30541. /**
  30542. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  30543. */
  30544. blendMode: number;
  30545. /**
  30546. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  30547. * to override the particles.
  30548. */
  30549. forceDepthWrite: boolean;
  30550. /** 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 */
  30551. preWarmCycles: number;
  30552. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  30553. preWarmStepOffset: number;
  30554. /**
  30555. * 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)
  30556. */
  30557. spriteCellChangeSpeed: number;
  30558. /**
  30559. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  30560. */
  30561. startSpriteCellID: number;
  30562. /**
  30563. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  30564. */
  30565. endSpriteCellID: number;
  30566. /**
  30567. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  30568. */
  30569. spriteCellWidth: number;
  30570. /**
  30571. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  30572. */
  30573. spriteCellHeight: number;
  30574. /**
  30575. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  30576. */
  30577. spriteRandomStartCell: boolean;
  30578. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  30579. translationPivot: Vector2;
  30580. /** @hidden */
  30581. protected _isAnimationSheetEnabled: boolean;
  30582. /**
  30583. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  30584. */
  30585. beginAnimationOnStart: boolean;
  30586. /**
  30587. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  30588. */
  30589. beginAnimationFrom: number;
  30590. /**
  30591. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  30592. */
  30593. beginAnimationTo: number;
  30594. /**
  30595. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  30596. */
  30597. beginAnimationLoop: boolean;
  30598. /**
  30599. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  30600. */
  30601. isAnimationSheetEnabled: boolean;
  30602. /**
  30603. * Get hosting scene
  30604. * @returns the scene
  30605. */
  30606. getScene(): Scene;
  30607. /**
  30608. * You can use gravity if you want to give an orientation to your particles.
  30609. */
  30610. gravity: Vector3;
  30611. protected _colorGradients: Nullable<Array<ColorGradient>>;
  30612. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  30613. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  30614. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  30615. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  30616. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  30617. protected _dragGradients: Nullable<Array<FactorGradient>>;
  30618. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  30619. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  30620. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  30621. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  30622. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  30623. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  30624. /**
  30625. * Defines the delay in milliseconds before starting the system (0 by default)
  30626. */
  30627. startDelay: number;
  30628. /**
  30629. * Gets the current list of drag gradients.
  30630. * You must use addDragGradient and removeDragGradient to udpate this list
  30631. * @returns the list of drag gradients
  30632. */
  30633. getDragGradients(): Nullable<Array<FactorGradient>>;
  30634. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  30635. limitVelocityDamping: number;
  30636. /**
  30637. * Gets the current list of limit velocity gradients.
  30638. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  30639. * @returns the list of limit velocity gradients
  30640. */
  30641. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  30642. /**
  30643. * Gets the current list of color gradients.
  30644. * You must use addColorGradient and removeColorGradient to udpate this list
  30645. * @returns the list of color gradients
  30646. */
  30647. getColorGradients(): Nullable<Array<ColorGradient>>;
  30648. /**
  30649. * Gets the current list of size gradients.
  30650. * You must use addSizeGradient and removeSizeGradient to udpate this list
  30651. * @returns the list of size gradients
  30652. */
  30653. getSizeGradients(): Nullable<Array<FactorGradient>>;
  30654. /**
  30655. * Gets the current list of color remap gradients.
  30656. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  30657. * @returns the list of color remap gradients
  30658. */
  30659. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  30660. /**
  30661. * Gets the current list of alpha remap gradients.
  30662. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  30663. * @returns the list of alpha remap gradients
  30664. */
  30665. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  30666. /**
  30667. * Gets the current list of life time gradients.
  30668. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  30669. * @returns the list of life time gradients
  30670. */
  30671. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  30672. /**
  30673. * Gets the current list of angular speed gradients.
  30674. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  30675. * @returns the list of angular speed gradients
  30676. */
  30677. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  30678. /**
  30679. * Gets the current list of velocity gradients.
  30680. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  30681. * @returns the list of velocity gradients
  30682. */
  30683. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  30684. /**
  30685. * Gets the current list of start size gradients.
  30686. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  30687. * @returns the list of start size gradients
  30688. */
  30689. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  30690. /**
  30691. * Gets the current list of emit rate gradients.
  30692. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  30693. * @returns the list of emit rate gradients
  30694. */
  30695. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  30696. /**
  30697. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  30698. * This only works when particleEmitterTyps is a BoxParticleEmitter
  30699. */
  30700. direction1: Vector3;
  30701. /**
  30702. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  30703. * This only works when particleEmitterTyps is a BoxParticleEmitter
  30704. */
  30705. direction2: Vector3;
  30706. /**
  30707. * 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.
  30708. * This only works when particleEmitterTyps is a BoxParticleEmitter
  30709. */
  30710. minEmitBox: Vector3;
  30711. /**
  30712. * 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.
  30713. * This only works when particleEmitterTyps is a BoxParticleEmitter
  30714. */
  30715. maxEmitBox: Vector3;
  30716. /**
  30717. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  30718. */
  30719. color1: Color4;
  30720. /**
  30721. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  30722. */
  30723. color2: Color4;
  30724. /**
  30725. * Color the particle will have at the end of its lifetime
  30726. */
  30727. colorDead: Color4;
  30728. /**
  30729. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  30730. */
  30731. textureMask: Color4;
  30732. /**
  30733. * The particle emitter type defines the emitter used by the particle system.
  30734. * It can be for example box, sphere, or cone...
  30735. */
  30736. particleEmitterType: IParticleEmitterType;
  30737. /** @hidden */
  30738. _isSubEmitter: boolean;
  30739. /**
  30740. * Gets or sets the billboard mode to use when isBillboardBased = true.
  30741. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  30742. */
  30743. billboardMode: number;
  30744. protected _isBillboardBased: boolean;
  30745. /**
  30746. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  30747. */
  30748. isBillboardBased: boolean;
  30749. /**
  30750. * The scene the particle system belongs to.
  30751. */
  30752. protected _scene: Scene;
  30753. /**
  30754. * Local cache of defines for image processing.
  30755. */
  30756. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  30757. /**
  30758. * Default configuration related to image processing available in the standard Material.
  30759. */
  30760. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  30761. /**
  30762. * Gets the image processing configuration used either in this material.
  30763. */
  30764. /**
  30765. * Sets the Default image processing configuration used either in the this material.
  30766. *
  30767. * If sets to null, the scene one is in use.
  30768. */
  30769. imageProcessingConfiguration: ImageProcessingConfiguration;
  30770. /**
  30771. * Attaches a new image processing configuration to the Standard Material.
  30772. * @param configuration
  30773. */
  30774. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  30775. /** @hidden */
  30776. protected _reset(): void;
  30777. /** @hidden */
  30778. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  30779. /**
  30780. * Instantiates a particle system.
  30781. * 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.
  30782. * @param name The name of the particle system
  30783. */
  30784. constructor(name: string);
  30785. /**
  30786. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  30787. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  30788. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  30789. * @returns the emitter
  30790. */
  30791. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  30792. /**
  30793. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  30794. * @param radius The radius of the hemisphere to emit from
  30795. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  30796. * @returns the emitter
  30797. */
  30798. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  30799. /**
  30800. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  30801. * @param radius The radius of the sphere to emit from
  30802. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  30803. * @returns the emitter
  30804. */
  30805. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  30806. /**
  30807. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  30808. * @param radius The radius of the sphere to emit from
  30809. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  30810. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  30811. * @returns the emitter
  30812. */
  30813. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  30814. /**
  30815. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  30816. * @param radius The radius of the emission cylinder
  30817. * @param height The height of the emission cylinder
  30818. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  30819. * @param directionRandomizer How much to randomize the particle direction [0-1]
  30820. * @returns the emitter
  30821. */
  30822. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  30823. /**
  30824. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  30825. * @param radius The radius of the cylinder to emit from
  30826. * @param height The height of the emission cylinder
  30827. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  30828. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  30829. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  30830. * @returns the emitter
  30831. */
  30832. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  30833. /**
  30834. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  30835. * @param radius The radius of the cone to emit from
  30836. * @param angle The base angle of the cone
  30837. * @returns the emitter
  30838. */
  30839. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  30840. /**
  30841. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  30842. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  30843. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  30844. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  30845. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  30846. * @returns the emitter
  30847. */
  30848. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  30849. }
  30850. }
  30851. declare module BABYLON {
  30852. /**
  30853. * This represents a GPU particle system in Babylon
  30854. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  30855. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  30856. */
  30857. class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  30858. /**
  30859. * The layer mask we are rendering the particles through.
  30860. */
  30861. layerMask: number;
  30862. private _capacity;
  30863. private _activeCount;
  30864. private _currentActiveCount;
  30865. private _accumulatedCount;
  30866. private _renderEffect;
  30867. private _updateEffect;
  30868. private _buffer0;
  30869. private _buffer1;
  30870. private _spriteBuffer;
  30871. private _updateVAO;
  30872. private _renderVAO;
  30873. private _targetIndex;
  30874. private _sourceBuffer;
  30875. private _targetBuffer;
  30876. private _engine;
  30877. private _currentRenderId;
  30878. private _started;
  30879. private _stopped;
  30880. private _timeDelta;
  30881. private _randomTexture;
  30882. private _randomTexture2;
  30883. private _attributesStrideSize;
  30884. private _updateEffectOptions;
  30885. private _randomTextureSize;
  30886. private _actualFrame;
  30887. private readonly _rawTextureWidth;
  30888. /**
  30889. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  30890. */
  30891. static readonly IsSupported: boolean;
  30892. /**
  30893. * An event triggered when the system is disposed.
  30894. */
  30895. onDisposeObservable: Observable<GPUParticleSystem>;
  30896. /**
  30897. * Gets the maximum number of particles active at the same time.
  30898. * @returns The max number of active particles.
  30899. */
  30900. getCapacity(): number;
  30901. /**
  30902. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  30903. * to override the particles.
  30904. */
  30905. forceDepthWrite: boolean;
  30906. /**
  30907. * Gets or set the number of active particles
  30908. */
  30909. activeParticleCount: number;
  30910. private _preWarmDone;
  30911. /**
  30912. * Is this system ready to be used/rendered
  30913. * @return true if the system is ready
  30914. */
  30915. isReady(): boolean;
  30916. /**
  30917. * Gets if the system has been started. (Note: this will still be true after stop is called)
  30918. * @returns True if it has been started, otherwise false.
  30919. */
  30920. isStarted(): boolean;
  30921. /**
  30922. * Starts the particle system and begins to emit
  30923. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  30924. */
  30925. start(delay?: number): void;
  30926. /**
  30927. * Stops the particle system.
  30928. */
  30929. stop(): void;
  30930. /**
  30931. * Remove all active particles
  30932. */
  30933. reset(): void;
  30934. /**
  30935. * Returns the string "GPUParticleSystem"
  30936. * @returns a string containing the class name
  30937. */
  30938. getClassName(): string;
  30939. private _colorGradientsTexture;
  30940. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  30941. /**
  30942. * Adds a new color gradient
  30943. * @param gradient defines the gradient to use (between 0 and 1)
  30944. * @param color1 defines the color to affect to the specified gradient
  30945. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  30946. * @returns the current particle system
  30947. */
  30948. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  30949. /**
  30950. * Remove a specific color gradient
  30951. * @param gradient defines the gradient to remove
  30952. * @returns the current particle system
  30953. */
  30954. removeColorGradient(gradient: number): GPUParticleSystem;
  30955. private _angularSpeedGradientsTexture;
  30956. private _sizeGradientsTexture;
  30957. private _velocityGradientsTexture;
  30958. private _limitVelocityGradientsTexture;
  30959. private _dragGradientsTexture;
  30960. private _addFactorGradient;
  30961. /**
  30962. * Adds a new size gradient
  30963. * @param gradient defines the gradient to use (between 0 and 1)
  30964. * @param factor defines the size factor to affect to the specified gradient
  30965. * @returns the current particle system
  30966. */
  30967. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  30968. /**
  30969. * Remove a specific size gradient
  30970. * @param gradient defines the gradient to remove
  30971. * @returns the current particle system
  30972. */
  30973. removeSizeGradient(gradient: number): GPUParticleSystem;
  30974. /**
  30975. * Adds a new angular speed gradient
  30976. * @param gradient defines the gradient to use (between 0 and 1)
  30977. * @param factor defines the angular speed to affect to the specified gradient
  30978. * @returns the current particle system
  30979. */
  30980. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  30981. /**
  30982. * Remove a specific angular speed gradient
  30983. * @param gradient defines the gradient to remove
  30984. * @returns the current particle system
  30985. */
  30986. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  30987. /**
  30988. * Adds a new velocity gradient
  30989. * @param gradient defines the gradient to use (between 0 and 1)
  30990. * @param factor defines the velocity to affect to the specified gradient
  30991. * @returns the current particle system
  30992. */
  30993. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  30994. /**
  30995. * Remove a specific velocity gradient
  30996. * @param gradient defines the gradient to remove
  30997. * @returns the current particle system
  30998. */
  30999. removeVelocityGradient(gradient: number): GPUParticleSystem;
  31000. /**
  31001. * Adds a new limit velocity gradient
  31002. * @param gradient defines the gradient to use (between 0 and 1)
  31003. * @param factor defines the limit velocity value to affect to the specified gradient
  31004. * @returns the current particle system
  31005. */
  31006. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  31007. /**
  31008. * Remove a specific limit velocity gradient
  31009. * @param gradient defines the gradient to remove
  31010. * @returns the current particle system
  31011. */
  31012. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  31013. /**
  31014. * Adds a new drag gradient
  31015. * @param gradient defines the gradient to use (between 0 and 1)
  31016. * @param factor defines the drag value to affect to the specified gradient
  31017. * @returns the current particle system
  31018. */
  31019. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  31020. /**
  31021. * Remove a specific drag gradient
  31022. * @param gradient defines the gradient to remove
  31023. * @returns the current particle system
  31024. */
  31025. removeDragGradient(gradient: number): GPUParticleSystem;
  31026. /**
  31027. * Not supported by GPUParticleSystem
  31028. * @param gradient defines the gradient to use (between 0 and 1)
  31029. * @param factor defines the emit rate value to affect to the specified gradient
  31030. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31031. * @returns the current particle system
  31032. */
  31033. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31034. /**
  31035. * Not supported by GPUParticleSystem
  31036. * @param gradient defines the gradient to remove
  31037. * @returns the current particle system
  31038. */
  31039. removeEmitRateGradient(gradient: number): IParticleSystem;
  31040. /**
  31041. * Not supported by GPUParticleSystem
  31042. * @param gradient defines the gradient to use (between 0 and 1)
  31043. * @param factor defines the start size value to affect to the specified gradient
  31044. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31045. * @returns the current particle system
  31046. */
  31047. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31048. /**
  31049. * Not supported by GPUParticleSystem
  31050. * @param gradient defines the gradient to remove
  31051. * @returns the current particle system
  31052. */
  31053. removeStartSizeGradient(gradient: number): IParticleSystem;
  31054. /**
  31055. * Not supported by GPUParticleSystem
  31056. * @param gradient defines the gradient to use (between 0 and 1)
  31057. * @param min defines the color remap minimal range
  31058. * @param max defines the color remap maximal range
  31059. * @returns the current particle system
  31060. */
  31061. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  31062. /**
  31063. * Not supported by GPUParticleSystem
  31064. * @param gradient defines the gradient to remove
  31065. * @returns the current particle system
  31066. */
  31067. removeColorRemapGradient(gradient: number): IParticleSystem;
  31068. /**
  31069. * Not supported by GPUParticleSystem
  31070. * @param gradient defines the gradient to use (between 0 and 1)
  31071. * @param min defines the alpha remap minimal range
  31072. * @param max defines the alpha remap maximal range
  31073. * @returns the current particle system
  31074. */
  31075. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  31076. /**
  31077. * Not supported by GPUParticleSystem
  31078. * @param gradient defines the gradient to remove
  31079. * @returns the current particle system
  31080. */
  31081. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  31082. /**
  31083. * Not supported by GPUParticleSystem
  31084. * @param gradient defines the gradient to use (between 0 and 1)
  31085. * @param color defines the color to affect to the specified gradient
  31086. * @returns the current particle system
  31087. */
  31088. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  31089. /**
  31090. * Not supported by GPUParticleSystem
  31091. * @param gradient defines the gradient to remove
  31092. * @returns the current particle system
  31093. */
  31094. removeRampGradient(gradient: number): IParticleSystem;
  31095. /**
  31096. * Not supported by GPUParticleSystem
  31097. * @returns the list of ramp gradients
  31098. */
  31099. getRampGradients(): Nullable<Array<Color3Gradient>>;
  31100. /**
  31101. * Not supported by GPUParticleSystem
  31102. * Gets or sets a boolean indicating that ramp gradients must be used
  31103. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  31104. */
  31105. useRampGradients: boolean;
  31106. /**
  31107. * Not supported by GPUParticleSystem
  31108. * @param gradient defines the gradient to use (between 0 and 1)
  31109. * @param factor defines the life time factor to affect to the specified gradient
  31110. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31111. * @returns the current particle system
  31112. */
  31113. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31114. /**
  31115. * Not supported by GPUParticleSystem
  31116. * @param gradient defines the gradient to remove
  31117. * @returns the current particle system
  31118. */
  31119. removeLifeTimeGradient(gradient: number): IParticleSystem;
  31120. /**
  31121. * Instantiates a GPU particle system.
  31122. * 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.
  31123. * @param name The name of the particle system
  31124. * @param options The options used to create the system
  31125. * @param scene The scene the particle system belongs to
  31126. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  31127. */
  31128. constructor(name: string, options: Partial<{
  31129. capacity: number;
  31130. randomTextureSize: number;
  31131. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  31132. protected _reset(): void;
  31133. private _createUpdateVAO;
  31134. private _createRenderVAO;
  31135. private _initialize;
  31136. /** @hidden */
  31137. _recreateUpdateEffect(): void;
  31138. /** @hidden */
  31139. _recreateRenderEffect(): void;
  31140. /**
  31141. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  31142. * @param preWarm defines if we are in the pre-warmimg phase
  31143. */
  31144. animate(preWarm?: boolean): void;
  31145. private _createFactorGradientTexture;
  31146. private _createSizeGradientTexture;
  31147. private _createAngularSpeedGradientTexture;
  31148. private _createVelocityGradientTexture;
  31149. private _createLimitVelocityGradientTexture;
  31150. private _createDragGradientTexture;
  31151. private _createColorGradientTexture;
  31152. /**
  31153. * Renders the particle system in its current state
  31154. * @param preWarm defines if the system should only update the particles but not render them
  31155. * @returns the current number of particles
  31156. */
  31157. render(preWarm?: boolean): number;
  31158. /**
  31159. * Rebuilds the particle system
  31160. */
  31161. rebuild(): void;
  31162. private _releaseBuffers;
  31163. private _releaseVAOs;
  31164. /**
  31165. * Disposes the particle system and free the associated resources
  31166. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  31167. */
  31168. dispose(disposeTexture?: boolean): void;
  31169. /**
  31170. * Clones the particle system.
  31171. * @param name The name of the cloned object
  31172. * @param newEmitter The new emitter to use
  31173. * @returns the cloned particle system
  31174. */
  31175. clone(name: string, newEmitter: any): GPUParticleSystem;
  31176. /**
  31177. * Serializes the particle system to a JSON object.
  31178. * @returns the JSON object
  31179. */
  31180. serialize(): any;
  31181. /**
  31182. * Parses a JSON object to create a GPU particle system.
  31183. * @param parsedParticleSystem The JSON object to parse
  31184. * @param scene The scene to create the particle system in
  31185. * @param rootUrl The root url to use to load external dependencies like texture
  31186. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  31187. * @returns the parsed GPU particle system
  31188. */
  31189. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  31190. }
  31191. }
  31192. declare module BABYLON {
  31193. /**
  31194. * Interface representing a particle system in Babylon.js.
  31195. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  31196. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  31197. */
  31198. interface IParticleSystem {
  31199. /**
  31200. * List of animations used by the particle system.
  31201. */
  31202. animations: Animation[];
  31203. /**
  31204. * The id of the Particle system.
  31205. */
  31206. id: string;
  31207. /**
  31208. * The name of the Particle system.
  31209. */
  31210. name: string;
  31211. /**
  31212. * The emitter represents the Mesh or position we are attaching the particle system to.
  31213. */
  31214. emitter: Nullable<AbstractMesh | Vector3>;
  31215. /**
  31216. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  31217. */
  31218. isBillboardBased: boolean;
  31219. /**
  31220. * The rendering group used by the Particle system to chose when to render.
  31221. */
  31222. renderingGroupId: number;
  31223. /**
  31224. * The layer mask we are rendering the particles through.
  31225. */
  31226. layerMask: number;
  31227. /**
  31228. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  31229. */
  31230. updateSpeed: number;
  31231. /**
  31232. * The amount of time the particle system is running (depends of the overall update speed).
  31233. */
  31234. targetStopDuration: number;
  31235. /**
  31236. * The texture used to render each particle. (this can be a spritesheet)
  31237. */
  31238. particleTexture: Nullable<Texture>;
  31239. /**
  31240. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  31241. */
  31242. blendMode: number;
  31243. /**
  31244. * Minimum life time of emitting particles.
  31245. */
  31246. minLifeTime: number;
  31247. /**
  31248. * Maximum life time of emitting particles.
  31249. */
  31250. maxLifeTime: number;
  31251. /**
  31252. * Minimum Size of emitting particles.
  31253. */
  31254. minSize: number;
  31255. /**
  31256. * Maximum Size of emitting particles.
  31257. */
  31258. maxSize: number;
  31259. /**
  31260. * Minimum scale of emitting particles on X axis.
  31261. */
  31262. minScaleX: number;
  31263. /**
  31264. * Maximum scale of emitting particles on X axis.
  31265. */
  31266. maxScaleX: number;
  31267. /**
  31268. * Minimum scale of emitting particles on Y axis.
  31269. */
  31270. minScaleY: number;
  31271. /**
  31272. * Maximum scale of emitting particles on Y axis.
  31273. */
  31274. maxScaleY: number;
  31275. /**
  31276. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  31277. */
  31278. color1: Color4;
  31279. /**
  31280. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  31281. */
  31282. color2: Color4;
  31283. /**
  31284. * Color the particle will have at the end of its lifetime.
  31285. */
  31286. colorDead: Color4;
  31287. /**
  31288. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  31289. */
  31290. emitRate: number;
  31291. /**
  31292. * You can use gravity if you want to give an orientation to your particles.
  31293. */
  31294. gravity: Vector3;
  31295. /**
  31296. * Minimum power of emitting particles.
  31297. */
  31298. minEmitPower: number;
  31299. /**
  31300. * Maximum power of emitting particles.
  31301. */
  31302. maxEmitPower: number;
  31303. /**
  31304. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  31305. */
  31306. minAngularSpeed: number;
  31307. /**
  31308. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  31309. */
  31310. maxAngularSpeed: number;
  31311. /**
  31312. * Gets or sets the minimal initial rotation in radians.
  31313. */
  31314. minInitialRotation: number;
  31315. /**
  31316. * Gets or sets the maximal initial rotation in radians.
  31317. */
  31318. maxInitialRotation: number;
  31319. /**
  31320. * The particle emitter type defines the emitter used by the particle system.
  31321. * It can be for example box, sphere, or cone...
  31322. */
  31323. particleEmitterType: Nullable<IParticleEmitterType>;
  31324. /**
  31325. * Defines the delay in milliseconds before starting the system (0 by default)
  31326. */
  31327. startDelay: number;
  31328. /**
  31329. * 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
  31330. */
  31331. preWarmCycles: number;
  31332. /**
  31333. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  31334. */
  31335. preWarmStepOffset: number;
  31336. /**
  31337. * 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)
  31338. */
  31339. spriteCellChangeSpeed: number;
  31340. /**
  31341. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  31342. */
  31343. startSpriteCellID: number;
  31344. /**
  31345. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  31346. */
  31347. endSpriteCellID: number;
  31348. /**
  31349. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  31350. */
  31351. spriteCellWidth: number;
  31352. /**
  31353. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  31354. */
  31355. spriteCellHeight: number;
  31356. /**
  31357. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  31358. */
  31359. spriteRandomStartCell: boolean;
  31360. /**
  31361. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  31362. */
  31363. isAnimationSheetEnabled: boolean;
  31364. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  31365. translationPivot: Vector2;
  31366. /**
  31367. * Gets or sets a texture used to add random noise to particle positions
  31368. */
  31369. noiseTexture: Nullable<BaseTexture>;
  31370. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  31371. noiseStrength: Vector3;
  31372. /**
  31373. * Gets or sets the billboard mode to use when isBillboardBased = true.
  31374. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  31375. */
  31376. billboardMode: number;
  31377. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  31378. limitVelocityDamping: number;
  31379. /**
  31380. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  31381. */
  31382. beginAnimationOnStart: boolean;
  31383. /**
  31384. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  31385. */
  31386. beginAnimationFrom: number;
  31387. /**
  31388. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  31389. */
  31390. beginAnimationTo: number;
  31391. /**
  31392. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  31393. */
  31394. beginAnimationLoop: boolean;
  31395. /**
  31396. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  31397. */
  31398. disposeOnStop: boolean;
  31399. /**
  31400. * Gets the maximum number of particles active at the same time.
  31401. * @returns The max number of active particles.
  31402. */
  31403. getCapacity(): number;
  31404. /**
  31405. * Gets if the system has been started. (Note: this will still be true after stop is called)
  31406. * @returns True if it has been started, otherwise false.
  31407. */
  31408. isStarted(): boolean;
  31409. /**
  31410. * Animates the particle system for this frame.
  31411. */
  31412. animate(): void;
  31413. /**
  31414. * Renders the particle system in its current state.
  31415. * @returns the current number of particles
  31416. */
  31417. render(): number;
  31418. /**
  31419. * Dispose the particle system and frees its associated resources.
  31420. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  31421. */
  31422. dispose(disposeTexture?: boolean): void;
  31423. /**
  31424. * Clones the particle system.
  31425. * @param name The name of the cloned object
  31426. * @param newEmitter The new emitter to use
  31427. * @returns the cloned particle system
  31428. */
  31429. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  31430. /**
  31431. * Serializes the particle system to a JSON object.
  31432. * @returns the JSON object
  31433. */
  31434. serialize(): any;
  31435. /**
  31436. * Rebuild the particle system
  31437. */
  31438. rebuild(): void;
  31439. /**
  31440. * Starts the particle system and begins to emit
  31441. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  31442. */
  31443. start(delay?: number): void;
  31444. /**
  31445. * Stops the particle system.
  31446. */
  31447. stop(): void;
  31448. /**
  31449. * Remove all active particles
  31450. */
  31451. reset(): void;
  31452. /**
  31453. * Is this system ready to be used/rendered
  31454. * @return true if the system is ready
  31455. */
  31456. isReady(): boolean;
  31457. /**
  31458. * Adds a new color gradient
  31459. * @param gradient defines the gradient to use (between 0 and 1)
  31460. * @param color1 defines the color to affect to the specified gradient
  31461. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  31462. * @returns the current particle system
  31463. */
  31464. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  31465. /**
  31466. * Remove a specific color gradient
  31467. * @param gradient defines the gradient to remove
  31468. * @returns the current particle system
  31469. */
  31470. removeColorGradient(gradient: number): IParticleSystem;
  31471. /**
  31472. * Adds a new size gradient
  31473. * @param gradient defines the gradient to use (between 0 and 1)
  31474. * @param factor defines the size factor to affect to the specified gradient
  31475. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31476. * @returns the current particle system
  31477. */
  31478. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31479. /**
  31480. * Remove a specific size gradient
  31481. * @param gradient defines the gradient to remove
  31482. * @returns the current particle system
  31483. */
  31484. removeSizeGradient(gradient: number): IParticleSystem;
  31485. /**
  31486. * Gets the current list of color gradients.
  31487. * You must use addColorGradient and removeColorGradient to udpate this list
  31488. * @returns the list of color gradients
  31489. */
  31490. getColorGradients(): Nullable<Array<ColorGradient>>;
  31491. /**
  31492. * Gets the current list of size gradients.
  31493. * You must use addSizeGradient and removeSizeGradient to udpate this list
  31494. * @returns the list of size gradients
  31495. */
  31496. getSizeGradients(): Nullable<Array<FactorGradient>>;
  31497. /**
  31498. * Gets the current list of angular speed gradients.
  31499. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  31500. * @returns the list of angular speed gradients
  31501. */
  31502. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  31503. /**
  31504. * Adds a new angular speed gradient
  31505. * @param gradient defines the gradient to use (between 0 and 1)
  31506. * @param factor defines the angular speed to affect to the specified gradient
  31507. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31508. * @returns the current particle system
  31509. */
  31510. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31511. /**
  31512. * Remove a specific angular speed gradient
  31513. * @param gradient defines the gradient to remove
  31514. * @returns the current particle system
  31515. */
  31516. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  31517. /**
  31518. * Gets the current list of velocity gradients.
  31519. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  31520. * @returns the list of velocity gradients
  31521. */
  31522. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  31523. /**
  31524. * Adds a new velocity gradient
  31525. * @param gradient defines the gradient to use (between 0 and 1)
  31526. * @param factor defines the velocity to affect to the specified gradient
  31527. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31528. * @returns the current particle system
  31529. */
  31530. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31531. /**
  31532. * Remove a specific velocity gradient
  31533. * @param gradient defines the gradient to remove
  31534. * @returns the current particle system
  31535. */
  31536. removeVelocityGradient(gradient: number): IParticleSystem;
  31537. /**
  31538. * Gets the current list of limit velocity gradients.
  31539. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  31540. * @returns the list of limit velocity gradients
  31541. */
  31542. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  31543. /**
  31544. * Adds a new limit velocity gradient
  31545. * @param gradient defines the gradient to use (between 0 and 1)
  31546. * @param factor defines the limit velocity to affect to the specified gradient
  31547. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31548. * @returns the current particle system
  31549. */
  31550. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31551. /**
  31552. * Remove a specific limit velocity gradient
  31553. * @param gradient defines the gradient to remove
  31554. * @returns the current particle system
  31555. */
  31556. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  31557. /**
  31558. * Adds a new drag gradient
  31559. * @param gradient defines the gradient to use (between 0 and 1)
  31560. * @param factor defines the drag to affect to the specified gradient
  31561. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31562. * @returns the current particle system
  31563. */
  31564. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31565. /**
  31566. * Remove a specific drag gradient
  31567. * @param gradient defines the gradient to remove
  31568. * @returns the current particle system
  31569. */
  31570. removeDragGradient(gradient: number): IParticleSystem;
  31571. /**
  31572. * Gets the current list of drag gradients.
  31573. * You must use addDragGradient and removeDragGradient to udpate this list
  31574. * @returns the list of drag gradients
  31575. */
  31576. getDragGradients(): Nullable<Array<FactorGradient>>;
  31577. /**
  31578. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  31579. * @param gradient defines the gradient to use (between 0 and 1)
  31580. * @param factor defines the emit rate to affect to the specified gradient
  31581. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31582. * @returns the current particle system
  31583. */
  31584. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31585. /**
  31586. * Remove a specific emit rate gradient
  31587. * @param gradient defines the gradient to remove
  31588. * @returns the current particle system
  31589. */
  31590. removeEmitRateGradient(gradient: number): IParticleSystem;
  31591. /**
  31592. * Gets the current list of emit rate gradients.
  31593. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  31594. * @returns the list of emit rate gradients
  31595. */
  31596. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  31597. /**
  31598. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  31599. * @param gradient defines the gradient to use (between 0 and 1)
  31600. * @param factor defines the start size to affect to the specified gradient
  31601. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31602. * @returns the current particle system
  31603. */
  31604. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31605. /**
  31606. * Remove a specific start size gradient
  31607. * @param gradient defines the gradient to remove
  31608. * @returns the current particle system
  31609. */
  31610. removeStartSizeGradient(gradient: number): IParticleSystem;
  31611. /**
  31612. * Gets the current list of start size gradients.
  31613. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  31614. * @returns the list of start size gradients
  31615. */
  31616. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  31617. /**
  31618. * Adds a new life time gradient
  31619. * @param gradient defines the gradient to use (between 0 and 1)
  31620. * @param factor defines the life time factor to affect to the specified gradient
  31621. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31622. * @returns the current particle system
  31623. */
  31624. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31625. /**
  31626. * Remove a specific life time gradient
  31627. * @param gradient defines the gradient to remove
  31628. * @returns the current particle system
  31629. */
  31630. removeLifeTimeGradient(gradient: number): IParticleSystem;
  31631. /**
  31632. * Gets the current list of life time gradients.
  31633. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  31634. * @returns the list of life time gradients
  31635. */
  31636. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  31637. /**
  31638. * Gets the current list of color gradients.
  31639. * You must use addColorGradient and removeColorGradient to udpate this list
  31640. * @returns the list of color gradients
  31641. */
  31642. getColorGradients(): Nullable<Array<ColorGradient>>;
  31643. /**
  31644. * Adds a new ramp gradient used to remap particle colors
  31645. * @param gradient defines the gradient to use (between 0 and 1)
  31646. * @param color defines the color to affect to the specified gradient
  31647. * @returns the current particle system
  31648. */
  31649. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  31650. /**
  31651. * Gets the current list of ramp gradients.
  31652. * You must use addRampGradient and removeRampGradient to udpate this list
  31653. * @returns the list of ramp gradients
  31654. */
  31655. getRampGradients(): Nullable<Array<Color3Gradient>>;
  31656. /** Gets or sets a boolean indicating that ramp gradients must be used
  31657. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  31658. */
  31659. useRampGradients: boolean;
  31660. /**
  31661. * Adds a new color remap gradient
  31662. * @param gradient defines the gradient to use (between 0 and 1)
  31663. * @param min defines the color remap minimal range
  31664. * @param max defines the color remap maximal range
  31665. * @returns the current particle system
  31666. */
  31667. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  31668. /**
  31669. * Gets the current list of color remap gradients.
  31670. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  31671. * @returns the list of color remap gradients
  31672. */
  31673. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  31674. /**
  31675. * Adds a new alpha remap gradient
  31676. * @param gradient defines the gradient to use (between 0 and 1)
  31677. * @param min defines the alpha remap minimal range
  31678. * @param max defines the alpha remap maximal range
  31679. * @returns the current particle system
  31680. */
  31681. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  31682. /**
  31683. * Gets the current list of alpha remap gradients.
  31684. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  31685. * @returns the list of alpha remap gradients
  31686. */
  31687. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  31688. /**
  31689. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  31690. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  31691. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  31692. * @returns the emitter
  31693. */
  31694. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  31695. /**
  31696. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  31697. * @param radius The radius of the hemisphere to emit from
  31698. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  31699. * @returns the emitter
  31700. */
  31701. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  31702. /**
  31703. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  31704. * @param radius The radius of the sphere to emit from
  31705. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  31706. * @returns the emitter
  31707. */
  31708. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  31709. /**
  31710. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  31711. * @param radius The radius of the sphere to emit from
  31712. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  31713. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  31714. * @returns the emitter
  31715. */
  31716. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  31717. /**
  31718. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  31719. * @param radius The radius of the emission cylinder
  31720. * @param height The height of the emission cylinder
  31721. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  31722. * @param directionRandomizer How much to randomize the particle direction [0-1]
  31723. * @returns the emitter
  31724. */
  31725. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  31726. /**
  31727. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  31728. * @param radius The radius of the cylinder to emit from
  31729. * @param height The height of the emission cylinder
  31730. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  31731. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  31732. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  31733. * @returns the emitter
  31734. */
  31735. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  31736. /**
  31737. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  31738. * @param radius The radius of the cone to emit from
  31739. * @param angle The base angle of the cone
  31740. * @returns the emitter
  31741. */
  31742. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  31743. /**
  31744. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  31745. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  31746. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  31747. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  31748. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  31749. * @returns the emitter
  31750. */
  31751. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  31752. /**
  31753. * Get hosting scene
  31754. * @returns the scene
  31755. */
  31756. getScene(): Scene;
  31757. }
  31758. }
  31759. declare module BABYLON {
  31760. /**
  31761. * A particle represents one of the element emitted by a particle system.
  31762. * This is mainly define by its coordinates, direction, velocity and age.
  31763. */
  31764. class Particle {
  31765. /**
  31766. * The particle system the particle belongs to.
  31767. */
  31768. particleSystem: ParticleSystem;
  31769. private static _Count;
  31770. /**
  31771. * Unique ID of the particle
  31772. */
  31773. id: number;
  31774. /**
  31775. * The world position of the particle in the scene.
  31776. */
  31777. position: Vector3;
  31778. /**
  31779. * The world direction of the particle in the scene.
  31780. */
  31781. direction: Vector3;
  31782. /**
  31783. * The color of the particle.
  31784. */
  31785. color: Color4;
  31786. /**
  31787. * The color change of the particle per step.
  31788. */
  31789. colorStep: Color4;
  31790. /**
  31791. * Defines how long will the life of the particle be.
  31792. */
  31793. lifeTime: number;
  31794. /**
  31795. * The current age of the particle.
  31796. */
  31797. age: number;
  31798. /**
  31799. * The current size of the particle.
  31800. */
  31801. size: number;
  31802. /**
  31803. * The current scale of the particle.
  31804. */
  31805. scale: Vector2;
  31806. /**
  31807. * The current angle of the particle.
  31808. */
  31809. angle: number;
  31810. /**
  31811. * Defines how fast is the angle changing.
  31812. */
  31813. angularSpeed: number;
  31814. /**
  31815. * Defines the cell index used by the particle to be rendered from a sprite.
  31816. */
  31817. cellIndex: number;
  31818. /**
  31819. * The information required to support color remapping
  31820. */
  31821. remapData: Vector4;
  31822. /** @hidden */
  31823. _randomCellOffset?: number;
  31824. /** @hidden */
  31825. _initialDirection: Nullable<Vector3>;
  31826. /** @hidden */
  31827. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  31828. /** @hidden */
  31829. _initialStartSpriteCellID: number;
  31830. /** @hidden */
  31831. _initialEndSpriteCellID: number;
  31832. /** @hidden */
  31833. _currentColorGradient: Nullable<ColorGradient>;
  31834. /** @hidden */
  31835. _currentColor1: Color4;
  31836. /** @hidden */
  31837. _currentColor2: Color4;
  31838. /** @hidden */
  31839. _currentSizeGradient: Nullable<FactorGradient>;
  31840. /** @hidden */
  31841. _currentSize1: number;
  31842. /** @hidden */
  31843. _currentSize2: number;
  31844. /** @hidden */
  31845. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  31846. /** @hidden */
  31847. _currentAngularSpeed1: number;
  31848. /** @hidden */
  31849. _currentAngularSpeed2: number;
  31850. /** @hidden */
  31851. _currentVelocityGradient: Nullable<FactorGradient>;
  31852. /** @hidden */
  31853. _currentVelocity1: number;
  31854. /** @hidden */
  31855. _currentVelocity2: number;
  31856. /** @hidden */
  31857. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  31858. /** @hidden */
  31859. _currentLimitVelocity1: number;
  31860. /** @hidden */
  31861. _currentLimitVelocity2: number;
  31862. /** @hidden */
  31863. _currentDragGradient: Nullable<FactorGradient>;
  31864. /** @hidden */
  31865. _currentDrag1: number;
  31866. /** @hidden */
  31867. _currentDrag2: number;
  31868. /** @hidden */
  31869. _randomNoiseCoordinates1: Vector3;
  31870. /** @hidden */
  31871. _randomNoiseCoordinates2: Vector3;
  31872. /**
  31873. * Creates a new instance Particle
  31874. * @param particleSystem the particle system the particle belongs to
  31875. */
  31876. constructor(
  31877. /**
  31878. * The particle system the particle belongs to.
  31879. */
  31880. particleSystem: ParticleSystem);
  31881. private updateCellInfoFromSystem;
  31882. /**
  31883. * Defines how the sprite cell index is updated for the particle
  31884. */
  31885. updateCellIndex(): void;
  31886. /** @hidden */
  31887. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  31888. /** @hidden */
  31889. _inheritParticleInfoToSubEmitters(): void;
  31890. /** @hidden */
  31891. _reset(): void;
  31892. /**
  31893. * Copy the properties of particle to another one.
  31894. * @param other the particle to copy the information to.
  31895. */
  31896. copyTo(other: Particle): void;
  31897. }
  31898. }
  31899. declare module BABYLON {
  31900. /**
  31901. * This class is made for on one-liner static method to help creating particle system set.
  31902. */
  31903. class ParticleHelper {
  31904. /**
  31905. * Gets or sets base Assets URL
  31906. */
  31907. static BaseAssetsUrl: string;
  31908. /**
  31909. * Create a default particle system that you can tweak
  31910. * @param emitter defines the emitter to use
  31911. * @param capacity defines the system capacity (default is 500 particles)
  31912. * @param scene defines the hosting scene
  31913. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  31914. * @returns the new Particle system
  31915. */
  31916. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  31917. /**
  31918. * This is the main static method (one-liner) of this helper to create different particle systems
  31919. * @param type This string represents the type to the particle system to create
  31920. * @param scene The scene where the particle system should live
  31921. * @param gpu If the system will use gpu
  31922. * @returns the ParticleSystemSet created
  31923. */
  31924. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  31925. /**
  31926. * Static function used to export a particle system to a ParticleSystemSet variable.
  31927. * Please note that the emitter shape is not exported
  31928. * @param systems defines the particle systems to export
  31929. * @returns the created particle system set
  31930. */
  31931. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  31932. }
  31933. }
  31934. declare module BABYLON {
  31935. /**
  31936. * This represents a particle system in Babylon.
  31937. * 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.
  31938. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  31939. * @example https://doc.babylonjs.com/babylon101/particles
  31940. */
  31941. class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  31942. /**
  31943. * Billboard mode will only apply to Y axis
  31944. */
  31945. static readonly BILLBOARDMODE_Y: number;
  31946. /**
  31947. * Billboard mode will apply to all axes
  31948. */
  31949. static readonly BILLBOARDMODE_ALL: number;
  31950. /**
  31951. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  31952. */
  31953. static readonly BILLBOARDMODE_STRETCHED: number;
  31954. /**
  31955. * This function can be defined to provide custom update for active particles.
  31956. * This function will be called instead of regular update (age, position, color, etc.).
  31957. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  31958. */
  31959. updateFunction: (particles: Particle[]) => void;
  31960. private _emitterWorldMatrix;
  31961. /**
  31962. * This function can be defined to specify initial direction for every new particle.
  31963. * It by default use the emitterType defined function
  31964. */
  31965. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  31966. /**
  31967. * This function can be defined to specify initial position for every new particle.
  31968. * It by default use the emitterType defined function
  31969. */
  31970. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  31971. /**
  31972. * @hidden
  31973. */
  31974. _inheritedVelocityOffset: Vector3;
  31975. /**
  31976. * An event triggered when the system is disposed
  31977. */
  31978. onDisposeObservable: Observable<ParticleSystem>;
  31979. private _onDisposeObserver;
  31980. /**
  31981. * Sets a callback that will be triggered when the system is disposed
  31982. */
  31983. onDispose: () => void;
  31984. private _particles;
  31985. private _epsilon;
  31986. private _capacity;
  31987. private _stockParticles;
  31988. private _newPartsExcess;
  31989. private _vertexData;
  31990. private _vertexBuffer;
  31991. private _vertexBuffers;
  31992. private _spriteBuffer;
  31993. private _indexBuffer;
  31994. private _effect;
  31995. private _customEffect;
  31996. private _cachedDefines;
  31997. private _scaledColorStep;
  31998. private _colorDiff;
  31999. private _scaledDirection;
  32000. private _scaledGravity;
  32001. private _currentRenderId;
  32002. private _alive;
  32003. private _useInstancing;
  32004. private _started;
  32005. private _stopped;
  32006. private _actualFrame;
  32007. private _scaledUpdateSpeed;
  32008. private _vertexBufferSize;
  32009. /** @hidden */
  32010. _currentEmitRateGradient: Nullable<FactorGradient>;
  32011. /** @hidden */
  32012. _currentEmitRate1: number;
  32013. /** @hidden */
  32014. _currentEmitRate2: number;
  32015. /** @hidden */
  32016. _currentStartSizeGradient: Nullable<FactorGradient>;
  32017. /** @hidden */
  32018. _currentStartSize1: number;
  32019. /** @hidden */
  32020. _currentStartSize2: number;
  32021. private readonly _rawTextureWidth;
  32022. private _rampGradientsTexture;
  32023. private _useRampGradients;
  32024. /** Gets or sets a boolean indicating that ramp gradients must be used
  32025. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  32026. */
  32027. useRampGradients: boolean;
  32028. /**
  32029. * 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.
  32030. * 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: [])
  32031. */
  32032. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  32033. private _subEmitters;
  32034. /**
  32035. * @hidden
  32036. * If the particle systems emitter should be disposed when the particle system is disposed
  32037. */
  32038. _disposeEmitterOnDispose: boolean;
  32039. /**
  32040. * The current active Sub-systems, this property is used by the root particle system only.
  32041. */
  32042. activeSubSystems: Array<ParticleSystem>;
  32043. private _rootParticleSystem;
  32044. /**
  32045. * Gets the current list of active particles
  32046. */
  32047. readonly particles: Particle[];
  32048. /**
  32049. * Returns the string "ParticleSystem"
  32050. * @returns a string containing the class name
  32051. */
  32052. getClassName(): string;
  32053. /**
  32054. * Instantiates a particle system.
  32055. * 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.
  32056. * @param name The name of the particle system
  32057. * @param capacity The max number of particles alive at the same time
  32058. * @param scene The scene the particle system belongs to
  32059. * @param customEffect a custom effect used to change the way particles are rendered by default
  32060. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  32061. * @param epsilon Offset used to render the particles
  32062. */
  32063. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  32064. private _addFactorGradient;
  32065. private _removeFactorGradient;
  32066. /**
  32067. * Adds a new life time gradient
  32068. * @param gradient defines the gradient to use (between 0 and 1)
  32069. * @param factor defines the life time factor to affect to the specified gradient
  32070. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32071. * @returns the current particle system
  32072. */
  32073. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32074. /**
  32075. * Remove a specific life time gradient
  32076. * @param gradient defines the gradient to remove
  32077. * @returns the current particle system
  32078. */
  32079. removeLifeTimeGradient(gradient: number): IParticleSystem;
  32080. /**
  32081. * Adds a new size gradient
  32082. * @param gradient defines the gradient to use (between 0 and 1)
  32083. * @param factor defines the size factor to affect to the specified gradient
  32084. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32085. * @returns the current particle system
  32086. */
  32087. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32088. /**
  32089. * Remove a specific size gradient
  32090. * @param gradient defines the gradient to remove
  32091. * @returns the current particle system
  32092. */
  32093. removeSizeGradient(gradient: number): IParticleSystem;
  32094. /**
  32095. * Adds a new color remap gradient
  32096. * @param gradient defines the gradient to use (between 0 and 1)
  32097. * @param min defines the color remap minimal range
  32098. * @param max defines the color remap maximal range
  32099. * @returns the current particle system
  32100. */
  32101. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  32102. /**
  32103. * Remove a specific color remap gradient
  32104. * @param gradient defines the gradient to remove
  32105. * @returns the current particle system
  32106. */
  32107. removeColorRemapGradient(gradient: number): IParticleSystem;
  32108. /**
  32109. * Adds a new alpha remap gradient
  32110. * @param gradient defines the gradient to use (between 0 and 1)
  32111. * @param min defines the alpha remap minimal range
  32112. * @param max defines the alpha remap maximal range
  32113. * @returns the current particle system
  32114. */
  32115. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  32116. /**
  32117. * Remove a specific alpha remap gradient
  32118. * @param gradient defines the gradient to remove
  32119. * @returns the current particle system
  32120. */
  32121. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  32122. /**
  32123. * Adds a new angular speed gradient
  32124. * @param gradient defines the gradient to use (between 0 and 1)
  32125. * @param factor defines the angular speed to affect to the specified gradient
  32126. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32127. * @returns the current particle system
  32128. */
  32129. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32130. /**
  32131. * Remove a specific angular speed gradient
  32132. * @param gradient defines the gradient to remove
  32133. * @returns the current particle system
  32134. */
  32135. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  32136. /**
  32137. * Adds a new velocity gradient
  32138. * @param gradient defines the gradient to use (between 0 and 1)
  32139. * @param factor defines the velocity to affect to the specified gradient
  32140. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32141. * @returns the current particle system
  32142. */
  32143. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32144. /**
  32145. * Remove a specific velocity gradient
  32146. * @param gradient defines the gradient to remove
  32147. * @returns the current particle system
  32148. */
  32149. removeVelocityGradient(gradient: number): IParticleSystem;
  32150. /**
  32151. * Adds a new limit velocity gradient
  32152. * @param gradient defines the gradient to use (between 0 and 1)
  32153. * @param factor defines the limit velocity value to affect to the specified gradient
  32154. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32155. * @returns the current particle system
  32156. */
  32157. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32158. /**
  32159. * Remove a specific limit velocity gradient
  32160. * @param gradient defines the gradient to remove
  32161. * @returns the current particle system
  32162. */
  32163. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  32164. /**
  32165. * Adds a new drag gradient
  32166. * @param gradient defines the gradient to use (between 0 and 1)
  32167. * @param factor defines the drag value to affect to the specified gradient
  32168. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32169. * @returns the current particle system
  32170. */
  32171. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32172. /**
  32173. * Remove a specific drag gradient
  32174. * @param gradient defines the gradient to remove
  32175. * @returns the current particle system
  32176. */
  32177. removeDragGradient(gradient: number): IParticleSystem;
  32178. /**
  32179. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  32180. * @param gradient defines the gradient to use (between 0 and 1)
  32181. * @param factor defines the emit rate value to affect to the specified gradient
  32182. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32183. * @returns the current particle system
  32184. */
  32185. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32186. /**
  32187. * Remove a specific emit rate gradient
  32188. * @param gradient defines the gradient to remove
  32189. * @returns the current particle system
  32190. */
  32191. removeEmitRateGradient(gradient: number): IParticleSystem;
  32192. /**
  32193. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  32194. * @param gradient defines the gradient to use (between 0 and 1)
  32195. * @param factor defines the start size value to affect to the specified gradient
  32196. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32197. * @returns the current particle system
  32198. */
  32199. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32200. /**
  32201. * Remove a specific start size gradient
  32202. * @param gradient defines the gradient to remove
  32203. * @returns the current particle system
  32204. */
  32205. removeStartSizeGradient(gradient: number): IParticleSystem;
  32206. private _createRampGradientTexture;
  32207. /**
  32208. * Gets the current list of ramp gradients.
  32209. * You must use addRampGradient and removeRampGradient to udpate this list
  32210. * @returns the list of ramp gradients
  32211. */
  32212. getRampGradients(): Nullable<Array<Color3Gradient>>;
  32213. /**
  32214. * Adds a new ramp gradient used to remap particle colors
  32215. * @param gradient defines the gradient to use (between 0 and 1)
  32216. * @param color defines the color to affect to the specified gradient
  32217. * @returns the current particle system
  32218. */
  32219. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  32220. /**
  32221. * Remove a specific ramp gradient
  32222. * @param gradient defines the gradient to remove
  32223. * @returns the current particle system
  32224. */
  32225. removeRampGradient(gradient: number): ParticleSystem;
  32226. /**
  32227. * Adds a new color gradient
  32228. * @param gradient defines the gradient to use (between 0 and 1)
  32229. * @param color1 defines the color to affect to the specified gradient
  32230. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  32231. * @returns this particle system
  32232. */
  32233. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  32234. /**
  32235. * Remove a specific color gradient
  32236. * @param gradient defines the gradient to remove
  32237. * @returns this particle system
  32238. */
  32239. removeColorGradient(gradient: number): IParticleSystem;
  32240. private _fetchR;
  32241. protected _reset(): void;
  32242. private _resetEffect;
  32243. private _createVertexBuffers;
  32244. private _createIndexBuffer;
  32245. /**
  32246. * Gets the maximum number of particles active at the same time.
  32247. * @returns The max number of active particles.
  32248. */
  32249. getCapacity(): number;
  32250. /**
  32251. * Gets whether there are still active particles in the system.
  32252. * @returns True if it is alive, otherwise false.
  32253. */
  32254. isAlive(): boolean;
  32255. /**
  32256. * Gets if the system has been started. (Note: this will still be true after stop is called)
  32257. * @returns True if it has been started, otherwise false.
  32258. */
  32259. isStarted(): boolean;
  32260. private _prepareSubEmitterInternalArray;
  32261. /**
  32262. * Starts the particle system and begins to emit
  32263. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  32264. */
  32265. start(delay?: number): void;
  32266. /**
  32267. * Stops the particle system.
  32268. * @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.
  32269. */
  32270. stop(stopSubEmitters?: boolean): void;
  32271. /**
  32272. * Remove all active particles
  32273. */
  32274. reset(): void;
  32275. /**
  32276. * @hidden (for internal use only)
  32277. */
  32278. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  32279. /**
  32280. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  32281. * Its lifetime will start back at 0.
  32282. */
  32283. recycleParticle: (particle: Particle) => void;
  32284. private _stopSubEmitters;
  32285. private _createParticle;
  32286. private _removeFromRoot;
  32287. private _emitFromParticle;
  32288. private _update;
  32289. /** @hidden */
  32290. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  32291. /** @hidden */
  32292. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  32293. /** @hidden */
  32294. private _getEffect;
  32295. /**
  32296. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  32297. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  32298. */
  32299. animate(preWarmOnly?: boolean): void;
  32300. private _appendParticleVertices;
  32301. /**
  32302. * Rebuilds the particle system.
  32303. */
  32304. rebuild(): void;
  32305. /**
  32306. * Is this system ready to be used/rendered
  32307. * @return true if the system is ready
  32308. */
  32309. isReady(): boolean;
  32310. private _render;
  32311. /**
  32312. * Renders the particle system in its current state.
  32313. * @returns the current number of particles
  32314. */
  32315. render(): number;
  32316. /**
  32317. * Disposes the particle system and free the associated resources
  32318. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  32319. */
  32320. dispose(disposeTexture?: boolean): void;
  32321. /**
  32322. * Clones the particle system.
  32323. * @param name The name of the cloned object
  32324. * @param newEmitter The new emitter to use
  32325. * @returns the cloned particle system
  32326. */
  32327. clone(name: string, newEmitter: any): ParticleSystem;
  32328. /**
  32329. * Serializes the particle system to a JSON object.
  32330. * @returns the JSON object
  32331. */
  32332. serialize(): any;
  32333. /** @hidden */
  32334. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  32335. /** @hidden */
  32336. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  32337. /**
  32338. * Parses a JSON object to create a particle system.
  32339. * @param parsedParticleSystem The JSON object to parse
  32340. * @param scene The scene to create the particle system in
  32341. * @param rootUrl The root url to use to load external dependencies like texture
  32342. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  32343. * @returns the Parsed particle system
  32344. */
  32345. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  32346. }
  32347. }
  32348. declare module BABYLON {
  32349. interface Engine {
  32350. /**
  32351. * Create an effect to use with particle systems.
  32352. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  32353. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  32354. * @param uniformsNames defines a list of attribute names
  32355. * @param samplers defines an array of string used to represent textures
  32356. * @param defines defines the string containing the defines to use to compile the shaders
  32357. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  32358. * @param onCompiled defines a function to call when the effect creation is successful
  32359. * @param onError defines a function to call when the effect creation has failed
  32360. * @returns the new Effect
  32361. */
  32362. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  32363. }
  32364. interface Mesh {
  32365. /**
  32366. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  32367. * @returns an array of IParticleSystem
  32368. */
  32369. getEmittedParticleSystems(): IParticleSystem[];
  32370. /**
  32371. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  32372. * @returns an array of IParticleSystem
  32373. */
  32374. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  32375. }
  32376. }
  32377. declare module BABYLON {
  32378. /**
  32379. * Represents a set of particle systems working together to create a specific effect
  32380. */
  32381. class ParticleSystemSet implements IDisposable {
  32382. private _emitterCreationOptions;
  32383. private _emitterNode;
  32384. /**
  32385. * Gets the particle system list
  32386. */
  32387. systems: IParticleSystem[];
  32388. /**
  32389. * Gets the emitter node used with this set
  32390. */
  32391. readonly emitterNode: Nullable<TransformNode>;
  32392. /**
  32393. * Creates a new emitter mesh as a sphere
  32394. * @param options defines the options used to create the sphere
  32395. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  32396. * @param scene defines the hosting scene
  32397. */
  32398. setEmitterAsSphere(options: {
  32399. diameter: number;
  32400. segments: number;
  32401. color: Color3;
  32402. }, renderingGroupId: number, scene: Scene): void;
  32403. /**
  32404. * Starts all particle systems of the set
  32405. * @param emitter defines an optional mesh to use as emitter for the particle systems
  32406. */
  32407. start(emitter?: AbstractMesh): void;
  32408. /**
  32409. * Release all associated resources
  32410. */
  32411. dispose(): void;
  32412. /**
  32413. * Serialize the set into a JSON compatible object
  32414. * @returns a JSON compatible representation of the set
  32415. */
  32416. serialize(): any;
  32417. /**
  32418. * Parse a new ParticleSystemSet from a serialized source
  32419. * @param data defines a JSON compatible representation of the set
  32420. * @param scene defines the hosting scene
  32421. * @param gpu defines if we want GPU particles or CPU particles
  32422. * @returns a new ParticleSystemSet
  32423. */
  32424. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  32425. }
  32426. }
  32427. declare module BABYLON {
  32428. /**
  32429. * Represents one particle of a solid particle system.
  32430. */
  32431. class SolidParticle {
  32432. /**
  32433. * particle global index
  32434. */
  32435. idx: number;
  32436. /**
  32437. * The color of the particle
  32438. */
  32439. color: Nullable<Color4>;
  32440. /**
  32441. * The world space position of the particle.
  32442. */
  32443. position: Vector3;
  32444. /**
  32445. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  32446. */
  32447. rotation: Vector3;
  32448. /**
  32449. * The world space rotation quaternion of the particle.
  32450. */
  32451. rotationQuaternion: Nullable<Quaternion>;
  32452. /**
  32453. * The scaling of the particle.
  32454. */
  32455. scaling: Vector3;
  32456. /**
  32457. * The uvs of the particle.
  32458. */
  32459. uvs: Vector4;
  32460. /**
  32461. * The current speed of the particle.
  32462. */
  32463. velocity: Vector3;
  32464. /**
  32465. * The pivot point in the particle local space.
  32466. */
  32467. pivot: Vector3;
  32468. /**
  32469. * Must the particle be translated from its pivot point in its local space ?
  32470. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  32471. * Default : false
  32472. */
  32473. translateFromPivot: boolean;
  32474. /**
  32475. * Is the particle active or not ?
  32476. */
  32477. alive: boolean;
  32478. /**
  32479. * Is the particle visible or not ?
  32480. */
  32481. isVisible: boolean;
  32482. /**
  32483. * Index of this particle in the global "positions" array (Internal use)
  32484. * @hidden
  32485. */
  32486. _pos: number;
  32487. /**
  32488. * @hidden Index of this particle in the global "indices" array (Internal use)
  32489. */
  32490. _ind: number;
  32491. /**
  32492. * @hidden ModelShape of this particle (Internal use)
  32493. */
  32494. _model: ModelShape;
  32495. /**
  32496. * ModelShape id of this particle
  32497. */
  32498. shapeId: number;
  32499. /**
  32500. * Index of the particle in its shape id (Internal use)
  32501. */
  32502. idxInShape: number;
  32503. /**
  32504. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  32505. */
  32506. _modelBoundingInfo: BoundingInfo;
  32507. /**
  32508. * @hidden Particle BoundingInfo object (Internal use)
  32509. */
  32510. _boundingInfo: BoundingInfo;
  32511. /**
  32512. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  32513. */
  32514. _sps: SolidParticleSystem;
  32515. /**
  32516. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  32517. */
  32518. _stillInvisible: boolean;
  32519. /**
  32520. * @hidden Last computed particle rotation matrix
  32521. */
  32522. _rotationMatrix: number[];
  32523. /**
  32524. * Parent particle Id, if any.
  32525. * Default null.
  32526. */
  32527. parentId: Nullable<number>;
  32528. /**
  32529. * @hidden Internal global position in the SPS.
  32530. */
  32531. _globalPosition: Vector3;
  32532. /**
  32533. * Creates a Solid Particle object.
  32534. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  32535. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  32536. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  32537. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  32538. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  32539. * @param shapeId (integer) is the model shape identifier in the SPS.
  32540. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  32541. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  32542. */
  32543. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  32544. /**
  32545. * Legacy support, changed scale to scaling
  32546. */
  32547. /**
  32548. * Legacy support, changed scale to scaling
  32549. */
  32550. scale: Vector3;
  32551. /**
  32552. * Legacy support, changed quaternion to rotationQuaternion
  32553. */
  32554. /**
  32555. * Legacy support, changed quaternion to rotationQuaternion
  32556. */
  32557. quaternion: Nullable<Quaternion>;
  32558. /**
  32559. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  32560. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  32561. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  32562. * @returns true if it intersects
  32563. */
  32564. intersectsMesh(target: Mesh | SolidParticle): boolean;
  32565. /**
  32566. * get the rotation matrix of the particle
  32567. * @hidden
  32568. */
  32569. getRotationMatrix(m: Matrix): void;
  32570. }
  32571. /**
  32572. * Represents the shape of the model used by one particle of a solid particle system.
  32573. * SPS internal tool, don't use it manually.
  32574. */
  32575. class ModelShape {
  32576. /**
  32577. * The shape id
  32578. * @hidden
  32579. */
  32580. shapeID: number;
  32581. /**
  32582. * flat array of model positions (internal use)
  32583. * @hidden
  32584. */
  32585. _shape: Vector3[];
  32586. /**
  32587. * flat array of model UVs (internal use)
  32588. * @hidden
  32589. */
  32590. _shapeUV: number[];
  32591. /**
  32592. * length of the shape in the model indices array (internal use)
  32593. * @hidden
  32594. */
  32595. _indicesLength: number;
  32596. /**
  32597. * Custom position function (internal use)
  32598. * @hidden
  32599. */
  32600. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  32601. /**
  32602. * Custom vertex function (internal use)
  32603. * @hidden
  32604. */
  32605. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  32606. /**
  32607. * 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.
  32608. * SPS internal tool, don't use it manually.
  32609. * @hidden
  32610. */
  32611. 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>);
  32612. }
  32613. /**
  32614. * Represents a Depth Sorted Particle in the solid particle system.
  32615. */
  32616. class DepthSortedParticle {
  32617. /**
  32618. * Index of the particle in the "indices" array
  32619. */
  32620. ind: number;
  32621. /**
  32622. * Length of the particle shape in the "indices" array
  32623. */
  32624. indicesLength: number;
  32625. /**
  32626. * Squared distance from the particle to the camera
  32627. */
  32628. sqDistance: number;
  32629. }
  32630. }
  32631. declare module BABYLON {
  32632. /**
  32633. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  32634. *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.
  32635. * The SPS is also a particle system. It provides some methods to manage the particles.
  32636. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  32637. *
  32638. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  32639. */
  32640. class SolidParticleSystem implements IDisposable {
  32641. /**
  32642. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  32643. * Example : var p = SPS.particles[i];
  32644. */
  32645. particles: SolidParticle[];
  32646. /**
  32647. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  32648. */
  32649. nbParticles: number;
  32650. /**
  32651. * If the particles must ever face the camera (default false). Useful for planar particles.
  32652. */
  32653. billboard: boolean;
  32654. /**
  32655. * Recompute normals when adding a shape
  32656. */
  32657. recomputeNormals: boolean;
  32658. /**
  32659. * This a counter ofr your own usage. It's not set by any SPS functions.
  32660. */
  32661. counter: number;
  32662. /**
  32663. * The SPS name. This name is also given to the underlying mesh.
  32664. */
  32665. name: string;
  32666. /**
  32667. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  32668. */
  32669. mesh: Mesh;
  32670. /**
  32671. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  32672. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  32673. */
  32674. vars: any;
  32675. /**
  32676. * This array is populated when the SPS is set as 'pickable'.
  32677. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  32678. * Each element of this array is an object `{idx: int, faceId: int}`.
  32679. * `idx` is the picked particle index in the `SPS.particles` array
  32680. * `faceId` is the picked face index counted within this particle.
  32681. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  32682. */
  32683. pickedParticles: {
  32684. idx: number;
  32685. faceId: number;
  32686. }[];
  32687. /**
  32688. * This array is populated when `enableDepthSort` is set to true.
  32689. * Each element of this array is an instance of the class DepthSortedParticle.
  32690. */
  32691. depthSortedParticles: DepthSortedParticle[];
  32692. /**
  32693. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  32694. * @hidden
  32695. */
  32696. _bSphereOnly: boolean;
  32697. /**
  32698. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  32699. * @hidden
  32700. */
  32701. _bSphereRadiusFactor: number;
  32702. private _scene;
  32703. private _positions;
  32704. private _indices;
  32705. private _normals;
  32706. private _colors;
  32707. private _uvs;
  32708. private _indices32;
  32709. private _positions32;
  32710. private _normals32;
  32711. private _fixedNormal32;
  32712. private _colors32;
  32713. private _uvs32;
  32714. private _index;
  32715. private _updatable;
  32716. private _pickable;
  32717. private _isVisibilityBoxLocked;
  32718. private _alwaysVisible;
  32719. private _depthSort;
  32720. private _shapeCounter;
  32721. private _copy;
  32722. private _color;
  32723. private _computeParticleColor;
  32724. private _computeParticleTexture;
  32725. private _computeParticleRotation;
  32726. private _computeParticleVertex;
  32727. private _computeBoundingBox;
  32728. private _depthSortParticles;
  32729. private _camera;
  32730. private _mustUnrotateFixedNormals;
  32731. private _particlesIntersect;
  32732. private _needs32Bits;
  32733. /**
  32734. * Creates a SPS (Solid Particle System) object.
  32735. * @param name (String) is the SPS name, this will be the underlying mesh name.
  32736. * @param scene (Scene) is the scene in which the SPS is added.
  32737. * @param updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  32738. * @param isPickable (optional boolean, default false) : if the solid particles must be pickable.
  32739. * @param enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  32740. * @param particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  32741. * @param boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  32742. * @param bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  32743. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  32744. */
  32745. constructor(name: string, scene: Scene, options?: {
  32746. updatable?: boolean;
  32747. isPickable?: boolean;
  32748. enableDepthSort?: boolean;
  32749. particleIntersection?: boolean;
  32750. boundingSphereOnly?: boolean;
  32751. bSphereRadiusFactor?: number;
  32752. });
  32753. /**
  32754. * Builds the SPS underlying mesh. Returns a standard Mesh.
  32755. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  32756. * @returns the created mesh
  32757. */
  32758. buildMesh(): Mesh;
  32759. /**
  32760. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  32761. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  32762. * Thus the particles generated from `digest()` have their property `position` set yet.
  32763. * @param mesh ( Mesh ) is the mesh to be digested
  32764. * @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
  32765. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  32766. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  32767. * @returns the current SPS
  32768. */
  32769. digest(mesh: Mesh, options?: {
  32770. facetNb?: number;
  32771. number?: number;
  32772. delta?: number;
  32773. }): SolidParticleSystem;
  32774. private _unrotateFixedNormals;
  32775. private _resetCopy;
  32776. private _meshBuilder;
  32777. private _posToShape;
  32778. private _uvsToShapeUV;
  32779. private _addParticle;
  32780. /**
  32781. * Adds some particles to the SPS from the model shape. Returns the shape id.
  32782. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  32783. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  32784. * @param nb (positive integer) the number of particles to be created from this model
  32785. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  32786. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  32787. * @returns the number of shapes in the system
  32788. */
  32789. addShape(mesh: Mesh, nb: number, options?: {
  32790. positionFunction?: any;
  32791. vertexFunction?: any;
  32792. }): number;
  32793. private _rebuildParticle;
  32794. /**
  32795. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  32796. * @returns the SPS.
  32797. */
  32798. rebuildMesh(): SolidParticleSystem;
  32799. /**
  32800. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  32801. * This method calls `updateParticle()` for each particle of the SPS.
  32802. * For an animated SPS, it is usually called within the render loop.
  32803. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  32804. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  32805. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  32806. * @returns the SPS.
  32807. */
  32808. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  32809. /**
  32810. * Disposes the SPS.
  32811. */
  32812. dispose(): void;
  32813. /**
  32814. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  32815. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32816. * @returns the SPS.
  32817. */
  32818. refreshVisibleSize(): SolidParticleSystem;
  32819. /**
  32820. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  32821. * @param size the size (float) of the visibility box
  32822. * note : this doesn't lock the SPS mesh bounding box.
  32823. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32824. */
  32825. setVisibilityBox(size: number): void;
  32826. /**
  32827. * Gets whether the SPS as always visible or not
  32828. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32829. */
  32830. /**
  32831. * Sets the SPS as always visible or not
  32832. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32833. */
  32834. isAlwaysVisible: boolean;
  32835. /**
  32836. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  32837. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32838. */
  32839. /**
  32840. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  32841. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32842. */
  32843. isVisibilityBoxLocked: boolean;
  32844. /**
  32845. * Tells to `setParticles()` to compute the particle rotations or not.
  32846. * Default value : true. The SPS is faster when it's set to false.
  32847. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  32848. */
  32849. /**
  32850. * Gets if `setParticles()` computes the particle rotations or not.
  32851. * Default value : true. The SPS is faster when it's set to false.
  32852. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  32853. */
  32854. computeParticleRotation: boolean;
  32855. /**
  32856. * Tells to `setParticles()` to compute the particle colors or not.
  32857. * Default value : true. The SPS is faster when it's set to false.
  32858. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  32859. */
  32860. /**
  32861. * Gets if `setParticles()` computes the particle colors or not.
  32862. * Default value : true. The SPS is faster when it's set to false.
  32863. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  32864. */
  32865. computeParticleColor: boolean;
  32866. /**
  32867. * Gets if `setParticles()` computes the particle textures or not.
  32868. * Default value : true. The SPS is faster when it's set to false.
  32869. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  32870. */
  32871. computeParticleTexture: boolean;
  32872. /**
  32873. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  32874. * Default value : false. The SPS is faster when it's set to false.
  32875. * Note : the particle custom vertex positions aren't stored values.
  32876. */
  32877. /**
  32878. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  32879. * Default value : false. The SPS is faster when it's set to false.
  32880. * Note : the particle custom vertex positions aren't stored values.
  32881. */
  32882. computeParticleVertex: boolean;
  32883. /**
  32884. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  32885. */
  32886. /**
  32887. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  32888. */
  32889. computeBoundingBox: boolean;
  32890. /**
  32891. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  32892. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  32893. * Default : `true`
  32894. */
  32895. /**
  32896. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  32897. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  32898. * Default : `true`
  32899. */
  32900. depthSortParticles: boolean;
  32901. /**
  32902. * This function does nothing. It may be overwritten to set all the particle first values.
  32903. * The SPS doesn't call this function, you may have to call it by your own.
  32904. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  32905. */
  32906. initParticles(): void;
  32907. /**
  32908. * This function does nothing. It may be overwritten to recycle a particle.
  32909. * The SPS doesn't call this function, you may have to call it by your own.
  32910. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  32911. * @param particle The particle to recycle
  32912. * @returns the recycled particle
  32913. */
  32914. recycleParticle(particle: SolidParticle): SolidParticle;
  32915. /**
  32916. * Updates a particle : this function should be overwritten by the user.
  32917. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  32918. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  32919. * @example : just set a particle position or velocity and recycle conditions
  32920. * @param particle The particle to update
  32921. * @returns the updated particle
  32922. */
  32923. updateParticle(particle: SolidParticle): SolidParticle;
  32924. /**
  32925. * Updates a vertex of a particle : it can be overwritten by the user.
  32926. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  32927. * @param particle the current particle
  32928. * @param vertex the current index of the current particle
  32929. * @param pt the index of the current vertex in the particle shape
  32930. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  32931. * @example : just set a vertex particle position
  32932. * @returns the updated vertex
  32933. */
  32934. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  32935. /**
  32936. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  32937. * This does nothing and may be overwritten by the user.
  32938. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32939. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32940. * @param update the boolean update value actually passed to setParticles()
  32941. */
  32942. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  32943. /**
  32944. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  32945. * This will be passed three parameters.
  32946. * This does nothing and may be overwritten by the user.
  32947. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32948. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32949. * @param update the boolean update value actually passed to setParticles()
  32950. */
  32951. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  32952. }
  32953. }
  32954. declare module BABYLON {
  32955. /**
  32956. * Type of sub emitter
  32957. */
  32958. enum SubEmitterType {
  32959. /**
  32960. * Attached to the particle over it's lifetime
  32961. */
  32962. ATTACHED = 0,
  32963. /**
  32964. * Created when the particle dies
  32965. */
  32966. END = 1
  32967. }
  32968. /**
  32969. * Sub emitter class used to emit particles from an existing particle
  32970. */
  32971. class SubEmitter {
  32972. /**
  32973. * the particle system to be used by the sub emitter
  32974. */
  32975. particleSystem: ParticleSystem;
  32976. /**
  32977. * Type of the submitter (Default: END)
  32978. */
  32979. type: SubEmitterType;
  32980. /**
  32981. * 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)
  32982. * Note: This only is supported when using an emitter of type Mesh
  32983. */
  32984. inheritDirection: boolean;
  32985. /**
  32986. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  32987. */
  32988. inheritedVelocityAmount: number;
  32989. /**
  32990. * Creates a sub emitter
  32991. * @param particleSystem the particle system to be used by the sub emitter
  32992. */
  32993. constructor(
  32994. /**
  32995. * the particle system to be used by the sub emitter
  32996. */
  32997. particleSystem: ParticleSystem);
  32998. /**
  32999. * Clones the sub emitter
  33000. * @returns the cloned sub emitter
  33001. */
  33002. clone(): SubEmitter;
  33003. /**
  33004. * Serialize current object to a JSON object
  33005. * @returns the serialized object
  33006. */
  33007. serialize(): any;
  33008. /**
  33009. * Creates a new SubEmitter from a serialized JSON version
  33010. * @param serializationObject defines the JSON object to read from
  33011. * @param scene defines the hosting scene
  33012. * @param rootUrl defines the rootUrl for data loading
  33013. * @returns a new SubEmitter
  33014. */
  33015. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  33016. /** Release associated resources */
  33017. dispose(): void;
  33018. }
  33019. }
  33020. declare module BABYLON {
  33021. /**
  33022. * Interface used to describe a physics joint
  33023. */
  33024. interface PhysicsImpostorJoint {
  33025. /** Defines the main impostor to which the joint is linked */
  33026. mainImpostor: PhysicsImpostor;
  33027. /** Defines the impostor that is connected to the main impostor using this joint */
  33028. connectedImpostor: PhysicsImpostor;
  33029. /** Defines the joint itself */
  33030. joint: PhysicsJoint;
  33031. }
  33032. /** @hidden */
  33033. interface IPhysicsEnginePlugin {
  33034. world: any;
  33035. name: string;
  33036. setGravity(gravity: Vector3): void;
  33037. setTimeStep(timeStep: number): void;
  33038. getTimeStep(): number;
  33039. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  33040. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  33041. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  33042. generatePhysicsBody(impostor: PhysicsImpostor): void;
  33043. removePhysicsBody(impostor: PhysicsImpostor): void;
  33044. generateJoint(joint: PhysicsImpostorJoint): void;
  33045. removeJoint(joint: PhysicsImpostorJoint): void;
  33046. isSupported(): boolean;
  33047. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  33048. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  33049. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  33050. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  33051. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  33052. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  33053. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  33054. getBodyMass(impostor: PhysicsImpostor): number;
  33055. getBodyFriction(impostor: PhysicsImpostor): number;
  33056. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  33057. getBodyRestitution(impostor: PhysicsImpostor): number;
  33058. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  33059. sleepBody(impostor: PhysicsImpostor): void;
  33060. wakeUpBody(impostor: PhysicsImpostor): void;
  33061. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  33062. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  33063. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  33064. getRadius(impostor: PhysicsImpostor): number;
  33065. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  33066. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  33067. dispose(): void;
  33068. }
  33069. /**
  33070. * Interface used to define a physics engine
  33071. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  33072. */
  33073. interface IPhysicsEngine {
  33074. /**
  33075. * Gets the gravity vector used by the simulation
  33076. */
  33077. gravity: Vector3;
  33078. /**
  33079. * Sets the gravity vector used by the simulation
  33080. * @param gravity defines the gravity vector to use
  33081. */
  33082. setGravity(gravity: Vector3): void;
  33083. /**
  33084. * Set the time step of the physics engine.
  33085. * Default is 1/60.
  33086. * To slow it down, enter 1/600 for example.
  33087. * To speed it up, 1/30
  33088. * @param newTimeStep the new timestep to apply to this world.
  33089. */
  33090. setTimeStep(newTimeStep: number): void;
  33091. /**
  33092. * Get the time step of the physics engine.
  33093. * @returns the current time step
  33094. */
  33095. getTimeStep(): number;
  33096. /**
  33097. * Release all resources
  33098. */
  33099. dispose(): void;
  33100. /**
  33101. * Gets the name of the current physics plugin
  33102. * @returns the name of the plugin
  33103. */
  33104. getPhysicsPluginName(): string;
  33105. /**
  33106. * Adding a new impostor for the impostor tracking.
  33107. * This will be done by the impostor itself.
  33108. * @param impostor the impostor to add
  33109. */
  33110. addImpostor(impostor: PhysicsImpostor): void;
  33111. /**
  33112. * Remove an impostor from the engine.
  33113. * This impostor and its mesh will not longer be updated by the physics engine.
  33114. * @param impostor the impostor to remove
  33115. */
  33116. removeImpostor(impostor: PhysicsImpostor): void;
  33117. /**
  33118. * Add a joint to the physics engine
  33119. * @param mainImpostor defines the main impostor to which the joint is added.
  33120. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  33121. * @param joint defines the joint that will connect both impostors.
  33122. */
  33123. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  33124. /**
  33125. * Removes a joint from the simulation
  33126. * @param mainImpostor defines the impostor used with the joint
  33127. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  33128. * @param joint defines the joint to remove
  33129. */
  33130. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  33131. /**
  33132. * Gets the current plugin used to run the simulation
  33133. * @returns current plugin
  33134. */
  33135. getPhysicsPlugin(): IPhysicsEnginePlugin;
  33136. /**
  33137. * Gets the list of physic impostors
  33138. * @returns an array of PhysicsImpostor
  33139. */
  33140. getImpostors(): Array<PhysicsImpostor>;
  33141. /**
  33142. * Gets the impostor for a physics enabled object
  33143. * @param object defines the object impersonated by the impostor
  33144. * @returns the PhysicsImpostor or null if not found
  33145. */
  33146. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  33147. /**
  33148. * Gets the impostor for a physics body object
  33149. * @param body defines physics body used by the impostor
  33150. * @returns the PhysicsImpostor or null if not found
  33151. */
  33152. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  33153. /**
  33154. * Called by the scene. No need to call it.
  33155. * @param delta defines the timespam between frames
  33156. */
  33157. _step(delta: number): void;
  33158. }
  33159. }
  33160. declare module BABYLON {
  33161. /**
  33162. * Class used to control physics engine
  33163. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  33164. */
  33165. class PhysicsEngine implements IPhysicsEngine {
  33166. private _physicsPlugin;
  33167. /**
  33168. * Global value used to control the smallest number supported by the simulation
  33169. */
  33170. static Epsilon: number;
  33171. private _impostors;
  33172. private _joints;
  33173. /**
  33174. * Gets the gravity vector used by the simulation
  33175. */
  33176. gravity: Vector3;
  33177. /**
  33178. * Creates a new Physics Engine
  33179. * @param gravity defines the gravity vector used by the simulation
  33180. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  33181. */
  33182. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  33183. /**
  33184. * Sets the gravity vector used by the simulation
  33185. * @param gravity defines the gravity vector to use
  33186. */
  33187. setGravity(gravity: Vector3): void;
  33188. /**
  33189. * Set the time step of the physics engine.
  33190. * Default is 1/60.
  33191. * To slow it down, enter 1/600 for example.
  33192. * To speed it up, 1/30
  33193. * @param newTimeStep defines the new timestep to apply to this world.
  33194. */
  33195. setTimeStep(newTimeStep?: number): void;
  33196. /**
  33197. * Get the time step of the physics engine.
  33198. * @returns the current time step
  33199. */
  33200. getTimeStep(): number;
  33201. /**
  33202. * Release all resources
  33203. */
  33204. dispose(): void;
  33205. /**
  33206. * Gets the name of the current physics plugin
  33207. * @returns the name of the plugin
  33208. */
  33209. getPhysicsPluginName(): string;
  33210. /**
  33211. * Adding a new impostor for the impostor tracking.
  33212. * This will be done by the impostor itself.
  33213. * @param impostor the impostor to add
  33214. */
  33215. addImpostor(impostor: PhysicsImpostor): void;
  33216. /**
  33217. * Remove an impostor from the engine.
  33218. * This impostor and its mesh will not longer be updated by the physics engine.
  33219. * @param impostor the impostor to remove
  33220. */
  33221. removeImpostor(impostor: PhysicsImpostor): void;
  33222. /**
  33223. * Add a joint to the physics engine
  33224. * @param mainImpostor defines the main impostor to which the joint is added.
  33225. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  33226. * @param joint defines the joint that will connect both impostors.
  33227. */
  33228. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  33229. /**
  33230. * Removes a joint from the simulation
  33231. * @param mainImpostor defines the impostor used with the joint
  33232. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  33233. * @param joint defines the joint to remove
  33234. */
  33235. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  33236. /**
  33237. * Called by the scene. No need to call it.
  33238. * @param delta defines the timespam between frames
  33239. */
  33240. _step(delta: number): void;
  33241. /**
  33242. * Gets the current plugin used to run the simulation
  33243. * @returns current plugin
  33244. */
  33245. getPhysicsPlugin(): IPhysicsEnginePlugin;
  33246. /**
  33247. * Gets the list of physic impostors
  33248. * @returns an array of PhysicsImpostor
  33249. */
  33250. getImpostors(): Array<PhysicsImpostor>;
  33251. /**
  33252. * Gets the impostor for a physics enabled object
  33253. * @param object defines the object impersonated by the impostor
  33254. * @returns the PhysicsImpostor or null if not found
  33255. */
  33256. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  33257. /**
  33258. * Gets the impostor for a physics body object
  33259. * @param body defines physics body used by the impostor
  33260. * @returns the PhysicsImpostor or null if not found
  33261. */
  33262. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  33263. }
  33264. }
  33265. declare module BABYLON {
  33266. interface Scene {
  33267. /** @hidden (Backing field) */
  33268. _physicsEngine: Nullable<IPhysicsEngine>;
  33269. /**
  33270. * Gets the current physics engine
  33271. * @returns a IPhysicsEngine or null if none attached
  33272. */
  33273. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  33274. /**
  33275. * Enables physics to the current scene
  33276. * @param gravity defines the scene's gravity for the physics engine
  33277. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  33278. * @return a boolean indicating if the physics engine was initialized
  33279. */
  33280. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  33281. /**
  33282. * Disables and disposes the physics engine associated with the scene
  33283. */
  33284. disablePhysicsEngine(): void;
  33285. /**
  33286. * Gets a boolean indicating if there is an active physics engine
  33287. * @returns a boolean indicating if there is an active physics engine
  33288. */
  33289. isPhysicsEnabled(): boolean;
  33290. /**
  33291. * Deletes a physics compound impostor
  33292. * @param compound defines the compound to delete
  33293. */
  33294. deleteCompoundImpostor(compound: any): void;
  33295. /**
  33296. * An event triggered when physic simulation is about to be run
  33297. */
  33298. onBeforePhysicsObservable: Observable<Scene>;
  33299. /**
  33300. * An event triggered when physic simulation has been done
  33301. */
  33302. onAfterPhysicsObservable: Observable<Scene>;
  33303. }
  33304. interface AbstractMesh {
  33305. /** @hidden */
  33306. _physicsImpostor: Nullable<PhysicsImpostor>;
  33307. /**
  33308. * Gets or sets impostor used for physic simulation
  33309. * @see http://doc.babylonjs.com/features/physics_engine
  33310. */
  33311. physicsImpostor: Nullable<PhysicsImpostor>;
  33312. /**
  33313. * Gets the current physics impostor
  33314. * @see http://doc.babylonjs.com/features/physics_engine
  33315. * @returns a physics impostor or null
  33316. */
  33317. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  33318. /** Apply a physic impulse to the mesh
  33319. * @param force defines the force to apply
  33320. * @param contactPoint defines where to apply the force
  33321. * @returns the current mesh
  33322. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  33323. */
  33324. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  33325. /**
  33326. * Creates a physic joint between two meshes
  33327. * @param otherMesh defines the other mesh to use
  33328. * @param pivot1 defines the pivot to use on this mesh
  33329. * @param pivot2 defines the pivot to use on the other mesh
  33330. * @param options defines additional options (can be plugin dependent)
  33331. * @returns the current mesh
  33332. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  33333. */
  33334. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  33335. /** @hidden */
  33336. _disposePhysicsObserver: Nullable<Observer<Node>>;
  33337. }
  33338. /**
  33339. * Defines the physics engine scene component responsible to manage a physics engine
  33340. */
  33341. class PhysicsEngineSceneComponent implements ISceneComponent {
  33342. /**
  33343. * The component name helpful to identify the component in the list of scene components.
  33344. */
  33345. readonly name: string;
  33346. /**
  33347. * The scene the component belongs to.
  33348. */
  33349. scene: Scene;
  33350. /**
  33351. * Creates a new instance of the component for the given scene
  33352. * @param scene Defines the scene to register the component in
  33353. */
  33354. constructor(scene: Scene);
  33355. /**
  33356. * Registers the component in a given scene
  33357. */
  33358. register(): void;
  33359. /**
  33360. * Rebuilds the elements related to this component in case of
  33361. * context lost for instance.
  33362. */
  33363. rebuild(): void;
  33364. /**
  33365. * Disposes the component and the associated ressources
  33366. */
  33367. dispose(): void;
  33368. }
  33369. }
  33370. declare module BABYLON {
  33371. /**
  33372. * A helper for physics simulations
  33373. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33374. */
  33375. class PhysicsHelper {
  33376. private _scene;
  33377. private _physicsEngine;
  33378. /**
  33379. * Initializes the Physics helper
  33380. * @param scene Babylon.js scene
  33381. */
  33382. constructor(scene: Scene);
  33383. /**
  33384. * Applies a radial explosion impulse
  33385. * @param origin the origin of the explosion
  33386. * @param radius the explosion radius
  33387. * @param strength the explosion strength
  33388. * @param falloff possible options: Constant & Linear. Defaults to Constant
  33389. * @returns A physics radial explosion event, or null
  33390. */
  33391. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  33392. /**
  33393. * Applies a radial explosion force
  33394. * @param origin the origin of the explosion
  33395. * @param radius the explosion radius
  33396. * @param strength the explosion strength
  33397. * @param falloff possible options: Constant & Linear. Defaults to Constant
  33398. * @returns A physics radial explosion event, or null
  33399. */
  33400. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  33401. /**
  33402. * Creates a gravitational field
  33403. * @param origin the origin of the explosion
  33404. * @param radius the explosion radius
  33405. * @param strength the explosion strength
  33406. * @param falloff possible options: Constant & Linear. Defaults to Constant
  33407. * @returns A physics gravitational field event, or null
  33408. */
  33409. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  33410. /**
  33411. * Creates a physics updraft event
  33412. * @param origin the origin of the updraft
  33413. * @param radius the radius of the updraft
  33414. * @param strength the strength of the updraft
  33415. * @param height the height of the updraft
  33416. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  33417. * @returns A physics updraft event, or null
  33418. */
  33419. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  33420. /**
  33421. * Creates a physics vortex event
  33422. * @param origin the of the vortex
  33423. * @param radius the radius of the vortex
  33424. * @param strength the strength of the vortex
  33425. * @param height the height of the vortex
  33426. * @returns a Physics vortex event, or null
  33427. * A physics vortex event or null
  33428. */
  33429. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  33430. }
  33431. /**
  33432. * Represents a physics radial explosion event
  33433. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33434. */
  33435. class PhysicsRadialExplosionEvent {
  33436. private _scene;
  33437. private _sphere;
  33438. private _sphereOptions;
  33439. private _rays;
  33440. private _dataFetched;
  33441. /**
  33442. * Initializes a radial explosioin event
  33443. * @param scene BabylonJS scene
  33444. */
  33445. constructor(scene: Scene);
  33446. /**
  33447. * Returns the data related to the radial explosion event (sphere & rays).
  33448. * @returns The radial explosion event data
  33449. */
  33450. getData(): PhysicsRadialExplosionEventData;
  33451. /**
  33452. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  33453. * @param impostor A physics imposter
  33454. * @param origin the origin of the explosion
  33455. * @param radius the explosion radius
  33456. * @param strength the explosion strength
  33457. * @param falloff possible options: Constant & Linear
  33458. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  33459. */
  33460. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  33461. /**
  33462. * Disposes the sphere.
  33463. * @param force Specifies if the sphere should be disposed by force
  33464. */
  33465. dispose(force?: boolean): void;
  33466. /*** Helpers ***/
  33467. private _prepareSphere;
  33468. private _intersectsWithSphere;
  33469. }
  33470. /**
  33471. * Represents a gravitational field event
  33472. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33473. */
  33474. class PhysicsGravitationalFieldEvent {
  33475. private _physicsHelper;
  33476. private _scene;
  33477. private _origin;
  33478. private _radius;
  33479. private _strength;
  33480. private _falloff;
  33481. private _tickCallback;
  33482. private _sphere;
  33483. private _dataFetched;
  33484. /**
  33485. * Initializes the physics gravitational field event
  33486. * @param physicsHelper A physics helper
  33487. * @param scene BabylonJS scene
  33488. * @param origin The origin position of the gravitational field event
  33489. * @param radius The radius of the gravitational field event
  33490. * @param strength The strength of the gravitational field event
  33491. * @param falloff The falloff for the gravitational field event
  33492. */
  33493. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  33494. /**
  33495. * Returns the data related to the gravitational field event (sphere).
  33496. * @returns A gravitational field event
  33497. */
  33498. getData(): PhysicsGravitationalFieldEventData;
  33499. /**
  33500. * Enables the gravitational field.
  33501. */
  33502. enable(): void;
  33503. /**
  33504. * Disables the gravitational field.
  33505. */
  33506. disable(): void;
  33507. /**
  33508. * Disposes the sphere.
  33509. * @param force The force to dispose from the gravitational field event
  33510. */
  33511. dispose(force?: boolean): void;
  33512. private _tick;
  33513. }
  33514. /**
  33515. * Represents a physics updraft event
  33516. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33517. */
  33518. class PhysicsUpdraftEvent {
  33519. private _scene;
  33520. private _origin;
  33521. private _radius;
  33522. private _strength;
  33523. private _height;
  33524. private _updraftMode;
  33525. private _physicsEngine;
  33526. private _originTop;
  33527. private _originDirection;
  33528. private _tickCallback;
  33529. private _cylinder;
  33530. private _cylinderPosition;
  33531. private _dataFetched;
  33532. /**
  33533. * Initializes the physics updraft event
  33534. * @param _scene BabylonJS scene
  33535. * @param _origin The origin position of the updraft
  33536. * @param _radius The radius of the updraft
  33537. * @param _strength The strength of the updraft
  33538. * @param _height The height of the updraft
  33539. * @param _updraftMode The mode of the updraft
  33540. */
  33541. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  33542. /**
  33543. * Returns the data related to the updraft event (cylinder).
  33544. * @returns A physics updraft event
  33545. */
  33546. getData(): PhysicsUpdraftEventData;
  33547. /**
  33548. * Enables the updraft.
  33549. */
  33550. enable(): void;
  33551. /**
  33552. * Disables the cortex.
  33553. */
  33554. disable(): void;
  33555. /**
  33556. * Disposes the sphere.
  33557. * @param force Specifies if the updraft should be disposed by force
  33558. */
  33559. dispose(force?: boolean): void;
  33560. private getImpostorForceAndContactPoint;
  33561. private _tick;
  33562. /*** Helpers ***/
  33563. private _prepareCylinder;
  33564. private _intersectsWithCylinder;
  33565. }
  33566. /**
  33567. * Represents a physics vortex event
  33568. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33569. */
  33570. class PhysicsVortexEvent {
  33571. private _scene;
  33572. private _origin;
  33573. private _radius;
  33574. private _strength;
  33575. private _height;
  33576. private _physicsEngine;
  33577. private _originTop;
  33578. private _centripetalForceThreshold;
  33579. private _updraftMultiplier;
  33580. private _tickCallback;
  33581. private _cylinder;
  33582. private _cylinderPosition;
  33583. private _dataFetched;
  33584. /**
  33585. * Initializes the physics vortex event
  33586. * @param _scene The BabylonJS scene
  33587. * @param _origin The origin position of the vortex
  33588. * @param _radius The radius of the vortex
  33589. * @param _strength The strength of the vortex
  33590. * @param _height The height of the vortex
  33591. */
  33592. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  33593. /**
  33594. * Returns the data related to the vortex event (cylinder).
  33595. * @returns The physics vortex event data
  33596. */
  33597. getData(): PhysicsVortexEventData;
  33598. /**
  33599. * Enables the vortex.
  33600. */
  33601. enable(): void;
  33602. /**
  33603. * Disables the cortex.
  33604. */
  33605. disable(): void;
  33606. /**
  33607. * Disposes the sphere.
  33608. * @param force
  33609. */
  33610. dispose(force?: boolean): void;
  33611. private getImpostorForceAndContactPoint;
  33612. private _tick;
  33613. /*** Helpers ***/
  33614. private _prepareCylinder;
  33615. private _intersectsWithCylinder;
  33616. }
  33617. /**
  33618. * The strenght of the force in correspondence to the distance of the affected object
  33619. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33620. */
  33621. enum PhysicsRadialImpulseFalloff {
  33622. /** Defines that impulse is constant in strength across it's whole radius */
  33623. Constant = 0,
  33624. /** DEfines that impulse gets weaker if it's further from the origin */
  33625. Linear = 1
  33626. }
  33627. /**
  33628. * The strength of the force in correspondence to the distance of the affected object
  33629. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33630. */
  33631. enum PhysicsUpdraftMode {
  33632. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  33633. Center = 0,
  33634. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  33635. Perpendicular = 1
  33636. }
  33637. /**
  33638. * Interface for a physics force and contact point
  33639. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33640. */
  33641. interface PhysicsForceAndContactPoint {
  33642. /**
  33643. * The force applied at the contact point
  33644. */
  33645. force: Vector3;
  33646. /**
  33647. * The contact point
  33648. */
  33649. contactPoint: Vector3;
  33650. }
  33651. /**
  33652. * Interface for radial explosion event data
  33653. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33654. */
  33655. interface PhysicsRadialExplosionEventData {
  33656. /**
  33657. * A sphere used for the radial explosion event
  33658. */
  33659. sphere: Mesh;
  33660. /**
  33661. * An array of rays for the radial explosion event
  33662. */
  33663. rays: Array<Ray>;
  33664. }
  33665. /**
  33666. * Interface for gravitational field event data
  33667. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33668. */
  33669. interface PhysicsGravitationalFieldEventData {
  33670. /**
  33671. * A sphere mesh used for the gravitational field event
  33672. */
  33673. sphere: Mesh;
  33674. }
  33675. /**
  33676. * Interface for updraft event data
  33677. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33678. */
  33679. interface PhysicsUpdraftEventData {
  33680. /**
  33681. * A cylinder used for the updraft event
  33682. */
  33683. cylinder: Mesh;
  33684. }
  33685. /**
  33686. * Interface for vortex event data
  33687. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33688. */
  33689. interface PhysicsVortexEventData {
  33690. /**
  33691. * A cylinder used for the vortex event
  33692. */
  33693. cylinder: Mesh;
  33694. }
  33695. }
  33696. declare module BABYLON {
  33697. /**
  33698. * The interface for the physics imposter parameters
  33699. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33700. */
  33701. interface PhysicsImpostorParameters {
  33702. /**
  33703. * The mass of the physics imposter
  33704. */
  33705. mass: number;
  33706. /**
  33707. * The friction of the physics imposter
  33708. */
  33709. friction?: number;
  33710. /**
  33711. * The coefficient of restitution of the physics imposter
  33712. */
  33713. restitution?: number;
  33714. /**
  33715. * The native options of the physics imposter
  33716. */
  33717. nativeOptions?: any;
  33718. /**
  33719. * Specifies if the parent should be ignored
  33720. */
  33721. ignoreParent?: boolean;
  33722. /**
  33723. * Specifies if bi-directional transformations should be disabled
  33724. */
  33725. disableBidirectionalTransformation?: boolean;
  33726. }
  33727. /**
  33728. * Interface for a physics-enabled object
  33729. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33730. */
  33731. interface IPhysicsEnabledObject {
  33732. /**
  33733. * The position of the physics-enabled object
  33734. */
  33735. position: Vector3;
  33736. /**
  33737. * The rotation of the physics-enabled object
  33738. */
  33739. rotationQuaternion: Nullable<Quaternion>;
  33740. /**
  33741. * The scale of the physics-enabled object
  33742. */
  33743. scaling: Vector3;
  33744. /**
  33745. * The rotation of the physics-enabled object
  33746. */
  33747. rotation?: Vector3;
  33748. /**
  33749. * The parent of the physics-enabled object
  33750. */
  33751. parent?: any;
  33752. /**
  33753. * The bounding info of the physics-enabled object
  33754. * @returns The bounding info of the physics-enabled object
  33755. */
  33756. getBoundingInfo(): BoundingInfo;
  33757. /**
  33758. * Computes the world matrix
  33759. * @param force Specifies if the world matrix should be computed by force
  33760. * @returns A world matrix
  33761. */
  33762. computeWorldMatrix(force: boolean): Matrix;
  33763. /**
  33764. * Gets the world matrix
  33765. * @returns A world matrix
  33766. */
  33767. getWorldMatrix?(): Matrix;
  33768. /**
  33769. * Gets the child meshes
  33770. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  33771. * @returns An array of abstract meshes
  33772. */
  33773. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  33774. /**
  33775. * Gets the vertex data
  33776. * @param kind The type of vertex data
  33777. * @returns A nullable array of numbers, or a float32 array
  33778. */
  33779. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  33780. /**
  33781. * Gets the indices from the mesh
  33782. * @returns A nullable array of index arrays
  33783. */
  33784. getIndices?(): Nullable<IndicesArray>;
  33785. /**
  33786. * Gets the scene from the mesh
  33787. * @returns the indices array or null
  33788. */
  33789. getScene?(): Scene;
  33790. /**
  33791. * Gets the absolute position from the mesh
  33792. * @returns the absolute position
  33793. */
  33794. getAbsolutePosition(): Vector3;
  33795. /**
  33796. * Gets the absolute pivot point from the mesh
  33797. * @returns the absolute pivot point
  33798. */
  33799. getAbsolutePivotPoint(): Vector3;
  33800. /**
  33801. * Rotates the mesh
  33802. * @param axis The axis of rotation
  33803. * @param amount The amount of rotation
  33804. * @param space The space of the rotation
  33805. * @returns The rotation transform node
  33806. */
  33807. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  33808. /**
  33809. * Translates the mesh
  33810. * @param axis The axis of translation
  33811. * @param distance The distance of translation
  33812. * @param space The space of the translation
  33813. * @returns The transform node
  33814. */
  33815. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  33816. /**
  33817. * Sets the absolute position of the mesh
  33818. * @param absolutePosition The absolute position of the mesh
  33819. * @returns The transform node
  33820. */
  33821. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  33822. /**
  33823. * Gets the class name of the mesh
  33824. * @returns The class name
  33825. */
  33826. getClassName(): string;
  33827. }
  33828. /**
  33829. * Represents a physics imposter
  33830. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33831. */
  33832. class PhysicsImpostor {
  33833. /**
  33834. * The physics-enabled object used as the physics imposter
  33835. */
  33836. object: IPhysicsEnabledObject;
  33837. /**
  33838. * The type of the physics imposter
  33839. */
  33840. type: number;
  33841. private _options;
  33842. private _scene?;
  33843. /**
  33844. * The default object size of the imposter
  33845. */
  33846. static DEFAULT_OBJECT_SIZE: Vector3;
  33847. /**
  33848. * The identity quaternion of the imposter
  33849. */
  33850. static IDENTITY_QUATERNION: Quaternion;
  33851. /** @hidden */
  33852. _pluginData: any;
  33853. private _physicsEngine;
  33854. private _physicsBody;
  33855. private _bodyUpdateRequired;
  33856. private _onBeforePhysicsStepCallbacks;
  33857. private _onAfterPhysicsStepCallbacks;
  33858. /** @hidden */
  33859. _onPhysicsCollideCallbacks: Array<{
  33860. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  33861. otherImpostors: Array<PhysicsImpostor>;
  33862. }>;
  33863. private _deltaPosition;
  33864. private _deltaRotation;
  33865. private _deltaRotationConjugated;
  33866. private _parent;
  33867. private _isDisposed;
  33868. private static _tmpVecs;
  33869. private static _tmpQuat;
  33870. /**
  33871. * Specifies if the physics imposter is disposed
  33872. */
  33873. readonly isDisposed: boolean;
  33874. /**
  33875. * Gets the mass of the physics imposter
  33876. */
  33877. mass: number;
  33878. /**
  33879. * Gets the coefficient of friction
  33880. */
  33881. /**
  33882. * Sets the coefficient of friction
  33883. */
  33884. friction: number;
  33885. /**
  33886. * Gets the coefficient of restitution
  33887. */
  33888. /**
  33889. * Sets the coefficient of restitution
  33890. */
  33891. restitution: number;
  33892. /**
  33893. * The unique id of the physics imposter
  33894. * set by the physics engine when adding this impostor to the array
  33895. */
  33896. uniqueId: number;
  33897. private _joints;
  33898. /**
  33899. * Initializes the physics imposter
  33900. * @param object The physics-enabled object used as the physics imposter
  33901. * @param type The type of the physics imposter
  33902. * @param _options The options for the physics imposter
  33903. * @param _scene The Babylon scene
  33904. */
  33905. constructor(
  33906. /**
  33907. * The physics-enabled object used as the physics imposter
  33908. */
  33909. object: IPhysicsEnabledObject,
  33910. /**
  33911. * The type of the physics imposter
  33912. */
  33913. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  33914. /**
  33915. * This function will completly initialize this impostor.
  33916. * It will create a new body - but only if this mesh has no parent.
  33917. * If it has, this impostor will not be used other than to define the impostor
  33918. * of the child mesh.
  33919. * @hidden
  33920. */
  33921. _init(): void;
  33922. private _getPhysicsParent;
  33923. /**
  33924. * Should a new body be generated.
  33925. * @returns boolean specifying if body initialization is required
  33926. */
  33927. isBodyInitRequired(): boolean;
  33928. /**
  33929. * Sets the updated scaling
  33930. * @param updated Specifies if the scaling is updated
  33931. */
  33932. setScalingUpdated(updated: boolean): void;
  33933. /**
  33934. * Force a regeneration of this or the parent's impostor's body.
  33935. * Use under cautious - This will remove all joints already implemented.
  33936. */
  33937. forceUpdate(): void;
  33938. /**
  33939. * Gets the body that holds this impostor. Either its own, or its parent.
  33940. */
  33941. /**
  33942. * Set the physics body. Used mainly by the physics engine/plugin
  33943. */
  33944. physicsBody: any;
  33945. /**
  33946. * Get the parent of the physics imposter
  33947. * @returns Physics imposter or null
  33948. */
  33949. /**
  33950. * Sets the parent of the physics imposter
  33951. */
  33952. parent: Nullable<PhysicsImpostor>;
  33953. /**
  33954. * Resets the update flags
  33955. */
  33956. resetUpdateFlags(): void;
  33957. /**
  33958. * Gets the object extend size
  33959. * @returns the object extend size
  33960. */
  33961. getObjectExtendSize(): Vector3;
  33962. /**
  33963. * Gets the object center
  33964. * @returns The object center
  33965. */
  33966. getObjectCenter(): Vector3;
  33967. /**
  33968. * Get a specific parametes from the options parameter
  33969. * @param paramName The object parameter name
  33970. * @returns The object parameter
  33971. */
  33972. getParam(paramName: string): any;
  33973. /**
  33974. * Sets a specific parameter in the options given to the physics plugin
  33975. * @param paramName The parameter name
  33976. * @param value The value of the parameter
  33977. */
  33978. setParam(paramName: string, value: number): void;
  33979. /**
  33980. * Specifically change the body's mass option. Won't recreate the physics body object
  33981. * @param mass The mass of the physics imposter
  33982. */
  33983. setMass(mass: number): void;
  33984. /**
  33985. * Gets the linear velocity
  33986. * @returns linear velocity or null
  33987. */
  33988. getLinearVelocity(): Nullable<Vector3>;
  33989. /**
  33990. * Sets the linear velocity
  33991. * @param velocity linear velocity or null
  33992. */
  33993. setLinearVelocity(velocity: Nullable<Vector3>): void;
  33994. /**
  33995. * Gets the angular velocity
  33996. * @returns angular velocity or null
  33997. */
  33998. getAngularVelocity(): Nullable<Vector3>;
  33999. /**
  34000. * Sets the angular velocity
  34001. * @param velocity The velocity or null
  34002. */
  34003. setAngularVelocity(velocity: Nullable<Vector3>): void;
  34004. /**
  34005. * Execute a function with the physics plugin native code
  34006. * Provide a function the will have two variables - the world object and the physics body object
  34007. * @param func The function to execute with the physics plugin native code
  34008. */
  34009. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  34010. /**
  34011. * Register a function that will be executed before the physics world is stepping forward
  34012. * @param func The function to execute before the physics world is stepped forward
  34013. */
  34014. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  34015. /**
  34016. * Unregister a function that will be executed before the physics world is stepping forward
  34017. * @param func The function to execute before the physics world is stepped forward
  34018. */
  34019. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  34020. /**
  34021. * Register a function that will be executed after the physics step
  34022. * @param func The function to execute after physics step
  34023. */
  34024. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  34025. /**
  34026. * Unregisters a function that will be executed after the physics step
  34027. * @param func The function to execute after physics step
  34028. */
  34029. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  34030. /**
  34031. * register a function that will be executed when this impostor collides against a different body
  34032. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  34033. * @param func Callback that is executed on collision
  34034. */
  34035. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  34036. /**
  34037. * Unregisters the physics imposter on contact
  34038. * @param collideAgainst The physics object to collide against
  34039. * @param func Callback to execute on collision
  34040. */
  34041. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  34042. private _tmpQuat;
  34043. private _tmpQuat2;
  34044. /**
  34045. * Get the parent rotation
  34046. * @returns The parent rotation
  34047. */
  34048. getParentsRotation(): Quaternion;
  34049. /**
  34050. * this function is executed by the physics engine.
  34051. */
  34052. beforeStep: () => void;
  34053. /**
  34054. * this function is executed by the physics engine
  34055. */
  34056. afterStep: () => void;
  34057. /**
  34058. * Legacy collision detection event support
  34059. */
  34060. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  34061. /**
  34062. * event and body object due to cannon's event-based architecture.
  34063. */
  34064. onCollide: (e: {
  34065. body: any;
  34066. }) => void;
  34067. /**
  34068. * Apply a force
  34069. * @param force The force to apply
  34070. * @param contactPoint The contact point for the force
  34071. * @returns The physics imposter
  34072. */
  34073. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  34074. /**
  34075. * Apply an impulse
  34076. * @param force The impulse force
  34077. * @param contactPoint The contact point for the impulse force
  34078. * @returns The physics imposter
  34079. */
  34080. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  34081. /**
  34082. * A help function to create a joint
  34083. * @param otherImpostor A physics imposter used to create a joint
  34084. * @param jointType The type of joint
  34085. * @param jointData The data for the joint
  34086. * @returns The physics imposter
  34087. */
  34088. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  34089. /**
  34090. * Add a joint to this impostor with a different impostor
  34091. * @param otherImpostor A physics imposter used to add a joint
  34092. * @param joint The joint to add
  34093. * @returns The physics imposter
  34094. */
  34095. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  34096. /**
  34097. * Will keep this body still, in a sleep mode.
  34098. * @returns the physics imposter
  34099. */
  34100. sleep(): PhysicsImpostor;
  34101. /**
  34102. * Wake the body up.
  34103. * @returns The physics imposter
  34104. */
  34105. wakeUp(): PhysicsImpostor;
  34106. /**
  34107. * Clones the physics imposter
  34108. * @param newObject The physics imposter clones to this physics-enabled object
  34109. * @returns A nullable physics imposter
  34110. */
  34111. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  34112. /**
  34113. * Disposes the physics imposter
  34114. */
  34115. dispose(): void;
  34116. /**
  34117. * Sets the delta position
  34118. * @param position The delta position amount
  34119. */
  34120. setDeltaPosition(position: Vector3): void;
  34121. /**
  34122. * Sets the delta rotation
  34123. * @param rotation The delta rotation amount
  34124. */
  34125. setDeltaRotation(rotation: Quaternion): void;
  34126. /**
  34127. * Gets the box size of the physics imposter and stores the result in the input parameter
  34128. * @param result Stores the box size
  34129. * @returns The physics imposter
  34130. */
  34131. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  34132. /**
  34133. * Gets the radius of the physics imposter
  34134. * @returns Radius of the physics imposter
  34135. */
  34136. getRadius(): number;
  34137. /**
  34138. * Sync a bone with this impostor
  34139. * @param bone The bone to sync to the impostor.
  34140. * @param boneMesh The mesh that the bone is influencing.
  34141. * @param jointPivot The pivot of the joint / bone in local space.
  34142. * @param distToJoint Optional distance from the impostor to the joint.
  34143. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  34144. */
  34145. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  34146. /**
  34147. * Sync impostor to a bone
  34148. * @param bone The bone that the impostor will be synced to.
  34149. * @param boneMesh The mesh that the bone is influencing.
  34150. * @param jointPivot The pivot of the joint / bone in local space.
  34151. * @param distToJoint Optional distance from the impostor to the joint.
  34152. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  34153. * @param boneAxis Optional vector3 axis the bone is aligned with
  34154. */
  34155. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  34156. /**
  34157. * No-Imposter type
  34158. */
  34159. static NoImpostor: number;
  34160. /**
  34161. * Sphere-Imposter type
  34162. */
  34163. static SphereImpostor: number;
  34164. /**
  34165. * Box-Imposter type
  34166. */
  34167. static BoxImpostor: number;
  34168. /**
  34169. * Plane-Imposter type
  34170. */
  34171. static PlaneImpostor: number;
  34172. /**
  34173. * Mesh-imposter type
  34174. */
  34175. static MeshImpostor: number;
  34176. /**
  34177. * Cylinder-Imposter type
  34178. */
  34179. static CylinderImpostor: number;
  34180. /**
  34181. * Particle-Imposter type
  34182. */
  34183. static ParticleImpostor: number;
  34184. /**
  34185. * Heightmap-Imposter type
  34186. */
  34187. static HeightmapImpostor: number;
  34188. }
  34189. }
  34190. declare module BABYLON {
  34191. /**
  34192. * Interface for Physics-Joint data
  34193. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34194. */
  34195. interface PhysicsJointData {
  34196. /**
  34197. * The main pivot of the joint
  34198. */
  34199. mainPivot?: Vector3;
  34200. /**
  34201. * The connected pivot of the joint
  34202. */
  34203. connectedPivot?: Vector3;
  34204. /**
  34205. * The main axis of the joint
  34206. */
  34207. mainAxis?: Vector3;
  34208. /**
  34209. * The connected axis of the joint
  34210. */
  34211. connectedAxis?: Vector3;
  34212. /**
  34213. * The collision of the joint
  34214. */
  34215. collision?: boolean;
  34216. /**
  34217. * Native Oimo/Cannon/Energy data
  34218. */
  34219. nativeParams?: any;
  34220. }
  34221. /**
  34222. * This is a holder class for the physics joint created by the physics plugin
  34223. * It holds a set of functions to control the underlying joint
  34224. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34225. */
  34226. class PhysicsJoint {
  34227. /**
  34228. * The type of the physics joint
  34229. */
  34230. type: number;
  34231. /**
  34232. * The data for the physics joint
  34233. */
  34234. jointData: PhysicsJointData;
  34235. private _physicsJoint;
  34236. protected _physicsPlugin: IPhysicsEnginePlugin;
  34237. /**
  34238. * Initializes the physics joint
  34239. * @param type The type of the physics joint
  34240. * @param jointData The data for the physics joint
  34241. */
  34242. constructor(
  34243. /**
  34244. * The type of the physics joint
  34245. */
  34246. type: number,
  34247. /**
  34248. * The data for the physics joint
  34249. */
  34250. jointData: PhysicsJointData);
  34251. /**
  34252. * Gets the physics joint
  34253. */
  34254. /**
  34255. * Sets the physics joint
  34256. */
  34257. physicsJoint: any;
  34258. /**
  34259. * Sets the physics plugin
  34260. */
  34261. physicsPlugin: IPhysicsEnginePlugin;
  34262. /**
  34263. * Execute a function that is physics-plugin specific.
  34264. * @param {Function} func the function that will be executed.
  34265. * It accepts two parameters: the physics world and the physics joint
  34266. */
  34267. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  34268. /**
  34269. * Distance-Joint type
  34270. */
  34271. static DistanceJoint: number;
  34272. /**
  34273. * Hinge-Joint type
  34274. */
  34275. static HingeJoint: number;
  34276. /**
  34277. * Ball-and-Socket joint type
  34278. */
  34279. static BallAndSocketJoint: number;
  34280. /**
  34281. * Wheel-Joint type
  34282. */
  34283. static WheelJoint: number;
  34284. /**
  34285. * Slider-Joint type
  34286. */
  34287. static SliderJoint: number;
  34288. /**
  34289. * Prismatic-Joint type
  34290. */
  34291. static PrismaticJoint: number;
  34292. /**
  34293. * Universal-Joint type
  34294. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  34295. */
  34296. static UniversalJoint: number;
  34297. /**
  34298. * Hinge-Joint 2 type
  34299. */
  34300. static Hinge2Joint: number;
  34301. /**
  34302. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  34303. */
  34304. static PointToPointJoint: number;
  34305. /**
  34306. * Spring-Joint type
  34307. */
  34308. static SpringJoint: number;
  34309. /**
  34310. * Lock-Joint type
  34311. */
  34312. static LockJoint: number;
  34313. }
  34314. /**
  34315. * A class representing a physics distance joint
  34316. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34317. */
  34318. class DistanceJoint extends PhysicsJoint {
  34319. /**
  34320. *
  34321. * @param jointData The data for the Distance-Joint
  34322. */
  34323. constructor(jointData: DistanceJointData);
  34324. /**
  34325. * Update the predefined distance.
  34326. * @param maxDistance The maximum preferred distance
  34327. * @param minDistance The minimum preferred distance
  34328. */
  34329. updateDistance(maxDistance: number, minDistance?: number): void;
  34330. }
  34331. /**
  34332. * Represents a Motor-Enabled Joint
  34333. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34334. */
  34335. class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  34336. /**
  34337. * Initializes the Motor-Enabled Joint
  34338. * @param type The type of the joint
  34339. * @param jointData The physica joint data for the joint
  34340. */
  34341. constructor(type: number, jointData: PhysicsJointData);
  34342. /**
  34343. * Set the motor values.
  34344. * Attention, this function is plugin specific. Engines won't react 100% the same.
  34345. * @param force the force to apply
  34346. * @param maxForce max force for this motor.
  34347. */
  34348. setMotor(force?: number, maxForce?: number): void;
  34349. /**
  34350. * Set the motor's limits.
  34351. * Attention, this function is plugin specific. Engines won't react 100% the same.
  34352. * @param upperLimit The upper limit of the motor
  34353. * @param lowerLimit The lower limit of the motor
  34354. */
  34355. setLimit(upperLimit: number, lowerLimit?: number): void;
  34356. }
  34357. /**
  34358. * This class represents a single physics Hinge-Joint
  34359. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34360. */
  34361. class HingeJoint extends MotorEnabledJoint {
  34362. /**
  34363. * Initializes the Hinge-Joint
  34364. * @param jointData The joint data for the Hinge-Joint
  34365. */
  34366. constructor(jointData: PhysicsJointData);
  34367. /**
  34368. * Set the motor values.
  34369. * Attention, this function is plugin specific. Engines won't react 100% the same.
  34370. * @param {number} force the force to apply
  34371. * @param {number} maxForce max force for this motor.
  34372. */
  34373. setMotor(force?: number, maxForce?: number): void;
  34374. /**
  34375. * Set the motor's limits.
  34376. * Attention, this function is plugin specific. Engines won't react 100% the same.
  34377. * @param upperLimit The upper limit of the motor
  34378. * @param lowerLimit The lower limit of the motor
  34379. */
  34380. setLimit(upperLimit: number, lowerLimit?: number): void;
  34381. }
  34382. /**
  34383. * This class represents a dual hinge physics joint (same as wheel joint)
  34384. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34385. */
  34386. class Hinge2Joint extends MotorEnabledJoint {
  34387. /**
  34388. * Initializes the Hinge2-Joint
  34389. * @param jointData The joint data for the Hinge2-Joint
  34390. */
  34391. constructor(jointData: PhysicsJointData);
  34392. /**
  34393. * Set the motor values.
  34394. * Attention, this function is plugin specific. Engines won't react 100% the same.
  34395. * @param {number} force the force to apply
  34396. * @param {number} maxForce max force for this motor.
  34397. * @param {motorIndex} the motor's index, 0 or 1.
  34398. */
  34399. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  34400. /**
  34401. * Set the motor limits.
  34402. * Attention, this function is plugin specific. Engines won't react 100% the same.
  34403. * @param {number} upperLimit the upper limit
  34404. * @param {number} lowerLimit lower limit
  34405. * @param {motorIndex} the motor's index, 0 or 1.
  34406. */
  34407. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  34408. }
  34409. /**
  34410. * Interface for a motor enabled joint
  34411. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34412. */
  34413. interface IMotorEnabledJoint {
  34414. /**
  34415. * Physics joint
  34416. */
  34417. physicsJoint: any;
  34418. /**
  34419. * Sets the motor of the motor-enabled joint
  34420. * @param force The force of the motor
  34421. * @param maxForce The maximum force of the motor
  34422. * @param motorIndex The index of the motor
  34423. */
  34424. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  34425. /**
  34426. * Sets the limit of the motor
  34427. * @param upperLimit The upper limit of the motor
  34428. * @param lowerLimit The lower limit of the motor
  34429. * @param motorIndex The index of the motor
  34430. */
  34431. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  34432. }
  34433. /**
  34434. * Joint data for a Distance-Joint
  34435. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34436. */
  34437. interface DistanceJointData extends PhysicsJointData {
  34438. /**
  34439. * Max distance the 2 joint objects can be apart
  34440. */
  34441. maxDistance: number;
  34442. }
  34443. /**
  34444. * Joint data from a spring joint
  34445. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34446. */
  34447. interface SpringJointData extends PhysicsJointData {
  34448. /**
  34449. * Length of the spring
  34450. */
  34451. length: number;
  34452. /**
  34453. * Stiffness of the spring
  34454. */
  34455. stiffness: number;
  34456. /**
  34457. * Damping of the spring
  34458. */
  34459. damping: number;
  34460. /** this callback will be called when applying the force to the impostors. */
  34461. forceApplicationCallback: () => void;
  34462. }
  34463. }
  34464. declare module BABYLON {
  34465. interface AbstractScene {
  34466. /**
  34467. * The list of reflection probes added to the scene
  34468. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  34469. */
  34470. reflectionProbes: Array<ReflectionProbe>;
  34471. /**
  34472. * Removes the given reflection probe from this scene.
  34473. * @param toRemove The reflection probe to remove
  34474. * @returns The index of the removed reflection probe
  34475. */
  34476. removeReflectionProbe(toRemove: ReflectionProbe): number;
  34477. /**
  34478. * Adds the given reflection probe to this scene.
  34479. * @param newReflectionProbe The reflection probe to add
  34480. */
  34481. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  34482. }
  34483. /**
  34484. * Class used to generate realtime reflection / refraction cube textures
  34485. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  34486. */
  34487. class ReflectionProbe {
  34488. /** defines the name of the probe */
  34489. name: string;
  34490. private _scene;
  34491. private _renderTargetTexture;
  34492. private _projectionMatrix;
  34493. private _viewMatrix;
  34494. private _target;
  34495. private _add;
  34496. private _attachedMesh;
  34497. private _invertYAxis;
  34498. /** Gets or sets probe position (center of the cube map) */
  34499. position: Vector3;
  34500. /**
  34501. * Creates a new reflection probe
  34502. * @param name defines the name of the probe
  34503. * @param size defines the texture resolution (for each face)
  34504. * @param scene defines the hosting scene
  34505. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  34506. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  34507. */
  34508. constructor(
  34509. /** defines the name of the probe */
  34510. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  34511. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  34512. samples: number;
  34513. /** Gets or sets the refresh rate to use (on every frame by default) */
  34514. refreshRate: number;
  34515. /**
  34516. * Gets the hosting scene
  34517. * @returns a Scene
  34518. */
  34519. getScene(): Scene;
  34520. /** Gets the internal CubeTexture used to render to */
  34521. readonly cubeTexture: RenderTargetTexture;
  34522. /** Gets the list of meshes to render */
  34523. readonly renderList: Nullable<AbstractMesh[]>;
  34524. /**
  34525. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  34526. * @param mesh defines the mesh to attach to
  34527. */
  34528. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  34529. /**
  34530. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  34531. * @param renderingGroupId The rendering group id corresponding to its index
  34532. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34533. */
  34534. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  34535. /**
  34536. * Clean all associated resources
  34537. */
  34538. dispose(): void;
  34539. /**
  34540. * Converts the reflection probe information to a readable string for debug purpose.
  34541. * @param fullDetails Supports for multiple levels of logging within scene loading
  34542. * @returns the human readable reflection probe info
  34543. */
  34544. toString(fullDetails?: boolean): string;
  34545. /**
  34546. * Get the class name of the relfection probe.
  34547. * @returns "ReflectionProbe"
  34548. */
  34549. getClassName(): string;
  34550. /**
  34551. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  34552. * @returns The JSON representation of the texture
  34553. */
  34554. serialize(): any;
  34555. /**
  34556. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  34557. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  34558. * @param scene Define the scene the parsed reflection probe should be instantiated in
  34559. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  34560. * @returns The parsed reflection probe if successful
  34561. */
  34562. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  34563. }
  34564. }
  34565. declare module BABYLON {
  34566. /**
  34567. * Postprocess used to generate anaglyphic rendering
  34568. */
  34569. class AnaglyphPostProcess extends PostProcess {
  34570. private _passedProcess;
  34571. /**
  34572. * Creates a new AnaglyphPostProcess
  34573. * @param name defines postprocess name
  34574. * @param options defines creation options or target ratio scale
  34575. * @param rigCameras defines cameras using this postprocess
  34576. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  34577. * @param engine defines hosting engine
  34578. * @param reusable defines if the postprocess will be reused multiple times per frame
  34579. */
  34580. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  34581. }
  34582. }
  34583. declare module BABYLON {
  34584. /**
  34585. * Post process used to render in black and white
  34586. */
  34587. class BlackAndWhitePostProcess extends PostProcess {
  34588. /**
  34589. * Linear about to convert he result to black and white (default: 1)
  34590. */
  34591. degree: number;
  34592. /**
  34593. * Creates a black and white post process
  34594. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  34595. * @param name The name of the effect.
  34596. * @param options The required width/height ratio to downsize to before computing the render pass.
  34597. * @param camera The camera to apply the render pass to.
  34598. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34599. * @param engine The engine which the post process will be applied. (default: current engine)
  34600. * @param reusable If the post process can be reused on the same frame. (default: false)
  34601. */
  34602. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  34603. }
  34604. }
  34605. declare module BABYLON {
  34606. /**
  34607. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  34608. */
  34609. class BloomEffect extends PostProcessRenderEffect {
  34610. private bloomScale;
  34611. /**
  34612. * @hidden Internal
  34613. */
  34614. _effects: Array<PostProcess>;
  34615. /**
  34616. * @hidden Internal
  34617. */
  34618. _downscale: ExtractHighlightsPostProcess;
  34619. private _blurX;
  34620. private _blurY;
  34621. private _merge;
  34622. /**
  34623. * The luminance threshold to find bright areas of the image to bloom.
  34624. */
  34625. threshold: number;
  34626. /**
  34627. * The strength of the bloom.
  34628. */
  34629. weight: number;
  34630. /**
  34631. * Specifies the size of the bloom blur kernel, relative to the final output size
  34632. */
  34633. kernel: number;
  34634. /**
  34635. * Creates a new instance of @see BloomEffect
  34636. * @param scene The scene the effect belongs to.
  34637. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  34638. * @param bloomKernel The size of the kernel to be used when applying the blur.
  34639. * @param bloomWeight The the strength of bloom.
  34640. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  34641. * @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)
  34642. */
  34643. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  34644. /**
  34645. * Disposes each of the internal effects for a given camera.
  34646. * @param camera The camera to dispose the effect on.
  34647. */
  34648. disposeEffects(camera: Camera): void;
  34649. /**
  34650. * @hidden Internal
  34651. */
  34652. _updateEffects(): void;
  34653. /**
  34654. * Internal
  34655. * @returns if all the contained post processes are ready.
  34656. * @hidden
  34657. */
  34658. _isReady(): boolean;
  34659. }
  34660. }
  34661. declare module BABYLON {
  34662. /**
  34663. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  34664. */
  34665. class BloomMergePostProcess extends PostProcess {
  34666. /** Weight of the bloom to be added to the original input. */
  34667. weight: number;
  34668. /**
  34669. * Creates a new instance of @see BloomMergePostProcess
  34670. * @param name The name of the effect.
  34671. * @param originalFromInput Post process which's input will be used for the merge.
  34672. * @param blurred Blurred highlights post process which's output will be used.
  34673. * @param weight Weight of the bloom to be added to the original input.
  34674. * @param options The required width/height ratio to downsize to before computing the render pass.
  34675. * @param camera The camera to apply the render pass to.
  34676. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34677. * @param engine The engine which the post process will be applied. (default: current engine)
  34678. * @param reusable If the post process can be reused on the same frame. (default: false)
  34679. * @param textureType Type of textures used when performing the post process. (default: 0)
  34680. * @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)
  34681. */
  34682. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  34683. /** Weight of the bloom to be added to the original input. */
  34684. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  34685. }
  34686. }
  34687. declare module BABYLON {
  34688. /**
  34689. * The Blur Post Process which blurs an image based on a kernel and direction.
  34690. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  34691. */
  34692. class BlurPostProcess extends PostProcess {
  34693. /** The direction in which to blur the image. */
  34694. direction: Vector2;
  34695. private blockCompilation;
  34696. protected _kernel: number;
  34697. protected _idealKernel: number;
  34698. protected _packedFloat: boolean;
  34699. private _staticDefines;
  34700. /**
  34701. * Sets the length in pixels of the blur sample region
  34702. */
  34703. /**
  34704. * Gets the length in pixels of the blur sample region
  34705. */
  34706. kernel: number;
  34707. /**
  34708. * Sets wether or not the blur needs to unpack/repack floats
  34709. */
  34710. /**
  34711. * Gets wether or not the blur is unpacking/repacking floats
  34712. */
  34713. packedFloat: boolean;
  34714. /**
  34715. * Creates a new instance BlurPostProcess
  34716. * @param name The name of the effect.
  34717. * @param direction The direction in which to blur the image.
  34718. * @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.
  34719. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  34720. * @param camera The camera to apply the render pass to.
  34721. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34722. * @param engine The engine which the post process will be applied. (default: current engine)
  34723. * @param reusable If the post process can be reused on the same frame. (default: false)
  34724. * @param textureType Type of textures used when performing the post process. (default: 0)
  34725. * @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)
  34726. */
  34727. constructor(name: string,
  34728. /** The direction in which to blur the image. */
  34729. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  34730. /**
  34731. * Updates the effect with the current post process compile time values and recompiles the shader.
  34732. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  34733. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  34734. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  34735. * @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
  34736. * @param onCompiled Called when the shader has been compiled.
  34737. * @param onError Called if there is an error when compiling a shader.
  34738. */
  34739. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  34740. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  34741. /**
  34742. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  34743. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  34744. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  34745. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  34746. * The gaps between physical kernels are compensated for in the weighting of the samples
  34747. * @param idealKernel Ideal blur kernel.
  34748. * @return Nearest best kernel.
  34749. */
  34750. protected _nearestBestKernel(idealKernel: number): number;
  34751. /**
  34752. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  34753. * @param x The point on the Gaussian distribution to sample.
  34754. * @return the value of the Gaussian function at x.
  34755. */
  34756. protected _gaussianWeight(x: number): number;
  34757. /**
  34758. * Generates a string that can be used as a floating point number in GLSL.
  34759. * @param x Value to print.
  34760. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  34761. * @return GLSL float string.
  34762. */
  34763. protected _glslFloat(x: number, decimalFigures?: number): string;
  34764. }
  34765. }
  34766. declare module BABYLON {
  34767. /**
  34768. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  34769. */
  34770. class ChromaticAberrationPostProcess extends PostProcess {
  34771. /**
  34772. * The amount of seperation of rgb channels (default: 30)
  34773. */
  34774. aberrationAmount: number;
  34775. /**
  34776. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  34777. */
  34778. radialIntensity: number;
  34779. /**
  34780. * 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))
  34781. */
  34782. direction: Vector2;
  34783. /**
  34784. * 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))
  34785. */
  34786. centerPosition: Vector2;
  34787. /**
  34788. * Creates a new instance ChromaticAberrationPostProcess
  34789. * @param name The name of the effect.
  34790. * @param screenWidth The width of the screen to apply the effect on.
  34791. * @param screenHeight The height of the screen to apply the effect on.
  34792. * @param options The required width/height ratio to downsize to before computing the render pass.
  34793. * @param camera The camera to apply the render pass to.
  34794. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34795. * @param engine The engine which the post process will be applied. (default: current engine)
  34796. * @param reusable If the post process can be reused on the same frame. (default: false)
  34797. * @param textureType Type of textures used when performing the post process. (default: 0)
  34798. * @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)
  34799. */
  34800. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  34801. }
  34802. }
  34803. declare module BABYLON {
  34804. /**
  34805. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  34806. */
  34807. class CircleOfConfusionPostProcess extends PostProcess {
  34808. /**
  34809. * 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.
  34810. */
  34811. lensSize: number;
  34812. /**
  34813. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  34814. */
  34815. fStop: number;
  34816. /**
  34817. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  34818. */
  34819. focusDistance: number;
  34820. /**
  34821. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  34822. */
  34823. focalLength: number;
  34824. private _depthTexture;
  34825. /**
  34826. * Creates a new instance CircleOfConfusionPostProcess
  34827. * @param name The name of the effect.
  34828. * @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.
  34829. * @param options The required width/height ratio to downsize to before computing the render pass.
  34830. * @param camera The camera to apply the render pass to.
  34831. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34832. * @param engine The engine which the post process will be applied. (default: current engine)
  34833. * @param reusable If the post process can be reused on the same frame. (default: false)
  34834. * @param textureType Type of textures used when performing the post process. (default: 0)
  34835. * @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)
  34836. */
  34837. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  34838. /**
  34839. * 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.
  34840. */
  34841. depthTexture: RenderTargetTexture;
  34842. }
  34843. }
  34844. declare module BABYLON {
  34845. /**
  34846. *
  34847. * This post-process allows the modification of rendered colors by using
  34848. * a 'look-up table' (LUT). This effect is also called Color Grading.
  34849. *
  34850. * The object needs to be provided an url to a texture containing the color
  34851. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  34852. * Use an image editing software to tweak the LUT to match your needs.
  34853. *
  34854. * For an example of a color LUT, see here:
  34855. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  34856. * For explanations on color grading, see here:
  34857. * @see http://udn.epicgames.com/Three/ColorGrading.html
  34858. *
  34859. */
  34860. class ColorCorrectionPostProcess extends PostProcess {
  34861. private _colorTableTexture;
  34862. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  34863. }
  34864. }
  34865. declare module BABYLON {
  34866. /**
  34867. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  34868. * input texture to perform effects such as edge detection or sharpening
  34869. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  34870. */
  34871. class ConvolutionPostProcess extends PostProcess {
  34872. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  34873. kernel: number[];
  34874. /**
  34875. * Creates a new instance ConvolutionPostProcess
  34876. * @param name The name of the effect.
  34877. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  34878. * @param options The required width/height ratio to downsize to before computing the render pass.
  34879. * @param camera The camera to apply the render pass to.
  34880. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34881. * @param engine The engine which the post process will be applied. (default: current engine)
  34882. * @param reusable If the post process can be reused on the same frame. (default: false)
  34883. * @param textureType Type of textures used when performing the post process. (default: 0)
  34884. */
  34885. constructor(name: string,
  34886. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  34887. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  34888. /**
  34889. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34890. */
  34891. static EdgeDetect0Kernel: number[];
  34892. /**
  34893. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34894. */
  34895. static EdgeDetect1Kernel: number[];
  34896. /**
  34897. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34898. */
  34899. static EdgeDetect2Kernel: number[];
  34900. /**
  34901. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34902. */
  34903. static SharpenKernel: number[];
  34904. /**
  34905. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34906. */
  34907. static EmbossKernel: number[];
  34908. /**
  34909. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34910. */
  34911. static GaussianKernel: number[];
  34912. }
  34913. }
  34914. declare module BABYLON {
  34915. /**
  34916. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  34917. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  34918. * based on samples that have a large difference in distance than the center pixel.
  34919. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  34920. */
  34921. class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  34922. direction: Vector2;
  34923. /**
  34924. * Creates a new instance CircleOfConfusionPostProcess
  34925. * @param name The name of the effect.
  34926. * @param scene The scene the effect belongs to.
  34927. * @param direction The direction the blur should be applied.
  34928. * @param kernel The size of the kernel used to blur.
  34929. * @param options The required width/height ratio to downsize to before computing the render pass.
  34930. * @param camera The camera to apply the render pass to.
  34931. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  34932. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  34933. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34934. * @param engine The engine which the post process will be applied. (default: current engine)
  34935. * @param reusable If the post process can be reused on the same frame. (default: false)
  34936. * @param textureType Type of textures used when performing the post process. (default: 0)
  34937. * @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)
  34938. */
  34939. 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);
  34940. }
  34941. }
  34942. declare module BABYLON {
  34943. /**
  34944. * Specifies the level of max blur that should be applied when using the depth of field effect
  34945. */
  34946. enum DepthOfFieldEffectBlurLevel {
  34947. /**
  34948. * Subtle blur
  34949. */
  34950. Low = 0,
  34951. /**
  34952. * Medium blur
  34953. */
  34954. Medium = 1,
  34955. /**
  34956. * Large blur
  34957. */
  34958. High = 2
  34959. }
  34960. /**
  34961. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  34962. */
  34963. class DepthOfFieldEffect extends PostProcessRenderEffect {
  34964. private _circleOfConfusion;
  34965. /**
  34966. * @hidden Internal, blurs from high to low
  34967. */
  34968. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  34969. private _depthOfFieldBlurY;
  34970. private _dofMerge;
  34971. /**
  34972. * @hidden Internal post processes in depth of field effect
  34973. */
  34974. _effects: Array<PostProcess>;
  34975. /**
  34976. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  34977. */
  34978. focalLength: number;
  34979. /**
  34980. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  34981. */
  34982. fStop: number;
  34983. /**
  34984. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  34985. */
  34986. focusDistance: number;
  34987. /**
  34988. * 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.
  34989. */
  34990. lensSize: number;
  34991. /**
  34992. * Creates a new instance DepthOfFieldEffect
  34993. * @param scene The scene the effect belongs to.
  34994. * @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.
  34995. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  34996. * @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)
  34997. */
  34998. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  34999. /**
  35000. * 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.
  35001. */
  35002. depthTexture: RenderTargetTexture;
  35003. /**
  35004. * Disposes each of the internal effects for a given camera.
  35005. * @param camera The camera to dispose the effect on.
  35006. */
  35007. disposeEffects(camera: Camera): void;
  35008. /**
  35009. * @hidden Internal
  35010. */
  35011. _updateEffects(): void;
  35012. /**
  35013. * Internal
  35014. * @returns if all the contained post processes are ready.
  35015. * @hidden
  35016. */
  35017. _isReady(): boolean;
  35018. }
  35019. }
  35020. declare module BABYLON {
  35021. /**
  35022. * Options to be set when merging outputs from the default pipeline.
  35023. */
  35024. class DepthOfFieldMergePostProcessOptions {
  35025. /**
  35026. * The original image to merge on top of
  35027. */
  35028. originalFromInput: PostProcess;
  35029. /**
  35030. * Parameters to perform the merge of the depth of field effect
  35031. */
  35032. depthOfField?: {
  35033. circleOfConfusion: PostProcess;
  35034. blurSteps: Array<PostProcess>;
  35035. };
  35036. /**
  35037. * Parameters to perform the merge of bloom effect
  35038. */
  35039. bloom?: {
  35040. blurred: PostProcess;
  35041. weight: number;
  35042. };
  35043. }
  35044. /**
  35045. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  35046. */
  35047. class DepthOfFieldMergePostProcess extends PostProcess {
  35048. private blurSteps;
  35049. /**
  35050. * Creates a new instance of DepthOfFieldMergePostProcess
  35051. * @param name The name of the effect.
  35052. * @param originalFromInput Post process which's input will be used for the merge.
  35053. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  35054. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  35055. * @param options The required width/height ratio to downsize to before computing the render pass.
  35056. * @param camera The camera to apply the render pass to.
  35057. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35058. * @param engine The engine which the post process will be applied. (default: current engine)
  35059. * @param reusable If the post process can be reused on the same frame. (default: false)
  35060. * @param textureType Type of textures used when performing the post process. (default: 0)
  35061. * @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)
  35062. */
  35063. 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);
  35064. /**
  35065. * Updates the effect with the current post process compile time values and recompiles the shader.
  35066. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  35067. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  35068. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  35069. * @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
  35070. * @param onCompiled Called when the shader has been compiled.
  35071. * @param onError Called if there is an error when compiling a shader.
  35072. */
  35073. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  35074. }
  35075. }
  35076. declare module BABYLON {
  35077. /**
  35078. * DisplayPassPostProcess which produces an output the same as it's input
  35079. */
  35080. class DisplayPassPostProcess extends PostProcess {
  35081. /**
  35082. * Creates the DisplayPassPostProcess
  35083. * @param name The name of the effect.
  35084. * @param options The required width/height ratio to downsize to before computing the render pass.
  35085. * @param camera The camera to apply the render pass to.
  35086. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35087. * @param engine The engine which the post process will be applied. (default: current engine)
  35088. * @param reusable If the post process can be reused on the same frame. (default: false)
  35089. */
  35090. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  35091. }
  35092. }
  35093. declare module BABYLON {
  35094. /**
  35095. * 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.
  35096. */
  35097. class ExtractHighlightsPostProcess extends PostProcess {
  35098. /**
  35099. * The luminance threshold, pixels below this value will be set to black.
  35100. */
  35101. threshold: number;
  35102. /** @hidden */
  35103. _exposure: number;
  35104. /**
  35105. * Post process which has the input texture to be used when performing highlight extraction
  35106. * @hidden
  35107. */
  35108. _inputPostProcess: Nullable<PostProcess>;
  35109. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35110. }
  35111. }
  35112. declare module BABYLON {
  35113. /**
  35114. * Applies a kernel filter to the image
  35115. */
  35116. class FilterPostProcess extends PostProcess {
  35117. /** The matrix to be applied to the image */
  35118. kernelMatrix: Matrix;
  35119. /**
  35120. *
  35121. * @param name The name of the effect.
  35122. * @param kernelMatrix The matrix to be applied to the image
  35123. * @param options The required width/height ratio to downsize to before computing the render pass.
  35124. * @param camera The camera to apply the render pass to.
  35125. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35126. * @param engine The engine which the post process will be applied. (default: current engine)
  35127. * @param reusable If the post process can be reused on the same frame. (default: false)
  35128. */
  35129. constructor(name: string,
  35130. /** The matrix to be applied to the image */
  35131. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  35132. }
  35133. }
  35134. declare module BABYLON {
  35135. /**
  35136. * Fxaa post process
  35137. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  35138. */
  35139. class FxaaPostProcess extends PostProcess {
  35140. /** @hidden */
  35141. texelWidth: number;
  35142. /** @hidden */
  35143. texelHeight: number;
  35144. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  35145. private _getDefines;
  35146. }
  35147. }
  35148. declare module BABYLON {
  35149. /**
  35150. * The GrainPostProcess adds noise to the image at mid luminance levels
  35151. */
  35152. class GrainPostProcess extends PostProcess {
  35153. /**
  35154. * The intensity of the grain added (default: 30)
  35155. */
  35156. intensity: number;
  35157. /**
  35158. * If the grain should be randomized on every frame
  35159. */
  35160. animated: boolean;
  35161. /**
  35162. * Creates a new instance of @see GrainPostProcess
  35163. * @param name The name of the effect.
  35164. * @param options The required width/height ratio to downsize to before computing the render pass.
  35165. * @param camera The camera to apply the render pass to.
  35166. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35167. * @param engine The engine which the post process will be applied. (default: current engine)
  35168. * @param reusable If the post process can be reused on the same frame. (default: false)
  35169. * @param textureType Type of textures used when performing the post process. (default: 0)
  35170. * @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)
  35171. */
  35172. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35173. }
  35174. }
  35175. declare module BABYLON {
  35176. /**
  35177. * Extracts highlights from the image
  35178. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  35179. */
  35180. class HighlightsPostProcess extends PostProcess {
  35181. /**
  35182. * Extracts highlights from the image
  35183. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  35184. * @param name The name of the effect.
  35185. * @param options The required width/height ratio to downsize to before computing the render pass.
  35186. * @param camera The camera to apply the render pass to.
  35187. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35188. * @param engine The engine which the post process will be applied. (default: current engine)
  35189. * @param reusable If the post process can be reused on the same frame. (default: false)
  35190. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  35191. */
  35192. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  35193. }
  35194. }
  35195. declare module BABYLON {
  35196. /**
  35197. * ImageProcessingPostProcess
  35198. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  35199. */
  35200. class ImageProcessingPostProcess extends PostProcess {
  35201. /**
  35202. * Default configuration related to image processing available in the PBR Material.
  35203. */
  35204. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  35205. /**
  35206. * Gets the image processing configuration used either in this material.
  35207. */
  35208. /**
  35209. * Sets the Default image processing configuration used either in the this material.
  35210. *
  35211. * If sets to null, the scene one is in use.
  35212. */
  35213. imageProcessingConfiguration: ImageProcessingConfiguration;
  35214. /**
  35215. * Keep track of the image processing observer to allow dispose and replace.
  35216. */
  35217. private _imageProcessingObserver;
  35218. /**
  35219. * Attaches a new image processing configuration to the PBR Material.
  35220. * @param configuration
  35221. */
  35222. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  35223. /**
  35224. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  35225. */
  35226. /**
  35227. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  35228. */
  35229. colorCurves: Nullable<ColorCurves>;
  35230. /**
  35231. * Gets wether the color curves effect is enabled.
  35232. */
  35233. /**
  35234. * Sets wether the color curves effect is enabled.
  35235. */
  35236. colorCurvesEnabled: boolean;
  35237. /**
  35238. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  35239. */
  35240. /**
  35241. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  35242. */
  35243. colorGradingTexture: Nullable<BaseTexture>;
  35244. /**
  35245. * Gets wether the color grading effect is enabled.
  35246. */
  35247. /**
  35248. * Gets wether the color grading effect is enabled.
  35249. */
  35250. colorGradingEnabled: boolean;
  35251. /**
  35252. * Gets exposure used in the effect.
  35253. */
  35254. /**
  35255. * Sets exposure used in the effect.
  35256. */
  35257. exposure: number;
  35258. /**
  35259. * Gets wether tonemapping is enabled or not.
  35260. */
  35261. /**
  35262. * Sets wether tonemapping is enabled or not
  35263. */
  35264. toneMappingEnabled: boolean;
  35265. /**
  35266. * Gets contrast used in the effect.
  35267. */
  35268. /**
  35269. * Sets contrast used in the effect.
  35270. */
  35271. contrast: number;
  35272. /**
  35273. * Gets Vignette stretch size.
  35274. */
  35275. /**
  35276. * Sets Vignette stretch size.
  35277. */
  35278. vignetteStretch: number;
  35279. /**
  35280. * Gets Vignette centre X Offset.
  35281. */
  35282. /**
  35283. * Sets Vignette centre X Offset.
  35284. */
  35285. vignetteCentreX: number;
  35286. /**
  35287. * Gets Vignette centre Y Offset.
  35288. */
  35289. /**
  35290. * Sets Vignette centre Y Offset.
  35291. */
  35292. vignetteCentreY: number;
  35293. /**
  35294. * Gets Vignette weight or intensity of the vignette effect.
  35295. */
  35296. /**
  35297. * Sets Vignette weight or intensity of the vignette effect.
  35298. */
  35299. vignetteWeight: number;
  35300. /**
  35301. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  35302. * if vignetteEnabled is set to true.
  35303. */
  35304. /**
  35305. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  35306. * if vignetteEnabled is set to true.
  35307. */
  35308. vignetteColor: Color4;
  35309. /**
  35310. * Gets Camera field of view used by the Vignette effect.
  35311. */
  35312. /**
  35313. * Sets Camera field of view used by the Vignette effect.
  35314. */
  35315. vignetteCameraFov: number;
  35316. /**
  35317. * Gets the vignette blend mode allowing different kind of effect.
  35318. */
  35319. /**
  35320. * Sets the vignette blend mode allowing different kind of effect.
  35321. */
  35322. vignetteBlendMode: number;
  35323. /**
  35324. * Gets wether the vignette effect is enabled.
  35325. */
  35326. /**
  35327. * Sets wether the vignette effect is enabled.
  35328. */
  35329. vignetteEnabled: boolean;
  35330. private _fromLinearSpace;
  35331. /**
  35332. * Gets wether the input of the processing is in Gamma or Linear Space.
  35333. */
  35334. /**
  35335. * Sets wether the input of the processing is in Gamma or Linear Space.
  35336. */
  35337. fromLinearSpace: boolean;
  35338. /**
  35339. * Defines cache preventing GC.
  35340. */
  35341. private _defines;
  35342. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  35343. /**
  35344. * "ImageProcessingPostProcess"
  35345. * @returns "ImageProcessingPostProcess"
  35346. */
  35347. getClassName(): string;
  35348. protected _updateParameters(): void;
  35349. dispose(camera?: Camera): void;
  35350. }
  35351. }
  35352. declare module BABYLON {
  35353. /**
  35354. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  35355. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  35356. * As an example, all you have to do is to create the post-process:
  35357. * var mb = new BABYLON.MotionBlurPostProcess(
  35358. * 'mb', // The name of the effect.
  35359. * scene, // The scene containing the objects to blur according to their velocity.
  35360. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  35361. * camera // The camera to apply the render pass to.
  35362. * );
  35363. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  35364. */
  35365. class MotionBlurPostProcess extends PostProcess {
  35366. /**
  35367. * Defines how much the image is blurred by the movement. Default value is equal to 1
  35368. */
  35369. motionStrength: number;
  35370. /**
  35371. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  35372. */
  35373. /**
  35374. * Sets the number of iterations to be used for motion blur quality
  35375. */
  35376. motionBlurSamples: number;
  35377. private _motionBlurSamples;
  35378. private _geometryBufferRenderer;
  35379. /**
  35380. * Creates a new instance MotionBlurPostProcess
  35381. * @param name The name of the effect.
  35382. * @param scene The scene containing the objects to blur according to their velocity.
  35383. * @param options The required width/height ratio to downsize to before computing the render pass.
  35384. * @param camera The camera to apply the render pass to.
  35385. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35386. * @param engine The engine which the post process will be applied. (default: current engine)
  35387. * @param reusable If the post process can be reused on the same frame. (default: false)
  35388. * @param textureType Type of textures used when performing the post process. (default: 0)
  35389. * @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)
  35390. */
  35391. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35392. /**
  35393. * Disposes the post process.
  35394. * @param camera The camera to dispose the post process on.
  35395. */
  35396. dispose(camera?: Camera): void;
  35397. }
  35398. }
  35399. declare module BABYLON {
  35400. /**
  35401. * PassPostProcess which produces an output the same as it's input
  35402. */
  35403. class PassPostProcess extends PostProcess {
  35404. /**
  35405. * Creates the PassPostProcess
  35406. * @param name The name of the effect.
  35407. * @param options The required width/height ratio to downsize to before computing the render pass.
  35408. * @param camera The camera to apply the render pass to.
  35409. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35410. * @param engine The engine which the post process will be applied. (default: current engine)
  35411. * @param reusable If the post process can be reused on the same frame. (default: false)
  35412. * @param textureType The type of texture to be used when performing the post processing.
  35413. * @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)
  35414. */
  35415. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35416. }
  35417. /**
  35418. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  35419. */
  35420. class PassCubePostProcess extends PostProcess {
  35421. private _face;
  35422. /**
  35423. * Gets or sets the cube face to display.
  35424. * * 0 is +X
  35425. * * 1 is -X
  35426. * * 2 is +Y
  35427. * * 3 is -Y
  35428. * * 4 is +Z
  35429. * * 5 is -Z
  35430. */
  35431. face: number;
  35432. /**
  35433. * Creates the PassCubePostProcess
  35434. * @param name The name of the effect.
  35435. * @param options The required width/height ratio to downsize to before computing the render pass.
  35436. * @param camera The camera to apply the render pass to.
  35437. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35438. * @param engine The engine which the post process will be applied. (default: current engine)
  35439. * @param reusable If the post process can be reused on the same frame. (default: false)
  35440. * @param textureType The type of texture to be used when performing the post processing.
  35441. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  35442. */
  35443. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35444. }
  35445. }
  35446. declare module BABYLON {
  35447. /**
  35448. * Size options for a post process
  35449. */
  35450. type PostProcessOptions = {
  35451. width: number;
  35452. height: number;
  35453. };
  35454. /**
  35455. * PostProcess can be used to apply a shader to a texture after it has been rendered
  35456. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  35457. */
  35458. class PostProcess {
  35459. /** Name of the PostProcess. */
  35460. name: string;
  35461. /**
  35462. * Width of the texture to apply the post process on
  35463. */
  35464. width: number;
  35465. /**
  35466. * Height of the texture to apply the post process on
  35467. */
  35468. height: number;
  35469. /**
  35470. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  35471. * @hidden
  35472. */
  35473. _outputTexture: Nullable<InternalTexture>;
  35474. /**
  35475. * Sampling mode used by the shader
  35476. * See https://doc.babylonjs.com/classes/3.1/texture
  35477. */
  35478. renderTargetSamplingMode: number;
  35479. /**
  35480. * Clear color to use when screen clearing
  35481. */
  35482. clearColor: Color4;
  35483. /**
  35484. * If the buffer needs to be cleared before applying the post process. (default: true)
  35485. * Should be set to false if shader will overwrite all previous pixels.
  35486. */
  35487. autoClear: boolean;
  35488. /**
  35489. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  35490. */
  35491. alphaMode: number;
  35492. /**
  35493. * Sets the setAlphaBlendConstants of the babylon engine
  35494. */
  35495. alphaConstants: Color4;
  35496. /**
  35497. * Animations to be used for the post processing
  35498. */
  35499. animations: Animation[];
  35500. /**
  35501. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  35502. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  35503. */
  35504. enablePixelPerfectMode: boolean;
  35505. /**
  35506. * Force the postprocess to be applied without taking in account viewport
  35507. */
  35508. forceFullscreenViewport: boolean;
  35509. /**
  35510. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  35511. *
  35512. * | Value | Type | Description |
  35513. * | ----- | ----------------------------------- | ----------- |
  35514. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  35515. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  35516. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  35517. *
  35518. */
  35519. scaleMode: number;
  35520. /**
  35521. * Force textures to be a power of two (default: false)
  35522. */
  35523. alwaysForcePOT: boolean;
  35524. private _samples;
  35525. /**
  35526. * Number of sample textures (default: 1)
  35527. */
  35528. samples: number;
  35529. /**
  35530. * Modify the scale of the post process to be the same as the viewport (default: false)
  35531. */
  35532. adaptScaleToCurrentViewport: boolean;
  35533. private _camera;
  35534. private _scene;
  35535. private _engine;
  35536. private _options;
  35537. private _reusable;
  35538. private _textureType;
  35539. /**
  35540. * Smart array of input and output textures for the post process.
  35541. * @hidden
  35542. */
  35543. _textures: SmartArray<InternalTexture>;
  35544. /**
  35545. * The index in _textures that corresponds to the output texture.
  35546. * @hidden
  35547. */
  35548. _currentRenderTextureInd: number;
  35549. private _effect;
  35550. private _samplers;
  35551. private _fragmentUrl;
  35552. private _vertexUrl;
  35553. private _parameters;
  35554. private _scaleRatio;
  35555. protected _indexParameters: any;
  35556. private _shareOutputWithPostProcess;
  35557. private _texelSize;
  35558. private _forcedOutputTexture;
  35559. /**
  35560. * An event triggered when the postprocess is activated.
  35561. */
  35562. onActivateObservable: Observable<Camera>;
  35563. private _onActivateObserver;
  35564. /**
  35565. * A function that is added to the onActivateObservable
  35566. */
  35567. onActivate: Nullable<(camera: Camera) => void>;
  35568. /**
  35569. * An event triggered when the postprocess changes its size.
  35570. */
  35571. onSizeChangedObservable: Observable<PostProcess>;
  35572. private _onSizeChangedObserver;
  35573. /**
  35574. * A function that is added to the onSizeChangedObservable
  35575. */
  35576. onSizeChanged: (postProcess: PostProcess) => void;
  35577. /**
  35578. * An event triggered when the postprocess applies its effect.
  35579. */
  35580. onApplyObservable: Observable<Effect>;
  35581. private _onApplyObserver;
  35582. /**
  35583. * A function that is added to the onApplyObservable
  35584. */
  35585. onApply: (effect: Effect) => void;
  35586. /**
  35587. * An event triggered before rendering the postprocess
  35588. */
  35589. onBeforeRenderObservable: Observable<Effect>;
  35590. private _onBeforeRenderObserver;
  35591. /**
  35592. * A function that is added to the onBeforeRenderObservable
  35593. */
  35594. onBeforeRender: (effect: Effect) => void;
  35595. /**
  35596. * An event triggered after rendering the postprocess
  35597. */
  35598. onAfterRenderObservable: Observable<Effect>;
  35599. private _onAfterRenderObserver;
  35600. /**
  35601. * A function that is added to the onAfterRenderObservable
  35602. */
  35603. onAfterRender: (efect: Effect) => void;
  35604. /**
  35605. * 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
  35606. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  35607. */
  35608. inputTexture: InternalTexture;
  35609. /**
  35610. * Gets the camera which post process is applied to.
  35611. * @returns The camera the post process is applied to.
  35612. */
  35613. getCamera(): Camera;
  35614. /**
  35615. * Gets the texel size of the postprocess.
  35616. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  35617. */
  35618. readonly texelSize: Vector2;
  35619. /**
  35620. * Creates a new instance PostProcess
  35621. * @param name The name of the PostProcess.
  35622. * @param fragmentUrl The url of the fragment shader to be used.
  35623. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  35624. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  35625. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  35626. * @param camera The camera to apply the render pass to.
  35627. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35628. * @param engine The engine which the post process will be applied. (default: current engine)
  35629. * @param reusable If the post process can be reused on the same frame. (default: false)
  35630. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  35631. * @param textureType Type of textures used when performing the post process. (default: 0)
  35632. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  35633. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  35634. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  35635. */
  35636. constructor(
  35637. /** Name of the PostProcess. */
  35638. 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);
  35639. /**
  35640. * Gets the engine which this post process belongs to.
  35641. * @returns The engine the post process was enabled with.
  35642. */
  35643. getEngine(): Engine;
  35644. /**
  35645. * The effect that is created when initializing the post process.
  35646. * @returns The created effect corrisponding the the postprocess.
  35647. */
  35648. getEffect(): Effect;
  35649. /**
  35650. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  35651. * @param postProcess The post process to share the output with.
  35652. * @returns This post process.
  35653. */
  35654. shareOutputWith(postProcess: PostProcess): PostProcess;
  35655. /**
  35656. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  35657. * This should be called if the post process that shares output with this post process is disabled/disposed.
  35658. */
  35659. useOwnOutput(): void;
  35660. /**
  35661. * Updates the effect with the current post process compile time values and recompiles the shader.
  35662. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  35663. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  35664. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  35665. * @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
  35666. * @param onCompiled Called when the shader has been compiled.
  35667. * @param onError Called if there is an error when compiling a shader.
  35668. */
  35669. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  35670. /**
  35671. * The post process is reusable if it can be used multiple times within one frame.
  35672. * @returns If the post process is reusable
  35673. */
  35674. isReusable(): boolean;
  35675. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  35676. markTextureDirty(): void;
  35677. /**
  35678. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  35679. * 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.
  35680. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  35681. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  35682. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  35683. * @returns The target texture that was bound to be written to.
  35684. */
  35685. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  35686. /**
  35687. * If the post process is supported.
  35688. */
  35689. readonly isSupported: boolean;
  35690. /**
  35691. * The aspect ratio of the output texture.
  35692. */
  35693. readonly aspectRatio: number;
  35694. /**
  35695. * Get a value indicating if the post-process is ready to be used
  35696. * @returns true if the post-process is ready (shader is compiled)
  35697. */
  35698. isReady(): boolean;
  35699. /**
  35700. * Binds all textures and uniforms to the shader, this will be run on every pass.
  35701. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  35702. */
  35703. apply(): Nullable<Effect>;
  35704. private _disposeTextures;
  35705. /**
  35706. * Disposes the post process.
  35707. * @param camera The camera to dispose the post process on.
  35708. */
  35709. dispose(camera?: Camera): void;
  35710. }
  35711. }
  35712. declare module BABYLON {
  35713. /**
  35714. * PostProcessManager is used to manage one or more post processes or post process pipelines
  35715. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  35716. */
  35717. class PostProcessManager {
  35718. private _scene;
  35719. private _indexBuffer;
  35720. private _vertexBuffers;
  35721. /**
  35722. * Creates a new instance PostProcess
  35723. * @param scene The scene that the post process is associated with.
  35724. */
  35725. constructor(scene: Scene);
  35726. private _prepareBuffers;
  35727. private _buildIndexBuffer;
  35728. /**
  35729. * Rebuilds the vertex buffers of the manager.
  35730. * @hidden
  35731. */
  35732. _rebuild(): void;
  35733. /**
  35734. * Prepares a frame to be run through a post process.
  35735. * @param sourceTexture The input texture to the post procesess. (default: null)
  35736. * @param postProcesses An array of post processes to be run. (default: null)
  35737. * @returns True if the post processes were able to be run.
  35738. * @hidden
  35739. */
  35740. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  35741. /**
  35742. * Manually render a set of post processes to a texture.
  35743. * @param postProcesses An array of post processes to be run.
  35744. * @param targetTexture The target texture to render to.
  35745. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  35746. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  35747. * @param lodLevel defines which lod of the texture to render to
  35748. */
  35749. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  35750. /**
  35751. * Finalize the result of the output of the postprocesses.
  35752. * @param doNotPresent If true the result will not be displayed to the screen.
  35753. * @param targetTexture The target texture to render to.
  35754. * @param faceIndex The index of the face to bind the target texture to.
  35755. * @param postProcesses The array of post processes to render.
  35756. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  35757. * @hidden
  35758. */
  35759. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  35760. /**
  35761. * Disposes of the post process manager.
  35762. */
  35763. dispose(): void;
  35764. }
  35765. }
  35766. declare module BABYLON {
  35767. /**
  35768. * Post process which applies a refractin texture
  35769. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  35770. */
  35771. class RefractionPostProcess extends PostProcess {
  35772. /** the base color of the refraction (used to taint the rendering) */
  35773. color: Color3;
  35774. /** simulated refraction depth */
  35775. depth: number;
  35776. /** the coefficient of the base color (0 to remove base color tainting) */
  35777. colorLevel: number;
  35778. private _refTexture;
  35779. private _ownRefractionTexture;
  35780. /**
  35781. * Gets or sets the refraction texture
  35782. * Please note that you are responsible for disposing the texture if you set it manually
  35783. */
  35784. refractionTexture: Texture;
  35785. /**
  35786. * Initializes the RefractionPostProcess
  35787. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  35788. * @param name The name of the effect.
  35789. * @param refractionTextureUrl Url of the refraction texture to use
  35790. * @param color the base color of the refraction (used to taint the rendering)
  35791. * @param depth simulated refraction depth
  35792. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  35793. * @param camera The camera to apply the render pass to.
  35794. * @param options The required width/height ratio to downsize to before computing the render pass.
  35795. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35796. * @param engine The engine which the post process will be applied. (default: current engine)
  35797. * @param reusable If the post process can be reused on the same frame. (default: false)
  35798. */
  35799. constructor(name: string, refractionTextureUrl: string,
  35800. /** the base color of the refraction (used to taint the rendering) */
  35801. color: Color3,
  35802. /** simulated refraction depth */
  35803. depth: number,
  35804. /** the coefficient of the base color (0 to remove base color tainting) */
  35805. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  35806. /**
  35807. * Disposes of the post process
  35808. * @param camera Camera to dispose post process on
  35809. */
  35810. dispose(camera: Camera): void;
  35811. }
  35812. }
  35813. declare module BABYLON {
  35814. /**
  35815. * The SharpenPostProcess applies a sharpen kernel to every pixel
  35816. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  35817. */
  35818. class SharpenPostProcess extends PostProcess {
  35819. /**
  35820. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  35821. */
  35822. colorAmount: number;
  35823. /**
  35824. * How much sharpness should be applied (default: 0.3)
  35825. */
  35826. edgeAmount: number;
  35827. /**
  35828. * Creates a new instance ConvolutionPostProcess
  35829. * @param name The name of the effect.
  35830. * @param options The required width/height ratio to downsize to before computing the render pass.
  35831. * @param camera The camera to apply the render pass to.
  35832. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35833. * @param engine The engine which the post process will be applied. (default: current engine)
  35834. * @param reusable If the post process can be reused on the same frame. (default: false)
  35835. * @param textureType Type of textures used when performing the post process. (default: 0)
  35836. * @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)
  35837. */
  35838. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35839. }
  35840. }
  35841. declare module BABYLON {
  35842. /**
  35843. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  35844. */
  35845. class StereoscopicInterlacePostProcess extends PostProcess {
  35846. private _stepSize;
  35847. private _passedProcess;
  35848. /**
  35849. * Initializes a StereoscopicInterlacePostProcess
  35850. * @param name The name of the effect.
  35851. * @param rigCameras The rig cameras to be appled to the post process
  35852. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  35853. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35854. * @param engine The engine which the post process will be applied. (default: current engine)
  35855. * @param reusable If the post process can be reused on the same frame. (default: false)
  35856. */
  35857. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  35858. }
  35859. }
  35860. declare module BABYLON {
  35861. /** Defines operator used for tonemapping */
  35862. enum TonemappingOperator {
  35863. /** Hable */
  35864. Hable = 0,
  35865. /** Reinhard */
  35866. Reinhard = 1,
  35867. /** HejiDawson */
  35868. HejiDawson = 2,
  35869. /** Photographic */
  35870. Photographic = 3
  35871. }
  35872. /**
  35873. * Defines a post process to apply tone mapping
  35874. */
  35875. class TonemapPostProcess extends PostProcess {
  35876. private _operator;
  35877. /** Defines the required exposure adjustement */
  35878. exposureAdjustment: number;
  35879. /**
  35880. * Creates a new TonemapPostProcess
  35881. * @param name defines the name of the postprocess
  35882. * @param _operator defines the operator to use
  35883. * @param exposureAdjustment defines the required exposure adjustement
  35884. * @param camera defines the camera to use (can be null)
  35885. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  35886. * @param engine defines the hosting engine (can be ignore if camera is set)
  35887. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  35888. */
  35889. constructor(name: string, _operator: TonemappingOperator,
  35890. /** Defines the required exposure adjustement */
  35891. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  35892. }
  35893. }
  35894. declare module BABYLON {
  35895. /**
  35896. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  35897. */
  35898. class VolumetricLightScatteringPostProcess extends PostProcess {
  35899. private _volumetricLightScatteringPass;
  35900. private _volumetricLightScatteringRTT;
  35901. private _viewPort;
  35902. private _screenCoordinates;
  35903. private _cachedDefines;
  35904. /**
  35905. * If not undefined, the mesh position is computed from the attached node position
  35906. */
  35907. attachedNode: {
  35908. position: Vector3;
  35909. };
  35910. /**
  35911. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  35912. */
  35913. customMeshPosition: Vector3;
  35914. /**
  35915. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  35916. */
  35917. useCustomMeshPosition: boolean;
  35918. /**
  35919. * If the post-process should inverse the light scattering direction
  35920. */
  35921. invert: boolean;
  35922. /**
  35923. * The internal mesh used by the post-process
  35924. */
  35925. mesh: Mesh;
  35926. /**
  35927. * @hidden
  35928. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  35929. */
  35930. useDiffuseColor: boolean;
  35931. /**
  35932. * Array containing the excluded meshes not rendered in the internal pass
  35933. */
  35934. excludedMeshes: AbstractMesh[];
  35935. /**
  35936. * Controls the overall intensity of the post-process
  35937. */
  35938. exposure: number;
  35939. /**
  35940. * Dissipates each sample's contribution in range [0, 1]
  35941. */
  35942. decay: number;
  35943. /**
  35944. * Controls the overall intensity of each sample
  35945. */
  35946. weight: number;
  35947. /**
  35948. * Controls the density of each sample
  35949. */
  35950. density: number;
  35951. /**
  35952. * @constructor
  35953. * @param name The post-process name
  35954. * @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)
  35955. * @param camera The camera that the post-process will be attached to
  35956. * @param mesh The mesh used to create the light scattering
  35957. * @param samples The post-process quality, default 100
  35958. * @param samplingModeThe post-process filtering mode
  35959. * @param engine The babylon engine
  35960. * @param reusable If the post-process is reusable
  35961. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  35962. */
  35963. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  35964. /**
  35965. * Returns the string "VolumetricLightScatteringPostProcess"
  35966. * @returns "VolumetricLightScatteringPostProcess"
  35967. */
  35968. getClassName(): string;
  35969. private _isReady;
  35970. /**
  35971. * Sets the new light position for light scattering effect
  35972. * @param position The new custom light position
  35973. */
  35974. setCustomMeshPosition(position: Vector3): void;
  35975. /**
  35976. * Returns the light position for light scattering effect
  35977. * @return Vector3 The custom light position
  35978. */
  35979. getCustomMeshPosition(): Vector3;
  35980. /**
  35981. * Disposes the internal assets and detaches the post-process from the camera
  35982. */
  35983. dispose(camera: Camera): void;
  35984. /**
  35985. * Returns the render target texture used by the post-process
  35986. * @return the render target texture used by the post-process
  35987. */
  35988. getPass(): RenderTargetTexture;
  35989. private _meshExcluded;
  35990. private _createPass;
  35991. private _updateMeshScreenCoordinates;
  35992. /**
  35993. * Creates a default mesh for the Volumeric Light Scattering post-process
  35994. * @param name The mesh name
  35995. * @param scene The scene where to create the mesh
  35996. * @return the default mesh
  35997. */
  35998. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  35999. }
  36000. }
  36001. declare module BABYLON {
  36002. /**
  36003. * VRDistortionCorrectionPostProcess used for mobile VR
  36004. */
  36005. class VRDistortionCorrectionPostProcess extends PostProcess {
  36006. private _isRightEye;
  36007. private _distortionFactors;
  36008. private _postProcessScaleFactor;
  36009. private _lensCenterOffset;
  36010. private _scaleIn;
  36011. private _scaleFactor;
  36012. private _lensCenter;
  36013. /**
  36014. * Initializes the VRDistortionCorrectionPostProcess
  36015. * @param name The name of the effect.
  36016. * @param camera The camera to apply the render pass to.
  36017. * @param isRightEye If this is for the right eye distortion
  36018. * @param vrMetrics All the required metrics for the VR camera
  36019. */
  36020. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  36021. }
  36022. }
  36023. declare module BABYLON {
  36024. interface Scene {
  36025. /** @hidden (Backing field) */
  36026. _boundingBoxRenderer: BoundingBoxRenderer;
  36027. /** @hidden (Backing field) */
  36028. _forceShowBoundingBoxes: boolean;
  36029. /**
  36030. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  36031. */
  36032. forceShowBoundingBoxes: boolean;
  36033. /**
  36034. * Gets the bounding box renderer associated with the scene
  36035. * @returns a BoundingBoxRenderer
  36036. */
  36037. getBoundingBoxRenderer(): BoundingBoxRenderer;
  36038. }
  36039. interface AbstractMesh {
  36040. /** @hidden (Backing field) */
  36041. _showBoundingBox: boolean;
  36042. /**
  36043. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  36044. */
  36045. showBoundingBox: boolean;
  36046. }
  36047. /**
  36048. * Component responsible of rendering the bounding box of the meshes in a scene.
  36049. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  36050. */
  36051. class BoundingBoxRenderer implements ISceneComponent {
  36052. /**
  36053. * The component name helpfull to identify the component in the list of scene components.
  36054. */
  36055. readonly name: string;
  36056. /**
  36057. * The scene the component belongs to.
  36058. */
  36059. scene: Scene;
  36060. /**
  36061. * Color of the bounding box lines placed in front of an object
  36062. */
  36063. frontColor: Color3;
  36064. /**
  36065. * Color of the bounding box lines placed behind an object
  36066. */
  36067. backColor: Color3;
  36068. /**
  36069. * Defines if the renderer should show the back lines or not
  36070. */
  36071. showBackLines: boolean;
  36072. /**
  36073. * @hidden
  36074. */
  36075. renderList: SmartArray<BoundingBox>;
  36076. private _colorShader;
  36077. private _vertexBuffers;
  36078. private _indexBuffer;
  36079. /**
  36080. * Instantiates a new bounding box renderer in a scene.
  36081. * @param scene the scene the renderer renders in
  36082. */
  36083. constructor(scene: Scene);
  36084. /**
  36085. * Registers the component in a given scene
  36086. */
  36087. register(): void;
  36088. private _evaluateSubMesh;
  36089. private _activeMesh;
  36090. private _prepareRessources;
  36091. private _createIndexBuffer;
  36092. /**
  36093. * Rebuilds the elements related to this component in case of
  36094. * context lost for instance.
  36095. */
  36096. rebuild(): void;
  36097. /**
  36098. * @hidden
  36099. */
  36100. reset(): void;
  36101. /**
  36102. * Render the bounding boxes of a specific rendering group
  36103. * @param renderingGroupId defines the rendering group to render
  36104. */
  36105. render(renderingGroupId: number): void;
  36106. /**
  36107. * In case of occlusion queries, we can render the occlusion bounding box through this method
  36108. * @param mesh Define the mesh to render the occlusion bounding box for
  36109. */
  36110. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  36111. /**
  36112. * Dispose and release the resources attached to this renderer.
  36113. */
  36114. dispose(): void;
  36115. }
  36116. }
  36117. declare module BABYLON {
  36118. /**
  36119. * This represents a depth renderer in Babylon.
  36120. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  36121. */
  36122. class DepthRenderer {
  36123. private _scene;
  36124. private _depthMap;
  36125. private _effect;
  36126. private _cachedDefines;
  36127. private _camera;
  36128. /**
  36129. * Specifiess that the depth renderer will only be used within
  36130. * the camera it is created for.
  36131. * This can help forcing its rendering during the camera processing.
  36132. */
  36133. useOnlyInActiveCamera: boolean;
  36134. /**
  36135. * Instantiates a depth renderer
  36136. * @param scene The scene the renderer belongs to
  36137. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  36138. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  36139. */
  36140. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  36141. /**
  36142. * Creates the depth rendering effect and checks if the effect is ready.
  36143. * @param subMesh The submesh to be used to render the depth map of
  36144. * @param useInstances If multiple world instances should be used
  36145. * @returns if the depth renderer is ready to render the depth map
  36146. */
  36147. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  36148. /**
  36149. * Gets the texture which the depth map will be written to.
  36150. * @returns The depth map texture
  36151. */
  36152. getDepthMap(): RenderTargetTexture;
  36153. /**
  36154. * Disposes of the depth renderer.
  36155. */
  36156. dispose(): void;
  36157. }
  36158. }
  36159. declare module BABYLON {
  36160. interface Scene {
  36161. /** @hidden (Backing field) */
  36162. _depthRenderer: {
  36163. [id: string]: DepthRenderer;
  36164. };
  36165. /**
  36166. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  36167. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  36168. * @returns the created depth renderer
  36169. */
  36170. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  36171. /**
  36172. * Disables a depth renderer for a given camera
  36173. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  36174. */
  36175. disableDepthRenderer(camera?: Nullable<Camera>): void;
  36176. }
  36177. /**
  36178. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  36179. * in several rendering techniques.
  36180. */
  36181. class DepthRendererSceneComponent implements ISceneComponent {
  36182. /**
  36183. * The component name helpfull to identify the component in the list of scene components.
  36184. */
  36185. readonly name: string;
  36186. /**
  36187. * The scene the component belongs to.
  36188. */
  36189. scene: Scene;
  36190. /**
  36191. * Creates a new instance of the component for the given scene
  36192. * @param scene Defines the scene to register the component in
  36193. */
  36194. constructor(scene: Scene);
  36195. /**
  36196. * Registers the component in a given scene
  36197. */
  36198. register(): void;
  36199. /**
  36200. * Rebuilds the elements related to this component in case of
  36201. * context lost for instance.
  36202. */
  36203. rebuild(): void;
  36204. /**
  36205. * Disposes the component and the associated ressources
  36206. */
  36207. dispose(): void;
  36208. private _gatherRenderTargets;
  36209. private _gatherActiveCameraRenderTargets;
  36210. }
  36211. }
  36212. declare module BABYLON {
  36213. interface AbstractMesh {
  36214. /**
  36215. * Disables the mesh edge rendering mode
  36216. * @returns the currentAbstractMesh
  36217. */
  36218. disableEdgesRendering(): AbstractMesh;
  36219. /**
  36220. * Enables the edge rendering mode on the mesh.
  36221. * This mode makes the mesh edges visible
  36222. * @param epsilon defines the maximal distance between two angles to detect a face
  36223. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  36224. * @returns the currentAbstractMesh
  36225. * @see https://www.babylonjs-playground.com/#19O9TU#0
  36226. */
  36227. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  36228. /**
  36229. * Gets the edgesRenderer associated with the mesh
  36230. */
  36231. edgesRenderer: Nullable<EdgesRenderer>;
  36232. }
  36233. interface LinesMesh {
  36234. /**
  36235. * Enables the edge rendering mode on the mesh.
  36236. * This mode makes the mesh edges visible
  36237. * @param epsilon defines the maximal distance between two angles to detect a face
  36238. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  36239. * @returns the currentAbstractMesh
  36240. * @see https://www.babylonjs-playground.com/#19O9TU#0
  36241. */
  36242. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  36243. }
  36244. interface InstancedLinesMesh {
  36245. /**
  36246. * Enables the edge rendering mode on the mesh.
  36247. * This mode makes the mesh edges visible
  36248. * @param epsilon defines the maximal distance between two angles to detect a face
  36249. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  36250. * @returns the current InstancedLinesMesh
  36251. * @see https://www.babylonjs-playground.com/#19O9TU#0
  36252. */
  36253. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  36254. }
  36255. /**
  36256. * Defines the minimum contract an Edges renderer should follow.
  36257. */
  36258. interface IEdgesRenderer extends IDisposable {
  36259. /**
  36260. * Gets or sets a boolean indicating if the edgesRenderer is active
  36261. */
  36262. isEnabled: boolean;
  36263. /**
  36264. * Renders the edges of the attached mesh,
  36265. */
  36266. render(): void;
  36267. /**
  36268. * Checks wether or not the edges renderer is ready to render.
  36269. * @return true if ready, otherwise false.
  36270. */
  36271. isReady(): boolean;
  36272. }
  36273. /**
  36274. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  36275. */
  36276. class EdgesRenderer implements IEdgesRenderer {
  36277. /**
  36278. * Define the size of the edges with an orthographic camera
  36279. */
  36280. edgesWidthScalerForOrthographic: number;
  36281. /**
  36282. * Define the size of the edges with a perspective camera
  36283. */
  36284. edgesWidthScalerForPerspective: number;
  36285. protected _source: AbstractMesh;
  36286. protected _linesPositions: number[];
  36287. protected _linesNormals: number[];
  36288. protected _linesIndices: number[];
  36289. protected _epsilon: number;
  36290. protected _indicesCount: number;
  36291. protected _lineShader: ShaderMaterial;
  36292. protected _ib: WebGLBuffer;
  36293. protected _buffers: {
  36294. [key: string]: Nullable<VertexBuffer>;
  36295. };
  36296. protected _checkVerticesInsteadOfIndices: boolean;
  36297. private _meshRebuildObserver;
  36298. private _meshDisposeObserver;
  36299. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  36300. isEnabled: boolean;
  36301. /**
  36302. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  36303. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  36304. * @param source Mesh used to create edges
  36305. * @param epsilon sum of angles in adjacency to check for edge
  36306. * @param checkVerticesInsteadOfIndices
  36307. * @param generateEdgesLines - should generate Lines or only prepare resources.
  36308. */
  36309. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  36310. protected _prepareRessources(): void;
  36311. /** @hidden */
  36312. _rebuild(): void;
  36313. /**
  36314. * Releases the required resources for the edges renderer
  36315. */
  36316. dispose(): void;
  36317. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  36318. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  36319. /**
  36320. * Checks if the pair of p0 and p1 is en edge
  36321. * @param faceIndex
  36322. * @param edge
  36323. * @param faceNormals
  36324. * @param p0
  36325. * @param p1
  36326. * @private
  36327. */
  36328. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  36329. /**
  36330. * push line into the position, normal and index buffer
  36331. * @protected
  36332. */
  36333. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  36334. /**
  36335. * Generates lines edges from adjacencjes
  36336. * @private
  36337. */
  36338. _generateEdgesLines(): void;
  36339. /**
  36340. * Checks wether or not the edges renderer is ready to render.
  36341. * @return true if ready, otherwise false.
  36342. */
  36343. isReady(): boolean;
  36344. /**
  36345. * Renders the edges of the attached mesh,
  36346. */
  36347. render(): void;
  36348. }
  36349. }
  36350. declare module BABYLON {
  36351. /**
  36352. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  36353. */
  36354. class GeometryBufferRenderer {
  36355. /**
  36356. * Constant used to retrieve the position texture index in the G-Buffer textures array
  36357. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  36358. */
  36359. static readonly POSITION_TEXTURE_TYPE: number;
  36360. /**
  36361. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  36362. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  36363. */
  36364. static readonly VELOCITY_TEXTURE_TYPE: number;
  36365. /**
  36366. * Dictionary used to store the previous transformation matrices of each rendered mesh
  36367. * in order to compute objects velocities when enableVelocity is set to "true"
  36368. * @hidden
  36369. */
  36370. _previousTransformationMatrices: {
  36371. [index: number]: Matrix;
  36372. };
  36373. private _scene;
  36374. private _multiRenderTarget;
  36375. private _ratio;
  36376. private _enablePosition;
  36377. private _enableVelocity;
  36378. private _positionIndex;
  36379. private _velocityIndex;
  36380. protected _effect: Effect;
  36381. protected _cachedDefines: string;
  36382. /**
  36383. * Set the render list (meshes to be rendered) used in the G buffer.
  36384. */
  36385. renderList: Mesh[];
  36386. /**
  36387. * Gets wether or not G buffer are supported by the running hardware.
  36388. * This requires draw buffer supports
  36389. */
  36390. readonly isSupported: boolean;
  36391. /**
  36392. * Returns the index of the given texture type in the G-Buffer textures array
  36393. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  36394. * @returns the index of the given texture type in the G-Buffer textures array
  36395. */
  36396. getTextureIndex(textureType: number): number;
  36397. /**
  36398. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  36399. */
  36400. /**
  36401. * Sets whether or not objects positions are enabled for the G buffer.
  36402. */
  36403. enablePosition: boolean;
  36404. /**
  36405. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  36406. */
  36407. /**
  36408. * Sets wether or not objects velocities are enabled for the G buffer.
  36409. */
  36410. enableVelocity: boolean;
  36411. /**
  36412. * Gets the scene associated with the buffer.
  36413. */
  36414. readonly scene: Scene;
  36415. /**
  36416. * Gets the ratio used by the buffer during its creation.
  36417. * How big is the buffer related to the main canvas.
  36418. */
  36419. readonly ratio: number;
  36420. /**
  36421. * Creates a new G Buffer for the scene
  36422. * @param scene The scene the buffer belongs to
  36423. * @param ratio How big is the buffer related to the main canvas.
  36424. */
  36425. constructor(scene: Scene, ratio?: number);
  36426. /**
  36427. * Checks wether everything is ready to render a submesh to the G buffer.
  36428. * @param subMesh the submesh to check readiness for
  36429. * @param useInstances is the mesh drawn using instance or not
  36430. * @returns true if ready otherwise false
  36431. */
  36432. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  36433. /**
  36434. * Gets the current underlying G Buffer.
  36435. * @returns the buffer
  36436. */
  36437. getGBuffer(): MultiRenderTarget;
  36438. /**
  36439. * Gets the number of samples used to render the buffer (anti aliasing).
  36440. */
  36441. /**
  36442. * Sets the number of samples used to render the buffer (anti aliasing).
  36443. */
  36444. samples: number;
  36445. /**
  36446. * Disposes the renderer and frees up associated resources.
  36447. */
  36448. dispose(): void;
  36449. protected _createRenderTargets(): void;
  36450. }
  36451. }
  36452. declare module BABYLON {
  36453. interface Scene {
  36454. /** @hidden (Backing field) */
  36455. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  36456. /**
  36457. * Gets or Sets the current geometry buffer associated to the scene.
  36458. */
  36459. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  36460. /**
  36461. * Enables a GeometryBufferRender and associates it with the scene
  36462. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  36463. * @returns the GeometryBufferRenderer
  36464. */
  36465. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  36466. /**
  36467. * Disables the GeometryBufferRender associated with the scene
  36468. */
  36469. disableGeometryBufferRenderer(): void;
  36470. }
  36471. /**
  36472. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  36473. * in several rendering techniques.
  36474. */
  36475. class GeometryBufferRendererSceneComponent implements ISceneComponent {
  36476. /**
  36477. * The component name helpful to identify the component in the list of scene components.
  36478. */
  36479. readonly name: string;
  36480. /**
  36481. * The scene the component belongs to.
  36482. */
  36483. scene: Scene;
  36484. /**
  36485. * Creates a new instance of the component for the given scene
  36486. * @param scene Defines the scene to register the component in
  36487. */
  36488. constructor(scene: Scene);
  36489. /**
  36490. * Registers the component in a given scene
  36491. */
  36492. register(): void;
  36493. /**
  36494. * Rebuilds the elements related to this component in case of
  36495. * context lost for instance.
  36496. */
  36497. rebuild(): void;
  36498. /**
  36499. * Disposes the component and the associated ressources
  36500. */
  36501. dispose(): void;
  36502. private _gatherRenderTargets;
  36503. }
  36504. }
  36505. declare module BABYLON {
  36506. /**
  36507. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  36508. */
  36509. class LineEdgesRenderer extends EdgesRenderer {
  36510. /**
  36511. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  36512. * @param source LineMesh used to generate edges
  36513. * @param epsilon not important (specified angle for edge detection)
  36514. * @param checkVerticesInsteadOfIndices not important for LineMesh
  36515. */
  36516. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  36517. /**
  36518. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  36519. */
  36520. _generateEdgesLines(): void;
  36521. }
  36522. }
  36523. declare module BABYLON {
  36524. interface Scene {
  36525. /** @hidden */
  36526. _outlineRenderer: OutlineRenderer;
  36527. /**
  36528. * Gets the outline renderer associated with the scene
  36529. * @returns a OutlineRenderer
  36530. */
  36531. getOutlineRenderer(): OutlineRenderer;
  36532. }
  36533. interface AbstractMesh {
  36534. /** @hidden (Backing field) */
  36535. _renderOutline: boolean;
  36536. /**
  36537. * Gets or sets a boolean indicating if the outline must be rendered as well
  36538. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  36539. */
  36540. renderOutline: boolean;
  36541. /** @hidden (Backing field) */
  36542. _renderOverlay: boolean;
  36543. /**
  36544. * Gets or sets a boolean indicating if the overlay must be rendered as well
  36545. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  36546. */
  36547. renderOverlay: boolean;
  36548. }
  36549. /**
  36550. * This class is responsible to draw bothe outline/overlay of meshes.
  36551. * It should not be used directly but through the available method on mesh.
  36552. */
  36553. class OutlineRenderer implements ISceneComponent {
  36554. /**
  36555. * The name of the component. Each component must have a unique name.
  36556. */
  36557. name: string;
  36558. /**
  36559. * The scene the component belongs to.
  36560. */
  36561. scene: Scene;
  36562. /**
  36563. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  36564. */
  36565. zOffset: number;
  36566. private _engine;
  36567. private _effect;
  36568. private _cachedDefines;
  36569. private _savedDepthWrite;
  36570. /**
  36571. * Instantiates a new outline renderer. (There could be only one per scene).
  36572. * @param scene Defines the scene it belongs to
  36573. */
  36574. constructor(scene: Scene);
  36575. /**
  36576. * Register the component to one instance of a scene.
  36577. */
  36578. register(): void;
  36579. /**
  36580. * Rebuilds the elements related to this component in case of
  36581. * context lost for instance.
  36582. */
  36583. rebuild(): void;
  36584. /**
  36585. * Disposes the component and the associated ressources.
  36586. */
  36587. dispose(): void;
  36588. /**
  36589. * Renders the outline in the canvas.
  36590. * @param subMesh Defines the sumesh to render
  36591. * @param batch Defines the batch of meshes in case of instances
  36592. * @param useOverlay Defines if the rendering is for the overlay or the outline
  36593. */
  36594. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  36595. /**
  36596. * Returns whether or not the outline renderer is ready for a given submesh.
  36597. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  36598. * @param subMesh Defines the submesh to check readyness for
  36599. * @param useInstances Defines wheter wee are trying to render instances or not
  36600. * @returns true if ready otherwise false
  36601. */
  36602. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  36603. private _beforeRenderingMesh;
  36604. private _afterRenderingMesh;
  36605. }
  36606. }
  36607. declare module BABYLON {
  36608. /**
  36609. * This represents the object necessary to create a rendering group.
  36610. * This is exclusively used and created by the rendering manager.
  36611. * To modify the behavior, you use the available helpers in your scene or meshes.
  36612. * @hidden
  36613. */
  36614. class RenderingGroup {
  36615. index: number;
  36616. private _scene;
  36617. private _opaqueSubMeshes;
  36618. private _transparentSubMeshes;
  36619. private _alphaTestSubMeshes;
  36620. private _depthOnlySubMeshes;
  36621. private _particleSystems;
  36622. private _spriteManagers;
  36623. private _opaqueSortCompareFn;
  36624. private _alphaTestSortCompareFn;
  36625. private _transparentSortCompareFn;
  36626. private _renderOpaque;
  36627. private _renderAlphaTest;
  36628. private _renderTransparent;
  36629. private _edgesRenderers;
  36630. onBeforeTransparentRendering: () => void;
  36631. /**
  36632. * Set the opaque sort comparison function.
  36633. * If null the sub meshes will be render in the order they were created
  36634. */
  36635. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  36636. /**
  36637. * Set the alpha test sort comparison function.
  36638. * If null the sub meshes will be render in the order they were created
  36639. */
  36640. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  36641. /**
  36642. * Set the transparent sort comparison function.
  36643. * If null the sub meshes will be render in the order they were created
  36644. */
  36645. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  36646. /**
  36647. * Creates a new rendering group.
  36648. * @param index The rendering group index
  36649. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  36650. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  36651. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  36652. */
  36653. 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>);
  36654. /**
  36655. * Render all the sub meshes contained in the group.
  36656. * @param customRenderFunction Used to override the default render behaviour of the group.
  36657. * @returns true if rendered some submeshes.
  36658. */
  36659. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  36660. /**
  36661. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  36662. * @param subMeshes The submeshes to render
  36663. */
  36664. private renderOpaqueSorted;
  36665. /**
  36666. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  36667. * @param subMeshes The submeshes to render
  36668. */
  36669. private renderAlphaTestSorted;
  36670. /**
  36671. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  36672. * @param subMeshes The submeshes to render
  36673. */
  36674. private renderTransparentSorted;
  36675. /**
  36676. * Renders the submeshes in a specified order.
  36677. * @param subMeshes The submeshes to sort before render
  36678. * @param sortCompareFn The comparison function use to sort
  36679. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  36680. * @param transparent Specifies to activate blending if true
  36681. */
  36682. private static renderSorted;
  36683. /**
  36684. * Renders the submeshes in the order they were dispatched (no sort applied).
  36685. * @param subMeshes The submeshes to render
  36686. */
  36687. private static renderUnsorted;
  36688. /**
  36689. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  36690. * are rendered back to front if in the same alpha index.
  36691. *
  36692. * @param a The first submesh
  36693. * @param b The second submesh
  36694. * @returns The result of the comparison
  36695. */
  36696. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  36697. /**
  36698. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  36699. * are rendered back to front.
  36700. *
  36701. * @param a The first submesh
  36702. * @param b The second submesh
  36703. * @returns The result of the comparison
  36704. */
  36705. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  36706. /**
  36707. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  36708. * are rendered front to back (prevent overdraw).
  36709. *
  36710. * @param a The first submesh
  36711. * @param b The second submesh
  36712. * @returns The result of the comparison
  36713. */
  36714. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  36715. /**
  36716. * Resets the different lists of submeshes to prepare a new frame.
  36717. */
  36718. prepare(): void;
  36719. dispose(): void;
  36720. /**
  36721. * Inserts the submesh in its correct queue depending on its material.
  36722. * @param subMesh The submesh to dispatch
  36723. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  36724. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  36725. */
  36726. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  36727. dispatchSprites(spriteManager: ISpriteManager): void;
  36728. dispatchParticles(particleSystem: IParticleSystem): void;
  36729. private _renderParticles;
  36730. private _renderSprites;
  36731. }
  36732. }
  36733. declare module BABYLON {
  36734. /**
  36735. * Interface describing the different options available in the rendering manager
  36736. * regarding Auto Clear between groups.
  36737. */
  36738. interface IRenderingManagerAutoClearSetup {
  36739. /**
  36740. * Defines whether or not autoclear is enable.
  36741. */
  36742. autoClear: boolean;
  36743. /**
  36744. * Defines whether or not to autoclear the depth buffer.
  36745. */
  36746. depth: boolean;
  36747. /**
  36748. * Defines whether or not to autoclear the stencil buffer.
  36749. */
  36750. stencil: boolean;
  36751. }
  36752. /**
  36753. * This is the manager responsible of all the rendering for meshes sprites and particles.
  36754. * It is enable to manage the different groups as well as the different necessary sort functions.
  36755. * This should not be used directly aside of the few static configurations
  36756. */
  36757. class RenderingManager {
  36758. /**
  36759. * The max id used for rendering groups (not included)
  36760. */
  36761. static MAX_RENDERINGGROUPS: number;
  36762. /**
  36763. * The min id used for rendering groups (included)
  36764. */
  36765. static MIN_RENDERINGGROUPS: number;
  36766. /**
  36767. * Used to globally prevent autoclearing scenes.
  36768. */
  36769. static AUTOCLEAR: boolean;
  36770. /**
  36771. * @hidden
  36772. */
  36773. _useSceneAutoClearSetup: boolean;
  36774. private _scene;
  36775. private _renderingGroups;
  36776. private _depthStencilBufferAlreadyCleaned;
  36777. private _autoClearDepthStencil;
  36778. private _customOpaqueSortCompareFn;
  36779. private _customAlphaTestSortCompareFn;
  36780. private _customTransparentSortCompareFn;
  36781. private _renderingGroupInfo;
  36782. /**
  36783. * Instantiates a new rendering group for a particular scene
  36784. * @param scene Defines the scene the groups belongs to
  36785. */
  36786. constructor(scene: Scene);
  36787. private _clearDepthStencilBuffer;
  36788. /**
  36789. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  36790. * @hidden
  36791. */
  36792. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  36793. /**
  36794. * Resets the different information of the group to prepare a new frame
  36795. * @hidden
  36796. */
  36797. reset(): void;
  36798. /**
  36799. * Dispose and release the group and its associated resources.
  36800. * @hidden
  36801. */
  36802. dispose(): void;
  36803. /**
  36804. * Clear the info related to rendering groups preventing retention points during dispose.
  36805. */
  36806. freeRenderingGroups(): void;
  36807. private _prepareRenderingGroup;
  36808. /**
  36809. * Add a sprite manager to the rendering manager in order to render it this frame.
  36810. * @param spriteManager Define the sprite manager to render
  36811. */
  36812. dispatchSprites(spriteManager: ISpriteManager): void;
  36813. /**
  36814. * Add a particle system to the rendering manager in order to render it this frame.
  36815. * @param particleSystem Define the particle system to render
  36816. */
  36817. dispatchParticles(particleSystem: IParticleSystem): void;
  36818. /**
  36819. * Add a submesh to the manager in order to render it this frame
  36820. * @param subMesh The submesh to dispatch
  36821. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  36822. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  36823. */
  36824. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  36825. /**
  36826. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  36827. * This allowed control for front to back rendering or reversly depending of the special needs.
  36828. *
  36829. * @param renderingGroupId The rendering group id corresponding to its index
  36830. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  36831. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  36832. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  36833. */
  36834. 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;
  36835. /**
  36836. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  36837. *
  36838. * @param renderingGroupId The rendering group id corresponding to its index
  36839. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  36840. * @param depth Automatically clears depth between groups if true and autoClear is true.
  36841. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  36842. */
  36843. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  36844. /**
  36845. * Gets the current auto clear configuration for one rendering group of the rendering
  36846. * manager.
  36847. * @param index the rendering group index to get the information for
  36848. * @returns The auto clear setup for the requested rendering group
  36849. */
  36850. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  36851. }
  36852. }
  36853. declare module BABYLON {
  36854. /**
  36855. * Renders a layer on top of an existing scene
  36856. */
  36857. class UtilityLayerRenderer implements IDisposable {
  36858. /** the original scene that will be rendered on top of */
  36859. originalScene: Scene;
  36860. private _pointerCaptures;
  36861. private _lastPointerEvents;
  36862. private static _DefaultUtilityLayer;
  36863. private static _DefaultKeepDepthUtilityLayer;
  36864. /**
  36865. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  36866. */
  36867. pickUtilitySceneFirst: boolean;
  36868. /**
  36869. * 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)
  36870. */
  36871. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  36872. /**
  36873. * 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)
  36874. */
  36875. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  36876. /**
  36877. * The scene that is rendered on top of the original scene
  36878. */
  36879. utilityLayerScene: Scene;
  36880. /**
  36881. * If the utility layer should automatically be rendered on top of existing scene
  36882. */
  36883. shouldRender: boolean;
  36884. /**
  36885. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  36886. */
  36887. onlyCheckPointerDownEvents: boolean;
  36888. /**
  36889. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  36890. */
  36891. processAllEvents: boolean;
  36892. /**
  36893. * Observable raised when the pointer move from the utility layer scene to the main scene
  36894. */
  36895. onPointerOutObservable: Observable<number>;
  36896. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  36897. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  36898. private _afterRenderObserver;
  36899. private _sceneDisposeObserver;
  36900. private _originalPointerObserver;
  36901. /**
  36902. * Instantiates a UtilityLayerRenderer
  36903. * @param originalScene the original scene that will be rendered on top of
  36904. * @param handleEvents boolean indicating if the utility layer should handle events
  36905. */
  36906. constructor(
  36907. /** the original scene that will be rendered on top of */
  36908. originalScene: Scene, handleEvents?: boolean);
  36909. private _notifyObservers;
  36910. /**
  36911. * Renders the utility layers scene on top of the original scene
  36912. */
  36913. render(): void;
  36914. /**
  36915. * Disposes of the renderer
  36916. */
  36917. dispose(): void;
  36918. private _updateCamera;
  36919. }
  36920. }
  36921. declare module BABYLON {
  36922. /**
  36923. * Class used to represent a sprite
  36924. * @see http://doc.babylonjs.com/babylon101/sprites
  36925. */
  36926. class Sprite {
  36927. /** defines the name */
  36928. name: string;
  36929. /** Gets or sets the current world position */
  36930. position: Vector3;
  36931. /** Gets or sets the main color */
  36932. color: Color4;
  36933. /** Gets or sets the width */
  36934. width: number;
  36935. /** Gets or sets the height */
  36936. height: number;
  36937. /** Gets or sets rotation angle */
  36938. angle: number;
  36939. /** Gets or sets the cell index in the sprite sheet */
  36940. cellIndex: number;
  36941. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  36942. invertU: number;
  36943. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  36944. invertV: number;
  36945. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  36946. disposeWhenFinishedAnimating: boolean;
  36947. /** Gets the list of attached animations */
  36948. animations: Animation[];
  36949. /** Gets or sets a boolean indicating if the sprite can be picked */
  36950. isPickable: boolean;
  36951. /**
  36952. * Gets or sets the associated action manager
  36953. */
  36954. actionManager: Nullable<ActionManager>;
  36955. private _animationStarted;
  36956. private _loopAnimation;
  36957. private _fromIndex;
  36958. private _toIndex;
  36959. private _delay;
  36960. private _direction;
  36961. private _manager;
  36962. private _time;
  36963. private _onAnimationEnd;
  36964. /**
  36965. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  36966. */
  36967. isVisible: boolean;
  36968. /**
  36969. * Gets or sets the sprite size
  36970. */
  36971. size: number;
  36972. /**
  36973. * Creates a new Sprite
  36974. * @param name defines the name
  36975. * @param manager defines the manager
  36976. */
  36977. constructor(
  36978. /** defines the name */
  36979. name: string, manager: ISpriteManager);
  36980. /**
  36981. * Starts an animation
  36982. * @param from defines the initial key
  36983. * @param to defines the end key
  36984. * @param loop defines if the animation must loop
  36985. * @param delay defines the start delay (in ms)
  36986. * @param onAnimationEnd defines a callback to call when animation ends
  36987. */
  36988. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  36989. /** Stops current animation (if any) */
  36990. stopAnimation(): void;
  36991. /** @hidden */
  36992. _animate(deltaTime: number): void;
  36993. /** Release associated resources */
  36994. dispose(): void;
  36995. }
  36996. }
  36997. declare module BABYLON {
  36998. /**
  36999. * Defines the minimum interface to fullfil in order to be a sprite manager.
  37000. */
  37001. interface ISpriteManager extends IDisposable {
  37002. /**
  37003. * Restricts the camera to viewing objects with the same layerMask.
  37004. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  37005. */
  37006. layerMask: number;
  37007. /**
  37008. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  37009. */
  37010. isPickable: boolean;
  37011. /**
  37012. * Specifies the rendering group id for this mesh (0 by default)
  37013. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  37014. */
  37015. renderingGroupId: number;
  37016. /**
  37017. * Defines the list of sprites managed by the manager.
  37018. */
  37019. sprites: Array<Sprite>;
  37020. /**
  37021. * Tests the intersection of a sprite with a specific ray.
  37022. * @param ray The ray we are sending to test the collision
  37023. * @param camera The camera space we are sending rays in
  37024. * @param predicate A predicate allowing excluding sprites from the list of object to test
  37025. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  37026. * @returns picking info or null.
  37027. */
  37028. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  37029. /**
  37030. * Renders the list of sprites on screen.
  37031. */
  37032. render(): void;
  37033. }
  37034. /**
  37035. * Class used to manage multiple sprites on the same spritesheet
  37036. * @see http://doc.babylonjs.com/babylon101/sprites
  37037. */
  37038. class SpriteManager implements ISpriteManager {
  37039. /** defines the manager's name */
  37040. name: string;
  37041. /** Gets the list of sprites */
  37042. sprites: Sprite[];
  37043. /** Gets or sets the rendering group id (0 by default) */
  37044. renderingGroupId: number;
  37045. /** Gets or sets camera layer mask */
  37046. layerMask: number;
  37047. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  37048. fogEnabled: boolean;
  37049. /** Gets or sets a boolean indicating if the sprites are pickable */
  37050. isPickable: boolean;
  37051. /** Defines the default width of a cell in the spritesheet */
  37052. cellWidth: number;
  37053. /** Defines the default height of a cell in the spritesheet */
  37054. cellHeight: number;
  37055. /**
  37056. * An event triggered when the manager is disposed.
  37057. */
  37058. onDisposeObservable: Observable<SpriteManager>;
  37059. private _onDisposeObserver;
  37060. /**
  37061. * Callback called when the manager is disposed
  37062. */
  37063. onDispose: () => void;
  37064. private _capacity;
  37065. private _spriteTexture;
  37066. private _epsilon;
  37067. private _scene;
  37068. private _vertexData;
  37069. private _buffer;
  37070. private _vertexBuffers;
  37071. private _indexBuffer;
  37072. private _effectBase;
  37073. private _effectFog;
  37074. /**
  37075. * Gets or sets the spritesheet texture
  37076. */
  37077. texture: Texture;
  37078. /**
  37079. * Creates a new sprite manager
  37080. * @param name defines the manager's name
  37081. * @param imgUrl defines the sprite sheet url
  37082. * @param capacity defines the maximum allowed number of sprites
  37083. * @param cellSize defines the size of a sprite cell
  37084. * @param scene defines the hosting scene
  37085. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  37086. * @param samplingMode defines the smapling mode to use with spritesheet
  37087. */
  37088. constructor(
  37089. /** defines the manager's name */
  37090. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  37091. private _appendSpriteVertex;
  37092. /**
  37093. * Intersects the sprites with a ray
  37094. * @param ray defines the ray to intersect with
  37095. * @param camera defines the current active camera
  37096. * @param predicate defines a predicate used to select candidate sprites
  37097. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  37098. * @returns null if no hit or a PickingInfo
  37099. */
  37100. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  37101. /**
  37102. * Render all child sprites
  37103. */
  37104. render(): void;
  37105. /**
  37106. * Release associated resources
  37107. */
  37108. dispose(): void;
  37109. }
  37110. }
  37111. declare module BABYLON {
  37112. interface Scene {
  37113. /** @hidden */
  37114. _pointerOverSprite: Nullable<Sprite>;
  37115. /** @hidden */
  37116. _pickedDownSprite: Nullable<Sprite>;
  37117. /** @hidden */
  37118. _tempSpritePickingRay: Nullable<Ray>;
  37119. /**
  37120. * All of the sprite managers added to this scene
  37121. * @see http://doc.babylonjs.com/babylon101/sprites
  37122. */
  37123. spriteManagers: Array<ISpriteManager>;
  37124. /**
  37125. * An event triggered when sprites rendering is about to start
  37126. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  37127. */
  37128. onBeforeSpritesRenderingObservable: Observable<Scene>;
  37129. /**
  37130. * An event triggered when sprites rendering is done
  37131. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  37132. */
  37133. onAfterSpritesRenderingObservable: Observable<Scene>;
  37134. /** @hidden */
  37135. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  37136. /** Launch a ray to try to pick a sprite in the scene
  37137. * @param x position on screen
  37138. * @param y position on screen
  37139. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  37140. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  37141. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37142. * @returns a PickingInfo
  37143. */
  37144. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  37145. /** Use the given ray to pick a sprite in the scene
  37146. * @param ray The ray (in world space) to use to pick meshes
  37147. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  37148. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  37149. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  37150. * @returns a PickingInfo
  37151. */
  37152. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  37153. /**
  37154. * Force the sprite under the pointer
  37155. * @param sprite defines the sprite to use
  37156. */
  37157. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  37158. /**
  37159. * Gets the sprite under the pointer
  37160. * @returns a Sprite or null if no sprite is under the pointer
  37161. */
  37162. getPointerOverSprite(): Nullable<Sprite>;
  37163. }
  37164. /**
  37165. * Defines the sprite scene component responsible to manage sprites
  37166. * in a given scene.
  37167. */
  37168. class SpriteSceneComponent implements ISceneComponent {
  37169. /**
  37170. * The component name helpfull to identify the component in the list of scene components.
  37171. */
  37172. readonly name: string;
  37173. /**
  37174. * The scene the component belongs to.
  37175. */
  37176. scene: Scene;
  37177. /** @hidden */
  37178. private _spritePredicate;
  37179. /**
  37180. * Creates a new instance of the component for the given scene
  37181. * @param scene Defines the scene to register the component in
  37182. */
  37183. constructor(scene: Scene);
  37184. /**
  37185. * Registers the component in a given scene
  37186. */
  37187. register(): void;
  37188. /**
  37189. * Rebuilds the elements related to this component in case of
  37190. * context lost for instance.
  37191. */
  37192. rebuild(): void;
  37193. /**
  37194. * Disposes the component and the associated ressources.
  37195. */
  37196. dispose(): void;
  37197. private _pickSpriteButKeepRay;
  37198. private _pointerMove;
  37199. private _pointerDown;
  37200. private _pointerUp;
  37201. }
  37202. }
  37203. declare module BABYLON {
  37204. /**
  37205. * @hidden
  37206. **/
  37207. class _AlphaState {
  37208. private _isAlphaBlendDirty;
  37209. private _isBlendFunctionParametersDirty;
  37210. private _isBlendEquationParametersDirty;
  37211. private _isBlendConstantsDirty;
  37212. private _alphaBlend;
  37213. private _blendFunctionParameters;
  37214. private _blendEquationParameters;
  37215. private _blendConstants;
  37216. /**
  37217. * Initializes the state.
  37218. */
  37219. constructor();
  37220. readonly isDirty: boolean;
  37221. alphaBlend: boolean;
  37222. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  37223. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  37224. setAlphaEquationParameters(rgb: number, alpha: number): void;
  37225. reset(): void;
  37226. apply(gl: WebGLRenderingContext): void;
  37227. }
  37228. }
  37229. declare module BABYLON {
  37230. /**
  37231. * @hidden
  37232. **/
  37233. class _DepthCullingState {
  37234. private _isDepthTestDirty;
  37235. private _isDepthMaskDirty;
  37236. private _isDepthFuncDirty;
  37237. private _isCullFaceDirty;
  37238. private _isCullDirty;
  37239. private _isZOffsetDirty;
  37240. private _isFrontFaceDirty;
  37241. private _depthTest;
  37242. private _depthMask;
  37243. private _depthFunc;
  37244. private _cull;
  37245. private _cullFace;
  37246. private _zOffset;
  37247. private _frontFace;
  37248. /**
  37249. * Initializes the state.
  37250. */
  37251. constructor();
  37252. readonly isDirty: boolean;
  37253. zOffset: number;
  37254. cullFace: Nullable<number>;
  37255. cull: Nullable<boolean>;
  37256. depthFunc: Nullable<number>;
  37257. depthMask: boolean;
  37258. depthTest: boolean;
  37259. frontFace: Nullable<number>;
  37260. reset(): void;
  37261. apply(gl: WebGLRenderingContext): void;
  37262. }
  37263. }
  37264. declare module BABYLON {
  37265. /**
  37266. * @hidden
  37267. **/
  37268. class _StencilState {
  37269. private _isStencilTestDirty;
  37270. private _isStencilMaskDirty;
  37271. private _isStencilFuncDirty;
  37272. private _isStencilOpDirty;
  37273. private _stencilTest;
  37274. private _stencilMask;
  37275. private _stencilFunc;
  37276. private _stencilFuncRef;
  37277. private _stencilFuncMask;
  37278. private _stencilOpStencilFail;
  37279. private _stencilOpDepthFail;
  37280. private _stencilOpStencilDepthPass;
  37281. readonly isDirty: boolean;
  37282. stencilFunc: number;
  37283. stencilFuncRef: number;
  37284. stencilFuncMask: number;
  37285. stencilOpStencilFail: number;
  37286. stencilOpDepthFail: number;
  37287. stencilOpStencilDepthPass: number;
  37288. stencilMask: number;
  37289. stencilTest: boolean;
  37290. constructor();
  37291. reset(): void;
  37292. apply(gl: WebGLRenderingContext): void;
  37293. }
  37294. }
  37295. declare module BABYLON {
  37296. /**
  37297. * Class used to evalaute queries containing `and` and `or` operators
  37298. */
  37299. class AndOrNotEvaluator {
  37300. /**
  37301. * Evaluate a query
  37302. * @param query defines the query to evaluate
  37303. * @param evaluateCallback defines the callback used to filter result
  37304. * @returns true if the query matches
  37305. */
  37306. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  37307. private static _HandleParenthesisContent;
  37308. private static _SimplifyNegation;
  37309. }
  37310. }
  37311. declare module BABYLON {
  37312. /**
  37313. * Defines the list of states available for a task inside a AssetsManager
  37314. */
  37315. enum AssetTaskState {
  37316. /**
  37317. * Initialization
  37318. */
  37319. INIT = 0,
  37320. /**
  37321. * Running
  37322. */
  37323. RUNNING = 1,
  37324. /**
  37325. * Done
  37326. */
  37327. DONE = 2,
  37328. /**
  37329. * Error
  37330. */
  37331. ERROR = 3
  37332. }
  37333. /**
  37334. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  37335. */
  37336. abstract class AbstractAssetTask {
  37337. /**
  37338. * Task name
  37339. */ name: string;
  37340. /**
  37341. * Callback called when the task is successful
  37342. */
  37343. onSuccess: (task: any) => void;
  37344. /**
  37345. * Callback called when the task is not successful
  37346. */
  37347. onError: (task: any, message?: string, exception?: any) => void;
  37348. /**
  37349. * Creates a new AssetsManager
  37350. * @param name defines the name of the task
  37351. */
  37352. constructor(
  37353. /**
  37354. * Task name
  37355. */ name: string);
  37356. private _isCompleted;
  37357. private _taskState;
  37358. private _errorObject;
  37359. /**
  37360. * Get if the task is completed
  37361. */
  37362. readonly isCompleted: boolean;
  37363. /**
  37364. * Gets the current state of the task
  37365. */
  37366. readonly taskState: AssetTaskState;
  37367. /**
  37368. * Gets the current error object (if task is in error)
  37369. */
  37370. readonly errorObject: {
  37371. message?: string;
  37372. exception?: any;
  37373. };
  37374. /**
  37375. * Internal only
  37376. * @hidden
  37377. */
  37378. _setErrorObject(message?: string, exception?: any): void;
  37379. /**
  37380. * Execute the current task
  37381. * @param scene defines the scene where you want your assets to be loaded
  37382. * @param onSuccess is a callback called when the task is successfully executed
  37383. * @param onError is a callback called if an error occurs
  37384. */
  37385. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37386. /**
  37387. * Execute the current task
  37388. * @param scene defines the scene where you want your assets to be loaded
  37389. * @param onSuccess is a callback called when the task is successfully executed
  37390. * @param onError is a callback called if an error occurs
  37391. */
  37392. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37393. /**
  37394. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  37395. * This can be used with failed tasks that have the reason for failure fixed.
  37396. */
  37397. reset(): void;
  37398. private onErrorCallback;
  37399. private onDoneCallback;
  37400. }
  37401. /**
  37402. * Define the interface used by progress events raised during assets loading
  37403. */
  37404. interface IAssetsProgressEvent {
  37405. /**
  37406. * Defines the number of remaining tasks to process
  37407. */
  37408. remainingCount: number;
  37409. /**
  37410. * Defines the total number of tasks
  37411. */
  37412. totalCount: number;
  37413. /**
  37414. * Defines the task that was just processed
  37415. */
  37416. task: AbstractAssetTask;
  37417. }
  37418. /**
  37419. * Class used to share progress information about assets loading
  37420. */
  37421. class AssetsProgressEvent implements IAssetsProgressEvent {
  37422. /**
  37423. * Defines the number of remaining tasks to process
  37424. */
  37425. remainingCount: number;
  37426. /**
  37427. * Defines the total number of tasks
  37428. */
  37429. totalCount: number;
  37430. /**
  37431. * Defines the task that was just processed
  37432. */
  37433. task: AbstractAssetTask;
  37434. /**
  37435. * Creates a AssetsProgressEvent
  37436. * @param remainingCount defines the number of remaining tasks to process
  37437. * @param totalCount defines the total number of tasks
  37438. * @param task defines the task that was just processed
  37439. */
  37440. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  37441. }
  37442. /**
  37443. * Define a task used by AssetsManager to load meshes
  37444. */
  37445. class MeshAssetTask extends AbstractAssetTask {
  37446. /**
  37447. * Defines the name of the task
  37448. */
  37449. name: string;
  37450. /**
  37451. * Defines the list of mesh's names you want to load
  37452. */
  37453. meshesNames: any;
  37454. /**
  37455. * Defines the root url to use as a base to load your meshes and associated resources
  37456. */
  37457. rootUrl: string;
  37458. /**
  37459. * Defines the filename of the scene to load from
  37460. */
  37461. sceneFilename: string;
  37462. /**
  37463. * Gets the list of loaded meshes
  37464. */
  37465. loadedMeshes: Array<AbstractMesh>;
  37466. /**
  37467. * Gets the list of loaded particle systems
  37468. */
  37469. loadedParticleSystems: Array<IParticleSystem>;
  37470. /**
  37471. * Gets the list of loaded skeletons
  37472. */
  37473. loadedSkeletons: Array<Skeleton>;
  37474. /**
  37475. * Callback called when the task is successful
  37476. */
  37477. onSuccess: (task: MeshAssetTask) => void;
  37478. /**
  37479. * Callback called when the task is successful
  37480. */
  37481. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  37482. /**
  37483. * Creates a new MeshAssetTask
  37484. * @param name defines the name of the task
  37485. * @param meshesNames defines the list of mesh's names you want to load
  37486. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  37487. * @param sceneFilename defines the filename of the scene to load from
  37488. */
  37489. constructor(
  37490. /**
  37491. * Defines the name of the task
  37492. */
  37493. name: string,
  37494. /**
  37495. * Defines the list of mesh's names you want to load
  37496. */
  37497. meshesNames: any,
  37498. /**
  37499. * Defines the root url to use as a base to load your meshes and associated resources
  37500. */
  37501. rootUrl: string,
  37502. /**
  37503. * Defines the filename of the scene to load from
  37504. */
  37505. sceneFilename: string);
  37506. /**
  37507. * Execute the current task
  37508. * @param scene defines the scene where you want your assets to be loaded
  37509. * @param onSuccess is a callback called when the task is successfully executed
  37510. * @param onError is a callback called if an error occurs
  37511. */
  37512. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37513. }
  37514. /**
  37515. * Define a task used by AssetsManager to load text content
  37516. */
  37517. class TextFileAssetTask extends AbstractAssetTask {
  37518. /**
  37519. * Defines the name of the task
  37520. */
  37521. name: string;
  37522. /**
  37523. * Defines the location of the file to load
  37524. */
  37525. url: string;
  37526. /**
  37527. * Gets the loaded text string
  37528. */
  37529. text: string;
  37530. /**
  37531. * Callback called when the task is successful
  37532. */
  37533. onSuccess: (task: TextFileAssetTask) => void;
  37534. /**
  37535. * Callback called when the task is successful
  37536. */
  37537. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  37538. /**
  37539. * Creates a new TextFileAssetTask object
  37540. * @param name defines the name of the task
  37541. * @param url defines the location of the file to load
  37542. */
  37543. constructor(
  37544. /**
  37545. * Defines the name of the task
  37546. */
  37547. name: string,
  37548. /**
  37549. * Defines the location of the file to load
  37550. */
  37551. url: string);
  37552. /**
  37553. * Execute the current task
  37554. * @param scene defines the scene where you want your assets to be loaded
  37555. * @param onSuccess is a callback called when the task is successfully executed
  37556. * @param onError is a callback called if an error occurs
  37557. */
  37558. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37559. }
  37560. /**
  37561. * Define a task used by AssetsManager to load binary data
  37562. */
  37563. class BinaryFileAssetTask extends AbstractAssetTask {
  37564. /**
  37565. * Defines the name of the task
  37566. */
  37567. name: string;
  37568. /**
  37569. * Defines the location of the file to load
  37570. */
  37571. url: string;
  37572. /**
  37573. * Gets the lodaded data (as an array buffer)
  37574. */
  37575. data: ArrayBuffer;
  37576. /**
  37577. * Callback called when the task is successful
  37578. */
  37579. onSuccess: (task: BinaryFileAssetTask) => void;
  37580. /**
  37581. * Callback called when the task is successful
  37582. */
  37583. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  37584. /**
  37585. * Creates a new BinaryFileAssetTask object
  37586. * @param name defines the name of the new task
  37587. * @param url defines the location of the file to load
  37588. */
  37589. constructor(
  37590. /**
  37591. * Defines the name of the task
  37592. */
  37593. name: string,
  37594. /**
  37595. * Defines the location of the file to load
  37596. */
  37597. url: string);
  37598. /**
  37599. * Execute the current task
  37600. * @param scene defines the scene where you want your assets to be loaded
  37601. * @param onSuccess is a callback called when the task is successfully executed
  37602. * @param onError is a callback called if an error occurs
  37603. */
  37604. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37605. }
  37606. /**
  37607. * Define a task used by AssetsManager to load images
  37608. */
  37609. class ImageAssetTask extends AbstractAssetTask {
  37610. /**
  37611. * Defines the name of the task
  37612. */
  37613. name: string;
  37614. /**
  37615. * Defines the location of the image to load
  37616. */
  37617. url: string;
  37618. /**
  37619. * Gets the loaded images
  37620. */
  37621. image: HTMLImageElement;
  37622. /**
  37623. * Callback called when the task is successful
  37624. */
  37625. onSuccess: (task: ImageAssetTask) => void;
  37626. /**
  37627. * Callback called when the task is successful
  37628. */
  37629. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  37630. /**
  37631. * Creates a new ImageAssetTask
  37632. * @param name defines the name of the task
  37633. * @param url defines the location of the image to load
  37634. */
  37635. constructor(
  37636. /**
  37637. * Defines the name of the task
  37638. */
  37639. name: string,
  37640. /**
  37641. * Defines the location of the image to load
  37642. */
  37643. url: string);
  37644. /**
  37645. * Execute the current task
  37646. * @param scene defines the scene where you want your assets to be loaded
  37647. * @param onSuccess is a callback called when the task is successfully executed
  37648. * @param onError is a callback called if an error occurs
  37649. */
  37650. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37651. }
  37652. /**
  37653. * Defines the interface used by texture loading tasks
  37654. */
  37655. interface ITextureAssetTask<TEX extends BaseTexture> {
  37656. /**
  37657. * Gets the loaded texture
  37658. */
  37659. texture: TEX;
  37660. }
  37661. /**
  37662. * Define a task used by AssetsManager to load 2D textures
  37663. */
  37664. class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  37665. /**
  37666. * Defines the name of the task
  37667. */
  37668. name: string;
  37669. /**
  37670. * Defines the location of the file to load
  37671. */
  37672. url: string;
  37673. /**
  37674. * Defines if mipmap should not be generated (default is false)
  37675. */
  37676. noMipmap?: boolean | undefined;
  37677. /**
  37678. * Defines if texture must be inverted on Y axis (default is false)
  37679. */
  37680. invertY?: boolean | undefined;
  37681. /**
  37682. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  37683. */
  37684. samplingMode: number;
  37685. /**
  37686. * Gets the loaded texture
  37687. */
  37688. texture: Texture;
  37689. /**
  37690. * Callback called when the task is successful
  37691. */
  37692. onSuccess: (task: TextureAssetTask) => void;
  37693. /**
  37694. * Callback called when the task is successful
  37695. */
  37696. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  37697. /**
  37698. * Creates a new TextureAssetTask object
  37699. * @param name defines the name of the task
  37700. * @param url defines the location of the file to load
  37701. * @param noMipmap defines if mipmap should not be generated (default is false)
  37702. * @param invertY defines if texture must be inverted on Y axis (default is false)
  37703. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  37704. */
  37705. constructor(
  37706. /**
  37707. * Defines the name of the task
  37708. */
  37709. name: string,
  37710. /**
  37711. * Defines the location of the file to load
  37712. */
  37713. url: string,
  37714. /**
  37715. * Defines if mipmap should not be generated (default is false)
  37716. */
  37717. noMipmap?: boolean | undefined,
  37718. /**
  37719. * Defines if texture must be inverted on Y axis (default is false)
  37720. */
  37721. invertY?: boolean | undefined,
  37722. /**
  37723. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  37724. */
  37725. samplingMode?: number);
  37726. /**
  37727. * Execute the current task
  37728. * @param scene defines the scene where you want your assets to be loaded
  37729. * @param onSuccess is a callback called when the task is successfully executed
  37730. * @param onError is a callback called if an error occurs
  37731. */
  37732. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37733. }
  37734. /**
  37735. * Define a task used by AssetsManager to load cube textures
  37736. */
  37737. class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  37738. /**
  37739. * Defines the name of the task
  37740. */
  37741. name: string;
  37742. /**
  37743. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  37744. */
  37745. url: string;
  37746. /**
  37747. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  37748. */
  37749. extensions?: string[] | undefined;
  37750. /**
  37751. * Defines if mipmaps should not be generated (default is false)
  37752. */
  37753. noMipmap?: boolean | undefined;
  37754. /**
  37755. * Defines the explicit list of files (undefined by default)
  37756. */
  37757. files?: string[] | undefined;
  37758. /**
  37759. * Gets the loaded texture
  37760. */
  37761. texture: CubeTexture;
  37762. /**
  37763. * Callback called when the task is successful
  37764. */
  37765. onSuccess: (task: CubeTextureAssetTask) => void;
  37766. /**
  37767. * Callback called when the task is successful
  37768. */
  37769. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  37770. /**
  37771. * Creates a new CubeTextureAssetTask
  37772. * @param name defines the name of the task
  37773. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  37774. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  37775. * @param noMipmap defines if mipmaps should not be generated (default is false)
  37776. * @param files defines the explicit list of files (undefined by default)
  37777. */
  37778. constructor(
  37779. /**
  37780. * Defines the name of the task
  37781. */
  37782. name: string,
  37783. /**
  37784. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  37785. */
  37786. url: string,
  37787. /**
  37788. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  37789. */
  37790. extensions?: string[] | undefined,
  37791. /**
  37792. * Defines if mipmaps should not be generated (default is false)
  37793. */
  37794. noMipmap?: boolean | undefined,
  37795. /**
  37796. * Defines the explicit list of files (undefined by default)
  37797. */
  37798. files?: string[] | undefined);
  37799. /**
  37800. * Execute the current task
  37801. * @param scene defines the scene where you want your assets to be loaded
  37802. * @param onSuccess is a callback called when the task is successfully executed
  37803. * @param onError is a callback called if an error occurs
  37804. */
  37805. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37806. }
  37807. /**
  37808. * Define a task used by AssetsManager to load HDR cube textures
  37809. */
  37810. class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  37811. /**
  37812. * Defines the name of the task
  37813. */
  37814. name: string;
  37815. /**
  37816. * Defines the location of the file to load
  37817. */
  37818. url: string;
  37819. /**
  37820. * Defines the desired size (the more it increases the longer the generation will be)
  37821. */
  37822. size: number;
  37823. /**
  37824. * Defines if mipmaps should not be generated (default is false)
  37825. */
  37826. noMipmap: boolean;
  37827. /**
  37828. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  37829. */
  37830. generateHarmonics: boolean;
  37831. /**
  37832. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space) (default is false)
  37833. */
  37834. gammaSpace: boolean;
  37835. /**
  37836. * Internal Use Only
  37837. */
  37838. reserved: boolean;
  37839. /**
  37840. * Gets the loaded texture
  37841. */
  37842. texture: HDRCubeTexture;
  37843. /**
  37844. * Callback called when the task is successful
  37845. */
  37846. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  37847. /**
  37848. * Callback called when the task is successful
  37849. */
  37850. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  37851. /**
  37852. * Creates a new HDRCubeTextureAssetTask object
  37853. * @param name defines the name of the task
  37854. * @param url defines the location of the file to load
  37855. * @param size defines the desired size (the more it increases the longer the generation will be) If the size is omitted this implies you are using a preprocessed cubemap.
  37856. * @param noMipmap defines if mipmaps should not be generated (default is false)
  37857. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  37858. * @param gammaSpace specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space) (default is false)
  37859. * @param reserved Internal use only
  37860. */
  37861. constructor(
  37862. /**
  37863. * Defines the name of the task
  37864. */
  37865. name: string,
  37866. /**
  37867. * Defines the location of the file to load
  37868. */
  37869. url: string,
  37870. /**
  37871. * Defines the desired size (the more it increases the longer the generation will be)
  37872. */
  37873. size: number,
  37874. /**
  37875. * Defines if mipmaps should not be generated (default is false)
  37876. */
  37877. noMipmap?: boolean,
  37878. /**
  37879. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  37880. */
  37881. generateHarmonics?: boolean,
  37882. /**
  37883. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space) (default is false)
  37884. */
  37885. gammaSpace?: boolean,
  37886. /**
  37887. * Internal Use Only
  37888. */
  37889. reserved?: boolean);
  37890. /**
  37891. * Execute the current task
  37892. * @param scene defines the scene where you want your assets to be loaded
  37893. * @param onSuccess is a callback called when the task is successfully executed
  37894. * @param onError is a callback called if an error occurs
  37895. */
  37896. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37897. }
  37898. /**
  37899. * This class can be used to easily import assets into a scene
  37900. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  37901. */
  37902. class AssetsManager {
  37903. private _scene;
  37904. private _isLoading;
  37905. protected _tasks: AbstractAssetTask[];
  37906. protected _waitingTasksCount: number;
  37907. protected _totalTasksCount: number;
  37908. /**
  37909. * Callback called when all tasks are processed
  37910. */
  37911. onFinish: (tasks: AbstractAssetTask[]) => void;
  37912. /**
  37913. * Callback called when a task is successful
  37914. */
  37915. onTaskSuccess: (task: AbstractAssetTask) => void;
  37916. /**
  37917. * Callback called when a task had an error
  37918. */
  37919. onTaskError: (task: AbstractAssetTask) => void;
  37920. /**
  37921. * Callback called when a task is done (whatever the result is)
  37922. */
  37923. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  37924. /**
  37925. * Observable called when all tasks are processed
  37926. */
  37927. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  37928. /**
  37929. * Observable called when a task had an error
  37930. */
  37931. onTaskErrorObservable: Observable<AbstractAssetTask>;
  37932. /**
  37933. * Observable called when a task is successful
  37934. */
  37935. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  37936. /**
  37937. * Observable called when a task is done (whatever the result is)
  37938. */
  37939. onProgressObservable: Observable<IAssetsProgressEvent>;
  37940. /**
  37941. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  37942. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37943. */
  37944. useDefaultLoadingScreen: boolean;
  37945. /**
  37946. * Creates a new AssetsManager
  37947. * @param scene defines the scene to work on
  37948. */
  37949. constructor(scene: Scene);
  37950. /**
  37951. * Add a MeshAssetTask to the list of active tasks
  37952. * @param taskName defines the name of the new task
  37953. * @param meshesNames defines the name of meshes to load
  37954. * @param rootUrl defines the root url to use to locate files
  37955. * @param sceneFilename defines the filename of the scene file
  37956. * @returns a new MeshAssetTask object
  37957. */
  37958. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  37959. /**
  37960. * Add a TextFileAssetTask to the list of active tasks
  37961. * @param taskName defines the name of the new task
  37962. * @param url defines the url of the file to load
  37963. * @returns a new TextFileAssetTask object
  37964. */
  37965. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  37966. /**
  37967. * Add a BinaryFileAssetTask to the list of active tasks
  37968. * @param taskName defines the name of the new task
  37969. * @param url defines the url of the file to load
  37970. * @returns a new BinaryFileAssetTask object
  37971. */
  37972. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  37973. /**
  37974. * Add a ImageAssetTask to the list of active tasks
  37975. * @param taskName defines the name of the new task
  37976. * @param url defines the url of the file to load
  37977. * @returns a new ImageAssetTask object
  37978. */
  37979. addImageTask(taskName: string, url: string): ImageAssetTask;
  37980. /**
  37981. * Add a TextureAssetTask to the list of active tasks
  37982. * @param taskName defines the name of the new task
  37983. * @param url defines the url of the file to load
  37984. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  37985. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  37986. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  37987. * @returns a new TextureAssetTask object
  37988. */
  37989. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  37990. /**
  37991. * Add a CubeTextureAssetTask to the list of active tasks
  37992. * @param taskName defines the name of the new task
  37993. * @param url defines the url of the file to load
  37994. * @param extensions defines the extension to use to load the cube map (can be null)
  37995. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  37996. * @param files defines the list of files to load (can be null)
  37997. * @returns a new CubeTextureAssetTask object
  37998. */
  37999. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  38000. /**
  38001. *
  38002. * Add a HDRCubeTextureAssetTask to the list of active tasks
  38003. * @param taskName defines the name of the new task
  38004. * @param url defines the url of the file to load
  38005. * @param size defines the size you want for the cubemap (can be null)
  38006. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  38007. * @param generateHarmonics defines if you want to automatically generate (true by default)
  38008. * @param gammaSpace specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space) (default is false)
  38009. * @param reserved Internal use only
  38010. * @returns a new HDRCubeTextureAssetTask object
  38011. */
  38012. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  38013. /**
  38014. * Remove a task from the assets manager.
  38015. * @param task the task to remove
  38016. */
  38017. removeTask(task: AbstractAssetTask): void;
  38018. private _decreaseWaitingTasksCount;
  38019. private _runTask;
  38020. /**
  38021. * Reset the AssetsManager and remove all tasks
  38022. * @return the current instance of the AssetsManager
  38023. */
  38024. reset(): AssetsManager;
  38025. /**
  38026. * Start the loading process
  38027. * @return the current instance of the AssetsManager
  38028. */
  38029. load(): AssetsManager;
  38030. }
  38031. }
  38032. declare module BABYLON {
  38033. /**
  38034. * Direct draw surface info
  38035. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  38036. */
  38037. interface DDSInfo {
  38038. /**
  38039. * Width of the texture
  38040. */
  38041. width: number;
  38042. /**
  38043. * Width of the texture
  38044. */
  38045. height: number;
  38046. /**
  38047. * Number of Mipmaps for the texture
  38048. * @see https://en.wikipedia.org/wiki/Mipmap
  38049. */
  38050. mipmapCount: number;
  38051. /**
  38052. * If the textures format is a known fourCC format
  38053. * @see https://www.fourcc.org/
  38054. */
  38055. isFourCC: boolean;
  38056. /**
  38057. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  38058. */
  38059. isRGB: boolean;
  38060. /**
  38061. * If the texture is a lumincance format
  38062. */
  38063. isLuminance: boolean;
  38064. /**
  38065. * If this is a cube texture
  38066. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  38067. */
  38068. isCube: boolean;
  38069. /**
  38070. * If the texture is a compressed format eg. FOURCC_DXT1
  38071. */
  38072. isCompressed: boolean;
  38073. /**
  38074. * The dxgiFormat of the texture
  38075. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  38076. */
  38077. dxgiFormat: number;
  38078. /**
  38079. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  38080. */
  38081. textureType: number;
  38082. /**
  38083. * Sphericle polynomial created for the dds texture
  38084. */
  38085. sphericalPolynomial?: SphericalPolynomial;
  38086. }
  38087. /**
  38088. * Class used to provide DDS decompression tools
  38089. */
  38090. class DDSTools {
  38091. /**
  38092. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  38093. */
  38094. static StoreLODInAlphaChannel: boolean;
  38095. /**
  38096. * Gets DDS information from an array buffer
  38097. * @param arrayBuffer defines the array buffer to read data from
  38098. * @returns the DDS information
  38099. */
  38100. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  38101. private static _FloatView;
  38102. private static _Int32View;
  38103. private static _ToHalfFloat;
  38104. private static _FromHalfFloat;
  38105. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  38106. private static _GetHalfFloatRGBAArrayBuffer;
  38107. private static _GetFloatRGBAArrayBuffer;
  38108. private static _GetFloatAsUIntRGBAArrayBuffer;
  38109. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  38110. private static _GetRGBAArrayBuffer;
  38111. private static _ExtractLongWordOrder;
  38112. private static _GetRGBArrayBuffer;
  38113. private static _GetLuminanceArrayBuffer;
  38114. /**
  38115. * Uploads DDS Levels to a Babylon Texture
  38116. * @hidden
  38117. */
  38118. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  38119. }
  38120. }
  38121. declare module BABYLON {
  38122. function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  38123. function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38124. function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38125. function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38126. function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38127. function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38128. function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38129. function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38130. function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38131. function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38132. function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38133. function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38134. /**
  38135. * Decorator used to define property that can be serialized as reference to a camera
  38136. * @param sourceName defines the name of the property to decorate
  38137. */
  38138. function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38139. /**
  38140. * Class used to help serialization objects
  38141. */
  38142. class SerializationHelper {
  38143. /**
  38144. * Static function used to serialized a specific entity
  38145. * @param entity defines the entity to serialize
  38146. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  38147. * @returns a JSON compatible object representing the serialization of the entity
  38148. */
  38149. static Serialize<T>(entity: T, serializationObject?: any): any;
  38150. /**
  38151. * Creates a new entity from a serialization data object
  38152. * @param creationFunction defines a function used to instanciated the new entity
  38153. * @param source defines the source serialization data
  38154. * @param scene defines the hosting scene
  38155. * @param rootUrl defines the root url for resources
  38156. * @returns a new entity
  38157. */
  38158. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  38159. /**
  38160. * Clones an object
  38161. * @param creationFunction defines the function used to instanciate the new object
  38162. * @param source defines the source object
  38163. * @returns the cloned object
  38164. */
  38165. static Clone<T>(creationFunction: () => T, source: T): T;
  38166. /**
  38167. * Instanciates a new object based on a source one (some data will be shared between both object)
  38168. * @param creationFunction defines the function used to instanciate the new object
  38169. * @param source defines the source object
  38170. * @returns the new object
  38171. */
  38172. static Instanciate<T>(creationFunction: () => T, source: T): T;
  38173. }
  38174. }
  38175. declare module BABYLON {
  38176. /**
  38177. * Wrapper class for promise with external resolve and reject.
  38178. */
  38179. class Deferred<T> {
  38180. /**
  38181. * The promise associated with this deferred object.
  38182. */
  38183. readonly promise: Promise<T>;
  38184. private _resolve;
  38185. private _reject;
  38186. /**
  38187. * The resolve method of the promise associated with this deferred object.
  38188. */
  38189. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  38190. /**
  38191. * The reject method of the promise associated with this deferred object.
  38192. */
  38193. readonly reject: (reason?: any) => void;
  38194. /**
  38195. * Constructor for this deferred object.
  38196. */
  38197. constructor();
  38198. }
  38199. }
  38200. declare module BABYLON {
  38201. /**
  38202. * Raw texture data and descriptor sufficient for WebGL texture upload
  38203. */
  38204. interface EnvironmentTextureInfo {
  38205. /**
  38206. * Version of the environment map
  38207. */
  38208. version: number;
  38209. /**
  38210. * Width of image
  38211. */
  38212. width: number;
  38213. /**
  38214. * Irradiance information stored in the file.
  38215. */
  38216. irradiance: any;
  38217. /**
  38218. * Specular information stored in the file.
  38219. */
  38220. specular: any;
  38221. }
  38222. /**
  38223. * Sets of helpers addressing the serialization and deserialization of environment texture
  38224. * stored in a BabylonJS env file.
  38225. * Those files are usually stored as .env files.
  38226. */
  38227. class EnvironmentTextureTools {
  38228. /**
  38229. * Magic number identifying the env file.
  38230. */
  38231. private static _MagicBytes;
  38232. /**
  38233. * Gets the environment info from an env file.
  38234. * @param data The array buffer containing the .env bytes.
  38235. * @returns the environment file info (the json header) if successfully parsed.
  38236. */
  38237. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  38238. /**
  38239. * Creates an environment texture from a loaded cube texture.
  38240. * @param texture defines the cube texture to convert in env file
  38241. * @return a promise containing the environment data if succesfull.
  38242. */
  38243. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  38244. /**
  38245. * Creates a JSON representation of the spherical data.
  38246. * @param texture defines the texture containing the polynomials
  38247. * @return the JSON representation of the spherical info
  38248. */
  38249. private static _CreateEnvTextureIrradiance;
  38250. /**
  38251. * Uploads the texture info contained in the env file to the GPU.
  38252. * @param texture defines the internal texture to upload to
  38253. * @param arrayBuffer defines the buffer cotaining the data to load
  38254. * @param info defines the texture info retrieved through the GetEnvInfo method
  38255. * @returns a promise
  38256. */
  38257. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  38258. /**
  38259. * Uploads the levels of image data to the GPU.
  38260. * @param texture defines the internal texture to upload to
  38261. * @param imageData defines the array buffer views of image data [mipmap][face]
  38262. * @returns a promise
  38263. */
  38264. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  38265. /**
  38266. * Uploads spherical polynomials information to the texture.
  38267. * @param texture defines the texture we are trying to upload the information to
  38268. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  38269. */
  38270. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  38271. }
  38272. }
  38273. declare module BABYLON {
  38274. /**
  38275. * Class used to help managing file picking and drag'n'drop
  38276. */
  38277. class FilesInput {
  38278. /**
  38279. * List of files ready to be loaded
  38280. */
  38281. static FilesToLoad: {
  38282. [key: string]: File;
  38283. };
  38284. /**
  38285. * Callback called when a file is processed
  38286. */
  38287. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  38288. private _engine;
  38289. private _currentScene;
  38290. private _sceneLoadedCallback;
  38291. private _progressCallback;
  38292. private _additionalRenderLoopLogicCallback;
  38293. private _textureLoadingCallback;
  38294. private _startingProcessingFilesCallback;
  38295. private _onReloadCallback;
  38296. private _errorCallback;
  38297. private _elementToMonitor;
  38298. private _sceneFileToLoad;
  38299. private _filesToLoad;
  38300. /**
  38301. * Creates a new FilesInput
  38302. * @param engine defines the rendering engine
  38303. * @param scene defines the hosting scene
  38304. * @param sceneLoadedCallback callback called when scene is loaded
  38305. * @param progressCallback callback called to track progress
  38306. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  38307. * @param textureLoadingCallback callback called when a texture is loading
  38308. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  38309. * @param onReloadCallback callback called when a reload is requested
  38310. * @param errorCallback callback call if an error occurs
  38311. */
  38312. constructor(engine: Engine, scene: Scene, sceneLoadedCallback: (sceneFile: File, scene: Scene) => void, progressCallback: (progress: SceneLoaderProgressEvent) => void, additionalRenderLoopLogicCallback: () => void, textureLoadingCallback: (remaining: number) => void, startingProcessingFilesCallback: (files?: File[]) => void, onReloadCallback: (sceneFile: File) => void, errorCallback: (sceneFile: File, scene: Scene, message: string) => void);
  38313. private _dragEnterHandler;
  38314. private _dragOverHandler;
  38315. private _dropHandler;
  38316. /**
  38317. * Calls this function to listen to drag'n'drop events on a specific DOM element
  38318. * @param elementToMonitor defines the DOM element to track
  38319. */
  38320. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  38321. /**
  38322. * Release all associated resources
  38323. */
  38324. dispose(): void;
  38325. private renderFunction;
  38326. private drag;
  38327. private drop;
  38328. private _traverseFolder;
  38329. private _processFiles;
  38330. /**
  38331. * Load files from a drop event
  38332. * @param event defines the drop event to use as source
  38333. */
  38334. loadFiles(event: any): void;
  38335. private _processReload;
  38336. /**
  38337. * Reload the current scene from the loaded files
  38338. */
  38339. reload(): void;
  38340. }
  38341. }
  38342. declare module BABYLON {
  38343. /**
  38344. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  38345. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  38346. */
  38347. class KhronosTextureContainer {
  38348. /** contents of the KTX container file */
  38349. arrayBuffer: any;
  38350. private static HEADER_LEN;
  38351. private static COMPRESSED_2D;
  38352. private static COMPRESSED_3D;
  38353. private static TEX_2D;
  38354. private static TEX_3D;
  38355. /**
  38356. * Gets the openGL type
  38357. */
  38358. glType: number;
  38359. /**
  38360. * Gets the openGL type size
  38361. */
  38362. glTypeSize: number;
  38363. /**
  38364. * Gets the openGL format
  38365. */
  38366. glFormat: number;
  38367. /**
  38368. * Gets the openGL internal format
  38369. */
  38370. glInternalFormat: number;
  38371. /**
  38372. * Gets the base internal format
  38373. */
  38374. glBaseInternalFormat: number;
  38375. /**
  38376. * Gets image width in pixel
  38377. */
  38378. pixelWidth: number;
  38379. /**
  38380. * Gets image height in pixel
  38381. */
  38382. pixelHeight: number;
  38383. /**
  38384. * Gets image depth in pixels
  38385. */
  38386. pixelDepth: number;
  38387. /**
  38388. * Gets the number of array elements
  38389. */
  38390. numberOfArrayElements: number;
  38391. /**
  38392. * Gets the number of faces
  38393. */
  38394. numberOfFaces: number;
  38395. /**
  38396. * Gets the number of mipmap levels
  38397. */
  38398. numberOfMipmapLevels: number;
  38399. /**
  38400. * Gets the bytes of key value data
  38401. */
  38402. bytesOfKeyValueData: number;
  38403. /**
  38404. * Gets the load type
  38405. */
  38406. loadType: number;
  38407. /**
  38408. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  38409. */
  38410. isInvalid: boolean;
  38411. /**
  38412. * Creates a new KhronosTextureContainer
  38413. * @param arrayBuffer contents of the KTX container file
  38414. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  38415. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  38416. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  38417. */
  38418. constructor(
  38419. /** contents of the KTX container file */
  38420. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  38421. /**
  38422. * Uploads KTX content to a Babylon Texture.
  38423. * It is assumed that the texture has already been created & is currently bound
  38424. * @hidden
  38425. */
  38426. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  38427. private _upload2DCompressedLevels;
  38428. }
  38429. }
  38430. declare module BABYLON {
  38431. /**
  38432. * A class serves as a medium between the observable and its observers
  38433. */
  38434. class EventState {
  38435. /**
  38436. * Create a new EventState
  38437. * @param mask defines the mask associated with this state
  38438. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  38439. * @param target defines the original target of the state
  38440. * @param currentTarget defines the current target of the state
  38441. */
  38442. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  38443. /**
  38444. * Initialize the current event state
  38445. * @param mask defines the mask associated with this state
  38446. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  38447. * @param target defines the original target of the state
  38448. * @param currentTarget defines the current target of the state
  38449. * @returns the current event state
  38450. */
  38451. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  38452. /**
  38453. * An Observer can set this property to true to prevent subsequent observers of being notified
  38454. */
  38455. skipNextObservers: boolean;
  38456. /**
  38457. * Get the mask value that were used to trigger the event corresponding to this EventState object
  38458. */
  38459. mask: number;
  38460. /**
  38461. * The object that originally notified the event
  38462. */
  38463. target?: any;
  38464. /**
  38465. * The current object in the bubbling phase
  38466. */
  38467. currentTarget?: any;
  38468. /**
  38469. * This will be populated with the return value of the last function that was executed.
  38470. * If it is the first function in the callback chain it will be the event data.
  38471. */
  38472. lastReturnValue?: any;
  38473. }
  38474. /**
  38475. * Represent an Observer registered to a given Observable object.
  38476. */
  38477. class Observer<T> {
  38478. /**
  38479. * Defines the callback to call when the observer is notified
  38480. */
  38481. callback: (eventData: T, eventState: EventState) => void;
  38482. /**
  38483. * Defines the mask of the observer (used to filter notifications)
  38484. */
  38485. mask: number;
  38486. /**
  38487. * Defines the current scope used to restore the JS context
  38488. */
  38489. scope: any;
  38490. /** @hidden */
  38491. _willBeUnregistered: boolean;
  38492. /**
  38493. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  38494. */
  38495. unregisterOnNextCall: boolean;
  38496. /**
  38497. * Creates a new observer
  38498. * @param callback defines the callback to call when the observer is notified
  38499. * @param mask defines the mask of the observer (used to filter notifications)
  38500. * @param scope defines the current scope used to restore the JS context
  38501. */
  38502. constructor(
  38503. /**
  38504. * Defines the callback to call when the observer is notified
  38505. */
  38506. callback: (eventData: T, eventState: EventState) => void,
  38507. /**
  38508. * Defines the mask of the observer (used to filter notifications)
  38509. */
  38510. mask: number,
  38511. /**
  38512. * Defines the current scope used to restore the JS context
  38513. */
  38514. scope?: any);
  38515. }
  38516. /**
  38517. * Represent a list of observers registered to multiple Observables object.
  38518. */
  38519. class MultiObserver<T> {
  38520. private _observers;
  38521. private _observables;
  38522. /**
  38523. * Release associated resources
  38524. */
  38525. dispose(): void;
  38526. /**
  38527. * Raise a callback when one of the observable will notify
  38528. * @param observables defines a list of observables to watch
  38529. * @param callback defines the callback to call on notification
  38530. * @param mask defines the mask used to filter notifications
  38531. * @param scope defines the current scope used to restore the JS context
  38532. * @returns the new MultiObserver
  38533. */
  38534. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  38535. }
  38536. /**
  38537. * The Observable class is a simple implementation of the Observable pattern.
  38538. *
  38539. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  38540. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  38541. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  38542. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  38543. */
  38544. class Observable<T> {
  38545. private _observers;
  38546. private _eventState;
  38547. private _onObserverAdded;
  38548. /**
  38549. * Creates a new observable
  38550. * @param onObserverAdded defines a callback to call when a new observer is added
  38551. */
  38552. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  38553. /**
  38554. * Create a new Observer with the specified callback
  38555. * @param callback the callback that will be executed for that Observer
  38556. * @param mask the mask used to filter observers
  38557. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  38558. * @param scope optional scope for the callback to be called from
  38559. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  38560. * @returns the new observer created for the callback
  38561. */
  38562. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  38563. /**
  38564. * Create a new Observer with the specified callback and unregisters after the next notification
  38565. * @param callback the callback that will be executed for that Observer
  38566. * @returns the new observer created for the callback
  38567. */
  38568. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  38569. /**
  38570. * Remove an Observer from the Observable object
  38571. * @param observer the instance of the Observer to remove
  38572. * @returns false if it doesn't belong to this Observable
  38573. */
  38574. remove(observer: Nullable<Observer<T>>): boolean;
  38575. /**
  38576. * Remove a callback from the Observable object
  38577. * @param callback the callback to remove
  38578. * @param scope optional scope. If used only the callbacks with this scope will be removed
  38579. * @returns false if it doesn't belong to this Observable
  38580. */
  38581. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  38582. private _deferUnregister;
  38583. private _remove;
  38584. /**
  38585. * Notify all Observers by calling their respective callback with the given data
  38586. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  38587. * @param eventData defines the data to send to all observers
  38588. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  38589. * @param target defines the original target of the state
  38590. * @param currentTarget defines the current target of the state
  38591. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  38592. */
  38593. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  38594. /**
  38595. * Calling this will execute each callback, expecting it to be a promise or return a value.
  38596. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  38597. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  38598. * and it is crucial that all callbacks will be executed.
  38599. * The order of the callbacks is kept, callbacks are not executed parallel.
  38600. *
  38601. * @param eventData The data to be sent to each callback
  38602. * @param mask is used to filter observers defaults to -1
  38603. * @param target defines the callback target (see EventState)
  38604. * @param currentTarget defines he current object in the bubbling phase
  38605. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  38606. */
  38607. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  38608. /**
  38609. * Notify a specific observer
  38610. * @param observer defines the observer to notify
  38611. * @param eventData defines the data to be sent to each callback
  38612. * @param mask is used to filter observers defaults to -1
  38613. */
  38614. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  38615. /**
  38616. * Gets a boolean indicating if the observable has at least one observer
  38617. * @returns true is the Observable has at least one Observer registered
  38618. */
  38619. hasObservers(): boolean;
  38620. /**
  38621. * Clear the list of observers
  38622. */
  38623. clear(): void;
  38624. /**
  38625. * Clone the current observable
  38626. * @returns a new observable
  38627. */
  38628. clone(): Observable<T>;
  38629. /**
  38630. * Does this observable handles observer registered with a given mask
  38631. * @param mask defines the mask to be tested
  38632. * @return whether or not one observer registered with the given mask is handeled
  38633. **/
  38634. hasSpecificMask(mask?: number): boolean;
  38635. }
  38636. }
  38637. declare module BABYLON {
  38638. /**
  38639. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  38640. */
  38641. class PerformanceMonitor {
  38642. private _enabled;
  38643. private _rollingFrameTime;
  38644. private _lastFrameTimeMs;
  38645. /**
  38646. * constructor
  38647. * @param frameSampleSize The number of samples required to saturate the sliding window
  38648. */
  38649. constructor(frameSampleSize?: number);
  38650. /**
  38651. * Samples current frame
  38652. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  38653. */
  38654. sampleFrame(timeMs?: number): void;
  38655. /**
  38656. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38657. */
  38658. readonly averageFrameTime: number;
  38659. /**
  38660. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38661. */
  38662. readonly averageFrameTimeVariance: number;
  38663. /**
  38664. * Returns the frame time of the most recent frame
  38665. */
  38666. readonly instantaneousFrameTime: number;
  38667. /**
  38668. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  38669. */
  38670. readonly averageFPS: number;
  38671. /**
  38672. * Returns the average framerate in frames per second using the most recent frame time
  38673. */
  38674. readonly instantaneousFPS: number;
  38675. /**
  38676. * Returns true if enough samples have been taken to completely fill the sliding window
  38677. */
  38678. readonly isSaturated: boolean;
  38679. /**
  38680. * Enables contributions to the sliding window sample set
  38681. */
  38682. enable(): void;
  38683. /**
  38684. * Disables contributions to the sliding window sample set
  38685. * Samples will not be interpolated over the disabled period
  38686. */
  38687. disable(): void;
  38688. /**
  38689. * Returns true if sampling is enabled
  38690. */
  38691. readonly isEnabled: boolean;
  38692. /**
  38693. * Resets performance monitor
  38694. */
  38695. reset(): void;
  38696. }
  38697. /**
  38698. * RollingAverage
  38699. *
  38700. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  38701. */
  38702. class RollingAverage {
  38703. /**
  38704. * Current average
  38705. */
  38706. average: number;
  38707. /**
  38708. * Current variance
  38709. */
  38710. variance: number;
  38711. protected _samples: Array<number>;
  38712. protected _sampleCount: number;
  38713. protected _pos: number;
  38714. protected _m2: number;
  38715. /**
  38716. * constructor
  38717. * @param length The number of samples required to saturate the sliding window
  38718. */
  38719. constructor(length: number);
  38720. /**
  38721. * Adds a sample to the sample set
  38722. * @param v The sample value
  38723. */
  38724. add(v: number): void;
  38725. /**
  38726. * Returns previously added values or null if outside of history or outside the sliding window domain
  38727. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  38728. * @return Value previously recorded with add() or null if outside of range
  38729. */
  38730. history(i: number): number;
  38731. /**
  38732. * Returns true if enough samples have been taken to completely fill the sliding window
  38733. * @return true if sample-set saturated
  38734. */
  38735. isSaturated(): boolean;
  38736. /**
  38737. * Resets the rolling average (equivalent to 0 samples taken so far)
  38738. */
  38739. reset(): void;
  38740. /**
  38741. * Wraps a value around the sample range boundaries
  38742. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  38743. * @return Wrapped position in sample range
  38744. */
  38745. protected _wrapPosition(i: number): number;
  38746. }
  38747. }
  38748. declare module BABYLON {
  38749. /**
  38750. * Helper class that provides a small promise polyfill
  38751. */
  38752. class PromisePolyfill {
  38753. /**
  38754. * Static function used to check if the polyfill is required
  38755. * If this is the case then the function will inject the polyfill to window.Promise
  38756. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  38757. */
  38758. static Apply(force?: boolean): void;
  38759. }
  38760. }
  38761. declare module BABYLON {
  38762. /**
  38763. * Defines the root class used to create scene optimization to use with SceneOptimizer
  38764. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38765. */
  38766. class SceneOptimization {
  38767. /**
  38768. * Defines the priority of this optimization (0 by default which means first in the list)
  38769. */
  38770. priority: number;
  38771. /**
  38772. * Gets a string describing the action executed by the current optimization
  38773. * @returns description string
  38774. */
  38775. getDescription(): string;
  38776. /**
  38777. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38778. * @param scene defines the current scene where to apply this optimization
  38779. * @param optimizer defines the current optimizer
  38780. * @returns true if everything that can be done was applied
  38781. */
  38782. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38783. /**
  38784. * Creates the SceneOptimization object
  38785. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  38786. * @param desc defines the description associated with the optimization
  38787. */
  38788. constructor(
  38789. /**
  38790. * Defines the priority of this optimization (0 by default which means first in the list)
  38791. */
  38792. priority?: number);
  38793. }
  38794. /**
  38795. * Defines an optimization used to reduce the size of render target textures
  38796. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38797. */
  38798. class TextureOptimization extends SceneOptimization {
  38799. /**
  38800. * Defines the priority of this optimization (0 by default which means first in the list)
  38801. */
  38802. priority: number;
  38803. /**
  38804. * Defines the maximum sized allowed for textures (1024 is the default value). If a texture is bigger, it will be scaled down using a factor defined by the step parameter
  38805. */
  38806. maximumSize: number;
  38807. /**
  38808. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  38809. */
  38810. step: number;
  38811. /**
  38812. * Gets a string describing the action executed by the current optimization
  38813. * @returns description string
  38814. */
  38815. getDescription(): string;
  38816. /**
  38817. * Creates the TextureOptimization object
  38818. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  38819. * @param maximumSize defines the maximum sized allowed for textures (1024 is the default value). If a texture is bigger, it will be scaled down using a factor defined by the step parameter
  38820. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  38821. */
  38822. constructor(
  38823. /**
  38824. * Defines the priority of this optimization (0 by default which means first in the list)
  38825. */
  38826. priority?: number,
  38827. /**
  38828. * Defines the maximum sized allowed for textures (1024 is the default value). If a texture is bigger, it will be scaled down using a factor defined by the step parameter
  38829. */
  38830. maximumSize?: number,
  38831. /**
  38832. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  38833. */
  38834. step?: number);
  38835. /**
  38836. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38837. * @param scene defines the current scene where to apply this optimization
  38838. * @param optimizer defines the current optimizer
  38839. * @returns true if everything that can be done was applied
  38840. */
  38841. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38842. }
  38843. /**
  38844. * Defines an optimization used to increase or decrease the rendering resolution
  38845. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38846. */
  38847. class HardwareScalingOptimization extends SceneOptimization {
  38848. /**
  38849. * Defines the priority of this optimization (0 by default which means first in the list)
  38850. */
  38851. priority: number;
  38852. /**
  38853. * Defines the maximum scale to use (2 by default)
  38854. */
  38855. maximumScale: number;
  38856. /**
  38857. * Defines the step to use between two passes (0.5 by default)
  38858. */
  38859. step: number;
  38860. private _currentScale;
  38861. private _directionOffset;
  38862. /**
  38863. * Gets a string describing the action executed by the current optimization
  38864. * @return description string
  38865. */
  38866. getDescription(): string;
  38867. /**
  38868. * Creates the HardwareScalingOptimization object
  38869. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  38870. * @param maximumScale defines the maximum scale to use (2 by default)
  38871. * @param step defines the step to use between two passes (0.5 by default)
  38872. */
  38873. constructor(
  38874. /**
  38875. * Defines the priority of this optimization (0 by default which means first in the list)
  38876. */
  38877. priority?: number,
  38878. /**
  38879. * Defines the maximum scale to use (2 by default)
  38880. */
  38881. maximumScale?: number,
  38882. /**
  38883. * Defines the step to use between two passes (0.5 by default)
  38884. */
  38885. step?: number);
  38886. /**
  38887. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38888. * @param scene defines the current scene where to apply this optimization
  38889. * @param optimizer defines the current optimizer
  38890. * @returns true if everything that can be done was applied
  38891. */
  38892. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38893. }
  38894. /**
  38895. * Defines an optimization used to remove shadows
  38896. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38897. */
  38898. class ShadowsOptimization extends SceneOptimization {
  38899. /**
  38900. * Gets a string describing the action executed by the current optimization
  38901. * @return description string
  38902. */
  38903. getDescription(): string;
  38904. /**
  38905. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38906. * @param scene defines the current scene where to apply this optimization
  38907. * @param optimizer defines the current optimizer
  38908. * @returns true if everything that can be done was applied
  38909. */
  38910. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38911. }
  38912. /**
  38913. * Defines an optimization used to turn post-processes off
  38914. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38915. */
  38916. class PostProcessesOptimization extends SceneOptimization {
  38917. /**
  38918. * Gets a string describing the action executed by the current optimization
  38919. * @return description string
  38920. */
  38921. getDescription(): string;
  38922. /**
  38923. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38924. * @param scene defines the current scene where to apply this optimization
  38925. * @param optimizer defines the current optimizer
  38926. * @returns true if everything that can be done was applied
  38927. */
  38928. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38929. }
  38930. /**
  38931. * Defines an optimization used to turn lens flares off
  38932. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38933. */
  38934. class LensFlaresOptimization extends SceneOptimization {
  38935. /**
  38936. * Gets a string describing the action executed by the current optimization
  38937. * @return description string
  38938. */
  38939. getDescription(): string;
  38940. /**
  38941. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38942. * @param scene defines the current scene where to apply this optimization
  38943. * @param optimizer defines the current optimizer
  38944. * @returns true if everything that can be done was applied
  38945. */
  38946. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38947. }
  38948. /**
  38949. * Defines an optimization based on user defined callback.
  38950. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38951. */
  38952. class CustomOptimization extends SceneOptimization {
  38953. /**
  38954. * Callback called to apply the custom optimization.
  38955. */
  38956. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  38957. /**
  38958. * Callback called to get custom description
  38959. */
  38960. onGetDescription: () => string;
  38961. /**
  38962. * Gets a string describing the action executed by the current optimization
  38963. * @returns description string
  38964. */
  38965. getDescription(): string;
  38966. /**
  38967. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38968. * @param scene defines the current scene where to apply this optimization
  38969. * @param optimizer defines the current optimizer
  38970. * @returns true if everything that can be done was applied
  38971. */
  38972. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38973. }
  38974. /**
  38975. * Defines an optimization used to turn particles off
  38976. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38977. */
  38978. class ParticlesOptimization extends SceneOptimization {
  38979. /**
  38980. * Gets a string describing the action executed by the current optimization
  38981. * @return description string
  38982. */
  38983. getDescription(): string;
  38984. /**
  38985. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38986. * @param scene defines the current scene where to apply this optimization
  38987. * @param optimizer defines the current optimizer
  38988. * @returns true if everything that can be done was applied
  38989. */
  38990. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38991. }
  38992. /**
  38993. * Defines an optimization used to turn render targets off
  38994. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38995. */
  38996. class RenderTargetsOptimization extends SceneOptimization {
  38997. /**
  38998. * Gets a string describing the action executed by the current optimization
  38999. * @return description string
  39000. */
  39001. getDescription(): string;
  39002. /**
  39003. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  39004. * @param scene defines the current scene where to apply this optimization
  39005. * @param optimizer defines the current optimizer
  39006. * @returns true if everything that can be done was applied
  39007. */
  39008. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  39009. }
  39010. /**
  39011. * Defines an optimization used to merge meshes with compatible materials
  39012. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  39013. */
  39014. class MergeMeshesOptimization extends SceneOptimization {
  39015. private static _UpdateSelectionTree;
  39016. /**
  39017. * Gets or sets a boolean which defines if optimization octree has to be updated
  39018. */
  39019. /**
  39020. * Gets or sets a boolean which defines if optimization octree has to be updated
  39021. */
  39022. static UpdateSelectionTree: boolean;
  39023. /**
  39024. * Gets a string describing the action executed by the current optimization
  39025. * @return description string
  39026. */
  39027. getDescription(): string;
  39028. private _canBeMerged;
  39029. /**
  39030. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  39031. * @param scene defines the current scene where to apply this optimization
  39032. * @param optimizer defines the current optimizer
  39033. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  39034. * @returns true if everything that can be done was applied
  39035. */
  39036. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  39037. }
  39038. /**
  39039. * Defines a list of options used by SceneOptimizer
  39040. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  39041. */
  39042. class SceneOptimizerOptions {
  39043. /**
  39044. * Defines the target frame rate to reach (60 by default)
  39045. */
  39046. targetFrameRate: number;
  39047. /**
  39048. * Defines the interval between two checkes (2000ms by default)
  39049. */
  39050. trackerDuration: number;
  39051. /**
  39052. * Gets the list of optimizations to apply
  39053. */
  39054. optimizations: SceneOptimization[];
  39055. /**
  39056. * Creates a new list of options used by SceneOptimizer
  39057. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  39058. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  39059. */
  39060. constructor(
  39061. /**
  39062. * Defines the target frame rate to reach (60 by default)
  39063. */
  39064. targetFrameRate?: number,
  39065. /**
  39066. * Defines the interval between two checkes (2000ms by default)
  39067. */
  39068. trackerDuration?: number);
  39069. /**
  39070. * Add a new optimization
  39071. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  39072. * @returns the current SceneOptimizerOptions
  39073. */
  39074. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  39075. /**
  39076. * Add a new custom optimization
  39077. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  39078. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  39079. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  39080. * @returns the current SceneOptimizerOptions
  39081. */
  39082. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  39083. /**
  39084. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  39085. * @param targetFrameRate defines the target frame rate (60 by default)
  39086. * @returns a SceneOptimizerOptions object
  39087. */
  39088. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  39089. /**
  39090. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  39091. * @param targetFrameRate defines the target frame rate (60 by default)
  39092. * @returns a SceneOptimizerOptions object
  39093. */
  39094. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  39095. /**
  39096. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  39097. * @param targetFrameRate defines the target frame rate (60 by default)
  39098. * @returns a SceneOptimizerOptions object
  39099. */
  39100. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  39101. }
  39102. /**
  39103. * Class used to run optimizations in order to reach a target frame rate
  39104. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  39105. */
  39106. class SceneOptimizer implements IDisposable {
  39107. private _isRunning;
  39108. private _options;
  39109. private _scene;
  39110. private _currentPriorityLevel;
  39111. private _targetFrameRate;
  39112. private _trackerDuration;
  39113. private _currentFrameRate;
  39114. private _sceneDisposeObserver;
  39115. private _improvementMode;
  39116. /**
  39117. * Defines an observable called when the optimizer reaches the target frame rate
  39118. */
  39119. onSuccessObservable: Observable<SceneOptimizer>;
  39120. /**
  39121. * Defines an observable called when the optimizer enables an optimization
  39122. */
  39123. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  39124. /**
  39125. * Defines an observable called when the optimizer is not able to reach the target frame rate
  39126. */
  39127. onFailureObservable: Observable<SceneOptimizer>;
  39128. /**
  39129. * Gets a boolean indicating if the optimizer is in improvement mode
  39130. */
  39131. readonly isInImprovementMode: boolean;
  39132. /**
  39133. * Gets the current priority level (0 at start)
  39134. */
  39135. readonly currentPriorityLevel: number;
  39136. /**
  39137. * Gets the current frame rate checked by the SceneOptimizer
  39138. */
  39139. readonly currentFrameRate: number;
  39140. /**
  39141. * Gets or sets the current target frame rate (60 by default)
  39142. */
  39143. /**
  39144. * Gets or sets the current target frame rate (60 by default)
  39145. */
  39146. targetFrameRate: number;
  39147. /**
  39148. * Gets or sets the current interval between two checks (every 2000ms by default)
  39149. */
  39150. /**
  39151. * Gets or sets the current interval between two checks (every 2000ms by default)
  39152. */
  39153. trackerDuration: number;
  39154. /**
  39155. * Gets the list of active optimizations
  39156. */
  39157. readonly optimizations: SceneOptimization[];
  39158. /**
  39159. * Creates a new SceneOptimizer
  39160. * @param scene defines the scene to work on
  39161. * @param options defines the options to use with the SceneOptimizer
  39162. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  39163. * @param improvementMode defines if the scene optimizer must run the maximum optimization while staying over a target frame instead of trying to reach the target framerate (false by default)
  39164. */
  39165. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  39166. /**
  39167. * Stops the current optimizer
  39168. */
  39169. stop(): void;
  39170. /**
  39171. * Reset the optimizer to initial step (current priority level = 0)
  39172. */
  39173. reset(): void;
  39174. /**
  39175. * Start the optimizer. By default it will try to reach a specific framerate
  39176. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  39177. */
  39178. start(): void;
  39179. private _checkCurrentState;
  39180. /**
  39181. * Release all resources
  39182. */
  39183. dispose(): void;
  39184. /**
  39185. * Helper function to create a SceneOptimizer with one single line of code
  39186. * @param scene defines the scene to work on
  39187. * @param options defines the options to use with the SceneOptimizer
  39188. * @param onSuccess defines a callback to call on success
  39189. * @param onFailure defines a callback to call on failure
  39190. * @returns the new SceneOptimizer object
  39191. */
  39192. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  39193. }
  39194. }
  39195. declare module BABYLON {
  39196. /**
  39197. * Class used to serialize a scene into a string
  39198. */
  39199. class SceneSerializer {
  39200. /**
  39201. * Clear cache used by a previous serialization
  39202. */
  39203. static ClearCache(): void;
  39204. /**
  39205. * Serialize a scene into a JSON compatible object
  39206. * @param scene defines the scene to serialize
  39207. * @returns a JSON compatible object
  39208. */
  39209. static Serialize(scene: Scene): any;
  39210. /**
  39211. * Serialize a mesh into a JSON compatible object
  39212. * @param toSerialize defines the mesh to serialize
  39213. * @param withParents defines if parents must be serialized as well
  39214. * @param withChildren defines if children must be serialized as well
  39215. * @returns a JSON compatible object
  39216. */
  39217. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  39218. }
  39219. }
  39220. declare module BABYLON {
  39221. /**
  39222. * Defines an array and its length.
  39223. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  39224. */
  39225. interface ISmartArrayLike<T> {
  39226. /**
  39227. * The data of the array.
  39228. */
  39229. data: Array<T>;
  39230. /**
  39231. * The active length of the array.
  39232. */
  39233. length: number;
  39234. }
  39235. /**
  39236. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  39237. */
  39238. class SmartArray<T> implements ISmartArrayLike<T> {
  39239. /**
  39240. * The full set of data from the array.
  39241. */
  39242. data: Array<T>;
  39243. /**
  39244. * The active length of the array.
  39245. */
  39246. length: number;
  39247. protected _id: number;
  39248. /**
  39249. * Instantiates a Smart Array.
  39250. * @param capacity defines the default capacity of the array.
  39251. */
  39252. constructor(capacity: number);
  39253. /**
  39254. * Pushes a value at the end of the active data.
  39255. * @param value defines the object to push in the array.
  39256. */
  39257. push(value: T): void;
  39258. /**
  39259. * Iterates over the active data and apply the lambda to them.
  39260. * @param func defines the action to apply on each value.
  39261. */
  39262. forEach(func: (content: T) => void): void;
  39263. /**
  39264. * Sorts the full sets of data.
  39265. * @param compareFn defines the comparison function to apply.
  39266. */
  39267. sort(compareFn: (a: T, b: T) => number): void;
  39268. /**
  39269. * Resets the active data to an empty array.
  39270. */
  39271. reset(): void;
  39272. /**
  39273. * Releases all the data from the array as well as the array.
  39274. */
  39275. dispose(): void;
  39276. /**
  39277. * Concats the active data with a given array.
  39278. * @param array defines the data to concatenate with.
  39279. */
  39280. concat(array: any): void;
  39281. /**
  39282. * Returns the position of a value in the active data.
  39283. * @param value defines the value to find the index for
  39284. * @returns the index if found in the active data otherwise -1
  39285. */
  39286. indexOf(value: T): number;
  39287. /**
  39288. * Returns whether an element is part of the active data.
  39289. * @param value defines the value to look for
  39290. * @returns true if found in the active data otherwise false
  39291. */
  39292. contains(value: T): boolean;
  39293. private static _GlobalId;
  39294. }
  39295. /**
  39296. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  39297. * The data in this array can only be present once
  39298. */
  39299. class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  39300. private _duplicateId;
  39301. /**
  39302. * Pushes a value at the end of the active data.
  39303. * THIS DOES NOT PREVENT DUPPLICATE DATA
  39304. * @param value defines the object to push in the array.
  39305. */
  39306. push(value: T): void;
  39307. /**
  39308. * Pushes a value at the end of the active data.
  39309. * If the data is already present, it won t be added again
  39310. * @param value defines the object to push in the array.
  39311. * @returns true if added false if it was already present
  39312. */
  39313. pushNoDuplicate(value: T): boolean;
  39314. /**
  39315. * Resets the active data to an empty array.
  39316. */
  39317. reset(): void;
  39318. /**
  39319. * Concats the active data with a given array.
  39320. * This ensures no dupplicate will be present in the result.
  39321. * @param array defines the data to concatenate with.
  39322. */
  39323. concatWithNoDuplicate(array: any): void;
  39324. }
  39325. }
  39326. declare module BABYLON {
  39327. /**
  39328. * This class implement a typical dictionary using a string as key and the generic type T as value.
  39329. * The underlying implementation relies on an associative array to ensure the best performances.
  39330. * The value can be anything including 'null' but except 'undefined'
  39331. */
  39332. class StringDictionary<T> {
  39333. /**
  39334. * This will clear this dictionary and copy the content from the 'source' one.
  39335. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  39336. * @param source the dictionary to take the content from and copy to this dictionary
  39337. */
  39338. copyFrom(source: StringDictionary<T>): void;
  39339. /**
  39340. * Get a value based from its key
  39341. * @param key the given key to get the matching value from
  39342. * @return the value if found, otherwise undefined is returned
  39343. */
  39344. get(key: string): T | undefined;
  39345. /**
  39346. * Get a value from its key or add it if it doesn't exist.
  39347. * This method will ensure you that a given key/data will be present in the dictionary.
  39348. * @param key the given key to get the matching value from
  39349. * @param factory the factory that will create the value if the key is not present in the dictionary.
  39350. * The factory will only be invoked if there's no data for the given key.
  39351. * @return the value corresponding to the key.
  39352. */
  39353. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  39354. /**
  39355. * Get a value from its key if present in the dictionary otherwise add it
  39356. * @param key the key to get the value from
  39357. * @param val if there's no such key/value pair in the dictionary add it with this value
  39358. * @return the value corresponding to the key
  39359. */
  39360. getOrAdd(key: string, val: T): T;
  39361. /**
  39362. * Check if there's a given key in the dictionary
  39363. * @param key the key to check for
  39364. * @return true if the key is present, false otherwise
  39365. */
  39366. contains(key: string): boolean;
  39367. /**
  39368. * Add a new key and its corresponding value
  39369. * @param key the key to add
  39370. * @param value the value corresponding to the key
  39371. * @return true if the operation completed successfully, false if we couldn't insert the key/value because there was already this key in the dictionary
  39372. */
  39373. add(key: string, value: T): boolean;
  39374. /**
  39375. * Update a specific value associated to a key
  39376. * @param key defines the key to use
  39377. * @param value defines the value to store
  39378. * @returns true if the value was updated (or false if the key was not found)
  39379. */
  39380. set(key: string, value: T): boolean;
  39381. /**
  39382. * Get the element of the given key and remove it from the dictionary
  39383. * @param key defines the key to search
  39384. * @returns the value associated with the key or null if not found
  39385. */
  39386. getAndRemove(key: string): Nullable<T>;
  39387. /**
  39388. * Remove a key/value from the dictionary.
  39389. * @param key the key to remove
  39390. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  39391. */
  39392. remove(key: string): boolean;
  39393. /**
  39394. * Clear the whole content of the dictionary
  39395. */
  39396. clear(): void;
  39397. /**
  39398. * Gets the current count
  39399. */
  39400. readonly count: number;
  39401. /**
  39402. * Execute a callback on each key/val of the dictionary.
  39403. * Note that you can remove any element in this dictionary in the callback implementation
  39404. * @param callback the callback to execute on a given key/value pair
  39405. */
  39406. forEach(callback: (key: string, val: T) => void): void;
  39407. /**
  39408. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  39409. * If the callback returns null or undefined the method will iterate to the next key/value pair
  39410. * Note that you can remove any element in this dictionary in the callback implementation
  39411. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  39412. * @returns the first item
  39413. */
  39414. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  39415. private _count;
  39416. private _data;
  39417. }
  39418. }
  39419. declare module BABYLON {
  39420. /**
  39421. * Class used to store custom tags
  39422. */
  39423. class Tags {
  39424. /**
  39425. * Adds support for tags on the given object
  39426. * @param obj defines the object to use
  39427. */
  39428. static EnableFor(obj: any): void;
  39429. /**
  39430. * Removes tags support
  39431. * @param obj defines the object to use
  39432. */
  39433. static DisableFor(obj: any): void;
  39434. /**
  39435. * Gets a boolean indicating if the given object has tags
  39436. * @param obj defines the object to use
  39437. * @returns a boolean
  39438. */
  39439. static HasTags(obj: any): boolean;
  39440. /**
  39441. * Gets the tags available on a given object
  39442. * @param obj defines the object to use
  39443. * @param asString defines if the tags must be returned as a string instead of an array of strings
  39444. * @returns the tags
  39445. */
  39446. static GetTags(obj: any, asString?: boolean): any;
  39447. /**
  39448. * Adds tags to an object
  39449. * @param obj defines the object to use
  39450. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  39451. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  39452. */
  39453. static AddTagsTo(obj: any, tagsString: string): void;
  39454. /**
  39455. * @hidden
  39456. */
  39457. static _AddTagTo(obj: any, tag: string): void;
  39458. /**
  39459. * Removes specific tags from a specific object
  39460. * @param obj defines the object to use
  39461. * @param tagsString defines the tags to remove
  39462. */
  39463. static RemoveTagsFrom(obj: any, tagsString: string): void;
  39464. /**
  39465. * @hidden
  39466. */
  39467. static _RemoveTagFrom(obj: any, tag: string): void;
  39468. /**
  39469. * Defines if tags hosted on an object match a given query
  39470. * @param obj defines the object to use
  39471. * @param tagsQuery defines the tag query
  39472. * @returns a boolean
  39473. */
  39474. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  39475. }
  39476. }
  39477. declare module BABYLON {
  39478. /**
  39479. * Class used to host texture specific utilities
  39480. */
  39481. class TextureTools {
  39482. /**
  39483. * Uses the GPU to create a copy texture rescaled at a given size
  39484. * @param texture Texture to copy from
  39485. * @param width defines the desired width
  39486. * @param height defines the desired height
  39487. * @param useBilinearMode defines if bilinear mode has to be used
  39488. * @return the generated texture
  39489. */
  39490. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  39491. /**
  39492. * Gets an environment BRDF texture for a given scene
  39493. * @param scene defines the hosting scene
  39494. * @returns the environment BRDF texture
  39495. */
  39496. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  39497. private static _environmentBRDFBase64Texture;
  39498. }
  39499. }
  39500. declare module BABYLON {
  39501. /**
  39502. * Based on jsTGALoader - Javascript loader for TGA file
  39503. * By Vincent Thibault
  39504. * @see http://blog.robrowser.com/javascript-tga-loader.html
  39505. */
  39506. class TGATools {
  39507. private static _TYPE_INDEXED;
  39508. private static _TYPE_RGB;
  39509. private static _TYPE_GREY;
  39510. private static _TYPE_RLE_INDEXED;
  39511. private static _TYPE_RLE_RGB;
  39512. private static _TYPE_RLE_GREY;
  39513. private static _ORIGIN_MASK;
  39514. private static _ORIGIN_SHIFT;
  39515. private static _ORIGIN_BL;
  39516. private static _ORIGIN_BR;
  39517. private static _ORIGIN_UL;
  39518. private static _ORIGIN_UR;
  39519. /**
  39520. * Gets the header of a TGA file
  39521. * @param data defines the TGA data
  39522. * @returns the header
  39523. */
  39524. static GetTGAHeader(data: Uint8Array): any;
  39525. /**
  39526. * Uploads TGA content to a Babylon Texture
  39527. * @hidden
  39528. */
  39529. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  39530. /** @hidden */
  39531. static _getImageData8bits(header: any, palettes: Uint8Array, pixel_data: Uint8Array, y_start: number, y_step: number, y_end: number, x_start: number, x_step: number, x_end: number): Uint8Array;
  39532. /** @hidden */
  39533. static _getImageData16bits(header: any, palettes: Uint8Array, pixel_data: Uint8Array, y_start: number, y_step: number, y_end: number, x_start: number, x_step: number, x_end: number): Uint8Array;
  39534. /** @hidden */
  39535. static _getImageData24bits(header: any, palettes: Uint8Array, pixel_data: Uint8Array, y_start: number, y_step: number, y_end: number, x_start: number, x_step: number, x_end: number): Uint8Array;
  39536. /** @hidden */
  39537. static _getImageData32bits(header: any, palettes: Uint8Array, pixel_data: Uint8Array, y_start: number, y_step: number, y_end: number, x_start: number, x_step: number, x_end: number): Uint8Array;
  39538. /** @hidden */
  39539. static _getImageDataGrey8bits(header: any, palettes: Uint8Array, pixel_data: Uint8Array, y_start: number, y_step: number, y_end: number, x_start: number, x_step: number, x_end: number): Uint8Array;
  39540. /** @hidden */
  39541. static _getImageDataGrey16bits(header: any, palettes: Uint8Array, pixel_data: Uint8Array, y_start: number, y_step: number, y_end: number, x_start: number, x_step: number, x_end: number): Uint8Array;
  39542. }
  39543. }
  39544. declare module BABYLON {
  39545. /**
  39546. * Interface for any object that can request an animation frame
  39547. */
  39548. interface ICustomAnimationFrameRequester {
  39549. /**
  39550. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  39551. */
  39552. renderFunction?: Function;
  39553. /**
  39554. * Called to request the next frame to render to
  39555. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  39556. */
  39557. requestAnimationFrame: Function;
  39558. /**
  39559. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  39560. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  39561. */
  39562. requestID?: number;
  39563. }
  39564. /**
  39565. * Interface containing an array of animations
  39566. */
  39567. interface IAnimatable {
  39568. /**
  39569. * Array of animations
  39570. */
  39571. animations: Array<Animation>;
  39572. }
  39573. /** Interface used by value gradients (color, factor, ...) */
  39574. interface IValueGradient {
  39575. /**
  39576. * Gets or sets the gradient value (between 0 and 1)
  39577. */
  39578. gradient: number;
  39579. }
  39580. /** Class used to store color4 gradient */
  39581. class ColorGradient implements IValueGradient {
  39582. /**
  39583. * Gets or sets the gradient value (between 0 and 1)
  39584. */
  39585. gradient: number;
  39586. /**
  39587. * Gets or sets first associated color
  39588. */
  39589. color1: Color4;
  39590. /**
  39591. * Gets or sets second associated color
  39592. */
  39593. color2?: Color4;
  39594. /**
  39595. * Will get a color picked randomly between color1 and color2.
  39596. * If color2 is undefined then color1 will be used
  39597. * @param result defines the target Color4 to store the result in
  39598. */
  39599. getColorToRef(result: Color4): void;
  39600. }
  39601. /** Class used to store color 3 gradient */
  39602. class Color3Gradient implements IValueGradient {
  39603. /**
  39604. * Gets or sets the gradient value (between 0 and 1)
  39605. */
  39606. gradient: number;
  39607. /**
  39608. * Gets or sets the associated color
  39609. */
  39610. color: Color3;
  39611. }
  39612. /** Class used to store factor gradient */
  39613. class FactorGradient implements IValueGradient {
  39614. /**
  39615. * Gets or sets the gradient value (between 0 and 1)
  39616. */
  39617. gradient: number;
  39618. /**
  39619. * Gets or sets first associated factor
  39620. */
  39621. factor1: number;
  39622. /**
  39623. * Gets or sets second associated factor
  39624. */
  39625. factor2?: number;
  39626. /**
  39627. * Will get a number picked randomly between factor1 and factor2.
  39628. * If factor2 is undefined then factor1 will be used
  39629. * @returns the picked number
  39630. */
  39631. getFactor(): number;
  39632. }
  39633. /**
  39634. * @ignore
  39635. * Application error to support additional information when loading a file
  39636. */
  39637. class LoadFileError extends Error {
  39638. /** defines the optional XHR request */
  39639. request?: XMLHttpRequest | undefined;
  39640. private static _setPrototypeOf;
  39641. /**
  39642. * Creates a new LoadFileError
  39643. * @param message defines the message of the error
  39644. * @param request defines the optional XHR request
  39645. */
  39646. constructor(message: string,
  39647. /** defines the optional XHR request */
  39648. request?: XMLHttpRequest | undefined);
  39649. }
  39650. /**
  39651. * Class used to define a retry strategy when error happens while loading assets
  39652. */
  39653. class RetryStrategy {
  39654. /**
  39655. * Function used to defines an exponential back off strategy
  39656. * @param maxRetries defines the maximum number of retries (3 by default)
  39657. * @param baseInterval defines the interval between retries
  39658. * @returns the strategy function to use
  39659. */
  39660. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  39661. }
  39662. /**
  39663. * File request interface
  39664. */
  39665. interface IFileRequest {
  39666. /**
  39667. * Raised when the request is complete (success or error).
  39668. */
  39669. onCompleteObservable: Observable<IFileRequest>;
  39670. /**
  39671. * Aborts the request for a file.
  39672. */
  39673. abort: () => void;
  39674. }
  39675. /**
  39676. * Class containing a set of static utilities functions
  39677. */
  39678. class Tools {
  39679. /**
  39680. * Gets or sets the base URL to use to load assets
  39681. */
  39682. static BaseUrl: string;
  39683. /**
  39684. * Enable/Disable Custom HTTP Request Headers globally.
  39685. * default = false
  39686. * @see CustomRequestHeaders
  39687. */
  39688. static UseCustomRequestHeaders: boolean;
  39689. /**
  39690. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  39691. * i.e. when loading files, where the server/service expects an Authorization header.
  39692. * @see InjectCustomRequestHeaders injects them to an XMLHttpRequest
  39693. */
  39694. static CustomRequestHeaders: {
  39695. [key: string]: string;
  39696. };
  39697. /**
  39698. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  39699. */
  39700. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  39701. /**
  39702. * Default behaviour for cors in the application.
  39703. * It can be a string if the expected behavior is identical in the entire app.
  39704. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  39705. */
  39706. static CorsBehavior: string | ((url: string | string[]) => string);
  39707. /**
  39708. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  39709. * @ignorenaming
  39710. */
  39711. static UseFallbackTexture: boolean;
  39712. /**
  39713. * Use this object to register external classes like custom textures or material
  39714. * to allow the laoders to instantiate them
  39715. */
  39716. static RegisteredExternalClasses: {
  39717. [key: string]: Object;
  39718. };
  39719. /**
  39720. * Texture content used if a texture cannot loaded
  39721. * @ignorenaming
  39722. */
  39723. static fallbackTexture: string;
  39724. /**
  39725. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  39726. * @param u defines the coordinate on X axis
  39727. * @param v defines the coordinate on Y axis
  39728. * @param width defines the width of the source data
  39729. * @param height defines the height of the source data
  39730. * @param pixels defines the source byte array
  39731. * @param color defines the output color
  39732. */
  39733. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  39734. /**
  39735. * Interpolates between a and b via alpha
  39736. * @param a The lower value (returned when alpha = 0)
  39737. * @param b The upper value (returned when alpha = 1)
  39738. * @param alpha The interpolation-factor
  39739. * @return The mixed value
  39740. */
  39741. static Mix(a: number, b: number, alpha: number): number;
  39742. /**
  39743. * Tries to instantiate a new object from a given class name
  39744. * @param className defines the class name to instantiate
  39745. * @returns the new object or null if the system was not able to do the instantiation
  39746. */
  39747. static Instantiate(className: string): any;
  39748. /**
  39749. * Provides a slice function that will work even on IE
  39750. * @param data defines the array to slice
  39751. * @param start defines the start of the data (optional)
  39752. * @param end defines the end of the data (optional)
  39753. * @returns the new sliced array
  39754. */
  39755. static Slice<T>(data: T, start?: number, end?: number): T;
  39756. /**
  39757. * Polyfill for setImmediate
  39758. * @param action defines the action to execute after the current execution block
  39759. */
  39760. static SetImmediate(action: () => void): void;
  39761. /**
  39762. * Function indicating if a number is an exponent of 2
  39763. * @param value defines the value to test
  39764. * @returns true if the value is an exponent of 2
  39765. */
  39766. static IsExponentOfTwo(value: number): boolean;
  39767. private static _tmpFloatArray;
  39768. /**
  39769. * Returns the nearest 32-bit single precision float representation of a Number
  39770. * @param value A Number. If the parameter is of a different type, it will get converted
  39771. * to a number or to NaN if it cannot be converted
  39772. * @returns number
  39773. */
  39774. static FloatRound(value: number): number;
  39775. /**
  39776. * Find the next highest power of two.
  39777. * @param x Number to start search from.
  39778. * @return Next highest power of two.
  39779. */
  39780. static CeilingPOT(x: number): number;
  39781. /**
  39782. * Find the next lowest power of two.
  39783. * @param x Number to start search from.
  39784. * @return Next lowest power of two.
  39785. */
  39786. static FloorPOT(x: number): number;
  39787. /**
  39788. * Find the nearest power of two.
  39789. * @param x Number to start search from.
  39790. * @return Next nearest power of two.
  39791. */
  39792. static NearestPOT(x: number): number;
  39793. /**
  39794. * Get the closest exponent of two
  39795. * @param value defines the value to approximate
  39796. * @param max defines the maximum value to return
  39797. * @param mode defines how to define the closest value
  39798. * @returns closest exponent of two of the given value
  39799. */
  39800. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  39801. /**
  39802. * Extracts the filename from a path
  39803. * @param path defines the path to use
  39804. * @returns the filename
  39805. */
  39806. static GetFilename(path: string): string;
  39807. /**
  39808. * Extracts the "folder" part of a path (everything before the filename).
  39809. * @param uri The URI to extract the info from
  39810. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  39811. * @returns The "folder" part of the path
  39812. */
  39813. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  39814. /**
  39815. * Extracts text content from a DOM element hierarchy
  39816. * @param element defines the root element
  39817. * @returns a string
  39818. */
  39819. static GetDOMTextContent(element: HTMLElement): string;
  39820. /**
  39821. * Convert an angle in radians to degrees
  39822. * @param angle defines the angle to convert
  39823. * @returns the angle in degrees
  39824. */
  39825. static ToDegrees(angle: number): number;
  39826. /**
  39827. * Convert an angle in degrees to radians
  39828. * @param angle defines the angle to convert
  39829. * @returns the angle in radians
  39830. */
  39831. static ToRadians(angle: number): number;
  39832. /**
  39833. * Encode a buffer to a base64 string
  39834. * @param buffer defines the buffer to encode
  39835. * @returns the encoded string
  39836. */
  39837. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  39838. /**
  39839. * Extracts minimum and maximum values from a list of indexed positions
  39840. * @param positions defines the positions to use
  39841. * @param indices defines the indices to the positions
  39842. * @param indexStart defines the start index
  39843. * @param indexCount defines the end index
  39844. * @param bias defines bias value to add to the result
  39845. * @return minimum and maximum values
  39846. */
  39847. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  39848. minimum: Vector3;
  39849. maximum: Vector3;
  39850. };
  39851. /**
  39852. * Extracts minimum and maximum values from a list of positions
  39853. * @param positions defines the positions to use
  39854. * @param start defines the start index in the positions array
  39855. * @param count defines the number of positions to handle
  39856. * @param bias defines bias value to add to the result
  39857. * @param stride defines the stride size to use (distance between two positions in the positions array)
  39858. * @return minimum and maximum values
  39859. */
  39860. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  39861. minimum: Vector3;
  39862. maximum: Vector3;
  39863. };
  39864. /**
  39865. * Returns an array if obj is not an array
  39866. * @param obj defines the object to evaluate as an array
  39867. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  39868. * @returns either obj directly if obj is an array or a new array containing obj
  39869. */
  39870. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  39871. /**
  39872. * Returns an array of the given size filled with element built from the given constructor and the paramters
  39873. * @param size the number of element to construct and put in the array
  39874. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  39875. * @returns a new array filled with new objects
  39876. */
  39877. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  39878. /**
  39879. * Gets the pointer prefix to use
  39880. * @returns "pointer" if touch is enabled. Else returns "mouse"
  39881. */
  39882. static GetPointerPrefix(): string;
  39883. /**
  39884. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  39885. * @param func - the function to be called
  39886. * @param requester - the object that will request the next frame. Falls back to window.
  39887. * @returns frame number
  39888. */
  39889. static QueueNewFrame(func: () => void, requester?: any): number;
  39890. /**
  39891. * Ask the browser to promote the current element to fullscreen rendering mode
  39892. * @param element defines the DOM element to promote
  39893. */
  39894. static RequestFullscreen(element: HTMLElement): void;
  39895. /**
  39896. * Asks the browser to exit fullscreen mode
  39897. */
  39898. static ExitFullscreen(): void;
  39899. /**
  39900. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  39901. * @param url define the url we are trying
  39902. * @param element define the dom element where to configure the cors policy
  39903. */
  39904. static SetCorsBehavior(url: string | string[], element: {
  39905. crossOrigin: string | null;
  39906. }): void;
  39907. /**
  39908. * Removes unwanted characters from an url
  39909. * @param url defines the url to clean
  39910. * @returns the cleaned url
  39911. */
  39912. static CleanUrl(url: string): string;
  39913. /**
  39914. * Gets or sets a function used to pre-process url before using them to load assets
  39915. */
  39916. static PreprocessUrl: (url: string) => string;
  39917. /**
  39918. * Loads an image as an HTMLImageElement.
  39919. * @param input url string, ArrayBuffer, or Blob to load
  39920. * @param onLoad callback called when the image successfully loads
  39921. * @param onError callback called when the image fails to load
  39922. * @param offlineProvider offline provider for caching
  39923. * @returns the HTMLImageElement of the loaded image
  39924. */
  39925. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  39926. /**
  39927. * Loads a file
  39928. * @param url url string, ArrayBuffer, or Blob to load
  39929. * @param onSuccess callback called when the file successfully loads
  39930. * @param onProgress callback called while file is loading (if the server supports this mode)
  39931. * @param offlineProvider defines the offline provider for caching
  39932. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  39933. * @param onError callback called when the file fails to load
  39934. * @returns a file request object
  39935. */
  39936. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  39937. /**
  39938. * Load a script (identified by an url). When the url returns, the
  39939. * content of this file is added into a new script element, attached to the DOM (body element)
  39940. * @param scriptUrl defines the url of the script to laod
  39941. * @param onSuccess defines the callback called when the script is loaded
  39942. * @param onError defines the callback to call if an error occurs
  39943. */
  39944. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  39945. /**
  39946. * Loads a file from a blob
  39947. * @param fileToLoad defines the blob to use
  39948. * @param callback defines the callback to call when data is loaded
  39949. * @param progressCallback defines the callback to call during loading process
  39950. * @returns a file request object
  39951. */
  39952. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  39953. /**
  39954. * Loads a file
  39955. * @param fileToLoad defines the file to load
  39956. * @param callback defines the callback to call when data is loaded
  39957. * @param progressCallBack defines the callback to call during loading process
  39958. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  39959. * @returns a file request object
  39960. */
  39961. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  39962. /**
  39963. * Creates a data url from a given string content
  39964. * @param content defines the content to convert
  39965. * @returns the new data url link
  39966. */
  39967. static FileAsURL(content: string): string;
  39968. /**
  39969. * Format the given number to a specific decimal format
  39970. * @param value defines the number to format
  39971. * @param decimals defines the number of decimals to use
  39972. * @returns the formatted string
  39973. */
  39974. static Format(value: number, decimals?: number): string;
  39975. /**
  39976. * Checks if a given vector is inside a specific range
  39977. * @param v defines the vector to test
  39978. * @param min defines the minimum range
  39979. * @param max defines the maximum range
  39980. */
  39981. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  39982. /**
  39983. * Tries to copy an object by duplicating every property
  39984. * @param source defines the source object
  39985. * @param destination defines the target object
  39986. * @param doNotCopyList defines a list of properties to avoid
  39987. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  39988. */
  39989. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  39990. /**
  39991. * Gets a boolean indicating if the given object has no own property
  39992. * @param obj defines the object to test
  39993. * @returns true if object has no own property
  39994. */
  39995. static IsEmpty(obj: any): boolean;
  39996. /**
  39997. * Function used to register events at window level
  39998. * @param events defines the events to register
  39999. */
  40000. static RegisterTopRootEvents(events: {
  40001. name: string;
  40002. handler: Nullable<(e: FocusEvent) => any>;
  40003. }[]): void;
  40004. /**
  40005. * Function used to unregister events from window level
  40006. * @param events defines the events to unregister
  40007. */
  40008. static UnregisterTopRootEvents(events: {
  40009. name: string;
  40010. handler: Nullable<(e: FocusEvent) => any>;
  40011. }[]): void;
  40012. /**
  40013. * Dumps the current bound framebuffer
  40014. * @param width defines the rendering width
  40015. * @param height defines the rendering height
  40016. * @param engine defines the hosting engine
  40017. * @param successCallback defines the callback triggered once the data are available
  40018. * @param mimeType defines the mime type of the result
  40019. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  40020. */
  40021. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  40022. /**
  40023. * Converts the canvas data to blob.
  40024. * This acts as a polyfill for browsers not supporting the to blob function.
  40025. * @param canvas Defines the canvas to extract the data from
  40026. * @param successCallback Defines the callback triggered once the data are available
  40027. * @param mimeType Defines the mime type of the result
  40028. */
  40029. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  40030. /**
  40031. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  40032. * @param successCallback defines the callback triggered once the data are available
  40033. * @param mimeType defines the mime type of the result
  40034. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  40035. */
  40036. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  40037. /**
  40038. * Downloads a blob in the browser
  40039. * @param blob defines the blob to download
  40040. * @param fileName defines the name of the downloaded file
  40041. */
  40042. static Download(blob: Blob, fileName: string): void;
  40043. /**
  40044. * Captures a screenshot of the current rendering
  40045. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  40046. * @param engine defines the rendering engine
  40047. * @param camera defines the source camera
  40048. * @param size This parameter can be set to a single number or to an object with the
  40049. * following (optional) properties: precision, width, height. If a single number is passed,
  40050. * it will be used for both width and height. If an object is passed, the screenshot size
  40051. * will be derived from the parameters. The precision property is a multiplier allowing
  40052. * rendering at a higher or lower resolution
  40053. * @param successCallback defines the callback receives a single parameter which contains the
  40054. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  40055. * src parameter of an <img> to display it
  40056. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  40057. * Check your browser for supported MIME types
  40058. */
  40059. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  40060. /**
  40061. * Generates an image screenshot from the specified camera.
  40062. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  40063. * @param engine The engine to use for rendering
  40064. * @param camera The camera to use for rendering
  40065. * @param size This parameter can be set to a single number or to an object with the
  40066. * following (optional) properties: precision, width, height. If a single number is passed,
  40067. * it will be used for both width and height. If an object is passed, the screenshot size
  40068. * will be derived from the parameters. The precision property is a multiplier allowing
  40069. * rendering at a higher or lower resolution
  40070. * @param successCallback The callback receives a single parameter which contains the
  40071. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  40072. * src parameter of an <img> to display it
  40073. * @param mimeType The MIME type of the screenshot image (default: image/png).
  40074. * Check your browser for supported MIME types
  40075. * @param samples Texture samples (default: 1)
  40076. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  40077. * @param fileName A name for for the downloaded file.
  40078. */
  40079. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  40080. /**
  40081. * Validates if xhr data is correct
  40082. * @param xhr defines the request to validate
  40083. * @param dataType defines the expected data type
  40084. * @returns true if data is correct
  40085. */
  40086. static ValidateXHRData(xhr: XMLHttpRequest, dataType?: number): boolean;
  40087. /**
  40088. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  40089. * Be aware Math.random() could cause collisions, but:
  40090. * "All but 6 of the 128 bits of the ID are randomly generated, which means that for any two ids, there's a 1 in 2^^122 (or 5.3x10^^36) chance they'll collide"
  40091. * @returns a pseudo random id
  40092. */
  40093. static RandomId(): string;
  40094. /**
  40095. * Test if the given uri is a base64 string
  40096. * @param uri The uri to test
  40097. * @return True if the uri is a base64 string or false otherwise
  40098. */
  40099. static IsBase64(uri: string): boolean;
  40100. /**
  40101. * Decode the given base64 uri.
  40102. * @param uri The uri to decode
  40103. * @return The decoded base64 data.
  40104. */
  40105. static DecodeBase64(uri: string): ArrayBuffer;
  40106. /**
  40107. * No log
  40108. */
  40109. static readonly NoneLogLevel: number;
  40110. /**
  40111. * Only message logs
  40112. */
  40113. static readonly MessageLogLevel: number;
  40114. /**
  40115. * Only warning logs
  40116. */
  40117. static readonly WarningLogLevel: number;
  40118. /**
  40119. * Only error logs
  40120. */
  40121. static readonly ErrorLogLevel: number;
  40122. /**
  40123. * All logs
  40124. */
  40125. static readonly AllLogLevel: number;
  40126. private static _LogCache;
  40127. /**
  40128. * Gets a value indicating the number of loading errors
  40129. * @ignorenaming
  40130. */
  40131. static errorsCount: number;
  40132. /**
  40133. * Callback called when a new log is added
  40134. */
  40135. static OnNewCacheEntry: (entry: string) => void;
  40136. private static _AddLogEntry;
  40137. private static _FormatMessage;
  40138. private static _LogDisabled;
  40139. private static _LogEnabled;
  40140. private static _WarnDisabled;
  40141. private static _WarnEnabled;
  40142. private static _ErrorDisabled;
  40143. private static _ErrorEnabled;
  40144. /**
  40145. * Log a message to the console
  40146. */
  40147. static Log: (message: string) => void;
  40148. /**
  40149. * Write a warning message to the console
  40150. */
  40151. static Warn: (message: string) => void;
  40152. /**
  40153. * Write an error message to the console
  40154. */
  40155. static Error: (message: string) => void;
  40156. /**
  40157. * Gets current log cache (list of logs)
  40158. */
  40159. static readonly LogCache: string;
  40160. /**
  40161. * Clears the log cache
  40162. */
  40163. static ClearLogCache(): void;
  40164. /**
  40165. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  40166. */
  40167. static LogLevels: number;
  40168. /**
  40169. * Checks if the loaded document was accessed via `file:`-Protocol.
  40170. * @returns boolean
  40171. */
  40172. static IsFileURL(): boolean;
  40173. /**
  40174. * Checks if the window object exists
  40175. * @returns true if the window object exists
  40176. */
  40177. static IsWindowObjectExist(): boolean;
  40178. /**
  40179. * No performance log
  40180. */
  40181. static readonly PerformanceNoneLogLevel: number;
  40182. /**
  40183. * Use user marks to log performance
  40184. */
  40185. static readonly PerformanceUserMarkLogLevel: number;
  40186. /**
  40187. * Log performance to the console
  40188. */
  40189. static readonly PerformanceConsoleLogLevel: number;
  40190. private static _performance;
  40191. /**
  40192. * Sets the current performance log level
  40193. */
  40194. static PerformanceLogLevel: number;
  40195. private static _StartPerformanceCounterDisabled;
  40196. private static _EndPerformanceCounterDisabled;
  40197. private static _StartUserMark;
  40198. private static _EndUserMark;
  40199. private static _StartPerformanceConsole;
  40200. private static _EndPerformanceConsole;
  40201. /**
  40202. * Injects the @see CustomRequestHeaders into the given request
  40203. * @param request the request that should be used for injection
  40204. */
  40205. static InjectCustomRequestHeaders(request: XMLHttpRequest): void;
  40206. /**
  40207. * Starts a performance counter
  40208. */
  40209. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  40210. /**
  40211. * Ends a specific performance coutner
  40212. */
  40213. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  40214. /**
  40215. * Gets either window.performance.now() if supported or Date.now() else
  40216. */
  40217. static readonly Now: number;
  40218. /**
  40219. * This method will return the name of the class used to create the instance of the given object.
  40220. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  40221. * @param object the object to get the class name from
  40222. * @param isType defines if the object is actually a type
  40223. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  40224. */
  40225. static GetClassName(object: any, isType?: boolean): string;
  40226. /**
  40227. * Gets the first element of an array satisfying a given predicate
  40228. * @param array defines the array to browse
  40229. * @param predicate defines the predicate to use
  40230. * @returns null if not found or the element
  40231. */
  40232. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  40233. /**
  40234. * This method will return the name of the full name of the class, including its owning module (if any).
  40235. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator or implementing a method getClassName():string (in which case the module won't be specified).
  40236. * @param object the object to get the class name from
  40237. * @param isType defines if the object is actually a type
  40238. * @return a string that can have two forms: "moduleName.className" if module was specified when the class' Name was registered or "className" if there was not module specified.
  40239. * @ignorenaming
  40240. */
  40241. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  40242. /**
  40243. * Returns a promise that resolves after the given amount of time.
  40244. * @param delay Number of milliseconds to delay
  40245. * @returns Promise that resolves after the given amount of time
  40246. */
  40247. static DelayAsync(delay: number): Promise<void>;
  40248. /**
  40249. * Gets the current gradient from an array of IValueGradient
  40250. * @param ratio defines the current ratio to get
  40251. * @param gradients defines the array of IValueGradient
  40252. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  40253. */
  40254. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  40255. }
  40256. /**
  40257. * This class is used to track a performance counter which is number based.
  40258. * The user has access to many properties which give statistics of different nature.
  40259. *
  40260. * The implementer can track two kinds of Performance Counter: time and count.
  40261. * For time you can optionally call fetchNewFrame() to notify the start of a new frame to monitor, then call beginMonitoring() to start and endMonitoring() to record the lapsed time. endMonitoring takes a newFrame parameter for you to specify if the monitored time should be set for a new frame or accumulated to the current frame being monitored.
  40262. * For count you first have to call fetchNewFrame() to notify the start of a new frame to monitor, then call addCount() how many time required to increment the count value you monitor.
  40263. */
  40264. class PerfCounter {
  40265. /**
  40266. * Gets or sets a global boolean to turn on and off all the counters
  40267. */
  40268. static Enabled: boolean;
  40269. /**
  40270. * Returns the smallest value ever
  40271. */
  40272. readonly min: number;
  40273. /**
  40274. * Returns the biggest value ever
  40275. */
  40276. readonly max: number;
  40277. /**
  40278. * Returns the average value since the performance counter is running
  40279. */
  40280. readonly average: number;
  40281. /**
  40282. * Returns the average value of the last second the counter was monitored
  40283. */
  40284. readonly lastSecAverage: number;
  40285. /**
  40286. * Returns the current value
  40287. */
  40288. readonly current: number;
  40289. /**
  40290. * Gets the accumulated total
  40291. */
  40292. readonly total: number;
  40293. /**
  40294. * Gets the total value count
  40295. */
  40296. readonly count: number;
  40297. /**
  40298. * Creates a new counter
  40299. */
  40300. constructor();
  40301. /**
  40302. * Call this method to start monitoring a new frame.
  40303. * This scenario is typically used when you accumulate monitoring time many times for a single frame, you call this method at the start of the frame, then beginMonitoring to start recording and endMonitoring(false) to accumulated the recorded time to the PerfCounter or addCount() to accumulate a monitored count.
  40304. */
  40305. fetchNewFrame(): void;
  40306. /**
  40307. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  40308. * @param newCount the count value to add to the monitored count
  40309. * @param fetchResult true when it's the last time in the frame you add to the counter and you wish to update the statistics properties (min/max/average), false if you only want to update statistics.
  40310. */
  40311. addCount(newCount: number, fetchResult: boolean): void;
  40312. /**
  40313. * Start monitoring this performance counter
  40314. */
  40315. beginMonitoring(): void;
  40316. /**
  40317. * Compute the time lapsed since the previous beginMonitoring() call.
  40318. * @param newFrame true by default to fetch the result and monitor a new frame, if false the time monitored will be added to the current frame counter
  40319. */
  40320. endMonitoring(newFrame?: boolean): void;
  40321. private _fetchResult;
  40322. private _startMonitoringTime;
  40323. private _min;
  40324. private _max;
  40325. private _average;
  40326. private _current;
  40327. private _totalValueCount;
  40328. private _totalAccumulated;
  40329. private _lastSecAverage;
  40330. private _lastSecAccumulated;
  40331. private _lastSecTime;
  40332. private _lastSecValueCount;
  40333. }
  40334. /**
  40335. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  40336. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  40337. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  40338. * @param name The name of the class, case should be preserved
  40339. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  40340. */
  40341. function className(name: string, module?: string): (target: Object) => void;
  40342. /**
  40343. * An implementation of a loop for asynchronous functions.
  40344. */
  40345. class AsyncLoop {
  40346. /**
  40347. * Defines the number of iterations for the loop
  40348. */
  40349. iterations: number;
  40350. /**
  40351. * Defines the current index of the loop.
  40352. */
  40353. index: number;
  40354. private _done;
  40355. private _fn;
  40356. private _successCallback;
  40357. /**
  40358. * Constructor.
  40359. * @param iterations the number of iterations.
  40360. * @param func the function to run each iteration
  40361. * @param successCallback the callback that will be called upon succesful execution
  40362. * @param offset starting offset.
  40363. */
  40364. constructor(
  40365. /**
  40366. * Defines the number of iterations for the loop
  40367. */
  40368. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  40369. /**
  40370. * Execute the next iteration. Must be called after the last iteration was finished.
  40371. */
  40372. executeNext(): void;
  40373. /**
  40374. * Break the loop and run the success callback.
  40375. */
  40376. breakLoop(): void;
  40377. /**
  40378. * Create and run an async loop.
  40379. * @param iterations the number of iterations.
  40380. * @param fn the function to run each iteration
  40381. * @param successCallback the callback that will be called upon succesful execution
  40382. * @param offset starting offset.
  40383. * @returns the created async loop object
  40384. */
  40385. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  40386. /**
  40387. * A for-loop that will run a given number of iterations synchronous and the rest async.
  40388. * @param iterations total number of iterations
  40389. * @param syncedIterations number of synchronous iterations in each async iteration.
  40390. * @param fn the function to call each iteration.
  40391. * @param callback a success call back that will be called when iterating stops.
  40392. * @param breakFunction a break condition (optional)
  40393. * @param timeout timeout settings for the setTimeout function. default - 0.
  40394. * @returns the created async loop object
  40395. */
  40396. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  40397. }
  40398. }
  40399. interface HTMLCanvasElement {
  40400. /** Track wether a record is in progress */
  40401. isRecording: boolean;
  40402. /** Capture Stream method defined by some browsers */
  40403. captureStream(fps?: number): MediaStream;
  40404. }
  40405. interface MediaRecorder {
  40406. /** Starts recording */
  40407. start(timeSlice: number): void;
  40408. /** Stops recording */
  40409. stop(): void;
  40410. /** Event raised when an error arised. */
  40411. onerror: (event: ErrorEvent) => void;
  40412. /** Event raised when the recording stops. */
  40413. onstop: (event: Event) => void;
  40414. /** Event raised when a new chunk of data is available and should be tracked. */
  40415. ondataavailable: (event: Event) => void;
  40416. }
  40417. interface MediaRecorderOptions {
  40418. /** The mime type you want to use as the recording container for the new MediaRecorder */
  40419. mimeType?: string;
  40420. /** The chosen bitrate for the audio component of the media. */
  40421. audioBitsPerSecond?: number;
  40422. /** The chosen bitrate for the video component of the media. */
  40423. videoBitsPerSecond?: number;
  40424. /** The chosen bitrate for the audio and video components of the media. This can be specified instead of the above two properties. If this is specified along with one or the other of the above properties, this will be used for the one that isn't specified. */
  40425. bitsPerSecond?: number;
  40426. }
  40427. interface MediaRecorderConstructor {
  40428. /**
  40429. * A reference to the prototype.
  40430. */
  40431. readonly prototype: MediaRecorder;
  40432. /**
  40433. * Creates a new MediaRecorder.
  40434. * @param stream Defines the stream to record.
  40435. * @param options Defines the options for the recorder available in the type MediaRecorderOptions.
  40436. */
  40437. new (stream: MediaStream, options?: MediaRecorderOptions): MediaRecorder;
  40438. }
  40439. /**
  40440. * MediaRecoreder object available in some browsers.
  40441. */
  40442. declare var MediaRecorder: MediaRecorderConstructor;
  40443. declare module BABYLON {
  40444. /**
  40445. * This represents the different options avilable for the video capture.
  40446. */
  40447. interface VideoRecorderOptions {
  40448. /** Defines the mime type of the video */
  40449. mimeType: string;
  40450. /** Defines the video the video should be recorded at */
  40451. fps: number;
  40452. /** Defines the chunk size for the recording data */
  40453. recordChunckSize: number;
  40454. }
  40455. /**
  40456. * This can helps recording videos from BabylonJS.
  40457. * This is based on the available WebRTC functionalities of the browser.
  40458. *
  40459. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  40460. */
  40461. class VideoRecorder {
  40462. private static readonly _defaultOptions;
  40463. /**
  40464. * Returns wehther or not the VideoRecorder is available in your browser.
  40465. * @param engine Defines the Babylon Engine to check the support for
  40466. * @returns true if supported otherwise false
  40467. */
  40468. static IsSupported(engine: Engine): boolean;
  40469. private readonly _options;
  40470. private _canvas;
  40471. private _mediaRecorder;
  40472. private _recordedChunks;
  40473. private _fileName;
  40474. private _resolve;
  40475. private _reject;
  40476. /**
  40477. * True wether a recording is already in progress.
  40478. */
  40479. readonly isRecording: boolean;
  40480. /**
  40481. * Create a new VideoCapture object which can help converting what you see in Babylon to
  40482. * a video file.
  40483. * @param engine Defines the BabylonJS Engine you wish to record
  40484. * @param options Defines options that can be used to customized the capture
  40485. */
  40486. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  40487. /**
  40488. * Stops the current recording before the default capture timeout passed in the startRecording
  40489. * functions.
  40490. */
  40491. stopRecording(): void;
  40492. /**
  40493. * Starts recording the canvas for a max duration specified in parameters.
  40494. * @param fileName Defines the name of the file to be downloaded when the recording stop. If null no automatic download will start and you can rely on the promise to get the data back.
  40495. * @param maxDuration Defines the maximum recording time in seconds.
  40496. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  40497. * @return a promise callback at the end of the recording with the video data in Blob.
  40498. */
  40499. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  40500. /**
  40501. * Releases internal resources used during the recording.
  40502. */
  40503. dispose(): void;
  40504. private _handleDataAvailable;
  40505. private _handleError;
  40506. private _handleStop;
  40507. }
  40508. }
  40509. declare module BABYLON {
  40510. /**
  40511. * Defines the potential axis of a Joystick
  40512. */
  40513. enum JoystickAxis {
  40514. /** X axis */
  40515. X = 0,
  40516. /** Y axis */
  40517. Y = 1,
  40518. /** Z axis */
  40519. Z = 2
  40520. }
  40521. /**
  40522. * Class used to define virtual joystick (used in touch mode)
  40523. */
  40524. class VirtualJoystick {
  40525. /**
  40526. * Gets or sets a boolean indicating that left and right values must be inverted
  40527. */
  40528. reverseLeftRight: boolean;
  40529. /**
  40530. * Gets or sets a boolean indicating that up and down values must be inverted
  40531. */
  40532. reverseUpDown: boolean;
  40533. /**
  40534. * Gets the offset value for the position (ie. the change of the position value)
  40535. */
  40536. deltaPosition: Vector3;
  40537. /**
  40538. * Gets a boolean indicating if the virtual joystick was pressed
  40539. */
  40540. pressed: boolean;
  40541. /**
  40542. * Canvas the virtual joystick will render onto, default z-index of this is 5
  40543. */
  40544. static Canvas: Nullable<HTMLCanvasElement>;
  40545. private static _globalJoystickIndex;
  40546. private static vjCanvasContext;
  40547. private static vjCanvasWidth;
  40548. private static vjCanvasHeight;
  40549. private static halfWidth;
  40550. private _action;
  40551. private _axisTargetedByLeftAndRight;
  40552. private _axisTargetedByUpAndDown;
  40553. private _joystickSensibility;
  40554. private _inversedSensibility;
  40555. private _joystickPointerID;
  40556. private _joystickColor;
  40557. private _joystickPointerPos;
  40558. private _joystickPreviousPointerPos;
  40559. private _joystickPointerStartPos;
  40560. private _deltaJoystickVector;
  40561. private _leftJoystick;
  40562. private _touches;
  40563. private _onPointerDownHandlerRef;
  40564. private _onPointerMoveHandlerRef;
  40565. private _onPointerUpHandlerRef;
  40566. private _onResize;
  40567. /**
  40568. * Creates a new virtual joystick
  40569. * @param leftJoystick defines that the joystick is for left hand (false by default)
  40570. */
  40571. constructor(leftJoystick?: boolean);
  40572. /**
  40573. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  40574. * @param newJoystickSensibility defines the new sensibility
  40575. */
  40576. setJoystickSensibility(newJoystickSensibility: number): void;
  40577. private _onPointerDown;
  40578. private _onPointerMove;
  40579. private _onPointerUp;
  40580. /**
  40581. * Change the color of the virtual joystick
  40582. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  40583. */
  40584. setJoystickColor(newColor: string): void;
  40585. /**
  40586. * Defines a callback to call when the joystick is touched
  40587. * @param action defines the callback
  40588. */
  40589. setActionOnTouch(action: () => any): void;
  40590. /**
  40591. * Defines which axis you'd like to control for left & right
  40592. * @param axis defines the axis to use
  40593. */
  40594. setAxisForLeftRight(axis: JoystickAxis): void;
  40595. /**
  40596. * Defines which axis you'd like to control for up & down
  40597. * @param axis defines the axis to use
  40598. */
  40599. setAxisForUpDown(axis: JoystickAxis): void;
  40600. private _drawVirtualJoystick;
  40601. /**
  40602. * Release internal HTML canvas
  40603. */
  40604. releaseCanvas(): void;
  40605. }
  40606. }
  40607. declare module BABYLON {
  40608. /**
  40609. * Helper class to push actions to a pool of workers.
  40610. */
  40611. class WorkerPool implements IDisposable {
  40612. private _workerInfos;
  40613. private _pendingActions;
  40614. /**
  40615. * Constructor
  40616. * @param workers Array of workers to use for actions
  40617. */
  40618. constructor(workers: Array<Worker>);
  40619. /**
  40620. * Terminates all workers and clears any pending actions.
  40621. */
  40622. dispose(): void;
  40623. /**
  40624. * Pushes an action to the worker pool. If all the workers are active, the action will be
  40625. * pended until a worker has completed its action.
  40626. * @param action The action to perform. Call onComplete when the action is complete.
  40627. */
  40628. push(action: (worker: Worker, onComplete: () => void) => void): void;
  40629. private _execute;
  40630. }
  40631. }
  40632. declare module BABYLON {
  40633. /**
  40634. * The autoRotation behavior (BABYLON.AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  40635. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40636. */
  40637. class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  40638. /**
  40639. * Gets the name of the behavior.
  40640. */
  40641. readonly name: string;
  40642. private _zoomStopsAnimation;
  40643. private _idleRotationSpeed;
  40644. private _idleRotationWaitTime;
  40645. private _idleRotationSpinupTime;
  40646. /**
  40647. * Sets the flag that indicates if user zooming should stop animation.
  40648. */
  40649. /**
  40650. * Gets the flag that indicates if user zooming should stop animation.
  40651. */
  40652. zoomStopsAnimation: boolean;
  40653. /**
  40654. * Sets the default speed at which the camera rotates around the model.
  40655. */
  40656. /**
  40657. * Gets the default speed at which the camera rotates around the model.
  40658. */
  40659. idleRotationSpeed: number;
  40660. /**
  40661. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  40662. */
  40663. /**
  40664. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  40665. */
  40666. idleRotationWaitTime: number;
  40667. /**
  40668. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40669. */
  40670. /**
  40671. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40672. */
  40673. idleRotationSpinupTime: number;
  40674. /**
  40675. * Gets a value indicating if the camera is currently rotating because of this behavior
  40676. */
  40677. readonly rotationInProgress: boolean;
  40678. private _onPrePointerObservableObserver;
  40679. private _onAfterCheckInputsObserver;
  40680. private _attachedCamera;
  40681. private _isPointerDown;
  40682. private _lastFrameTime;
  40683. private _lastInteractionTime;
  40684. private _cameraRotationSpeed;
  40685. /**
  40686. * Initializes the behavior.
  40687. */
  40688. init(): void;
  40689. /**
  40690. * Attaches the behavior to its arc rotate camera.
  40691. * @param camera Defines the camera to attach the behavior to
  40692. */
  40693. attach(camera: ArcRotateCamera): void;
  40694. /**
  40695. * Detaches the behavior from its current arc rotate camera.
  40696. */
  40697. detach(): void;
  40698. /**
  40699. * Returns true if user is scrolling.
  40700. * @return true if user is scrolling.
  40701. */
  40702. private _userIsZooming;
  40703. private _lastFrameRadius;
  40704. private _shouldAnimationStopForInteraction;
  40705. /**
  40706. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  40707. */
  40708. private _applyUserInteraction;
  40709. private _userIsMoving;
  40710. }
  40711. }
  40712. declare module BABYLON {
  40713. /**
  40714. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  40715. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  40716. */
  40717. class BouncingBehavior implements Behavior<ArcRotateCamera> {
  40718. /**
  40719. * Gets the name of the behavior.
  40720. */
  40721. readonly name: string;
  40722. /**
  40723. * The easing function used by animations
  40724. */
  40725. static EasingFunction: BackEase;
  40726. /**
  40727. * The easing mode used by animations
  40728. */
  40729. static EasingMode: number;
  40730. /**
  40731. * The duration of the animation, in milliseconds
  40732. */
  40733. transitionDuration: number;
  40734. /**
  40735. * Length of the distance animated by the transition when lower radius is reached
  40736. */
  40737. lowerRadiusTransitionRange: number;
  40738. /**
  40739. * Length of the distance animated by the transition when upper radius is reached
  40740. */
  40741. upperRadiusTransitionRange: number;
  40742. private _autoTransitionRange;
  40743. /**
  40744. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  40745. */
  40746. /**
  40747. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  40748. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  40749. */
  40750. autoTransitionRange: boolean;
  40751. private _attachedCamera;
  40752. private _onAfterCheckInputsObserver;
  40753. private _onMeshTargetChangedObserver;
  40754. /**
  40755. * Initializes the behavior.
  40756. */
  40757. init(): void;
  40758. /**
  40759. * Attaches the behavior to its arc rotate camera.
  40760. * @param camera Defines the camera to attach the behavior to
  40761. */
  40762. attach(camera: ArcRotateCamera): void;
  40763. /**
  40764. * Detaches the behavior from its current arc rotate camera.
  40765. */
  40766. detach(): void;
  40767. private _radiusIsAnimating;
  40768. private _radiusBounceTransition;
  40769. private _animatables;
  40770. private _cachedWheelPrecision;
  40771. /**
  40772. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  40773. * @param radiusLimit The limit to check against.
  40774. * @return Bool to indicate if at limit.
  40775. */
  40776. private _isRadiusAtLimit;
  40777. /**
  40778. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  40779. * @param radiusDelta The delta by which to animate to. Can be negative.
  40780. */
  40781. private _applyBoundRadiusAnimation;
  40782. /**
  40783. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  40784. */
  40785. protected _clearAnimationLocks(): void;
  40786. /**
  40787. * Stops and removes all animations that have been applied to the camera
  40788. */
  40789. stopAllAnimations(): void;
  40790. }
  40791. }
  40792. declare module BABYLON {
  40793. /**
  40794. * The framing behavior (BABYLON.FramingBehavior) is designed to automatically position an ArcRotateCamera when its target is set to a mesh. It is also useful if you want to prevent the camera to go under a virtual horizontal plane.
  40795. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  40796. */
  40797. class FramingBehavior implements Behavior<ArcRotateCamera> {
  40798. /**
  40799. * Gets the name of the behavior.
  40800. */
  40801. readonly name: string;
  40802. private _mode;
  40803. private _radiusScale;
  40804. private _positionScale;
  40805. private _defaultElevation;
  40806. private _elevationReturnTime;
  40807. private _elevationReturnWaitTime;
  40808. private _zoomStopsAnimation;
  40809. private _framingTime;
  40810. /**
  40811. * The easing function used by animations
  40812. */
  40813. static EasingFunction: ExponentialEase;
  40814. /**
  40815. * The easing mode used by animations
  40816. */
  40817. static EasingMode: number;
  40818. /**
  40819. * Sets the current mode used by the behavior
  40820. */
  40821. /**
  40822. * Gets current mode used by the behavior.
  40823. */
  40824. mode: number;
  40825. /**
  40826. * Sets the scale applied to the radius (1 by default)
  40827. */
  40828. /**
  40829. * Gets the scale applied to the radius
  40830. */
  40831. radiusScale: number;
  40832. /**
  40833. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  40834. */
  40835. /**
  40836. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  40837. */
  40838. positionScale: number;
  40839. /**
  40840. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  40841. * behaviour is triggered, in radians.
  40842. */
  40843. /**
  40844. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  40845. * behaviour is triggered, in radians.
  40846. */
  40847. defaultElevation: number;
  40848. /**
  40849. * Sets the time (in milliseconds) taken to return to the default beta position.
  40850. * Negative value indicates camera should not return to default.
  40851. */
  40852. /**
  40853. * Gets the time (in milliseconds) taken to return to the default beta position.
  40854. * Negative value indicates camera should not return to default.
  40855. */
  40856. elevationReturnTime: number;
  40857. /**
  40858. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  40859. */
  40860. /**
  40861. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  40862. */
  40863. elevationReturnWaitTime: number;
  40864. /**
  40865. * Sets the flag that indicates if user zooming should stop animation.
  40866. */
  40867. /**
  40868. * Gets the flag that indicates if user zooming should stop animation.
  40869. */
  40870. zoomStopsAnimation: boolean;
  40871. /**
  40872. * Sets the transition time when framing the mesh, in milliseconds
  40873. */
  40874. /**
  40875. * Gets the transition time when framing the mesh, in milliseconds
  40876. */
  40877. framingTime: number;
  40878. /**
  40879. * Define if the behavior should automatically change the configured
  40880. * camera limits and sensibilities.
  40881. */
  40882. autoCorrectCameraLimitsAndSensibility: boolean;
  40883. private _onPrePointerObservableObserver;
  40884. private _onAfterCheckInputsObserver;
  40885. private _onMeshTargetChangedObserver;
  40886. private _attachedCamera;
  40887. private _isPointerDown;
  40888. private _lastInteractionTime;
  40889. /**
  40890. * Initializes the behavior.
  40891. */
  40892. init(): void;
  40893. /**
  40894. * Attaches the behavior to its arc rotate camera.
  40895. * @param camera Defines the camera to attach the behavior to
  40896. */
  40897. attach(camera: ArcRotateCamera): void;
  40898. /**
  40899. * Detaches the behavior from its current arc rotate camera.
  40900. */
  40901. detach(): void;
  40902. private _animatables;
  40903. private _betaIsAnimating;
  40904. private _betaTransition;
  40905. private _radiusTransition;
  40906. private _vectorTransition;
  40907. /**
  40908. * Targets the given mesh and updates zoom level accordingly.
  40909. * @param mesh The mesh to target.
  40910. * @param radius Optional. If a cached radius position already exists, overrides default.
  40911. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  40912. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40913. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40914. */
  40915. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40916. /**
  40917. * Targets the given mesh with its children and updates zoom level accordingly.
  40918. * @param mesh The mesh to target.
  40919. * @param radius Optional. If a cached radius position already exists, overrides default.
  40920. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  40921. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40922. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40923. */
  40924. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40925. /**
  40926. * Targets the given meshes with their children and updates zoom level accordingly.
  40927. * @param meshes The mesh to target.
  40928. * @param radius Optional. If a cached radius position already exists, overrides default.
  40929. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  40930. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40931. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40932. */
  40933. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40934. /**
  40935. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  40936. * @param minimumWorld Determines the smaller position of the bounding box extend
  40937. * @param maximumWorld Determines the bigger position of the bounding box extend
  40938. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40939. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40940. */
  40941. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40942. /**
  40943. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  40944. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  40945. * frustum width.
  40946. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  40947. * to fully enclose the mesh in the viewing frustum.
  40948. */
  40949. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  40950. /**
  40951. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  40952. * is automatically returned to its default position (expected to be above ground plane).
  40953. */
  40954. private _maintainCameraAboveGround;
  40955. /**
  40956. * Returns the frustum slope based on the canvas ratio and camera FOV
  40957. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  40958. */
  40959. private _getFrustumSlope;
  40960. /**
  40961. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  40962. */
  40963. private _clearAnimationLocks;
  40964. /**
  40965. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  40966. */
  40967. private _applyUserInteraction;
  40968. /**
  40969. * Stops and removes all animations that have been applied to the camera
  40970. */
  40971. stopAllAnimations(): void;
  40972. /**
  40973. * Gets a value indicating if the user is moving the camera
  40974. */
  40975. readonly isUserIsMoving: boolean;
  40976. /**
  40977. * The camera can move all the way towards the mesh.
  40978. */
  40979. static IgnoreBoundsSizeMode: number;
  40980. /**
  40981. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  40982. */
  40983. static FitFrustumSidesMode: number;
  40984. }
  40985. }
  40986. declare module BABYLON {
  40987. /**
  40988. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  40989. */
  40990. class AttachToBoxBehavior implements BABYLON.Behavior<BABYLON.Mesh> {
  40991. private ui;
  40992. /**
  40993. * The name of the behavior
  40994. */
  40995. name: string;
  40996. /**
  40997. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  40998. */
  40999. distanceAwayFromFace: number;
  41000. /**
  41001. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  41002. */
  41003. distanceAwayFromBottomOfFace: number;
  41004. private _faceVectors;
  41005. private _target;
  41006. private _scene;
  41007. private _onRenderObserver;
  41008. private _tmpMatrix;
  41009. private _tmpVector;
  41010. /**
  41011. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  41012. * @param ui The transform node that should be attched to the mesh
  41013. */
  41014. constructor(ui: BABYLON.TransformNode);
  41015. /**
  41016. * Initializes the behavior
  41017. */
  41018. init(): void;
  41019. private _closestFace;
  41020. private _zeroVector;
  41021. private _lookAtTmpMatrix;
  41022. private _lookAtToRef;
  41023. /**
  41024. * Attaches the AttachToBoxBehavior to the passed in mesh
  41025. * @param target The mesh that the specified node will be attached to
  41026. */
  41027. attach(target: BABYLON.Mesh): void;
  41028. /**
  41029. * Detaches the behavior from the mesh
  41030. */
  41031. detach(): void;
  41032. }
  41033. }
  41034. declare module BABYLON {
  41035. /**
  41036. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  41037. */
  41038. class FadeInOutBehavior implements Behavior<Mesh> {
  41039. /**
  41040. * Time in milliseconds to delay before fading in (Default: 0)
  41041. */
  41042. delay: number;
  41043. /**
  41044. * Time in milliseconds for the mesh to fade in (Default: 300)
  41045. */
  41046. fadeInTime: number;
  41047. private _millisecondsPerFrame;
  41048. private _hovered;
  41049. private _hoverValue;
  41050. private _ownerNode;
  41051. /**
  41052. * Instatiates the FadeInOutBehavior
  41053. */
  41054. constructor();
  41055. /**
  41056. * The name of the behavior
  41057. */
  41058. readonly name: string;
  41059. /**
  41060. * Initializes the behavior
  41061. */
  41062. init(): void;
  41063. /**
  41064. * Attaches the fade behavior on the passed in mesh
  41065. * @param ownerNode The mesh that will be faded in/out once attached
  41066. */
  41067. attach(ownerNode: Mesh): void;
  41068. /**
  41069. * Detaches the behavior from the mesh
  41070. */
  41071. detach(): void;
  41072. /**
  41073. * Triggers the mesh to begin fading in or out
  41074. * @param value if the object should fade in or out (true to fade in)
  41075. */
  41076. fadeIn(value: boolean): void;
  41077. private _update;
  41078. private _setAllVisibility;
  41079. }
  41080. }
  41081. declare module BABYLON {
  41082. /**
  41083. * A behavior that when attached to a mesh will allow the mesh to be scaled
  41084. */
  41085. class MultiPointerScaleBehavior implements Behavior<Mesh> {
  41086. private _dragBehaviorA;
  41087. private _dragBehaviorB;
  41088. private _startDistance;
  41089. private _initialScale;
  41090. private _targetScale;
  41091. private _ownerNode;
  41092. private _sceneRenderObserver;
  41093. /**
  41094. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  41095. */
  41096. constructor();
  41097. /**
  41098. * The name of the behavior
  41099. */
  41100. readonly name: string;
  41101. /**
  41102. * Initializes the behavior
  41103. */
  41104. init(): void;
  41105. private _getCurrentDistance;
  41106. /**
  41107. * Attaches the scale behavior the passed in mesh
  41108. * @param ownerNode The mesh that will be scaled around once attached
  41109. */
  41110. attach(ownerNode: Mesh): void;
  41111. /**
  41112. * Detaches the behavior from the mesh
  41113. */
  41114. detach(): void;
  41115. }
  41116. }
  41117. declare module BABYLON {
  41118. /**
  41119. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  41120. */
  41121. class PointerDragBehavior implements Behavior<AbstractMesh> {
  41122. private static _AnyMouseID;
  41123. private _attachedNode;
  41124. private _dragPlane;
  41125. private _scene;
  41126. private _pointerObserver;
  41127. private _beforeRenderObserver;
  41128. private static _planeScene;
  41129. /**
  41130. * The maximum tolerated angle between the drag plane and dragging pointer rays to trigger pointer events. Set to 0 to allow any angle (default: 0)
  41131. */
  41132. maxDragAngle: number;
  41133. /**
  41134. * @hidden
  41135. */
  41136. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  41137. /**
  41138. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  41139. */
  41140. currentDraggingPointerID: number;
  41141. /**
  41142. * The last position where the pointer hit the drag plane in world space
  41143. */
  41144. lastDragPosition: Vector3;
  41145. /**
  41146. * If the behavior is currently in a dragging state
  41147. */
  41148. dragging: boolean;
  41149. /**
  41150. * The distance towards the target drag position to move each frame. This can be useful to avoid jitter. Set this to 1 for no delay. (Default: 0.2)
  41151. */
  41152. dragDeltaRatio: number;
  41153. /**
  41154. * If the drag plane orientation should be updated during the dragging (Default: true)
  41155. */
  41156. updateDragPlane: boolean;
  41157. private _debugMode;
  41158. private _moving;
  41159. /**
  41160. * Fires each time the attached mesh is dragged with the pointer
  41161. * * delta between last drag position and current drag position in world space
  41162. * * dragDistance along the drag axis
  41163. * * dragPlaneNormal normal of the current drag plane used during the drag
  41164. * * dragPlanePoint in world space where the drag intersects the drag plane
  41165. */
  41166. onDragObservable: Observable<{
  41167. delta: Vector3;
  41168. dragPlanePoint: Vector3;
  41169. dragPlaneNormal: Vector3;
  41170. dragDistance: number;
  41171. pointerId: number;
  41172. }>;
  41173. /**
  41174. * Fires each time a drag begins (eg. mouse down on mesh)
  41175. */
  41176. onDragStartObservable: Observable<{
  41177. dragPlanePoint: Vector3;
  41178. pointerId: number;
  41179. }>;
  41180. /**
  41181. * Fires each time a drag ends (eg. mouse release after drag)
  41182. */
  41183. onDragEndObservable: Observable<{
  41184. dragPlanePoint: Vector3;
  41185. pointerId: number;
  41186. }>;
  41187. /**
  41188. * If the attached mesh should be moved when dragged
  41189. */
  41190. moveAttached: boolean;
  41191. /**
  41192. * If the drag behavior will react to drag events (Default: true)
  41193. */
  41194. enabled: boolean;
  41195. /**
  41196. * If camera controls should be detached during the drag
  41197. */
  41198. detachCameraControls: boolean;
  41199. /**
  41200. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  41201. */
  41202. useObjectOrienationForDragging: boolean;
  41203. private _options;
  41204. /**
  41205. * Creates a pointer drag behavior that can be attached to a mesh
  41206. * @param options The drag axis or normal of the plane that will be dragged across. If no options are specified the drag plane will always face the ray's origin (eg. camera)
  41207. */
  41208. constructor(options?: {
  41209. dragAxis?: Vector3;
  41210. dragPlaneNormal?: Vector3;
  41211. });
  41212. /**
  41213. * The name of the behavior
  41214. */
  41215. readonly name: string;
  41216. /**
  41217. * Initializes the behavior
  41218. */
  41219. init(): void;
  41220. private _tmpVector;
  41221. private _alternatePickedPoint;
  41222. private _worldDragAxis;
  41223. private _targetPosition;
  41224. private _attachedElement;
  41225. /**
  41226. * Attaches the drag behavior the passed in mesh
  41227. * @param ownerNode The mesh that will be dragged around once attached
  41228. */
  41229. attach(ownerNode: AbstractMesh): void;
  41230. /**
  41231. * Force relase the drag action by code.
  41232. */
  41233. releaseDrag(): void;
  41234. private _startDragRay;
  41235. private _lastPointerRay;
  41236. /**
  41237. * Simulates the start of a pointer drag event on the behavior
  41238. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  41239. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  41240. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  41241. */
  41242. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  41243. private _startDrag;
  41244. private _dragDelta;
  41245. private _moveDrag;
  41246. private _pickWithRayOnDragPlane;
  41247. private _pointA;
  41248. private _pointB;
  41249. private _pointC;
  41250. private _lineA;
  41251. private _lineB;
  41252. private _localAxis;
  41253. private _lookAt;
  41254. private _updateDragPlanePosition;
  41255. /**
  41256. * Detaches the behavior from the mesh
  41257. */
  41258. detach(): void;
  41259. }
  41260. }
  41261. declare module BABYLON {
  41262. /**
  41263. * A behavior that when attached to a mesh will allow the mesh to be dragged around based on directions and origin of the pointer's ray
  41264. */
  41265. class SixDofDragBehavior implements Behavior<Mesh> {
  41266. private static _virtualScene;
  41267. private _ownerNode;
  41268. private _sceneRenderObserver;
  41269. private _scene;
  41270. private _targetPosition;
  41271. private _virtualOriginMesh;
  41272. private _virtualDragMesh;
  41273. private _pointerObserver;
  41274. private _moving;
  41275. private _startingOrientation;
  41276. /**
  41277. * How much faster the object should move when the controller is moving towards it. This is useful to bring objects that are far away from the user to them faster. Set this to 0 to avoid any speed increase. (Default: 3)
  41278. */
  41279. private zDragFactor;
  41280. /**
  41281. * If the object should rotate to face the drag origin
  41282. */
  41283. rotateDraggedObject: boolean;
  41284. /**
  41285. * If the behavior is currently in a dragging state
  41286. */
  41287. dragging: boolean;
  41288. /**
  41289. * The distance towards the target drag position to move each frame. This can be useful to avoid jitter. Set this to 1 for no delay. (Default: 0.2)
  41290. */
  41291. dragDeltaRatio: number;
  41292. /**
  41293. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  41294. */
  41295. currentDraggingPointerID: number;
  41296. /**
  41297. * If camera controls should be detached during the drag
  41298. */
  41299. detachCameraControls: boolean;
  41300. /**
  41301. * Fires each time a drag starts
  41302. */
  41303. onDragStartObservable: Observable<{}>;
  41304. /**
  41305. * Fires each time a drag ends (eg. mouse release after drag)
  41306. */
  41307. onDragEndObservable: Observable<{}>;
  41308. /**
  41309. * Instantiates a behavior that when attached to a mesh will allow the mesh to be dragged around based on directions and origin of the pointer's ray
  41310. */
  41311. constructor();
  41312. /**
  41313. * The name of the behavior
  41314. */
  41315. readonly name: string;
  41316. /**
  41317. * Initializes the behavior
  41318. */
  41319. init(): void;
  41320. /**
  41321. * Attaches the scale behavior the passed in mesh
  41322. * @param ownerNode The mesh that will be scaled around once attached
  41323. */
  41324. attach(ownerNode: Mesh): void;
  41325. /**
  41326. * Detaches the behavior from the mesh
  41327. */
  41328. detach(): void;
  41329. }
  41330. }
  41331. declare module BABYLON {
  41332. /**
  41333. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  41334. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41335. */
  41336. class AnaglyphArcRotateCamera extends ArcRotateCamera {
  41337. /**
  41338. * Creates a new AnaglyphArcRotateCamera
  41339. * @param name defines camera name
  41340. * @param alpha defines alpha angle (in radians)
  41341. * @param beta defines beta angle (in radians)
  41342. * @param radius defines radius
  41343. * @param target defines camera target
  41344. * @param interaxialDistance defines distance between each color axis
  41345. * @param scene defines the hosting scene
  41346. */
  41347. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  41348. /**
  41349. * Gets camera class name
  41350. * @returns AnaglyphArcRotateCamera
  41351. */
  41352. getClassName(): string;
  41353. }
  41354. }
  41355. declare module BABYLON {
  41356. /**
  41357. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  41358. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41359. */
  41360. class AnaglyphFreeCamera extends FreeCamera {
  41361. /**
  41362. * Creates a new AnaglyphFreeCamera
  41363. * @param name defines camera name
  41364. * @param position defines initial position
  41365. * @param interaxialDistance defines distance between each color axis
  41366. * @param scene defines the hosting scene
  41367. */
  41368. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41369. /**
  41370. * Gets camera class name
  41371. * @returns AnaglyphFreeCamera
  41372. */
  41373. getClassName(): string;
  41374. }
  41375. }
  41376. declare module BABYLON {
  41377. /**
  41378. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  41379. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41380. */
  41381. class AnaglyphGamepadCamera extends GamepadCamera {
  41382. /**
  41383. * Creates a new AnaglyphGamepadCamera
  41384. * @param name defines camera name
  41385. * @param position defines initial position
  41386. * @param interaxialDistance defines distance between each color axis
  41387. * @param scene defines the hosting scene
  41388. */
  41389. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41390. /**
  41391. * Gets camera class name
  41392. * @returns AnaglyphGamepadCamera
  41393. */
  41394. getClassName(): string;
  41395. }
  41396. }
  41397. declare module BABYLON {
  41398. /**
  41399. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  41400. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41401. */
  41402. class AnaglyphUniversalCamera extends UniversalCamera {
  41403. /**
  41404. * Creates a new AnaglyphUniversalCamera
  41405. * @param name defines camera name
  41406. * @param position defines initial position
  41407. * @param interaxialDistance defines distance between each color axis
  41408. * @param scene defines the hosting scene
  41409. */
  41410. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41411. /**
  41412. * Gets camera class name
  41413. * @returns AnaglyphUniversalCamera
  41414. */
  41415. getClassName(): string;
  41416. }
  41417. }
  41418. declare module BABYLON {
  41419. /**
  41420. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  41421. * @see http://doc.babylonjs.com/features/cameras
  41422. */
  41423. class StereoscopicArcRotateCamera extends ArcRotateCamera {
  41424. /**
  41425. * Creates a new StereoscopicArcRotateCamera
  41426. * @param name defines camera name
  41427. * @param alpha defines alpha angle (in radians)
  41428. * @param beta defines beta angle (in radians)
  41429. * @param radius defines radius
  41430. * @param target defines camera target
  41431. * @param interaxialDistance defines distance between each color axis
  41432. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41433. * @param scene defines the hosting scene
  41434. */
  41435. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41436. /**
  41437. * Gets camera class name
  41438. * @returns StereoscopicArcRotateCamera
  41439. */
  41440. getClassName(): string;
  41441. }
  41442. }
  41443. declare module BABYLON {
  41444. /**
  41445. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  41446. * @see http://doc.babylonjs.com/features/cameras
  41447. */
  41448. class StereoscopicFreeCamera extends FreeCamera {
  41449. /**
  41450. * Creates a new StereoscopicFreeCamera
  41451. * @param name defines camera name
  41452. * @param position defines initial position
  41453. * @param interaxialDistance defines distance between each color axis
  41454. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41455. * @param scene defines the hosting scene
  41456. */
  41457. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41458. /**
  41459. * Gets camera class name
  41460. * @returns StereoscopicFreeCamera
  41461. */
  41462. getClassName(): string;
  41463. }
  41464. }
  41465. declare module BABYLON {
  41466. /**
  41467. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  41468. * @see http://doc.babylonjs.com/features/cameras
  41469. */
  41470. class StereoscopicGamepadCamera extends GamepadCamera {
  41471. /**
  41472. * Creates a new StereoscopicGamepadCamera
  41473. * @param name defines camera name
  41474. * @param position defines initial position
  41475. * @param interaxialDistance defines distance between each color axis
  41476. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41477. * @param scene defines the hosting scene
  41478. */
  41479. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41480. /**
  41481. * Gets camera class name
  41482. * @returns StereoscopicGamepadCamera
  41483. */
  41484. getClassName(): string;
  41485. }
  41486. }
  41487. declare module BABYLON {
  41488. /**
  41489. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  41490. * @see http://doc.babylonjs.com/features/cameras
  41491. */
  41492. class StereoscopicUniversalCamera extends UniversalCamera {
  41493. /**
  41494. * Creates a new StereoscopicUniversalCamera
  41495. * @param name defines camera name
  41496. * @param position defines initial position
  41497. * @param interaxialDistance defines distance between each color axis
  41498. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41499. * @param scene defines the hosting scene
  41500. */
  41501. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41502. /**
  41503. * Gets camera class name
  41504. * @returns StereoscopicUniversalCamera
  41505. */
  41506. getClassName(): string;
  41507. }
  41508. }
  41509. declare module BABYLON {
  41510. /**
  41511. * This represents all the required metrics to create a VR camera.
  41512. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  41513. */
  41514. class VRCameraMetrics {
  41515. /**
  41516. * Define the horizontal resolution off the screen.
  41517. */
  41518. hResolution: number;
  41519. /**
  41520. * Define the vertical resolution off the screen.
  41521. */
  41522. vResolution: number;
  41523. /**
  41524. * Define the horizontal screen size.
  41525. */
  41526. hScreenSize: number;
  41527. /**
  41528. * Define the vertical screen size.
  41529. */
  41530. vScreenSize: number;
  41531. /**
  41532. * Define the vertical screen center position.
  41533. */
  41534. vScreenCenter: number;
  41535. /**
  41536. * Define the distance of the eyes to the screen.
  41537. */
  41538. eyeToScreenDistance: number;
  41539. /**
  41540. * Define the distance between both lenses
  41541. */
  41542. lensSeparationDistance: number;
  41543. /**
  41544. * Define the distance between both viewer's eyes.
  41545. */
  41546. interpupillaryDistance: number;
  41547. /**
  41548. * Define the distortion factor of the VR postprocess.
  41549. * Please, touch with care.
  41550. */
  41551. distortionK: number[];
  41552. /**
  41553. * Define the chromatic aberration correction factors for the VR post process.
  41554. */
  41555. chromaAbCorrection: number[];
  41556. /**
  41557. * Define the scale factor of the post process.
  41558. * The smaller the better but the slower.
  41559. */
  41560. postProcessScaleFactor: number;
  41561. /**
  41562. * Define an offset for the lens center.
  41563. */
  41564. lensCenterOffset: number;
  41565. /**
  41566. * Define if the current vr camera should compensate the distortion of the lense or not.
  41567. */
  41568. compensateDistortion: boolean;
  41569. /**
  41570. * Gets the rendering aspect ratio based on the provided resolutions.
  41571. */
  41572. readonly aspectRatio: number;
  41573. /**
  41574. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  41575. */
  41576. readonly aspectRatioFov: number;
  41577. /**
  41578. * @hidden
  41579. */
  41580. readonly leftHMatrix: Matrix;
  41581. /**
  41582. * @hidden
  41583. */
  41584. readonly rightHMatrix: Matrix;
  41585. /**
  41586. * @hidden
  41587. */
  41588. readonly leftPreViewMatrix: Matrix;
  41589. /**
  41590. * @hidden
  41591. */
  41592. readonly rightPreViewMatrix: Matrix;
  41593. /**
  41594. * Get the default VRMetrics based on the most generic setup.
  41595. * @returns the default vr metrics
  41596. */
  41597. static GetDefault(): VRCameraMetrics;
  41598. }
  41599. }
  41600. declare module BABYLON {
  41601. /**
  41602. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  41603. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41604. */
  41605. class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  41606. /**
  41607. * Creates a new VRDeviceOrientationArcRotateCamera
  41608. * @param name defines camera name
  41609. * @param alpha defines the camera rotation along the logitudinal axis
  41610. * @param beta defines the camera rotation along the latitudinal axis
  41611. * @param radius defines the camera distance from its target
  41612. * @param target defines the camera target
  41613. * @param scene defines the scene the camera belongs to
  41614. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41615. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41616. */
  41617. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41618. /**
  41619. * Gets camera class name
  41620. * @returns VRDeviceOrientationArcRotateCamera
  41621. */
  41622. getClassName(): string;
  41623. }
  41624. }
  41625. declare module BABYLON {
  41626. /**
  41627. * Camera used to simulate VR rendering (based on FreeCamera)
  41628. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41629. */
  41630. class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  41631. /**
  41632. * Creates a new VRDeviceOrientationFreeCamera
  41633. * @param name defines camera name
  41634. * @param position defines the start position of the camera
  41635. * @param scene defines the scene the camera belongs to
  41636. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41637. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41638. */
  41639. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41640. /**
  41641. * Gets camera class name
  41642. * @returns VRDeviceOrientationFreeCamera
  41643. */
  41644. getClassName(): string;
  41645. }
  41646. }
  41647. declare module BABYLON {
  41648. /**
  41649. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  41650. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41651. */
  41652. class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  41653. /**
  41654. * Creates a new VRDeviceOrientationGamepadCamera
  41655. * @param name defines camera name
  41656. * @param position defines the start position of the camera
  41657. * @param scene defines the scene the camera belongs to
  41658. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41659. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41660. */
  41661. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41662. /**
  41663. * Gets camera class name
  41664. * @returns VRDeviceOrientationGamepadCamera
  41665. */
  41666. getClassName(): string;
  41667. }
  41668. }
  41669. declare module BABYLON {
  41670. /**
  41671. * Options to modify the vr teleportation behavior.
  41672. */
  41673. interface VRTeleportationOptions {
  41674. /**
  41675. * The name of the mesh which should be used as the teleportation floor. (default: null)
  41676. */
  41677. floorMeshName?: string;
  41678. /**
  41679. * A list of meshes to be used as the teleportation floor. (default: empty)
  41680. */
  41681. floorMeshes?: Mesh[];
  41682. }
  41683. /**
  41684. * Options to modify the vr experience helper's behavior.
  41685. */
  41686. interface VRExperienceHelperOptions extends WebVROptions {
  41687. /**
  41688. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  41689. */
  41690. createDeviceOrientationCamera?: boolean;
  41691. /**
  41692. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  41693. */
  41694. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  41695. /**
  41696. * Uses the main button on the controller to toggle the laser casted. (default: true)
  41697. */
  41698. laserToggle?: boolean;
  41699. /**
  41700. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  41701. */
  41702. floorMeshes?: Mesh[];
  41703. }
  41704. /**
  41705. * Helps to quickly add VR support to an existing scene.
  41706. * See http://doc.babylonjs.com/how_to/webvr_helper
  41707. */
  41708. class VRExperienceHelper {
  41709. /** Options to modify the vr experience helper's behavior. */
  41710. webVROptions: VRExperienceHelperOptions;
  41711. private _scene;
  41712. private _position;
  41713. private _btnVR;
  41714. private _btnVRDisplayed;
  41715. private _webVRsupported;
  41716. private _webVRready;
  41717. private _webVRrequesting;
  41718. private _webVRpresenting;
  41719. private _hasEnteredVR;
  41720. private _fullscreenVRpresenting;
  41721. private _canvas;
  41722. private _webVRCamera;
  41723. private _vrDeviceOrientationCamera;
  41724. private _deviceOrientationCamera;
  41725. private _existingCamera;
  41726. private _onKeyDown;
  41727. private _onVrDisplayPresentChange;
  41728. private _onVRDisplayChanged;
  41729. private _onVRRequestPresentStart;
  41730. private _onVRRequestPresentComplete;
  41731. /**
  41732. * Observable raised when entering VR.
  41733. */
  41734. onEnteringVRObservable: Observable<VRExperienceHelper>;
  41735. /**
  41736. * Observable raised when exiting VR.
  41737. */
  41738. onExitingVRObservable: Observable<VRExperienceHelper>;
  41739. /**
  41740. * Observable raised when controller mesh is loaded.
  41741. */
  41742. onControllerMeshLoadedObservable: Observable<WebVRController>;
  41743. /** Return this.onEnteringVRObservable
  41744. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  41745. */
  41746. readonly onEnteringVR: Observable<VRExperienceHelper>;
  41747. /** Return this.onExitingVRObservable
  41748. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  41749. */
  41750. readonly onExitingVR: Observable<VRExperienceHelper>;
  41751. /** Return this.onControllerMeshLoadedObservable
  41752. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  41753. */
  41754. readonly onControllerMeshLoaded: Observable<WebVRController>;
  41755. private _rayLength;
  41756. private _useCustomVRButton;
  41757. private _teleportationRequested;
  41758. private _teleportActive;
  41759. private _floorMeshName;
  41760. private _floorMeshesCollection;
  41761. private _rotationAllowed;
  41762. private _teleportBackwardsVector;
  41763. private _teleportationTarget;
  41764. private _isDefaultTeleportationTarget;
  41765. private _postProcessMove;
  41766. private _teleportationFillColor;
  41767. private _teleportationBorderColor;
  41768. private _rotationAngle;
  41769. private _haloCenter;
  41770. private _cameraGazer;
  41771. private _padSensibilityUp;
  41772. private _padSensibilityDown;
  41773. private _leftController;
  41774. private _rightController;
  41775. /**
  41776. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  41777. */
  41778. onNewMeshSelected: Observable<AbstractMesh>;
  41779. /**
  41780. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  41781. */
  41782. onNewMeshPicked: Observable<PickingInfo>;
  41783. private _circleEase;
  41784. /**
  41785. * Observable raised before camera teleportation
  41786. */
  41787. onBeforeCameraTeleport: Observable<Vector3>;
  41788. /**
  41789. * Observable raised after camera teleportation
  41790. */
  41791. onAfterCameraTeleport: Observable<Vector3>;
  41792. /**
  41793. * Observable raised when current selected mesh gets unselected
  41794. */
  41795. onSelectedMeshUnselected: Observable<AbstractMesh>;
  41796. private _raySelectionPredicate;
  41797. /**
  41798. * To be optionaly changed by user to define custom ray selection
  41799. */
  41800. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  41801. /**
  41802. * To be optionaly changed by user to define custom selection logic (after ray selection)
  41803. */
  41804. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  41805. /**
  41806. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  41807. */
  41808. teleportationEnabled: boolean;
  41809. private _defaultHeight;
  41810. private _teleportationInitialized;
  41811. private _interactionsEnabled;
  41812. private _interactionsRequested;
  41813. private _displayGaze;
  41814. private _displayLaserPointer;
  41815. /**
  41816. * The mesh used to display where the user is going to teleport.
  41817. */
  41818. /**
  41819. * Sets the mesh to be used to display where the user is going to teleport.
  41820. */
  41821. teleportationTarget: Mesh;
  41822. /**
  41823. * 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
  41824. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  41825. * See http://doc.babylonjs.com/resources/baking_transformations
  41826. */
  41827. gazeTrackerMesh: Mesh;
  41828. /**
  41829. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  41830. */
  41831. updateGazeTrackerScale: boolean;
  41832. /**
  41833. * The gaze tracking mesh corresponding to the left controller
  41834. */
  41835. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  41836. /**
  41837. * The gaze tracking mesh corresponding to the right controller
  41838. */
  41839. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  41840. /**
  41841. * If the ray of the gaze should be displayed.
  41842. */
  41843. /**
  41844. * Sets if the ray of the gaze should be displayed.
  41845. */
  41846. displayGaze: boolean;
  41847. /**
  41848. * If the ray of the LaserPointer should be displayed.
  41849. */
  41850. /**
  41851. * Sets if the ray of the LaserPointer should be displayed.
  41852. */
  41853. displayLaserPointer: boolean;
  41854. /**
  41855. * The deviceOrientationCamera used as the camera when not in VR.
  41856. */
  41857. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  41858. /**
  41859. * Based on the current WebVR support, returns the current VR camera used.
  41860. */
  41861. readonly currentVRCamera: Nullable<Camera>;
  41862. /**
  41863. * The webVRCamera which is used when in VR.
  41864. */
  41865. readonly webVRCamera: WebVRFreeCamera;
  41866. /**
  41867. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  41868. */
  41869. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  41870. private readonly _teleportationRequestInitiated;
  41871. /**
  41872. * Instantiates a VRExperienceHelper.
  41873. * Helps to quickly add VR support to an existing scene.
  41874. * @param scene The scene the VRExperienceHelper belongs to.
  41875. * @param webVROptions Options to modify the vr experience helper's behavior.
  41876. */
  41877. constructor(scene: Scene,
  41878. /** Options to modify the vr experience helper's behavior. */
  41879. webVROptions?: VRExperienceHelperOptions);
  41880. private _onDefaultMeshLoaded;
  41881. private _onResize;
  41882. private _onFullscreenChange;
  41883. /**
  41884. * Gets a value indicating if we are currently in VR mode.
  41885. */
  41886. readonly isInVRMode: boolean;
  41887. private onVrDisplayPresentChange;
  41888. private onVRDisplayChanged;
  41889. private moveButtonToBottomRight;
  41890. private displayVRButton;
  41891. private updateButtonVisibility;
  41892. private _cachedAngularSensibility;
  41893. /**
  41894. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  41895. * Otherwise, will use the fullscreen API.
  41896. */
  41897. enterVR(): void;
  41898. /**
  41899. * Attempt to exit VR, or fullscreen.
  41900. */
  41901. exitVR(): void;
  41902. /**
  41903. * The position of the vr experience helper.
  41904. */
  41905. /**
  41906. * Sets the position of the vr experience helper.
  41907. */
  41908. position: Vector3;
  41909. /**
  41910. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  41911. */
  41912. enableInteractions(): void;
  41913. private readonly _noControllerIsActive;
  41914. private beforeRender;
  41915. private _isTeleportationFloor;
  41916. /**
  41917. * Adds a floor mesh to be used for teleportation.
  41918. * @param floorMesh the mesh to be used for teleportation.
  41919. */
  41920. addFloorMesh(floorMesh: Mesh): void;
  41921. /**
  41922. * Removes a floor mesh from being used for teleportation.
  41923. * @param floorMesh the mesh to be removed.
  41924. */
  41925. removeFloorMesh(floorMesh: Mesh): void;
  41926. /**
  41927. * Enables interactions and teleportation using the VR controllers and gaze.
  41928. * @param vrTeleportationOptions options to modify teleportation behavior.
  41929. */
  41930. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  41931. private _onNewGamepadConnected;
  41932. private _tryEnableInteractionOnController;
  41933. private _onNewGamepadDisconnected;
  41934. private _enableInteractionOnController;
  41935. private _checkTeleportWithRay;
  41936. private _checkRotate;
  41937. private _checkTeleportBackwards;
  41938. private _enableTeleportationOnController;
  41939. private _createTeleportationCircles;
  41940. private _displayTeleportationTarget;
  41941. private _hideTeleportationTarget;
  41942. private _rotateCamera;
  41943. private _moveTeleportationSelectorTo;
  41944. private _workingVector;
  41945. private _workingQuaternion;
  41946. private _workingMatrix;
  41947. /**
  41948. * Teleports the users feet to the desired location
  41949. * @param location The location where the user's feet should be placed
  41950. */
  41951. teleportCamera(location: Vector3): void;
  41952. private _convertNormalToDirectionOfRay;
  41953. private _castRayAndSelectObject;
  41954. private _notifySelectedMeshUnselected;
  41955. /**
  41956. * Sets the color of the laser ray from the vr controllers.
  41957. * @param color new color for the ray.
  41958. */
  41959. changeLaserColor(color: Color3): void;
  41960. /**
  41961. * Sets the color of the ray from the vr headsets gaze.
  41962. * @param color new color for the ray.
  41963. */
  41964. changeGazeColor(color: Color3): void;
  41965. /**
  41966. * Exits VR and disposes of the vr experience helper
  41967. */
  41968. dispose(): void;
  41969. /**
  41970. * Gets the name of the VRExperienceHelper class
  41971. * @returns "VRExperienceHelper"
  41972. */
  41973. getClassName(): string;
  41974. }
  41975. }
  41976. declare module BABYLON {
  41977. /**
  41978. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  41979. * IMPORTANT!! The data is right-hand data.
  41980. * @export
  41981. * @interface DevicePose
  41982. */
  41983. interface DevicePose {
  41984. /**
  41985. * The position of the device, values in array are [x,y,z].
  41986. */
  41987. readonly position: Nullable<Float32Array>;
  41988. /**
  41989. * The linearVelocity of the device, values in array are [x,y,z].
  41990. */
  41991. readonly linearVelocity: Nullable<Float32Array>;
  41992. /**
  41993. * The linearAcceleration of the device, values in array are [x,y,z].
  41994. */
  41995. readonly linearAcceleration: Nullable<Float32Array>;
  41996. /**
  41997. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  41998. */
  41999. readonly orientation: Nullable<Float32Array>;
  42000. /**
  42001. * The angularVelocity of the device, values in array are [x,y,z].
  42002. */
  42003. readonly angularVelocity: Nullable<Float32Array>;
  42004. /**
  42005. * The angularAcceleration of the device, values in array are [x,y,z].
  42006. */
  42007. readonly angularAcceleration: Nullable<Float32Array>;
  42008. }
  42009. /**
  42010. * Interface representing a pose controlled object in Babylon.
  42011. * A pose controlled object has both regular pose values as well as pose values
  42012. * from an external device such as a VR head mounted display
  42013. */
  42014. interface PoseControlled {
  42015. /**
  42016. * The position of the object in babylon space.
  42017. */
  42018. position: Vector3;
  42019. /**
  42020. * The rotation quaternion of the object in babylon space.
  42021. */
  42022. rotationQuaternion: Quaternion;
  42023. /**
  42024. * The position of the device in babylon space.
  42025. */
  42026. devicePosition?: Vector3;
  42027. /**
  42028. * The rotation quaternion of the device in babylon space.
  42029. */
  42030. deviceRotationQuaternion: Quaternion;
  42031. /**
  42032. * The raw pose coming from the device.
  42033. */
  42034. rawPose: Nullable<DevicePose>;
  42035. /**
  42036. * The scale of the device to be used when translating from device space to babylon space.
  42037. */
  42038. deviceScaleFactor: number;
  42039. /**
  42040. * Updates the poseControlled values based on the input device pose.
  42041. * @param poseData the pose data to update the object with
  42042. */
  42043. updateFromDevice(poseData: DevicePose): void;
  42044. }
  42045. /**
  42046. * Set of options to customize the webVRCamera
  42047. */
  42048. interface WebVROptions {
  42049. /**
  42050. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  42051. */
  42052. trackPosition?: boolean;
  42053. /**
  42054. * Sets the scale of the vrDevice in babylon space. (default: 1)
  42055. */
  42056. positionScale?: number;
  42057. /**
  42058. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  42059. */
  42060. displayName?: string;
  42061. /**
  42062. * Should the native controller meshes be initialized. (default: true)
  42063. */
  42064. controllerMeshes?: boolean;
  42065. /**
  42066. * Creating a default HemiLight only on controllers. (default: true)
  42067. */
  42068. defaultLightingOnControllers?: boolean;
  42069. /**
  42070. * If you don't want to use the default VR button of the helper. (default: false)
  42071. */
  42072. useCustomVRButton?: boolean;
  42073. /**
  42074. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  42075. */
  42076. customVRButton?: HTMLButtonElement;
  42077. /**
  42078. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  42079. */
  42080. rayLength?: number;
  42081. /**
  42082. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  42083. */
  42084. defaultHeight?: number;
  42085. }
  42086. /**
  42087. * This represents a WebVR camera.
  42088. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  42089. * @example http://doc.babylonjs.com/how_to/webvr_camera
  42090. */
  42091. class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  42092. private webVROptions;
  42093. /**
  42094. * @hidden
  42095. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  42096. */
  42097. _vrDevice: any;
  42098. /**
  42099. * The rawPose of the vrDevice.
  42100. */
  42101. rawPose: Nullable<DevicePose>;
  42102. private _onVREnabled;
  42103. private _specsVersion;
  42104. private _attached;
  42105. private _frameData;
  42106. protected _descendants: Array<Node>;
  42107. private _deviceRoomPosition;
  42108. /** @hidden */
  42109. _deviceRoomRotationQuaternion: Quaternion;
  42110. private _standingMatrix;
  42111. /**
  42112. * Represents device position in babylon space.
  42113. */
  42114. devicePosition: Vector3;
  42115. /**
  42116. * Represents device rotation in babylon space.
  42117. */
  42118. deviceRotationQuaternion: Quaternion;
  42119. /**
  42120. * The scale of the device to be used when translating from device space to babylon space.
  42121. */
  42122. deviceScaleFactor: number;
  42123. private _deviceToWorld;
  42124. private _worldToDevice;
  42125. /**
  42126. * References to the webVR controllers for the vrDevice.
  42127. */
  42128. controllers: Array<WebVRController>;
  42129. /**
  42130. * Emits an event when a controller is attached.
  42131. */
  42132. onControllersAttachedObservable: Observable<WebVRController[]>;
  42133. /**
  42134. * Emits an event when a controller's mesh has been loaded;
  42135. */
  42136. onControllerMeshLoadedObservable: Observable<WebVRController>;
  42137. /**
  42138. * Emits an event when the HMD's pose has been updated.
  42139. */
  42140. onPoseUpdatedFromDeviceObservable: Observable<any>;
  42141. private _poseSet;
  42142. /**
  42143. * If the rig cameras be used as parent instead of this camera.
  42144. */
  42145. rigParenting: boolean;
  42146. private _lightOnControllers;
  42147. private _defaultHeight?;
  42148. /**
  42149. * Instantiates a WebVRFreeCamera.
  42150. * @param name The name of the WebVRFreeCamera
  42151. * @param position The starting anchor position for the camera
  42152. * @param scene The scene the camera belongs to
  42153. * @param webVROptions a set of customizable options for the webVRCamera
  42154. */
  42155. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  42156. /**
  42157. * Gets the device distance from the ground in meters.
  42158. * @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.
  42159. */
  42160. deviceDistanceToRoomGround(): number;
  42161. /**
  42162. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  42163. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  42164. */
  42165. useStandingMatrix(callback?: (bool: boolean) => void): void;
  42166. /**
  42167. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  42168. * @returns A promise with a boolean set to if the standing matrix is supported.
  42169. */
  42170. useStandingMatrixAsync(): Promise<boolean>;
  42171. /**
  42172. * Disposes the camera
  42173. */
  42174. dispose(): void;
  42175. /**
  42176. * Gets a vrController by name.
  42177. * @param name The name of the controller to retreive
  42178. * @returns the controller matching the name specified or null if not found
  42179. */
  42180. getControllerByName(name: string): Nullable<WebVRController>;
  42181. private _leftController;
  42182. /**
  42183. * The controller corrisponding to the users left hand.
  42184. */
  42185. readonly leftController: Nullable<WebVRController>;
  42186. private _rightController;
  42187. /**
  42188. * The controller corrisponding to the users right hand.
  42189. */
  42190. readonly rightController: Nullable<WebVRController>;
  42191. /**
  42192. * Casts a ray forward from the vrCamera's gaze.
  42193. * @param length Length of the ray (default: 100)
  42194. * @returns the ray corrisponding to the gaze
  42195. */
  42196. getForwardRay(length?: number): Ray;
  42197. /**
  42198. * @hidden
  42199. * Updates the camera based on device's frame data
  42200. */
  42201. _checkInputs(): void;
  42202. /**
  42203. * Updates the poseControlled values based on the input device pose.
  42204. * @param poseData Pose coming from the device
  42205. */
  42206. updateFromDevice(poseData: DevicePose): void;
  42207. private _htmlElementAttached;
  42208. private _detachIfAttached;
  42209. /**
  42210. * WebVR's attach control will start broadcasting frames to the device.
  42211. * Note that in certain browsers (chrome for example) this function must be called
  42212. * within a user-interaction callback. Example:
  42213. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  42214. *
  42215. * @param element html element to attach the vrDevice to
  42216. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  42217. */
  42218. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42219. /**
  42220. * Detaches the camera from the html element and disables VR
  42221. *
  42222. * @param element html element to detach from
  42223. */
  42224. detachControl(element: HTMLElement): void;
  42225. /**
  42226. * @returns the name of this class
  42227. */
  42228. getClassName(): string;
  42229. /**
  42230. * Calls resetPose on the vrDisplay
  42231. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  42232. */
  42233. resetToCurrentRotation(): void;
  42234. /**
  42235. * @hidden
  42236. * Updates the rig cameras (left and right eye)
  42237. */
  42238. _updateRigCameras(): void;
  42239. private _workingVector;
  42240. private _oneVector;
  42241. private _workingMatrix;
  42242. private updateCacheCalled;
  42243. private _correctPositionIfNotTrackPosition;
  42244. /**
  42245. * @hidden
  42246. * Updates the cached values of the camera
  42247. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  42248. */
  42249. _updateCache(ignoreParentClass?: boolean): void;
  42250. /**
  42251. * @hidden
  42252. * Get current device position in babylon world
  42253. */
  42254. _computeDevicePosition(): void;
  42255. /**
  42256. * Updates the current device position and rotation in the babylon world
  42257. */
  42258. update(): void;
  42259. /**
  42260. * @hidden
  42261. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  42262. * @returns an identity matrix
  42263. */
  42264. _getViewMatrix(): Matrix;
  42265. private _tmpMatrix;
  42266. /**
  42267. * This function is called by the two RIG cameras.
  42268. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  42269. */
  42270. protected _getWebVRViewMatrix(): Matrix;
  42271. protected _getWebVRProjectionMatrix(): Matrix;
  42272. private _onGamepadConnectedObserver;
  42273. private _onGamepadDisconnectedObserver;
  42274. private _updateCacheWhenTrackingDisabledObserver;
  42275. /**
  42276. * Initializes the controllers and their meshes
  42277. */
  42278. initControllers(): void;
  42279. }
  42280. }
  42281. declare module BABYLON {
  42282. /**
  42283. * Manage the gamepad inputs to control an arc rotate camera.
  42284. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42285. */
  42286. class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  42287. /**
  42288. * Defines the camera the input is attached to.
  42289. */
  42290. camera: ArcRotateCamera;
  42291. /**
  42292. * Defines the gamepad the input is gathering event from.
  42293. */
  42294. gamepad: Nullable<Gamepad>;
  42295. /**
  42296. * Defines the gamepad rotation sensiblity.
  42297. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42298. */
  42299. gamepadRotationSensibility: number;
  42300. /**
  42301. * Defines the gamepad move sensiblity.
  42302. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42303. */
  42304. gamepadMoveSensibility: number;
  42305. private _onGamepadConnectedObserver;
  42306. private _onGamepadDisconnectedObserver;
  42307. /**
  42308. * Attach the input controls to a specific dom element to get the input from.
  42309. * @param element Defines the element the controls should be listened from
  42310. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42311. */
  42312. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42313. /**
  42314. * Detach the current controls from the specified dom element.
  42315. * @param element Defines the element to stop listening the inputs from
  42316. */
  42317. detachControl(element: Nullable<HTMLElement>): void;
  42318. /**
  42319. * Update the current camera state depending on the inputs that have been used this frame.
  42320. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42321. */
  42322. checkInputs(): void;
  42323. /**
  42324. * Gets the class name of the current intput.
  42325. * @returns the class name
  42326. */
  42327. getClassName(): string;
  42328. /**
  42329. * Get the friendly name associated with the input class.
  42330. * @returns the input friendly name
  42331. */
  42332. getSimpleName(): string;
  42333. }
  42334. }
  42335. declare module BABYLON {
  42336. /**
  42337. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  42338. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42339. */
  42340. class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  42341. /**
  42342. * Defines the camera the input is attached to.
  42343. */
  42344. camera: ArcRotateCamera;
  42345. /**
  42346. * Defines the list of key codes associated with the up action (increase alpha)
  42347. */
  42348. keysUp: number[];
  42349. /**
  42350. * Defines the list of key codes associated with the down action (decrease alpha)
  42351. */
  42352. keysDown: number[];
  42353. /**
  42354. * Defines the list of key codes associated with the left action (increase beta)
  42355. */
  42356. keysLeft: number[];
  42357. /**
  42358. * Defines the list of key codes associated with the right action (decrease beta)
  42359. */
  42360. keysRight: number[];
  42361. /**
  42362. * Defines the list of key codes associated with the reset action.
  42363. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  42364. */
  42365. keysReset: number[];
  42366. /**
  42367. * Defines the panning sensibility of the inputs.
  42368. * (How fast is the camera paning)
  42369. */
  42370. panningSensibility: number;
  42371. /**
  42372. * Defines the zooming sensibility of the inputs.
  42373. * (How fast is the camera zooming)
  42374. */
  42375. zoomingSensibility: number;
  42376. /**
  42377. * Defines wether maintaining the alt key down switch the movement mode from
  42378. * orientation to zoom.
  42379. */
  42380. useAltToZoom: boolean;
  42381. /**
  42382. * Rotation speed of the camera
  42383. */
  42384. angularSpeed: number;
  42385. private _keys;
  42386. private _ctrlPressed;
  42387. private _altPressed;
  42388. private _onCanvasBlurObserver;
  42389. private _onKeyboardObserver;
  42390. private _engine;
  42391. private _scene;
  42392. /**
  42393. * Attach the input controls to a specific dom element to get the input from.
  42394. * @param element Defines the element the controls should be listened from
  42395. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42396. */
  42397. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42398. /**
  42399. * Detach the current controls from the specified dom element.
  42400. * @param element Defines the element to stop listening the inputs from
  42401. */
  42402. detachControl(element: Nullable<HTMLElement>): void;
  42403. /**
  42404. * Update the current camera state depending on the inputs that have been used this frame.
  42405. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42406. */
  42407. checkInputs(): void;
  42408. /**
  42409. * Gets the class name of the current intput.
  42410. * @returns the class name
  42411. */
  42412. getClassName(): string;
  42413. /**
  42414. * Get the friendly name associated with the input class.
  42415. * @returns the input friendly name
  42416. */
  42417. getSimpleName(): string;
  42418. }
  42419. }
  42420. declare module BABYLON {
  42421. /**
  42422. * Manage the mouse wheel inputs to control an arc rotate camera.
  42423. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42424. */
  42425. class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  42426. /**
  42427. * Defines the camera the input is attached to.
  42428. */
  42429. camera: ArcRotateCamera;
  42430. /**
  42431. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  42432. */
  42433. wheelPrecision: number;
  42434. /**
  42435. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  42436. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  42437. */
  42438. wheelDeltaPercentage: number;
  42439. private _wheel;
  42440. private _observer;
  42441. /**
  42442. * Attach the input controls to a specific dom element to get the input from.
  42443. * @param element Defines the element the controls should be listened from
  42444. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42445. */
  42446. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42447. /**
  42448. * Detach the current controls from the specified dom element.
  42449. * @param element Defines the element to stop listening the inputs from
  42450. */
  42451. detachControl(element: Nullable<HTMLElement>): void;
  42452. /**
  42453. * Gets the class name of the current intput.
  42454. * @returns the class name
  42455. */
  42456. getClassName(): string;
  42457. /**
  42458. * Get the friendly name associated with the input class.
  42459. * @returns the input friendly name
  42460. */
  42461. getSimpleName(): string;
  42462. }
  42463. }
  42464. declare module BABYLON {
  42465. /**
  42466. * Manage the pointers inputs to control an arc rotate camera.
  42467. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42468. */
  42469. class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  42470. /**
  42471. * Defines the camera the input is attached to.
  42472. */
  42473. camera: ArcRotateCamera;
  42474. /**
  42475. * Defines the buttons associated with the input to handle camera move.
  42476. */
  42477. buttons: number[];
  42478. /**
  42479. * Defines the pointer angular sensibility along the X axis or how fast is the camera rotating.
  42480. */
  42481. angularSensibilityX: number;
  42482. /**
  42483. * Defines the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  42484. */
  42485. angularSensibilityY: number;
  42486. /**
  42487. * Defines the pointer pinch precision or how fast is the camera zooming.
  42488. */
  42489. pinchPrecision: number;
  42490. /**
  42491. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  42492. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  42493. */
  42494. pinchDeltaPercentage: number;
  42495. /**
  42496. * Defines the pointer panning sensibility or how fast is the camera moving.
  42497. */
  42498. panningSensibility: number;
  42499. /**
  42500. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  42501. */
  42502. multiTouchPanning: boolean;
  42503. /**
  42504. * Defines whether panning is enabled for both pan (2 fingers swipe) and zoom (pinch) through multitouch.
  42505. */
  42506. multiTouchPanAndZoom: boolean;
  42507. /**
  42508. * Revers pinch action direction.
  42509. */
  42510. pinchInwards: boolean;
  42511. private _isPanClick;
  42512. private _pointerInput;
  42513. private _observer;
  42514. private _onMouseMove;
  42515. private _onGestureStart;
  42516. private _onGesture;
  42517. private _MSGestureHandler;
  42518. private _onLostFocus;
  42519. private _onContextMenu;
  42520. /**
  42521. * Attach the input controls to a specific dom element to get the input from.
  42522. * @param element Defines the element the controls should be listened from
  42523. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42524. */
  42525. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42526. /**
  42527. * Detach the current controls from the specified dom element.
  42528. * @param element Defines the element to stop listening the inputs from
  42529. */
  42530. detachControl(element: Nullable<HTMLElement>): void;
  42531. /**
  42532. * Gets the class name of the current intput.
  42533. * @returns the class name
  42534. */
  42535. getClassName(): string;
  42536. /**
  42537. * Get the friendly name associated with the input class.
  42538. * @returns the input friendly name
  42539. */
  42540. getSimpleName(): string;
  42541. }
  42542. }
  42543. declare module BABYLON {
  42544. /**
  42545. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  42546. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42547. */
  42548. class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  42549. /**
  42550. * Defines the camera the input is attached to.
  42551. */
  42552. camera: ArcRotateCamera;
  42553. /**
  42554. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  42555. */
  42556. alphaCorrection: number;
  42557. /**
  42558. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  42559. */
  42560. gammaCorrection: number;
  42561. private _alpha;
  42562. private _gamma;
  42563. private _dirty;
  42564. private _deviceOrientationHandler;
  42565. /**
  42566. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  42567. */
  42568. constructor();
  42569. /**
  42570. * Attach the input controls to a specific dom element to get the input from.
  42571. * @param element Defines the element the controls should be listened from
  42572. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42573. */
  42574. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42575. /** @hidden */
  42576. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  42577. /**
  42578. * Update the current camera state depending on the inputs that have been used this frame.
  42579. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42580. */
  42581. checkInputs(): void;
  42582. /**
  42583. * Detach the current controls from the specified dom element.
  42584. * @param element Defines the element to stop listening the inputs from
  42585. */
  42586. detachControl(element: Nullable<HTMLElement>): void;
  42587. /**
  42588. * Gets the class name of the current intput.
  42589. * @returns the class name
  42590. */
  42591. getClassName(): string;
  42592. /**
  42593. * Get the friendly name associated with the input class.
  42594. * @returns the input friendly name
  42595. */
  42596. getSimpleName(): string;
  42597. }
  42598. }
  42599. declare module BABYLON {
  42600. /**
  42601. * Listen to keyboard events to control the camera.
  42602. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42603. */
  42604. class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  42605. /**
  42606. * Defines the camera the input is attached to.
  42607. */
  42608. camera: FlyCamera;
  42609. /**
  42610. * The list of keyboard keys used to control the forward move of the camera.
  42611. */
  42612. keysForward: number[];
  42613. /**
  42614. * The list of keyboard keys used to control the backward move of the camera.
  42615. */
  42616. keysBackward: number[];
  42617. /**
  42618. * The list of keyboard keys used to control the forward move of the camera.
  42619. */
  42620. keysUp: number[];
  42621. /**
  42622. * The list of keyboard keys used to control the backward move of the camera.
  42623. */
  42624. keysDown: number[];
  42625. /**
  42626. * The list of keyboard keys used to control the right strafe move of the camera.
  42627. */
  42628. keysRight: number[];
  42629. /**
  42630. * The list of keyboard keys used to control the left strafe move of the camera.
  42631. */
  42632. keysLeft: number[];
  42633. private _keys;
  42634. private _onCanvasBlurObserver;
  42635. private _onKeyboardObserver;
  42636. private _engine;
  42637. private _scene;
  42638. /**
  42639. * Attach the input controls to a specific dom element to get the input from.
  42640. * @param element Defines the element the controls should be listened from
  42641. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42642. */
  42643. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42644. /**
  42645. * Detach the current controls from the specified dom element.
  42646. * @param element Defines the element to stop listening the inputs from
  42647. */
  42648. detachControl(element: Nullable<HTMLElement>): void;
  42649. /**
  42650. * Gets the class name of the current intput.
  42651. * @returns the class name
  42652. */
  42653. getClassName(): string;
  42654. /** @hidden */
  42655. _onLostFocus(e: FocusEvent): void;
  42656. /**
  42657. * Get the friendly name associated with the input class.
  42658. * @returns the input friendly name
  42659. */
  42660. getSimpleName(): string;
  42661. /**
  42662. * Update the current camera state depending on the inputs that have been used this frame.
  42663. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42664. */
  42665. checkInputs(): void;
  42666. }
  42667. }
  42668. declare module BABYLON {
  42669. /**
  42670. * Listen to mouse events to control the camera.
  42671. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42672. */
  42673. class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  42674. /**
  42675. * Defines the camera the input is attached to.
  42676. */
  42677. camera: FlyCamera;
  42678. /**
  42679. * Defines if touch is enabled. (Default is true.)
  42680. */
  42681. touchEnabled: boolean;
  42682. /**
  42683. * Defines the buttons associated with the input to handle camera rotation.
  42684. */
  42685. buttons: number[];
  42686. /**
  42687. * Assign buttons for Yaw control.
  42688. */
  42689. buttonsYaw: number[];
  42690. /**
  42691. * Assign buttons for Pitch control.
  42692. */
  42693. buttonsPitch: number[];
  42694. /**
  42695. * Assign buttons for Roll control.
  42696. */
  42697. buttonsRoll: number[];
  42698. /**
  42699. * Detect if any button is being pressed while mouse is moved.
  42700. * -1 = Mouse locked.
  42701. * 0 = Left button.
  42702. * 1 = Middle Button.
  42703. * 2 = Right Button.
  42704. */
  42705. activeButton: number;
  42706. /**
  42707. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  42708. * Higher values reduce its sensitivity.
  42709. */
  42710. angularSensibility: number;
  42711. private _mousemoveCallback;
  42712. private _observer;
  42713. private _rollObserver;
  42714. private previousPosition;
  42715. private noPreventDefault;
  42716. private element;
  42717. /**
  42718. * Listen to mouse events to control the camera.
  42719. * @param touchEnabled Define if touch is enabled. (Default is true.)
  42720. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42721. */
  42722. constructor(touchEnabled?: boolean);
  42723. /**
  42724. * Attach the mouse control to the HTML DOM element.
  42725. * @param element Defines the element that listens to the input events.
  42726. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  42727. */
  42728. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42729. /**
  42730. * Detach the current controls from the specified dom element.
  42731. * @param element Defines the element to stop listening the inputs from
  42732. */
  42733. detachControl(element: Nullable<HTMLElement>): void;
  42734. /**
  42735. * Gets the class name of the current input.
  42736. * @returns the class name.
  42737. */
  42738. getClassName(): string;
  42739. /**
  42740. * Get the friendly name associated with the input class.
  42741. * @returns the input's friendly name.
  42742. */
  42743. getSimpleName(): string;
  42744. private _pointerInput;
  42745. private _onMouseMove;
  42746. /**
  42747. * Rotate camera by mouse offset.
  42748. */
  42749. private rotateCamera;
  42750. }
  42751. }
  42752. declare module BABYLON {
  42753. /**
  42754. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  42755. * Screen rotation is taken into account.
  42756. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42757. */
  42758. class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  42759. private _camera;
  42760. private _screenOrientationAngle;
  42761. private _constantTranform;
  42762. private _screenQuaternion;
  42763. private _alpha;
  42764. private _beta;
  42765. private _gamma;
  42766. /**
  42767. * Instantiates a new input
  42768. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42769. */
  42770. constructor();
  42771. /**
  42772. * Define the camera controlled by the input.
  42773. */
  42774. camera: FreeCamera;
  42775. /**
  42776. * Attach the input controls to a specific dom element to get the input from.
  42777. * @param element Defines the element the controls should be listened from
  42778. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42779. */
  42780. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42781. private _orientationChanged;
  42782. private _deviceOrientation;
  42783. /**
  42784. * Detach the current controls from the specified dom element.
  42785. * @param element Defines the element to stop listening the inputs from
  42786. */
  42787. detachControl(element: Nullable<HTMLElement>): void;
  42788. /**
  42789. * Update the current camera state depending on the inputs that have been used this frame.
  42790. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42791. */
  42792. checkInputs(): void;
  42793. /**
  42794. * Gets the class name of the current intput.
  42795. * @returns the class name
  42796. */
  42797. getClassName(): string;
  42798. /**
  42799. * Get the friendly name associated with the input class.
  42800. * @returns the input friendly name
  42801. */
  42802. getSimpleName(): string;
  42803. }
  42804. }
  42805. declare module BABYLON {
  42806. /**
  42807. * Manage the gamepad inputs to control a free camera.
  42808. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42809. */
  42810. class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  42811. /**
  42812. * Define the camera the input is attached to.
  42813. */
  42814. camera: FreeCamera;
  42815. /**
  42816. * Define the Gamepad controlling the input
  42817. */
  42818. gamepad: Nullable<Gamepad>;
  42819. /**
  42820. * Defines the gamepad rotation sensiblity.
  42821. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42822. */
  42823. gamepadAngularSensibility: number;
  42824. /**
  42825. * Defines the gamepad move sensiblity.
  42826. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42827. */
  42828. gamepadMoveSensibility: number;
  42829. private _onGamepadConnectedObserver;
  42830. private _onGamepadDisconnectedObserver;
  42831. private _cameraTransform;
  42832. private _deltaTransform;
  42833. private _vector3;
  42834. private _vector2;
  42835. /**
  42836. * Attach the input controls to a specific dom element to get the input from.
  42837. * @param element Defines the element the controls should be listened from
  42838. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42839. */
  42840. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42841. /**
  42842. * Detach the current controls from the specified dom element.
  42843. * @param element Defines the element to stop listening the inputs from
  42844. */
  42845. detachControl(element: Nullable<HTMLElement>): void;
  42846. /**
  42847. * Update the current camera state depending on the inputs that have been used this frame.
  42848. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42849. */
  42850. checkInputs(): void;
  42851. /**
  42852. * Gets the class name of the current intput.
  42853. * @returns the class name
  42854. */
  42855. getClassName(): string;
  42856. /**
  42857. * Get the friendly name associated with the input class.
  42858. * @returns the input friendly name
  42859. */
  42860. getSimpleName(): string;
  42861. }
  42862. }
  42863. declare module BABYLON {
  42864. /**
  42865. * Manage the keyboard inputs to control the movement of a free camera.
  42866. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42867. */
  42868. class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  42869. /**
  42870. * Defines the camera the input is attached to.
  42871. */
  42872. camera: FreeCamera;
  42873. /**
  42874. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  42875. */
  42876. keysUp: number[];
  42877. /**
  42878. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  42879. */
  42880. keysDown: number[];
  42881. /**
  42882. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  42883. */
  42884. keysLeft: number[];
  42885. /**
  42886. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  42887. */
  42888. keysRight: number[];
  42889. private _keys;
  42890. private _onCanvasBlurObserver;
  42891. private _onKeyboardObserver;
  42892. private _engine;
  42893. private _scene;
  42894. /**
  42895. * Attach the input controls to a specific dom element to get the input from.
  42896. * @param element Defines the element the controls should be listened from
  42897. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42898. */
  42899. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42900. /**
  42901. * Detach the current controls from the specified dom element.
  42902. * @param element Defines the element to stop listening the inputs from
  42903. */
  42904. detachControl(element: Nullable<HTMLElement>): void;
  42905. /**
  42906. * Update the current camera state depending on the inputs that have been used this frame.
  42907. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42908. */
  42909. checkInputs(): void;
  42910. /**
  42911. * Gets the class name of the current intput.
  42912. * @returns the class name
  42913. */
  42914. getClassName(): string;
  42915. /** @hidden */
  42916. _onLostFocus(e: FocusEvent): void;
  42917. /**
  42918. * Get the friendly name associated with the input class.
  42919. * @returns the input friendly name
  42920. */
  42921. getSimpleName(): string;
  42922. }
  42923. }
  42924. declare module BABYLON {
  42925. /**
  42926. * Manage the mouse inputs to control the movement of a free camera.
  42927. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42928. */
  42929. class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  42930. /**
  42931. * Define if touch is enabled in the mouse input
  42932. */
  42933. touchEnabled: boolean;
  42934. /**
  42935. * Defines the camera the input is attached to.
  42936. */
  42937. camera: FreeCamera;
  42938. /**
  42939. * Defines the buttons associated with the input to handle camera move.
  42940. */
  42941. buttons: number[];
  42942. /**
  42943. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  42944. */
  42945. angularSensibility: number;
  42946. private _pointerInput;
  42947. private _onMouseMove;
  42948. private _observer;
  42949. private previousPosition;
  42950. /**
  42951. * Manage the mouse inputs to control the movement of a free camera.
  42952. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42953. * @param touchEnabled Defines if touch is enabled or not
  42954. */
  42955. constructor(
  42956. /**
  42957. * Define if touch is enabled in the mouse input
  42958. */
  42959. touchEnabled?: boolean);
  42960. /**
  42961. * Attach the input controls to a specific dom element to get the input from.
  42962. * @param element Defines the element the controls should be listened from
  42963. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42964. */
  42965. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42966. /**
  42967. * Detach the current controls from the specified dom element.
  42968. * @param element Defines the element to stop listening the inputs from
  42969. */
  42970. detachControl(element: Nullable<HTMLElement>): void;
  42971. /**
  42972. * Gets the class name of the current intput.
  42973. * @returns the class name
  42974. */
  42975. getClassName(): string;
  42976. /**
  42977. * Get the friendly name associated with the input class.
  42978. * @returns the input friendly name
  42979. */
  42980. getSimpleName(): string;
  42981. }
  42982. }
  42983. declare module BABYLON {
  42984. /**
  42985. * Manage the touch inputs to control the movement of a free camera.
  42986. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42987. */
  42988. class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  42989. /**
  42990. * Defines the camera the input is attached to.
  42991. */
  42992. camera: FreeCamera;
  42993. /**
  42994. * Defines the touch sensibility for rotation.
  42995. * The higher the faster.
  42996. */
  42997. touchAngularSensibility: number;
  42998. /**
  42999. * Defines the touch sensibility for move.
  43000. * The higher the faster.
  43001. */
  43002. touchMoveSensibility: number;
  43003. private _offsetX;
  43004. private _offsetY;
  43005. private _pointerPressed;
  43006. private _pointerInput;
  43007. private _observer;
  43008. private _onLostFocus;
  43009. /**
  43010. * Attach the input controls to a specific dom element to get the input from.
  43011. * @param element Defines the element the controls should be listened from
  43012. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43013. */
  43014. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43015. /**
  43016. * Detach the current controls from the specified dom element.
  43017. * @param element Defines the element to stop listening the inputs from
  43018. */
  43019. detachControl(element: Nullable<HTMLElement>): void;
  43020. /**
  43021. * Update the current camera state depending on the inputs that have been used this frame.
  43022. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43023. */
  43024. checkInputs(): void;
  43025. /**
  43026. * Gets the class name of the current intput.
  43027. * @returns the class name
  43028. */
  43029. getClassName(): string;
  43030. /**
  43031. * Get the friendly name associated with the input class.
  43032. * @returns the input friendly name
  43033. */
  43034. getSimpleName(): string;
  43035. }
  43036. }
  43037. declare module BABYLON {
  43038. /**
  43039. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  43040. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43041. */
  43042. class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  43043. /**
  43044. * Defines the camera the input is attached to.
  43045. */
  43046. camera: FreeCamera;
  43047. private _leftjoystick;
  43048. private _rightjoystick;
  43049. /**
  43050. * Gets the left stick of the virtual joystick.
  43051. * @returns The virtual Joystick
  43052. */
  43053. getLeftJoystick(): VirtualJoystick;
  43054. /**
  43055. * Gets the right stick of the virtual joystick.
  43056. * @returns The virtual Joystick
  43057. */
  43058. getRightJoystick(): VirtualJoystick;
  43059. /**
  43060. * Update the current camera state depending on the inputs that have been used this frame.
  43061. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43062. */
  43063. checkInputs(): void;
  43064. /**
  43065. * Attach the input controls to a specific dom element to get the input from.
  43066. * @param element Defines the element the controls should be listened from
  43067. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43068. */
  43069. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43070. /**
  43071. * Detach the current controls from the specified dom element.
  43072. * @param element Defines the element to stop listening the inputs from
  43073. */
  43074. detachControl(element: Nullable<HTMLElement>): void;
  43075. /**
  43076. * Gets the class name of the current intput.
  43077. * @returns the class name
  43078. */
  43079. getClassName(): string;
  43080. /**
  43081. * Get the friendly name associated with the input class.
  43082. * @returns the input friendly name
  43083. */
  43084. getSimpleName(): string;
  43085. }
  43086. }
  43087. declare module BABYLON {
  43088. /**
  43089. * WebXR Camera which holds the views for the xrSession
  43090. * @see https://doc.babylonjs.com/how_to/webxr
  43091. */
  43092. class WebXRCamera extends FreeCamera {
  43093. private static _TmpMatrix;
  43094. /**
  43095. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  43096. * @param name the name of the camera
  43097. * @param scene the scene to add the camera to
  43098. */
  43099. constructor(name: string, scene: BABYLON.Scene);
  43100. private _updateNumberOfRigCameras;
  43101. /** @hidden */
  43102. _updateForDualEyeDebugging(pupilDistance?: number): void;
  43103. /**
  43104. * Updates the cameras position from the current pose information of the XR session
  43105. * @param xrSessionManager the session containing pose information
  43106. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  43107. */
  43108. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  43109. }
  43110. }
  43111. declare module BABYLON {
  43112. /**
  43113. * Button which can be used to enter a different mode of XR
  43114. */
  43115. class WebXREnterExitUIButton {
  43116. /** button element */
  43117. element: HTMLElement;
  43118. /** XR initialization options for the button */
  43119. initializationOptions: XRSessionCreationOptions;
  43120. /**
  43121. * Creates a WebXREnterExitUIButton
  43122. * @param element button element
  43123. * @param initializationOptions XR initialization options for the button
  43124. */
  43125. constructor(
  43126. /** button element */
  43127. element: HTMLElement,
  43128. /** XR initialization options for the button */
  43129. initializationOptions: XRSessionCreationOptions);
  43130. /**
  43131. * Overwritable function which can be used to update the button's visuals when the state changes
  43132. * @param activeButton the current active button in the UI
  43133. */
  43134. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  43135. }
  43136. /**
  43137. * Options to create the webXR UI
  43138. */
  43139. class WebXREnterExitUIOptions {
  43140. /**
  43141. * Context to enter xr with
  43142. */
  43143. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  43144. /**
  43145. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  43146. */
  43147. customButtons?: Array<WebXREnterExitUIButton>;
  43148. }
  43149. /**
  43150. * UI to allow the user to enter/exit XR mode
  43151. */
  43152. class WebXREnterExitUI implements IDisposable {
  43153. private scene;
  43154. private _overlay;
  43155. private _buttons;
  43156. private _activeButton;
  43157. /**
  43158. * Fired every time the active button is changed.
  43159. *
  43160. * When xr is entered via a button that launches xr that button will be the callback parameter
  43161. *
  43162. * When exiting xr the callback parameter will be null)
  43163. */
  43164. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  43165. /**
  43166. * Creates UI to allow the user to enter/exit XR mode
  43167. * @param scene the scene to add the ui to
  43168. * @param helper the xr experience helper to enter/exit xr with
  43169. * @param options options to configure the UI
  43170. * @returns the created ui
  43171. */
  43172. static CreateAsync(scene: BABYLON.Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  43173. private constructor();
  43174. private _updateButtons;
  43175. /**
  43176. * Disposes of the object
  43177. */
  43178. dispose(): void;
  43179. }
  43180. }
  43181. declare module BABYLON {
  43182. /**
  43183. * States of the webXR experience
  43184. */
  43185. enum WebXRState {
  43186. /**
  43187. * Transitioning to being in XR mode
  43188. */
  43189. ENTERING_XR = 0,
  43190. /**
  43191. * Transitioning to non XR mode
  43192. */
  43193. EXITING_XR = 1,
  43194. /**
  43195. * In XR mode and presenting
  43196. */
  43197. IN_XR = 2,
  43198. /**
  43199. * Not entered XR mode
  43200. */
  43201. NOT_IN_XR = 3
  43202. }
  43203. /**
  43204. * Helper class used to enable XR
  43205. * @see https://doc.babylonjs.com/how_to/webxr
  43206. */
  43207. class WebXRExperienceHelper implements IDisposable {
  43208. private scene;
  43209. /**
  43210. * 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
  43211. */
  43212. container: AbstractMesh;
  43213. /**
  43214. * Camera used to render xr content
  43215. */
  43216. camera: WebXRCamera;
  43217. /**
  43218. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  43219. */
  43220. state: WebXRState;
  43221. private _setState;
  43222. private static _TmpVector;
  43223. /**
  43224. * Fires when the state of the experience helper has changed
  43225. */
  43226. onStateChangedObservable: Observable<WebXRState>;
  43227. /** @hidden */
  43228. _sessionManager: WebXRSessionManager;
  43229. private _nonVRCamera;
  43230. private _originalSceneAutoClear;
  43231. private _supported;
  43232. /**
  43233. * Creates the experience helper
  43234. * @param scene the scene to attach the experience helper to
  43235. * @returns a promise for the experience helper
  43236. */
  43237. static CreateAsync(scene: BABYLON.Scene): Promise<WebXRExperienceHelper>;
  43238. /**
  43239. * Creates a WebXRExperienceHelper
  43240. * @param scene The scene the helper should be created in
  43241. */
  43242. private constructor();
  43243. /**
  43244. * Exits XR mode and returns the scene to its original state
  43245. * @returns promise that resolves after xr mode has exited
  43246. */
  43247. exitXRAsync(): Promise<void>;
  43248. /**
  43249. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43250. * @param sessionCreationOptions options for the XR session
  43251. * @param frameOfReference frame of reference of the XR session
  43252. * @returns promise that resolves after xr mode has entered
  43253. */
  43254. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  43255. /**
  43256. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  43257. * @param ray ray to cast into the environment
  43258. * @returns Promise which resolves with a collision point in the environment if it exists
  43259. */
  43260. environmentPointHitTestAsync(ray: BABYLON.Ray): Promise<Nullable<Vector3>>;
  43261. /**
  43262. * Updates the global position of the camera by moving the camera's container
  43263. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  43264. * @param position The desired global position of the camera
  43265. */
  43266. setPositionOfCameraUsingContainer(position: Vector3): void;
  43267. /**
  43268. * Rotates the xr camera by rotating the camera's container around the camera's position
  43269. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  43270. * @param rotation the desired quaternion rotation to apply to the camera
  43271. */
  43272. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  43273. /**
  43274. * Checks if the creation options are supported by the xr session
  43275. * @param options creation options
  43276. * @returns true if supported
  43277. */
  43278. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  43279. /**
  43280. * Disposes of the experience helper
  43281. */
  43282. dispose(): void;
  43283. }
  43284. }
  43285. declare module BABYLON {
  43286. /**
  43287. * Represents an XR input
  43288. */
  43289. class WebXRController {
  43290. /**
  43291. * 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
  43292. */
  43293. grip?: BABYLON.AbstractMesh;
  43294. /**
  43295. * Pointer which can be used to select objects or attach a visible laser to
  43296. */
  43297. pointer: BABYLON.AbstractMesh;
  43298. /**
  43299. * Creates the controller
  43300. * @see https://doc.babylonjs.com/how_to/webxr
  43301. * @param scene the scene which the controller should be associated to
  43302. */
  43303. constructor(scene: BABYLON.Scene);
  43304. /**
  43305. * Disposes of the object
  43306. */
  43307. dispose(): void;
  43308. }
  43309. /**
  43310. * XR input used to track XR inputs such as controllers/rays
  43311. */
  43312. class WebXRInput implements IDisposable {
  43313. private helper;
  43314. /**
  43315. * XR controllers being tracked
  43316. */
  43317. controllers: Array<WebXRController>;
  43318. private _tmpMatrix;
  43319. private _frameObserver;
  43320. /**
  43321. * Initializes the WebXRInput
  43322. * @param helper experience helper which the input should be created for
  43323. */
  43324. constructor(helper: WebXRExperienceHelper);
  43325. /**
  43326. * Disposes of the object
  43327. */
  43328. dispose(): void;
  43329. }
  43330. }
  43331. declare module BABYLON {
  43332. /**
  43333. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  43334. */
  43335. class WebXRManagedOutputCanvas implements IDisposable {
  43336. private _canvas;
  43337. /**
  43338. * xrpresent context of the canvas which can be used to display/mirror xr content
  43339. */
  43340. canvasContext: Nullable<WebGLRenderingContext>;
  43341. /**
  43342. * Initializes the canvas to be added/removed upon entering/exiting xr
  43343. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  43344. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  43345. */
  43346. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  43347. /**
  43348. * Disposes of the object
  43349. */
  43350. dispose(): void;
  43351. private _setManagedOutputCanvas;
  43352. private _addCanvas;
  43353. private _removeCanvas;
  43354. }
  43355. }
  43356. declare module BABYLON {
  43357. /**
  43358. * Manages an XRSession
  43359. * @see https://doc.babylonjs.com/how_to/webxr
  43360. */
  43361. class WebXRSessionManager implements IDisposable {
  43362. private scene;
  43363. /**
  43364. * Fires every time a new xrFrame arrives which can be used to update the camera
  43365. */
  43366. onXRFrameObservable: Observable<any>;
  43367. /**
  43368. * Fires when the xr session is ended either by the device or manually done
  43369. */
  43370. onXRSessionEnded: Observable<any>;
  43371. /** @hidden */
  43372. _xrSession: XRSession;
  43373. /** @hidden */
  43374. _frameOfReference: XRFrameOfReference;
  43375. /** @hidden */
  43376. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  43377. /** @hidden */
  43378. _currentXRFrame: Nullable<XRFrame>;
  43379. private _xrNavigator;
  43380. private _xrDevice;
  43381. private _tmpMatrix;
  43382. /**
  43383. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  43384. * @param scene The scene which the session should be created for
  43385. */
  43386. constructor(scene: BABYLON.Scene);
  43387. /**
  43388. * Initializes the manager
  43389. * After initialization enterXR can be called to start an XR session
  43390. * @returns Promise which resolves after it is initialized
  43391. */
  43392. initializeAsync(): Promise<void>;
  43393. /**
  43394. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  43395. * @param sessionCreationOptions xr options to create the session with
  43396. * @param frameOfReferenceType option to configure how the xr pose is expressed
  43397. * @returns Promise which resolves after it enters XR
  43398. */
  43399. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  43400. /**
  43401. * Stops the xrSession and restores the renderloop
  43402. * @returns Promise which resolves after it exits XR
  43403. */
  43404. exitXRAsync(): Promise<void>;
  43405. /**
  43406. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  43407. * @param ray ray to cast into the environment
  43408. * @returns Promise which resolves with a collision point in the environment if it exists
  43409. */
  43410. environmentPointHitTestAsync(ray: BABYLON.Ray): Promise<Nullable<Vector3>>;
  43411. /**
  43412. * Checks if a session would be supported for the creation options specified
  43413. * @param options creation options to check if they are supported
  43414. * @returns true if supported
  43415. */
  43416. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  43417. /**
  43418. * @hidden
  43419. * Converts the render layer of xrSession to a render target
  43420. * @param session session to create render target for
  43421. * @param scene scene the new render target should be created for
  43422. */
  43423. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: BABYLON.Scene): RenderTargetTexture;
  43424. /**
  43425. * Disposes of the session manager
  43426. */
  43427. dispose(): void;
  43428. }
  43429. }
  43430. declare module BABYLON {
  43431. /**
  43432. * Contains an array of blocks representing the octree
  43433. */
  43434. interface IOctreeContainer<T> {
  43435. /**
  43436. * Blocks within the octree
  43437. */
  43438. blocks: Array<OctreeBlock<T>>;
  43439. }
  43440. /**
  43441. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  43442. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43443. */
  43444. class Octree<T> {
  43445. /** 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.) */
  43446. maxDepth: number;
  43447. /**
  43448. * Blocks within the octree containing objects
  43449. */
  43450. blocks: Array<OctreeBlock<T>>;
  43451. /**
  43452. * Content stored in the octree
  43453. */
  43454. dynamicContent: T[];
  43455. private _maxBlockCapacity;
  43456. private _selectionContent;
  43457. private _creationFunc;
  43458. /**
  43459. * Creates a octree
  43460. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43461. * @param creationFunc function to be used to instatiate the octree
  43462. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  43463. * @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.)
  43464. */
  43465. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  43466. /** 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.) */
  43467. maxDepth?: number);
  43468. /**
  43469. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  43470. * @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);
  43471. * @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);
  43472. * @param entries meshes to be added to the octree blocks
  43473. */
  43474. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  43475. /**
  43476. * Adds a mesh to the octree
  43477. * @param entry Mesh to add to the octree
  43478. */
  43479. addMesh(entry: T): void;
  43480. /**
  43481. * Selects an array of meshes within the frustum
  43482. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  43483. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  43484. * @returns array of meshes within the frustum
  43485. */
  43486. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  43487. /**
  43488. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  43489. * @param sphereCenter defines the bounding sphere center
  43490. * @param sphereRadius defines the bounding sphere radius
  43491. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43492. * @returns an array of objects that intersect the sphere
  43493. */
  43494. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  43495. /**
  43496. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  43497. * @param ray defines the ray to test with
  43498. * @returns array of intersected objects
  43499. */
  43500. intersectsRay(ray: Ray): SmartArray<T>;
  43501. /**
  43502. * @hidden
  43503. */
  43504. 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;
  43505. /**
  43506. * Adds a mesh into the octree block if it intersects the block
  43507. */
  43508. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  43509. /**
  43510. * Adds a submesh into the octree block if it intersects the block
  43511. */
  43512. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  43513. }
  43514. }
  43515. declare module BABYLON {
  43516. /**
  43517. * Class used to store a cell in an octree
  43518. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43519. */
  43520. class OctreeBlock<T> {
  43521. /**
  43522. * Gets the content of the current block
  43523. */
  43524. entries: T[];
  43525. /**
  43526. * Gets the list of block children
  43527. */
  43528. blocks: Array<OctreeBlock<T>>;
  43529. private _depth;
  43530. private _maxDepth;
  43531. private _capacity;
  43532. private _minPoint;
  43533. private _maxPoint;
  43534. private _boundingVectors;
  43535. private _creationFunc;
  43536. /**
  43537. * Creates a new block
  43538. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  43539. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  43540. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  43541. * @param depth defines the current depth of this block in the octree
  43542. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  43543. * @param creationFunc defines a callback to call when an element is added to the block
  43544. */
  43545. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  43546. /**
  43547. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  43548. */
  43549. readonly capacity: number;
  43550. /**
  43551. * Gets the minimum vector (in world space) of the block's bounding box
  43552. */
  43553. readonly minPoint: Vector3;
  43554. /**
  43555. * Gets the maximum vector (in world space) of the block's bounding box
  43556. */
  43557. readonly maxPoint: Vector3;
  43558. /**
  43559. * Add a new element to this block
  43560. * @param entry defines the element to add
  43561. */
  43562. addEntry(entry: T): void;
  43563. /**
  43564. * Add an array of elements to this block
  43565. * @param entries defines the array of elements to add
  43566. */
  43567. addEntries(entries: T[]): void;
  43568. /**
  43569. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  43570. * @param frustumPlanes defines the frustum planes to test
  43571. * @param selection defines the array to store current content if selection is positive
  43572. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43573. */
  43574. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  43575. /**
  43576. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  43577. * @param sphereCenter defines the bounding sphere center
  43578. * @param sphereRadius defines the bounding sphere radius
  43579. * @param selection defines the array to store current content if selection is positive
  43580. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43581. */
  43582. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  43583. /**
  43584. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  43585. * @param ray defines the ray to test with
  43586. * @param selection defines the array to store current content if selection is positive
  43587. */
  43588. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  43589. /**
  43590. * Subdivide the content into child blocks (this block will then be empty)
  43591. */
  43592. createInnerBlocks(): void;
  43593. }
  43594. }
  43595. declare module BABYLON {
  43596. interface Scene {
  43597. /**
  43598. * @hidden
  43599. * Backing Filed
  43600. */
  43601. _selectionOctree: Octree<AbstractMesh>;
  43602. /**
  43603. * Gets the octree used to boost mesh selection (picking)
  43604. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43605. */
  43606. selectionOctree: Octree<AbstractMesh>;
  43607. /**
  43608. * Creates or updates the octree used to boost selection (picking)
  43609. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43610. * @param maxCapacity defines the maximum capacity per leaf
  43611. * @param maxDepth defines the maximum depth of the octree
  43612. * @returns an octree of AbstractMesh
  43613. */
  43614. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  43615. }
  43616. interface AbstractMesh {
  43617. /**
  43618. * @hidden
  43619. * Backing Field
  43620. */
  43621. _submeshesOctree: Octree<SubMesh>;
  43622. /**
  43623. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  43624. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  43625. * @param maxCapacity defines the maximum size of each block (64 by default)
  43626. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  43627. * @returns the new octree
  43628. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  43629. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43630. */
  43631. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  43632. }
  43633. /**
  43634. * Defines the octree scene component responsible to manage any octrees
  43635. * in a given scene.
  43636. */
  43637. class OctreeSceneComponent {
  43638. /**
  43639. * The component name helpfull to identify the component in the list of scene components.
  43640. */
  43641. readonly name: string;
  43642. /**
  43643. * The scene the component belongs to.
  43644. */
  43645. scene: Scene;
  43646. /**
  43647. * Indicates if the meshes have been checked to make sure they are isEnabled()
  43648. */
  43649. readonly checksIsEnabled: boolean;
  43650. /**
  43651. * Creates a new instance of the component for the given scene
  43652. * @param scene Defines the scene to register the component in
  43653. */
  43654. constructor(scene: Scene);
  43655. /**
  43656. * Registers the component in a given scene
  43657. */
  43658. register(): void;
  43659. /**
  43660. * Return the list of active meshes
  43661. * @returns the list of active meshes
  43662. */
  43663. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  43664. /**
  43665. * Return the list of active sub meshes
  43666. * @param mesh The mesh to get the candidates sub meshes from
  43667. * @returns the list of active sub meshes
  43668. */
  43669. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  43670. private _tempRay;
  43671. /**
  43672. * Return the list of sub meshes intersecting with a given local ray
  43673. * @param mesh defines the mesh to find the submesh for
  43674. * @param localRay defines the ray in local space
  43675. * @returns the list of intersecting sub meshes
  43676. */
  43677. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  43678. /**
  43679. * Return the list of sub meshes colliding with a collider
  43680. * @param mesh defines the mesh to find the submesh for
  43681. * @param collider defines the collider to evaluate the collision against
  43682. * @returns the list of colliding sub meshes
  43683. */
  43684. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  43685. /**
  43686. * Rebuilds the elements related to this component in case of
  43687. * context lost for instance.
  43688. */
  43689. rebuild(): void;
  43690. /**
  43691. * Disposes the component and the associated ressources.
  43692. */
  43693. dispose(): void;
  43694. }
  43695. }
  43696. declare module BABYLON {
  43697. /** @hidden */
  43698. class _OcclusionDataStorage {
  43699. /** @hidden */
  43700. occlusionInternalRetryCounter: number;
  43701. /** @hidden */
  43702. isOcclusionQueryInProgress: boolean;
  43703. /** @hidden */
  43704. isOccluded: boolean;
  43705. /** @hidden */
  43706. occlusionRetryCount: number;
  43707. /** @hidden */
  43708. occlusionType: number;
  43709. /** @hidden */
  43710. occlusionQueryAlgorithmType: number;
  43711. }
  43712. interface Engine {
  43713. /**
  43714. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  43715. * @return the new query
  43716. */
  43717. createQuery(): WebGLQuery;
  43718. /**
  43719. * Delete and release a webGL query
  43720. * @param query defines the query to delete
  43721. * @return the current engine
  43722. */
  43723. deleteQuery(query: WebGLQuery): Engine;
  43724. /**
  43725. * Check if a given query has resolved and got its value
  43726. * @param query defines the query to check
  43727. * @returns true if the query got its value
  43728. */
  43729. isQueryResultAvailable(query: WebGLQuery): boolean;
  43730. /**
  43731. * Gets the value of a given query
  43732. * @param query defines the query to check
  43733. * @returns the value of the query
  43734. */
  43735. getQueryResult(query: WebGLQuery): number;
  43736. /**
  43737. * Initiates an occlusion query
  43738. * @param algorithmType defines the algorithm to use
  43739. * @param query defines the query to use
  43740. * @returns the current engine
  43741. * @see http://doc.babylonjs.com/features/occlusionquery
  43742. */
  43743. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  43744. /**
  43745. * Ends an occlusion query
  43746. * @see http://doc.babylonjs.com/features/occlusionquery
  43747. * @param algorithmType defines the algorithm to use
  43748. * @returns the current engine
  43749. */
  43750. endOcclusionQuery(algorithmType: number): Engine;
  43751. /**
  43752. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  43753. * Please note that only one query can be issued at a time
  43754. * @returns a time token used to track the time span
  43755. */
  43756. startTimeQuery(): Nullable<_TimeToken>;
  43757. /**
  43758. * Ends a time query
  43759. * @param token defines the token used to measure the time span
  43760. * @returns the time spent (in ns)
  43761. */
  43762. endTimeQuery(token: _TimeToken): int;
  43763. /** @hidden */
  43764. _currentNonTimestampToken: Nullable<_TimeToken>;
  43765. /** @hidden */
  43766. _createTimeQuery(): WebGLQuery;
  43767. /** @hidden */
  43768. _deleteTimeQuery(query: WebGLQuery): void;
  43769. /** @hidden */
  43770. _getGlAlgorithmType(algorithmType: number): number;
  43771. /** @hidden */
  43772. _getTimeQueryResult(query: WebGLQuery): any;
  43773. /** @hidden */
  43774. _getTimeQueryAvailability(query: WebGLQuery): any;
  43775. }
  43776. interface AbstractMesh {
  43777. /**
  43778. * Backing filed
  43779. * @hidden
  43780. */
  43781. __occlusionDataStorage: _OcclusionDataStorage;
  43782. /**
  43783. * Access property
  43784. * @hidden
  43785. */
  43786. _occlusionDataStorage: _OcclusionDataStorage;
  43787. /**
  43788. * This number indicates the number of allowed retries before stop the occlusion query, this is useful if the occlusion query is taking long time before to the query result is retireved, the query result indicates if the object is visible within the scene or not and based on that Babylon.Js engine decideds to show or hide the object.
  43789. * The default value is -1 which means don't break the query and wait till the result
  43790. * @see http://doc.babylonjs.com/features/occlusionquery
  43791. */
  43792. occlusionRetryCount: number;
  43793. /**
  43794. * This property is responsible for starting the occlusion query within the Mesh or not, this property is also used to determine what should happen when the occlusionRetryCount is reached. It has supports 3 values:
  43795. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  43796. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  43797. * * OCCLUSION_TYPE_STRICT: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken restore the last state of the mesh occlusion if the mesh was visible then show the mesh if was hidden then hide don't show.
  43798. * @see http://doc.babylonjs.com/features/occlusionquery
  43799. */
  43800. occlusionType: number;
  43801. /**
  43802. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  43803. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  43804. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE (Default Value) which is mapped to GL_ANY_SAMPLES_PASSED_CONSERVATIVE which is a false positive algorithm that is faster than GL_ANY_SAMPLES_PASSED but less accurate.
  43805. * @see http://doc.babylonjs.com/features/occlusionquery
  43806. */
  43807. occlusionQueryAlgorithmType: number;
  43808. /**
  43809. * Gets or sets whether the mesh is occluded or not, it is used also to set the intial state of the mesh to be occluded or not
  43810. * @see http://doc.babylonjs.com/features/occlusionquery
  43811. */
  43812. isOccluded: boolean;
  43813. /**
  43814. * Flag to check the progress status of the query
  43815. * @see http://doc.babylonjs.com/features/occlusionquery
  43816. */
  43817. isOcclusionQueryInProgress: boolean;
  43818. }
  43819. }
  43820. declare module BABYLON {
  43821. interface Engine {
  43822. /**
  43823. * Creates a webGL transform feedback object
  43824. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  43825. * @returns the webGL transform feedback object
  43826. */
  43827. createTransformFeedback(): WebGLTransformFeedback;
  43828. /**
  43829. * Delete a webGL transform feedback object
  43830. * @param value defines the webGL transform feedback object to delete
  43831. */
  43832. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  43833. /**
  43834. * Bind a webGL transform feedback object to the webgl context
  43835. * @param value defines the webGL transform feedback object to bind
  43836. */
  43837. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  43838. /**
  43839. * Begins a transform feedback operation
  43840. * @param usePoints defines if points or triangles must be used
  43841. */
  43842. beginTransformFeedback(usePoints: boolean): void;
  43843. /**
  43844. * Ends a transform feedback operation
  43845. */
  43846. endTransformFeedback(): void;
  43847. /**
  43848. * Specify the varyings to use with transform feedback
  43849. * @param program defines the associated webGL program
  43850. * @param value defines the list of strings representing the varying names
  43851. */
  43852. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  43853. /**
  43854. * Bind a webGL buffer for a transform feedback operation
  43855. * @param value defines the webGL buffer to bind
  43856. */
  43857. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  43858. }
  43859. }
  43860. declare module BABYLON {
  43861. /**
  43862. * Google Daydream controller
  43863. */
  43864. class DaydreamController extends WebVRController {
  43865. /**
  43866. * Base Url for the controller model.
  43867. */
  43868. static MODEL_BASE_URL: string;
  43869. /**
  43870. * File name for the controller model.
  43871. */
  43872. static MODEL_FILENAME: string;
  43873. /**
  43874. * Gamepad Id prefix used to identify Daydream Controller.
  43875. */
  43876. static readonly GAMEPAD_ID_PREFIX: string;
  43877. /**
  43878. * Creates a new DaydreamController from a gamepad
  43879. * @param vrGamepad the gamepad that the controller should be created from
  43880. */
  43881. constructor(vrGamepad: any);
  43882. /**
  43883. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43884. * @param scene scene in which to add meshes
  43885. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43886. */
  43887. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43888. /**
  43889. * Called once for each button that changed state since the last frame
  43890. * @param buttonIdx Which button index changed
  43891. * @param state New state of the button
  43892. * @param changes Which properties on the state changed since last frame
  43893. */
  43894. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43895. }
  43896. }
  43897. declare module BABYLON {
  43898. /**
  43899. * Gear VR Controller
  43900. */
  43901. class GearVRController extends WebVRController {
  43902. /**
  43903. * Base Url for the controller model.
  43904. */
  43905. static MODEL_BASE_URL: string;
  43906. /**
  43907. * File name for the controller model.
  43908. */
  43909. static MODEL_FILENAME: string;
  43910. /**
  43911. * Gamepad Id prefix used to identify this controller.
  43912. */
  43913. static readonly GAMEPAD_ID_PREFIX: string;
  43914. private readonly _buttonIndexToObservableNameMap;
  43915. /**
  43916. * Creates a new GearVRController from a gamepad
  43917. * @param vrGamepad the gamepad that the controller should be created from
  43918. */
  43919. constructor(vrGamepad: any);
  43920. /**
  43921. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43922. * @param scene scene in which to add meshes
  43923. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43924. */
  43925. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43926. /**
  43927. * Called once for each button that changed state since the last frame
  43928. * @param buttonIdx Which button index changed
  43929. * @param state New state of the button
  43930. * @param changes Which properties on the state changed since last frame
  43931. */
  43932. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43933. }
  43934. }
  43935. declare module BABYLON {
  43936. /**
  43937. * Generic Controller
  43938. */
  43939. class GenericController extends WebVRController {
  43940. /**
  43941. * Base Url for the controller model.
  43942. */
  43943. static readonly MODEL_BASE_URL: string;
  43944. /**
  43945. * File name for the controller model.
  43946. */
  43947. static readonly MODEL_FILENAME: string;
  43948. /**
  43949. * Creates a new GenericController from a gamepad
  43950. * @param vrGamepad the gamepad that the controller should be created from
  43951. */
  43952. constructor(vrGamepad: any);
  43953. /**
  43954. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43955. * @param scene scene in which to add meshes
  43956. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43957. */
  43958. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43959. /**
  43960. * Called once for each button that changed state since the last frame
  43961. * @param buttonIdx Which button index changed
  43962. * @param state New state of the button
  43963. * @param changes Which properties on the state changed since last frame
  43964. */
  43965. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43966. }
  43967. }
  43968. declare module BABYLON {
  43969. /**
  43970. * Oculus Touch Controller
  43971. */
  43972. class OculusTouchController extends WebVRController {
  43973. /**
  43974. * Base Url for the controller model.
  43975. */
  43976. static MODEL_BASE_URL: string;
  43977. /**
  43978. * File name for the left controller model.
  43979. */
  43980. static MODEL_LEFT_FILENAME: string;
  43981. /**
  43982. * File name for the right controller model.
  43983. */
  43984. static MODEL_RIGHT_FILENAME: string;
  43985. /**
  43986. * Fired when the secondary trigger on this controller is modified
  43987. */
  43988. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43989. /**
  43990. * Fired when the thumb rest on this controller is modified
  43991. */
  43992. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43993. /**
  43994. * Creates a new OculusTouchController from a gamepad
  43995. * @param vrGamepad the gamepad that the controller should be created from
  43996. */
  43997. constructor(vrGamepad: any);
  43998. /**
  43999. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44000. * @param scene scene in which to add meshes
  44001. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44002. */
  44003. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44004. /**
  44005. * Fired when the A button on this controller is modified
  44006. */
  44007. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44008. /**
  44009. * Fired when the B button on this controller is modified
  44010. */
  44011. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44012. /**
  44013. * Fired when the X button on this controller is modified
  44014. */
  44015. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44016. /**
  44017. * Fired when the Y button on this controller is modified
  44018. */
  44019. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44020. /**
  44021. * Called once for each button that changed state since the last frame
  44022. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  44023. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  44024. * 2) secondary trigger (same)
  44025. * 3) A (right) X (left), touch, pressed = value
  44026. * 4) B / Y
  44027. * 5) thumb rest
  44028. * @param buttonIdx Which button index changed
  44029. * @param state New state of the button
  44030. * @param changes Which properties on the state changed since last frame
  44031. */
  44032. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44033. }
  44034. }
  44035. declare module BABYLON {
  44036. /**
  44037. * Defines the types of pose enabled controllers that are supported
  44038. */
  44039. enum PoseEnabledControllerType {
  44040. /**
  44041. * HTC Vive
  44042. */
  44043. VIVE = 0,
  44044. /**
  44045. * Oculus Rift
  44046. */
  44047. OCULUS = 1,
  44048. /**
  44049. * Windows mixed reality
  44050. */
  44051. WINDOWS = 2,
  44052. /**
  44053. * Samsung gear VR
  44054. */
  44055. GEAR_VR = 3,
  44056. /**
  44057. * Google Daydream
  44058. */
  44059. DAYDREAM = 4,
  44060. /**
  44061. * Generic
  44062. */
  44063. GENERIC = 5
  44064. }
  44065. /**
  44066. * Defines the MutableGamepadButton interface for the state of a gamepad button
  44067. */
  44068. interface MutableGamepadButton {
  44069. /**
  44070. * Value of the button/trigger
  44071. */
  44072. value: number;
  44073. /**
  44074. * If the button/trigger is currently touched
  44075. */
  44076. touched: boolean;
  44077. /**
  44078. * If the button/trigger is currently pressed
  44079. */
  44080. pressed: boolean;
  44081. }
  44082. /**
  44083. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  44084. * @hidden
  44085. */
  44086. interface ExtendedGamepadButton extends GamepadButton {
  44087. /**
  44088. * If the button/trigger is currently pressed
  44089. */
  44090. readonly pressed: boolean;
  44091. /**
  44092. * If the button/trigger is currently touched
  44093. */
  44094. readonly touched: boolean;
  44095. /**
  44096. * Value of the button/trigger
  44097. */
  44098. readonly value: number;
  44099. }
  44100. /**
  44101. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  44102. */
  44103. class PoseEnabledControllerHelper {
  44104. /**
  44105. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  44106. * @param vrGamepad the gamepad to initialized
  44107. * @returns a vr controller of the type the gamepad identified as
  44108. */
  44109. static InitiateController(vrGamepad: any): OculusTouchController | WindowsMotionController | ViveController | GearVRController | DaydreamController | GenericController;
  44110. }
  44111. /**
  44112. * Defines the PoseEnabledController object that contains state of a vr capable controller
  44113. */
  44114. class PoseEnabledController extends Gamepad implements PoseControlled {
  44115. private _deviceRoomPosition;
  44116. private _deviceRoomRotationQuaternion;
  44117. /**
  44118. * The device position in babylon space
  44119. */
  44120. devicePosition: Vector3;
  44121. /**
  44122. * The device rotation in babylon space
  44123. */
  44124. deviceRotationQuaternion: Quaternion;
  44125. /**
  44126. * The scale factor of the device in babylon space
  44127. */
  44128. deviceScaleFactor: number;
  44129. /**
  44130. * (Likely devicePosition should be used instead) The device position in its room space
  44131. */
  44132. position: Vector3;
  44133. /**
  44134. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  44135. */
  44136. rotationQuaternion: Quaternion;
  44137. /**
  44138. * The type of controller (Eg. Windows mixed reality)
  44139. */
  44140. controllerType: PoseEnabledControllerType;
  44141. protected _calculatedPosition: Vector3;
  44142. private _calculatedRotation;
  44143. /**
  44144. * The raw pose from the device
  44145. */
  44146. rawPose: DevicePose;
  44147. private _trackPosition;
  44148. private _maxRotationDistFromHeadset;
  44149. private _draggedRoomRotation;
  44150. /**
  44151. * @hidden
  44152. */
  44153. _disableTrackPosition(fixedPosition: Vector3): void;
  44154. /**
  44155. * Internal, the mesh attached to the controller
  44156. * @hidden
  44157. */
  44158. _mesh: Nullable<AbstractMesh>;
  44159. private _poseControlledCamera;
  44160. private _leftHandSystemQuaternion;
  44161. /**
  44162. * Internal, matrix used to convert room space to babylon space
  44163. * @hidden
  44164. */
  44165. _deviceToWorld: Matrix;
  44166. /**
  44167. * Node to be used when casting a ray from the controller
  44168. * @hidden
  44169. */
  44170. _pointingPoseNode: Nullable<TransformNode>;
  44171. /**
  44172. * Name of the child mesh that can be used to cast a ray from the controller
  44173. */
  44174. static readonly POINTING_POSE: string;
  44175. /**
  44176. * Creates a new PoseEnabledController from a gamepad
  44177. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  44178. */
  44179. constructor(browserGamepad: any);
  44180. private _workingMatrix;
  44181. /**
  44182. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  44183. */
  44184. update(): void;
  44185. /**
  44186. * Updates only the pose device and mesh without doing any button event checking
  44187. */
  44188. protected _updatePoseAndMesh(): void;
  44189. /**
  44190. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  44191. * @param poseData raw pose fromthe device
  44192. */
  44193. updateFromDevice(poseData: DevicePose): void;
  44194. /**
  44195. * @hidden
  44196. */
  44197. _meshAttachedObservable: Observable<AbstractMesh>;
  44198. /**
  44199. * Attaches a mesh to the controller
  44200. * @param mesh the mesh to be attached
  44201. */
  44202. attachToMesh(mesh: AbstractMesh): void;
  44203. /**
  44204. * Attaches the controllers mesh to a camera
  44205. * @param camera the camera the mesh should be attached to
  44206. */
  44207. attachToPoseControlledCamera(camera: TargetCamera): void;
  44208. /**
  44209. * Disposes of the controller
  44210. */
  44211. dispose(): void;
  44212. /**
  44213. * The mesh that is attached to the controller
  44214. */
  44215. readonly mesh: Nullable<AbstractMesh>;
  44216. /**
  44217. * Gets the ray of the controller in the direction the controller is pointing
  44218. * @param length the length the resulting ray should be
  44219. * @returns a ray in the direction the controller is pointing
  44220. */
  44221. getForwardRay(length?: number): Ray;
  44222. }
  44223. }
  44224. declare module BABYLON {
  44225. /**
  44226. * Vive Controller
  44227. */
  44228. class ViveController extends WebVRController {
  44229. /**
  44230. * Base Url for the controller model.
  44231. */
  44232. static MODEL_BASE_URL: string;
  44233. /**
  44234. * File name for the controller model.
  44235. */
  44236. static MODEL_FILENAME: string;
  44237. /**
  44238. * Creates a new ViveController from a gamepad
  44239. * @param vrGamepad the gamepad that the controller should be created from
  44240. */
  44241. constructor(vrGamepad: any);
  44242. /**
  44243. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44244. * @param scene scene in which to add meshes
  44245. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44246. */
  44247. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44248. /**
  44249. * Fired when the left button on this controller is modified
  44250. */
  44251. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44252. /**
  44253. * Fired when the right button on this controller is modified
  44254. */
  44255. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44256. /**
  44257. * Fired when the menu button on this controller is modified
  44258. */
  44259. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44260. /**
  44261. * Called once for each button that changed state since the last frame
  44262. * Vive mapping:
  44263. * 0: touchpad
  44264. * 1: trigger
  44265. * 2: left AND right buttons
  44266. * 3: menu button
  44267. * @param buttonIdx Which button index changed
  44268. * @param state New state of the button
  44269. * @param changes Which properties on the state changed since last frame
  44270. */
  44271. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44272. }
  44273. }
  44274. declare module BABYLON {
  44275. /**
  44276. * Defines the WebVRController object that represents controllers tracked in 3D space
  44277. */
  44278. abstract class WebVRController extends PoseEnabledController {
  44279. /**
  44280. * Internal, the default controller model for the controller
  44281. */
  44282. protected _defaultModel: AbstractMesh;
  44283. /**
  44284. * Fired when the trigger state has changed
  44285. */
  44286. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  44287. /**
  44288. * Fired when the main button state has changed
  44289. */
  44290. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44291. /**
  44292. * Fired when the secondary button state has changed
  44293. */
  44294. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44295. /**
  44296. * Fired when the pad state has changed
  44297. */
  44298. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  44299. /**
  44300. * Fired when controllers stick values have changed
  44301. */
  44302. onPadValuesChangedObservable: Observable<StickValues>;
  44303. /**
  44304. * Array of button availible on the controller
  44305. */
  44306. protected _buttons: Array<MutableGamepadButton>;
  44307. private _onButtonStateChange;
  44308. /**
  44309. * Fired when a controller button's state has changed
  44310. * @param callback the callback containing the button that was modified
  44311. */
  44312. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  44313. /**
  44314. * X and Y axis corrisponding to the controllers joystick
  44315. */
  44316. pad: StickValues;
  44317. /**
  44318. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  44319. */
  44320. hand: string;
  44321. /**
  44322. * The default controller model for the controller
  44323. */
  44324. readonly defaultModel: AbstractMesh;
  44325. /**
  44326. * Creates a new WebVRController from a gamepad
  44327. * @param vrGamepad the gamepad that the WebVRController should be created from
  44328. */
  44329. constructor(vrGamepad: any);
  44330. /**
  44331. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  44332. */
  44333. update(): void;
  44334. /**
  44335. * Function to be called when a button is modified
  44336. */
  44337. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44338. /**
  44339. * Loads a mesh and attaches it to the controller
  44340. * @param scene the scene the mesh should be added to
  44341. * @param meshLoaded callback for when the mesh has been loaded
  44342. */
  44343. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44344. private _setButtonValue;
  44345. private _changes;
  44346. private _checkChanges;
  44347. /**
  44348. * Disposes of th webVRCOntroller
  44349. */
  44350. dispose(): void;
  44351. }
  44352. }
  44353. declare module BABYLON {
  44354. /**
  44355. * Defines the WindowsMotionController object that the state of the windows motion controller
  44356. */
  44357. class WindowsMotionController extends WebVRController {
  44358. /**
  44359. * The base url used to load the left and right controller models
  44360. */
  44361. static MODEL_BASE_URL: string;
  44362. /**
  44363. * The name of the left controller model file
  44364. */
  44365. static MODEL_LEFT_FILENAME: string;
  44366. /**
  44367. * The name of the right controller model file
  44368. */
  44369. static MODEL_RIGHT_FILENAME: string;
  44370. /**
  44371. * The controller name prefix for this controller type
  44372. */
  44373. static readonly GAMEPAD_ID_PREFIX: string;
  44374. /**
  44375. * The controller id pattern for this controller type
  44376. */
  44377. private static readonly GAMEPAD_ID_PATTERN;
  44378. private _loadedMeshInfo;
  44379. private readonly _mapping;
  44380. /**
  44381. * Fired when the trackpad on this controller is clicked
  44382. */
  44383. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  44384. /**
  44385. * Fired when the trackpad on this controller is modified
  44386. */
  44387. onTrackpadValuesChangedObservable: Observable<StickValues>;
  44388. /**
  44389. * The current x and y values of this controller's trackpad
  44390. */
  44391. trackpad: StickValues;
  44392. /**
  44393. * Creates a new WindowsMotionController from a gamepad
  44394. * @param vrGamepad the gamepad that the controller should be created from
  44395. */
  44396. constructor(vrGamepad: any);
  44397. /**
  44398. * Fired when the trigger on this controller is modified
  44399. */
  44400. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44401. /**
  44402. * Fired when the menu button on this controller is modified
  44403. */
  44404. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44405. /**
  44406. * Fired when the grip button on this controller is modified
  44407. */
  44408. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44409. /**
  44410. * Fired when the thumbstick button on this controller is modified
  44411. */
  44412. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44413. /**
  44414. * Fired when the touchpad button on this controller is modified
  44415. */
  44416. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44417. /**
  44418. * Fired when the touchpad values on this controller are modified
  44419. */
  44420. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  44421. private _updateTrackpad;
  44422. /**
  44423. * Called once per frame by the engine.
  44424. */
  44425. update(): void;
  44426. /**
  44427. * Called once for each button that changed state since the last frame
  44428. * @param buttonIdx Which button index changed
  44429. * @param state New state of the button
  44430. * @param changes Which properties on the state changed since last frame
  44431. */
  44432. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44433. /**
  44434. * Moves the buttons on the controller mesh based on their current state
  44435. * @param buttonName the name of the button to move
  44436. * @param buttonValue the value of the button which determines the buttons new position
  44437. */
  44438. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  44439. /**
  44440. * Moves the axis on the controller mesh based on its current state
  44441. * @param axis the index of the axis
  44442. * @param axisValue the value of the axis which determines the meshes new position
  44443. * @hidden
  44444. */
  44445. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  44446. /**
  44447. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44448. * @param scene scene in which to add meshes
  44449. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44450. */
  44451. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  44452. /**
  44453. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  44454. * can be transformed by button presses and axes values, based on this._mapping.
  44455. *
  44456. * @param scene scene in which the meshes exist
  44457. * @param meshes list of meshes that make up the controller model to process
  44458. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  44459. */
  44460. private processModel;
  44461. private createMeshInfo;
  44462. /**
  44463. * Gets the ray of the controller in the direction the controller is pointing
  44464. * @param length the length the resulting ray should be
  44465. * @returns a ray in the direction the controller is pointing
  44466. */
  44467. getForwardRay(length?: number): Ray;
  44468. /**
  44469. * Disposes of the controller
  44470. */
  44471. dispose(): void;
  44472. }
  44473. }
  44474. declare module BABYLON {
  44475. /**
  44476. * Interface to implement to create a shadow generator compatible with BJS.
  44477. */
  44478. interface IShadowGenerator {
  44479. /**
  44480. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  44481. * @returns The render target texture if present otherwise, null
  44482. */
  44483. getShadowMap(): Nullable<RenderTargetTexture>;
  44484. /**
  44485. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  44486. * @returns The render target texture if the shadow map is present otherwise, null
  44487. */
  44488. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  44489. /**
  44490. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  44491. * @param subMesh The submesh we want to render in the shadow map
  44492. * @param useInstances Defines wether will draw in the map using instances
  44493. * @returns true if ready otherwise, false
  44494. */
  44495. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  44496. /**
  44497. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  44498. * @param defines Defines of the material we want to update
  44499. * @param lightIndex Index of the light in the enabled light list of the material
  44500. */
  44501. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  44502. /**
  44503. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  44504. * defined in the generator but impacting the effect).
  44505. * It implies the unifroms available on the materials are the standard BJS ones.
  44506. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  44507. * @param effect The effect we are binfing the information for
  44508. */
  44509. bindShadowLight(lightIndex: string, effect: Effect): void;
  44510. /**
  44511. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  44512. * (eq to shadow prjection matrix * light transform matrix)
  44513. * @returns The transform matrix used to create the shadow map
  44514. */
  44515. getTransformMatrix(): Matrix;
  44516. /**
  44517. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  44518. * Cube and 2D textures for instance.
  44519. */
  44520. recreateShadowMap(): void;
  44521. /**
  44522. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  44523. * @param onCompiled Callback triggered at the and of the effects compilation
  44524. * @param options Sets of optional options forcing the compilation with different modes
  44525. */
  44526. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  44527. useInstances: boolean;
  44528. }>): void;
  44529. /**
  44530. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  44531. * @param options Sets of optional options forcing the compilation with different modes
  44532. * @returns A promise that resolves when the compilation completes
  44533. */
  44534. forceCompilationAsync(options?: Partial<{
  44535. useInstances: boolean;
  44536. }>): Promise<void>;
  44537. /**
  44538. * Serializes the shadow generator setup to a json object.
  44539. * @returns The serialized JSON object
  44540. */
  44541. serialize(): any;
  44542. /**
  44543. * Disposes the Shadow map and related Textures and effects.
  44544. */
  44545. dispose(): void;
  44546. }
  44547. /**
  44548. * Default implementation IShadowGenerator.
  44549. * This is the main object responsible of generating shadows in the framework.
  44550. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  44551. */
  44552. class ShadowGenerator implements IShadowGenerator {
  44553. /**
  44554. * Shadow generator mode None: no filtering applied.
  44555. */
  44556. static readonly FILTER_NONE: number;
  44557. /**
  44558. * Shadow generator mode ESM: Exponential Shadow Mapping.
  44559. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  44560. */
  44561. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  44562. /**
  44563. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  44564. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  44565. */
  44566. static readonly FILTER_POISSONSAMPLING: number;
  44567. /**
  44568. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  44569. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  44570. */
  44571. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  44572. /**
  44573. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  44574. * edge artifacts on steep falloff.
  44575. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  44576. */
  44577. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  44578. /**
  44579. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  44580. * edge artifacts on steep falloff.
  44581. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  44582. */
  44583. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  44584. /**
  44585. * Shadow generator mode PCF: Percentage Closer Filtering
  44586. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  44587. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  44588. */
  44589. static readonly FILTER_PCF: number;
  44590. /**
  44591. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  44592. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  44593. * Contact Hardening
  44594. */
  44595. static readonly FILTER_PCSS: number;
  44596. /**
  44597. * Reserved for PCF and PCSS
  44598. * Highest Quality.
  44599. *
  44600. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  44601. *
  44602. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  44603. */
  44604. static readonly QUALITY_HIGH: number;
  44605. /**
  44606. * Reserved for PCF and PCSS
  44607. * Good tradeoff for quality/perf cross devices
  44608. *
  44609. * Execute PCF on a 3*3 kernel.
  44610. *
  44611. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  44612. */
  44613. static readonly QUALITY_MEDIUM: number;
  44614. /**
  44615. * Reserved for PCF and PCSS
  44616. * The lowest quality but the fastest.
  44617. *
  44618. * Execute PCF on a 1*1 kernel.
  44619. *
  44620. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  44621. */
  44622. static readonly QUALITY_LOW: number;
  44623. private _bias;
  44624. /**
  44625. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  44626. */
  44627. /**
  44628. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  44629. */
  44630. bias: number;
  44631. private _normalBias;
  44632. /**
  44633. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  44634. */
  44635. /**
  44636. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  44637. */
  44638. normalBias: number;
  44639. private _blurBoxOffset;
  44640. /**
  44641. * Gets the blur box offset: offset applied during the blur pass.
  44642. * Only useful if useKernelBlur = false
  44643. */
  44644. /**
  44645. * Sets the blur box offset: offset applied during the blur pass.
  44646. * Only useful if useKernelBlur = false
  44647. */
  44648. blurBoxOffset: number;
  44649. private _blurScale;
  44650. /**
  44651. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  44652. * 2 means half of the size.
  44653. */
  44654. /**
  44655. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  44656. * 2 means half of the size.
  44657. */
  44658. blurScale: number;
  44659. private _blurKernel;
  44660. /**
  44661. * Gets the blur kernel: kernel size of the blur pass.
  44662. * Only useful if useKernelBlur = true
  44663. */
  44664. /**
  44665. * Sets the blur kernel: kernel size of the blur pass.
  44666. * Only useful if useKernelBlur = true
  44667. */
  44668. blurKernel: number;
  44669. private _useKernelBlur;
  44670. /**
  44671. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  44672. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  44673. */
  44674. /**
  44675. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  44676. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  44677. */
  44678. useKernelBlur: boolean;
  44679. private _depthScale;
  44680. /**
  44681. * Gets the depth scale used in ESM mode.
  44682. */
  44683. /**
  44684. * Sets the depth scale used in ESM mode.
  44685. * This can override the scale stored on the light.
  44686. */
  44687. depthScale: number;
  44688. private _filter;
  44689. /**
  44690. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  44691. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  44692. */
  44693. /**
  44694. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  44695. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  44696. */
  44697. filter: number;
  44698. /**
  44699. * Gets if the current filter is set to Poisson Sampling.
  44700. */
  44701. /**
  44702. * Sets the current filter to Poisson Sampling.
  44703. */
  44704. usePoissonSampling: boolean;
  44705. /**
  44706. * Gets if the current filter is set to ESM.
  44707. */
  44708. /**
  44709. * Sets the current filter is to ESM.
  44710. */
  44711. useExponentialShadowMap: boolean;
  44712. /**
  44713. * Gets if the current filter is set to filtered ESM.
  44714. */
  44715. /**
  44716. * Gets if the current filter is set to filtered ESM.
  44717. */
  44718. useBlurExponentialShadowMap: boolean;
  44719. /**
  44720. * Gets if the current filter is set to "close ESM" (using the inverse of the
  44721. * exponential to prevent steep falloff artifacts).
  44722. */
  44723. /**
  44724. * Sets the current filter to "close ESM" (using the inverse of the
  44725. * exponential to prevent steep falloff artifacts).
  44726. */
  44727. useCloseExponentialShadowMap: boolean;
  44728. /**
  44729. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  44730. * exponential to prevent steep falloff artifacts).
  44731. */
  44732. /**
  44733. * Sets the current filter to filtered "close ESM" (using the inverse of the
  44734. * exponential to prevent steep falloff artifacts).
  44735. */
  44736. useBlurCloseExponentialShadowMap: boolean;
  44737. /**
  44738. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  44739. */
  44740. /**
  44741. * Sets the current filter to "PCF" (percentage closer filtering).
  44742. */
  44743. usePercentageCloserFiltering: boolean;
  44744. private _filteringQuality;
  44745. /**
  44746. * Gets the PCF or PCSS Quality.
  44747. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  44748. */
  44749. /**
  44750. * Sets the PCF or PCSS Quality.
  44751. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  44752. */
  44753. filteringQuality: number;
  44754. /**
  44755. * Gets if the current filter is set to "PCSS" (contact hardening).
  44756. */
  44757. /**
  44758. * Sets the current filter to "PCSS" (contact hardening).
  44759. */
  44760. useContactHardeningShadow: boolean;
  44761. private _contactHardeningLightSizeUVRatio;
  44762. /**
  44763. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  44764. * Using a ratio helps keeping shape stability independently of the map size.
  44765. *
  44766. * It does not account for the light projection as it was having too much
  44767. * instability during the light setup or during light position changes.
  44768. *
  44769. * Only valid if useContactHardeningShadow is true.
  44770. */
  44771. /**
  44772. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  44773. * Using a ratio helps keeping shape stability independently of the map size.
  44774. *
  44775. * It does not account for the light projection as it was having too much
  44776. * instability during the light setup or during light position changes.
  44777. *
  44778. * Only valid if useContactHardeningShadow is true.
  44779. */
  44780. contactHardeningLightSizeUVRatio: number;
  44781. private _darkness;
  44782. /**
  44783. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  44784. * 0 means strongest and 1 would means no shadow.
  44785. * @returns the darkness.
  44786. */
  44787. getDarkness(): number;
  44788. /**
  44789. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  44790. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  44791. * @returns the shadow generator allowing fluent coding.
  44792. */
  44793. setDarkness(darkness: number): ShadowGenerator;
  44794. private _transparencyShadow;
  44795. /**
  44796. * Sets the ability to have transparent shadow (boolean).
  44797. * @param transparent True if transparent else False
  44798. * @returns the shadow generator allowing fluent coding
  44799. */
  44800. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  44801. private _shadowMap;
  44802. private _shadowMap2;
  44803. /**
  44804. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  44805. * @returns The render target texture if present otherwise, null
  44806. */
  44807. getShadowMap(): Nullable<RenderTargetTexture>;
  44808. /**
  44809. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  44810. * @returns The render target texture if the shadow map is present otherwise, null
  44811. */
  44812. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  44813. /**
  44814. * Helper function to add a mesh and its descendants to the list of shadow casters.
  44815. * @param mesh Mesh to add
  44816. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  44817. * @returns the Shadow Generator itself
  44818. */
  44819. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  44820. /**
  44821. * Helper function to remove a mesh and its descendants from the list of shadow casters
  44822. * @param mesh Mesh to remove
  44823. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  44824. * @returns the Shadow Generator itself
  44825. */
  44826. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  44827. /**
  44828. * Controls the extent to which the shadows fade out at the edge of the frustum
  44829. * Used only by directionals and spots
  44830. */
  44831. frustumEdgeFalloff: number;
  44832. private _light;
  44833. /**
  44834. * Returns the associated light object.
  44835. * @returns the light generating the shadow
  44836. */
  44837. getLight(): IShadowLight;
  44838. /**
  44839. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  44840. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  44841. * It might on the other hand introduce peter panning.
  44842. */
  44843. forceBackFacesOnly: boolean;
  44844. private _scene;
  44845. private _lightDirection;
  44846. private _effect;
  44847. private _viewMatrix;
  44848. private _projectionMatrix;
  44849. private _transformMatrix;
  44850. private _cachedPosition;
  44851. private _cachedDirection;
  44852. private _cachedDefines;
  44853. private _currentRenderID;
  44854. private _boxBlurPostprocess;
  44855. private _kernelBlurXPostprocess;
  44856. private _kernelBlurYPostprocess;
  44857. private _blurPostProcesses;
  44858. private _mapSize;
  44859. private _currentFaceIndex;
  44860. private _currentFaceIndexCache;
  44861. private _textureType;
  44862. private _defaultTextureMatrix;
  44863. /**
  44864. * Creates a ShadowGenerator object.
  44865. * A ShadowGenerator is the required tool to use the shadows.
  44866. * Each light casting shadows needs to use its own ShadowGenerator.
  44867. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  44868. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  44869. * @param light The light object generating the shadows.
  44870. * @param usefulFloatFirst By default the generator will try to use half float textures but if you need precision (for self shadowing for instance), you can use this option to enforce full float texture.
  44871. */
  44872. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  44873. private _initializeGenerator;
  44874. private _initializeShadowMap;
  44875. private _initializeBlurRTTAndPostProcesses;
  44876. private _renderForShadowMap;
  44877. private _renderSubMeshForShadowMap;
  44878. private _applyFilterValues;
  44879. /**
  44880. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  44881. * @param onCompiled Callback triggered at the and of the effects compilation
  44882. * @param options Sets of optional options forcing the compilation with different modes
  44883. */
  44884. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  44885. useInstances: boolean;
  44886. }>): void;
  44887. /**
  44888. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  44889. * @param options Sets of optional options forcing the compilation with different modes
  44890. * @returns A promise that resolves when the compilation completes
  44891. */
  44892. forceCompilationAsync(options?: Partial<{
  44893. useInstances: boolean;
  44894. }>): Promise<void>;
  44895. /**
  44896. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  44897. * @param subMesh The submesh we want to render in the shadow map
  44898. * @param useInstances Defines wether will draw in the map using instances
  44899. * @returns true if ready otherwise, false
  44900. */
  44901. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  44902. /**
  44903. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  44904. * @param defines Defines of the material we want to update
  44905. * @param lightIndex Index of the light in the enabled light list of the material
  44906. */
  44907. prepareDefines(defines: any, lightIndex: number): void;
  44908. /**
  44909. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  44910. * defined in the generator but impacting the effect).
  44911. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  44912. * @param effect The effect we are binfing the information for
  44913. */
  44914. bindShadowLight(lightIndex: string, effect: Effect): void;
  44915. /**
  44916. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  44917. * (eq to shadow prjection matrix * light transform matrix)
  44918. * @returns The transform matrix used to create the shadow map
  44919. */
  44920. getTransformMatrix(): Matrix;
  44921. /**
  44922. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  44923. * Cube and 2D textures for instance.
  44924. */
  44925. recreateShadowMap(): void;
  44926. private _disposeBlurPostProcesses;
  44927. private _disposeRTTandPostProcesses;
  44928. /**
  44929. * Disposes the ShadowGenerator.
  44930. * Returns nothing.
  44931. */
  44932. dispose(): void;
  44933. /**
  44934. * Serializes the shadow generator setup to a json object.
  44935. * @returns The serialized JSON object
  44936. */
  44937. serialize(): any;
  44938. /**
  44939. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  44940. * @param parsedShadowGenerator The JSON object to parse
  44941. * @param scene The scene to create the shadow map for
  44942. * @returns The parsed shadow generator
  44943. */
  44944. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  44945. }
  44946. }
  44947. declare module BABYLON {
  44948. /**
  44949. * Defines the shadow generator component responsible to manage any shadow generators
  44950. * in a given scene.
  44951. */
  44952. class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  44953. /**
  44954. * The component name helpfull to identify the component in the list of scene components.
  44955. */
  44956. readonly name: string;
  44957. /**
  44958. * The scene the component belongs to.
  44959. */
  44960. scene: Scene;
  44961. /**
  44962. * Creates a new instance of the component for the given scene
  44963. * @param scene Defines the scene to register the component in
  44964. */
  44965. constructor(scene: Scene);
  44966. /**
  44967. * Registers the component in a given scene
  44968. */
  44969. register(): void;
  44970. /**
  44971. * Rebuilds the elements related to this component in case of
  44972. * context lost for instance.
  44973. */
  44974. rebuild(): void;
  44975. /**
  44976. * Serializes the component data to the specified json object
  44977. * @param serializationObject The object to serialize to
  44978. */
  44979. serialize(serializationObject: any): void;
  44980. /**
  44981. * Adds all the element from the container to the scene
  44982. * @param container the container holding the elements
  44983. */
  44984. addFromContainer(container: AbstractScene): void;
  44985. /**
  44986. * Removes all the elements in the container from the scene
  44987. * @param container contains the elements to remove
  44988. */
  44989. removeFromContainer(container: AbstractScene): void;
  44990. /**
  44991. * Rebuilds the elements related to this component in case of
  44992. * context lost for instance.
  44993. */
  44994. dispose(): void;
  44995. private _gatherRenderTargets;
  44996. }
  44997. }
  44998. declare module BABYLON {
  44999. /**
  45000. * Background material used to create an efficient environement around your scene.
  45001. */
  45002. class BackgroundMaterial extends PushMaterial {
  45003. /**
  45004. * Standard reflectance value at parallel view angle.
  45005. */
  45006. static StandardReflectance0: number;
  45007. /**
  45008. * Standard reflectance value at grazing angle.
  45009. */
  45010. static StandardReflectance90: number;
  45011. protected _primaryColor: Color3;
  45012. /**
  45013. * Key light Color (multiply against the environement texture)
  45014. */
  45015. primaryColor: Color3;
  45016. protected __perceptualColor: Nullable<Color3>;
  45017. /**
  45018. * Experimental Internal Use Only.
  45019. *
  45020. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  45021. * This acts as a helper to set the primary color to a more "human friendly" value.
  45022. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  45023. * output color as close as possible from the chosen value.
  45024. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  45025. * part of lighting setup.)
  45026. */
  45027. _perceptualColor: Nullable<Color3>;
  45028. protected _primaryColorShadowLevel: float;
  45029. /**
  45030. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  45031. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  45032. */
  45033. primaryColorShadowLevel: float;
  45034. protected _primaryColorHighlightLevel: float;
  45035. /**
  45036. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  45037. * The primary color is used at the level chosen to define what the white area would look.
  45038. */
  45039. primaryColorHighlightLevel: float;
  45040. protected _reflectionTexture: Nullable<BaseTexture>;
  45041. /**
  45042. * Reflection Texture used in the material.
  45043. * Should be author in a specific way for the best result (refer to the documentation).
  45044. */
  45045. reflectionTexture: Nullable<BaseTexture>;
  45046. protected _reflectionBlur: float;
  45047. /**
  45048. * Reflection Texture level of blur.
  45049. *
  45050. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  45051. * texture twice.
  45052. */
  45053. reflectionBlur: float;
  45054. protected _diffuseTexture: Nullable<BaseTexture>;
  45055. /**
  45056. * Diffuse Texture used in the material.
  45057. * Should be author in a specific way for the best result (refer to the documentation).
  45058. */
  45059. diffuseTexture: Nullable<BaseTexture>;
  45060. protected _shadowLights: Nullable<IShadowLight[]>;
  45061. /**
  45062. * Specify the list of lights casting shadow on the material.
  45063. * All scene shadow lights will be included if null.
  45064. */
  45065. shadowLights: Nullable<IShadowLight[]>;
  45066. protected _shadowLevel: float;
  45067. /**
  45068. * Helps adjusting the shadow to a softer level if required.
  45069. * 0 means black shadows and 1 means no shadows.
  45070. */
  45071. shadowLevel: float;
  45072. protected _sceneCenter: Vector3;
  45073. /**
  45074. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  45075. * It is usually zero but might be interesting to modify according to your setup.
  45076. */
  45077. sceneCenter: Vector3;
  45078. protected _opacityFresnel: boolean;
  45079. /**
  45080. * This helps specifying that the material is falling off to the sky box at grazing angle.
  45081. * This helps ensuring a nice transition when the camera goes under the ground.
  45082. */
  45083. opacityFresnel: boolean;
  45084. protected _reflectionFresnel: boolean;
  45085. /**
  45086. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  45087. * This helps adding a mirror texture on the ground.
  45088. */
  45089. reflectionFresnel: boolean;
  45090. protected _reflectionFalloffDistance: number;
  45091. /**
  45092. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  45093. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  45094. */
  45095. reflectionFalloffDistance: number;
  45096. protected _reflectionAmount: number;
  45097. /**
  45098. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  45099. */
  45100. reflectionAmount: number;
  45101. protected _reflectionReflectance0: number;
  45102. /**
  45103. * This specifies the weight of the reflection at grazing angle.
  45104. */
  45105. reflectionReflectance0: number;
  45106. protected _reflectionReflectance90: number;
  45107. /**
  45108. * This specifies the weight of the reflection at a perpendicular point of view.
  45109. */
  45110. reflectionReflectance90: number;
  45111. /**
  45112. * Sets the reflection reflectance fresnel values according to the default standard
  45113. * empirically know to work well :-)
  45114. */
  45115. reflectionStandardFresnelWeight: number;
  45116. protected _useRGBColor: boolean;
  45117. /**
  45118. * Helps to directly use the maps channels instead of their level.
  45119. */
  45120. useRGBColor: boolean;
  45121. protected _enableNoise: boolean;
  45122. /**
  45123. * This helps reducing the banding effect that could occur on the background.
  45124. */
  45125. enableNoise: boolean;
  45126. /**
  45127. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45128. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  45129. * Recommended to be keep at 1.0 except for special cases.
  45130. */
  45131. fovMultiplier: number;
  45132. private _fovMultiplier;
  45133. /**
  45134. * Enable the FOV adjustment feature controlled by fovMultiplier.
  45135. */
  45136. useEquirectangularFOV: boolean;
  45137. private _maxSimultaneousLights;
  45138. /**
  45139. * Number of Simultaneous lights allowed on the material.
  45140. */
  45141. maxSimultaneousLights: int;
  45142. /**
  45143. * Default configuration related to image processing available in the Background Material.
  45144. */
  45145. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45146. /**
  45147. * Keep track of the image processing observer to allow dispose and replace.
  45148. */
  45149. private _imageProcessingObserver;
  45150. /**
  45151. * Attaches a new image processing configuration to the PBR Material.
  45152. * @param configuration (if null the scene configuration will be use)
  45153. */
  45154. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45155. /**
  45156. * Gets the image processing configuration used either in this material.
  45157. */
  45158. /**
  45159. * Sets the Default image processing configuration used either in the this material.
  45160. *
  45161. * If sets to null, the scene one is in use.
  45162. */
  45163. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  45164. /**
  45165. * Gets wether the color curves effect is enabled.
  45166. */
  45167. /**
  45168. * Sets wether the color curves effect is enabled.
  45169. */
  45170. cameraColorCurvesEnabled: boolean;
  45171. /**
  45172. * Gets wether the color grading effect is enabled.
  45173. */
  45174. /**
  45175. * Gets wether the color grading effect is enabled.
  45176. */
  45177. cameraColorGradingEnabled: boolean;
  45178. /**
  45179. * Gets wether tonemapping is enabled or not.
  45180. */
  45181. /**
  45182. * Sets wether tonemapping is enabled or not
  45183. */
  45184. cameraToneMappingEnabled: boolean;
  45185. /**
  45186. * The camera exposure used on this material.
  45187. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45188. * This corresponds to a photographic exposure.
  45189. */
  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. cameraExposure: float;
  45196. /**
  45197. * Gets The camera contrast used on this material.
  45198. */
  45199. /**
  45200. * Sets The camera contrast used on this material.
  45201. */
  45202. cameraContrast: float;
  45203. /**
  45204. * Gets the Color Grading 2D Lookup Texture.
  45205. */
  45206. /**
  45207. * Sets the Color Grading 2D Lookup Texture.
  45208. */
  45209. cameraColorGradingTexture: Nullable<BaseTexture>;
  45210. /**
  45211. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45212. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45213. * 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;
  45214. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45215. */
  45216. /**
  45217. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45218. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45219. * 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;
  45220. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45221. */
  45222. cameraColorCurves: Nullable<ColorCurves>;
  45223. /**
  45224. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  45225. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  45226. */
  45227. switchToBGR: boolean;
  45228. private _renderTargets;
  45229. private _reflectionControls;
  45230. private _white;
  45231. private _primaryShadowColor;
  45232. private _primaryHighlightColor;
  45233. /**
  45234. * Instantiates a Background Material in the given scene
  45235. * @param name The friendly name of the material
  45236. * @param scene The scene to add the material to
  45237. */
  45238. constructor(name: string, scene: Scene);
  45239. /**
  45240. * Gets a boolean indicating that current material needs to register RTT
  45241. */
  45242. readonly hasRenderTargetTextures: boolean;
  45243. /**
  45244. * The entire material has been created in order to prevent overdraw.
  45245. * @returns false
  45246. */
  45247. needAlphaTesting(): boolean;
  45248. /**
  45249. * The entire material has been created in order to prevent overdraw.
  45250. * @returns true if blending is enable
  45251. */
  45252. needAlphaBlending(): boolean;
  45253. /**
  45254. * Checks wether the material is ready to be rendered for a given mesh.
  45255. * @param mesh The mesh to render
  45256. * @param subMesh The submesh to check against
  45257. * @param useInstances Specify wether or not the material is used with instances
  45258. * @returns true if all the dependencies are ready (Textures, Effects...)
  45259. */
  45260. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45261. /**
  45262. * Compute the primary color according to the chosen perceptual color.
  45263. */
  45264. private _computePrimaryColorFromPerceptualColor;
  45265. /**
  45266. * Compute the highlights and shadow colors according to their chosen levels.
  45267. */
  45268. private _computePrimaryColors;
  45269. /**
  45270. * Build the uniform buffer used in the material.
  45271. */
  45272. buildUniformLayout(): void;
  45273. /**
  45274. * Unbind the material.
  45275. */
  45276. unbind(): void;
  45277. /**
  45278. * Bind only the world matrix to the material.
  45279. * @param world The world matrix to bind.
  45280. */
  45281. bindOnlyWorldMatrix(world: Matrix): void;
  45282. /**
  45283. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  45284. * @param world The world matrix to bind.
  45285. * @param subMesh The submesh to bind for.
  45286. */
  45287. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45288. /**
  45289. * Dispose the material.
  45290. * @param forceDisposeEffect Force disposal of the associated effect.
  45291. * @param forceDisposeTextures Force disposal of the associated textures.
  45292. */
  45293. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45294. /**
  45295. * Clones the material.
  45296. * @param name The cloned name.
  45297. * @returns The cloned material.
  45298. */
  45299. clone(name: string): BackgroundMaterial;
  45300. /**
  45301. * Serializes the current material to its JSON representation.
  45302. * @returns The JSON representation.
  45303. */
  45304. serialize(): any;
  45305. /**
  45306. * Gets the class name of the material
  45307. * @returns "BackgroundMaterial"
  45308. */
  45309. getClassName(): string;
  45310. /**
  45311. * Parse a JSON input to create back a background material.
  45312. * @param source The JSON data to parse
  45313. * @param scene The scene to create the parsed material in
  45314. * @param rootUrl The root url of the assets the material depends upon
  45315. * @returns the instantiated BackgroundMaterial.
  45316. */
  45317. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  45318. }
  45319. }
  45320. declare module BABYLON {
  45321. /**
  45322. * The Physically based material base class of BJS.
  45323. *
  45324. * This offers the main features of a standard PBR material.
  45325. * For more information, please refer to the documentation :
  45326. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  45327. */
  45328. abstract class PBRBaseMaterial extends PushMaterial {
  45329. /**
  45330. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  45331. */
  45332. static readonly LIGHTFALLOFF_PHYSICAL: number;
  45333. /**
  45334. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  45335. * to enhance interoperability with other engines.
  45336. */
  45337. static readonly LIGHTFALLOFF_GLTF: number;
  45338. /**
  45339. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  45340. * to enhance interoperability with other materials.
  45341. */
  45342. static readonly LIGHTFALLOFF_STANDARD: number;
  45343. /**
  45344. * Intensity of the direct lights e.g. the four lights available in your scene.
  45345. * This impacts both the direct diffuse and specular highlights.
  45346. */
  45347. protected _directIntensity: number;
  45348. /**
  45349. * Intensity of the emissive part of the material.
  45350. * This helps controlling the emissive effect without modifying the emissive color.
  45351. */
  45352. protected _emissiveIntensity: number;
  45353. /**
  45354. * Intensity of the environment e.g. how much the environment will light the object
  45355. * either through harmonics for rough material or through the refelction for shiny ones.
  45356. */
  45357. protected _environmentIntensity: number;
  45358. /**
  45359. * This is a special control allowing the reduction of the specular highlights coming from the
  45360. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45361. */
  45362. protected _specularIntensity: number;
  45363. /**
  45364. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  45365. */
  45366. private _lightingInfos;
  45367. /**
  45368. * Debug Control allowing disabling the bump map on this material.
  45369. */
  45370. protected _disableBumpMap: boolean;
  45371. /**
  45372. * AKA Diffuse Texture in standard nomenclature.
  45373. */
  45374. protected _albedoTexture: BaseTexture;
  45375. /**
  45376. * AKA Occlusion Texture in other nomenclature.
  45377. */
  45378. protected _ambientTexture: BaseTexture;
  45379. /**
  45380. * AKA Occlusion Texture Intensity in other nomenclature.
  45381. */
  45382. protected _ambientTextureStrength: number;
  45383. /**
  45384. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45385. * 1 means it completely occludes it
  45386. * 0 mean it has no impact
  45387. */
  45388. protected _ambientTextureImpactOnAnalyticalLights: number;
  45389. /**
  45390. * Stores the alpha values in a texture.
  45391. */
  45392. protected _opacityTexture: BaseTexture;
  45393. /**
  45394. * Stores the reflection values in a texture.
  45395. */
  45396. protected _reflectionTexture: BaseTexture;
  45397. /**
  45398. * Stores the refraction values in a texture.
  45399. */
  45400. protected _refractionTexture: BaseTexture;
  45401. /**
  45402. * Stores the emissive values in a texture.
  45403. */
  45404. protected _emissiveTexture: BaseTexture;
  45405. /**
  45406. * AKA Specular texture in other nomenclature.
  45407. */
  45408. protected _reflectivityTexture: BaseTexture;
  45409. /**
  45410. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45411. */
  45412. protected _metallicTexture: BaseTexture;
  45413. /**
  45414. * Specifies the metallic scalar of the metallic/roughness workflow.
  45415. * Can also be used to scale the metalness values of the metallic texture.
  45416. */
  45417. protected _metallic: Nullable<number>;
  45418. /**
  45419. * Specifies the roughness scalar of the metallic/roughness workflow.
  45420. * Can also be used to scale the roughness values of the metallic texture.
  45421. */
  45422. protected _roughness: Nullable<number>;
  45423. /**
  45424. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45425. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45426. */
  45427. protected _microSurfaceTexture: BaseTexture;
  45428. /**
  45429. * Stores surface normal data used to displace a mesh in a texture.
  45430. */
  45431. protected _bumpTexture: BaseTexture;
  45432. /**
  45433. * Stores the pre-calculated light information of a mesh in a texture.
  45434. */
  45435. protected _lightmapTexture: BaseTexture;
  45436. /**
  45437. * The color of a material in ambient lighting.
  45438. */
  45439. protected _ambientColor: Color3;
  45440. /**
  45441. * AKA Diffuse Color in other nomenclature.
  45442. */
  45443. protected _albedoColor: Color3;
  45444. /**
  45445. * AKA Specular Color in other nomenclature.
  45446. */
  45447. protected _reflectivityColor: Color3;
  45448. /**
  45449. * The color applied when light is reflected from a material.
  45450. */
  45451. protected _reflectionColor: Color3;
  45452. /**
  45453. * The color applied when light is emitted from a material.
  45454. */
  45455. protected _emissiveColor: Color3;
  45456. /**
  45457. * AKA Glossiness in other nomenclature.
  45458. */
  45459. protected _microSurface: number;
  45460. /**
  45461. * source material index of refraction (IOR)' / 'destination material IOR.
  45462. */
  45463. protected _indexOfRefraction: number;
  45464. /**
  45465. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45466. */
  45467. protected _invertRefractionY: boolean;
  45468. /**
  45469. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45470. * Materials half opaque for instance using refraction could benefit from this control.
  45471. */
  45472. protected _linkRefractionWithTransparency: boolean;
  45473. /**
  45474. * Specifies that the material will use the light map as a show map.
  45475. */
  45476. protected _useLightmapAsShadowmap: boolean;
  45477. /**
  45478. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45479. * makes the reflect vector face the model (under horizon).
  45480. */
  45481. protected _useHorizonOcclusion: boolean;
  45482. /**
  45483. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45484. * too much the area relying on ambient texture to define their ambient occlusion.
  45485. */
  45486. protected _useRadianceOcclusion: boolean;
  45487. /**
  45488. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45489. */
  45490. protected _useAlphaFromAlbedoTexture: boolean;
  45491. /**
  45492. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  45493. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45494. */
  45495. protected _useSpecularOverAlpha: boolean;
  45496. /**
  45497. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45498. */
  45499. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45500. /**
  45501. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45502. */
  45503. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  45504. /**
  45505. * Specifies if the metallic texture contains the roughness information in its green channel.
  45506. */
  45507. protected _useRoughnessFromMetallicTextureGreen: boolean;
  45508. /**
  45509. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45510. */
  45511. protected _useMetallnessFromMetallicTextureBlue: boolean;
  45512. /**
  45513. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45514. */
  45515. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  45516. /**
  45517. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45518. */
  45519. protected _useAmbientInGrayScale: boolean;
  45520. /**
  45521. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45522. * The material will try to infer what glossiness each pixel should be.
  45523. */
  45524. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  45525. /**
  45526. * Defines the falloff type used in this material.
  45527. * It by default is Physical.
  45528. */
  45529. protected _lightFalloff: number;
  45530. /**
  45531. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45532. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45533. */
  45534. protected _useRadianceOverAlpha: boolean;
  45535. /**
  45536. * Allows using an object space normal map (instead of tangent space).
  45537. */
  45538. protected _useObjectSpaceNormalMap: boolean;
  45539. /**
  45540. * Allows using the bump map in parallax mode.
  45541. */
  45542. protected _useParallax: boolean;
  45543. /**
  45544. * Allows using the bump map in parallax occlusion mode.
  45545. */
  45546. protected _useParallaxOcclusion: boolean;
  45547. /**
  45548. * Controls the scale bias of the parallax mode.
  45549. */
  45550. protected _parallaxScaleBias: number;
  45551. /**
  45552. * If sets to true, disables all the lights affecting the material.
  45553. */
  45554. protected _disableLighting: boolean;
  45555. /**
  45556. * Number of Simultaneous lights allowed on the material.
  45557. */
  45558. protected _maxSimultaneousLights: number;
  45559. /**
  45560. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45561. */
  45562. protected _invertNormalMapX: boolean;
  45563. /**
  45564. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45565. */
  45566. protected _invertNormalMapY: boolean;
  45567. /**
  45568. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45569. */
  45570. protected _twoSidedLighting: boolean;
  45571. /**
  45572. * Defines the alpha limits in alpha test mode.
  45573. */
  45574. protected _alphaCutOff: number;
  45575. /**
  45576. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45577. */
  45578. protected _forceAlphaTest: boolean;
  45579. /**
  45580. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45581. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45582. */
  45583. protected _useAlphaFresnel: 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 stays linear to compute the fresnel)
  45587. */
  45588. protected _useLinearAlphaFresnel: boolean;
  45589. /**
  45590. * The transparency mode of the material.
  45591. */
  45592. protected _transparencyMode: Nullable<number>;
  45593. /**
  45594. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  45595. * from cos thetav and roughness:
  45596. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  45597. */
  45598. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  45599. /**
  45600. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45601. */
  45602. protected _forceIrradianceInFragment: boolean;
  45603. /**
  45604. * Force normal to face away from face.
  45605. */
  45606. protected _forceNormalForward: boolean;
  45607. /**
  45608. * Enables specular anti aliasing in the PBR shader.
  45609. * It will both interacts on the Geometry for analytical and IBL lighting.
  45610. * It also prefilter the roughness map based on the bump values.
  45611. */
  45612. protected _enableSpecularAntiAliasing: boolean;
  45613. /**
  45614. * Default configuration related to image processing available in the PBR Material.
  45615. */
  45616. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45617. /**
  45618. * Keep track of the image processing observer to allow dispose and replace.
  45619. */
  45620. private _imageProcessingObserver;
  45621. /**
  45622. * Attaches a new image processing configuration to the PBR Material.
  45623. * @param configuration
  45624. */
  45625. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45626. /**
  45627. * Stores the available render targets.
  45628. */
  45629. private _renderTargets;
  45630. /**
  45631. * Sets the global ambient color for the material used in lighting calculations.
  45632. */
  45633. private _globalAmbientColor;
  45634. /**
  45635. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  45636. */
  45637. private _useLogarithmicDepth;
  45638. /**
  45639. * If set to true, no lighting calculations will be applied.
  45640. */
  45641. private _unlit;
  45642. /**
  45643. * Instantiates a new PBRMaterial instance.
  45644. *
  45645. * @param name The material name
  45646. * @param scene The scene the material will be use in.
  45647. */
  45648. constructor(name: string, scene: Scene);
  45649. /**
  45650. * Gets a boolean indicating that current material needs to register RTT
  45651. */
  45652. readonly hasRenderTargetTextures: boolean;
  45653. /**
  45654. * Gets the name of the material class.
  45655. */
  45656. getClassName(): string;
  45657. /**
  45658. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45659. */
  45660. /**
  45661. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45662. */
  45663. useLogarithmicDepth: boolean;
  45664. /**
  45665. * Gets the current transparency mode.
  45666. */
  45667. /**
  45668. * Sets the transparency mode of the material.
  45669. *
  45670. * | Value | Type | Description |
  45671. * | ----- | ----------------------------------- | ----------- |
  45672. * | 0 | OPAQUE | |
  45673. * | 1 | ALPHATEST | |
  45674. * | 2 | ALPHABLEND | |
  45675. * | 3 | ALPHATESTANDBLEND | |
  45676. *
  45677. */
  45678. transparencyMode: Nullable<number>;
  45679. /**
  45680. * Returns true if alpha blending should be disabled.
  45681. */
  45682. private readonly _disableAlphaBlending;
  45683. /**
  45684. * Specifies whether or not this material should be rendered in alpha blend mode.
  45685. */
  45686. needAlphaBlending(): boolean;
  45687. /**
  45688. * Specifies if the mesh will require alpha blending.
  45689. * @param mesh - BJS mesh.
  45690. */
  45691. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  45692. /**
  45693. * Specifies whether or not this material should be rendered in alpha test mode.
  45694. */
  45695. needAlphaTesting(): boolean;
  45696. /**
  45697. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  45698. */
  45699. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  45700. /**
  45701. * Gets the texture used for the alpha test.
  45702. */
  45703. getAlphaTestTexture(): BaseTexture;
  45704. /**
  45705. * Stores the reflectivity values based on metallic roughness workflow.
  45706. */
  45707. private static _scaledReflectivity;
  45708. /**
  45709. * Specifies that the submesh is ready to be used.
  45710. * @param mesh - BJS mesh.
  45711. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  45712. * @param useInstances - Specifies that instances should be used.
  45713. * @returns - boolean indicating that the submesh is ready or not.
  45714. */
  45715. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45716. /**
  45717. * Specifies if the material uses metallic roughness workflow.
  45718. * @returns boolean specifiying if the material uses metallic roughness workflow.
  45719. */
  45720. isMetallicWorkflow(): boolean;
  45721. private _prepareEffect;
  45722. private _prepareDefines;
  45723. /**
  45724. * Force shader compilation
  45725. */
  45726. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  45727. clipPlane: boolean;
  45728. }>): void;
  45729. /**
  45730. * Initializes the uniform buffer layout for the shader.
  45731. */
  45732. buildUniformLayout(): void;
  45733. /**
  45734. * Unbinds the textures.
  45735. */
  45736. unbind(): void;
  45737. /**
  45738. * Binds the submesh data.
  45739. * @param world - The world matrix.
  45740. * @param mesh - The BJS mesh.
  45741. * @param subMesh - A submesh of the BJS mesh.
  45742. */
  45743. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45744. /**
  45745. * Returns the animatable textures.
  45746. * @returns - Array of animatable textures.
  45747. */
  45748. getAnimatables(): IAnimatable[];
  45749. /**
  45750. * Returns the texture used for reflections.
  45751. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  45752. */
  45753. private _getReflectionTexture;
  45754. /**
  45755. * Returns the texture used for refraction or null if none is used.
  45756. * @returns - Refection texture if present. If no refraction texture and refraction
  45757. * is linked with transparency, returns environment texture. Otherwise, returns null.
  45758. */
  45759. private _getRefractionTexture;
  45760. /**
  45761. * Disposes the resources of the material.
  45762. * @param forceDisposeEffect - Forces the disposal of effects.
  45763. * @param forceDisposeTextures - Forces the disposal of all textures.
  45764. */
  45765. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45766. }
  45767. }
  45768. declare module BABYLON {
  45769. /**
  45770. * The Physically based simple base material of BJS.
  45771. *
  45772. * This enables better naming and convention enforcements on top of the pbrMaterial.
  45773. * It is used as the base class for both the specGloss and metalRough conventions.
  45774. */
  45775. abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  45776. /**
  45777. * Number of Simultaneous lights allowed on the material.
  45778. */
  45779. maxSimultaneousLights: number;
  45780. /**
  45781. * If sets to true, disables all the lights affecting the material.
  45782. */
  45783. disableLighting: boolean;
  45784. /**
  45785. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  45786. */
  45787. environmentTexture: BaseTexture;
  45788. /**
  45789. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  45790. */
  45791. invertNormalMapX: boolean;
  45792. /**
  45793. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  45794. */
  45795. invertNormalMapY: boolean;
  45796. /**
  45797. * Normal map used in the model.
  45798. */
  45799. normalTexture: BaseTexture;
  45800. /**
  45801. * Emissivie color used to self-illuminate the model.
  45802. */
  45803. emissiveColor: Color3;
  45804. /**
  45805. * Emissivie texture used to self-illuminate the model.
  45806. */
  45807. emissiveTexture: BaseTexture;
  45808. /**
  45809. * Occlusion Channel Strenght.
  45810. */
  45811. occlusionStrength: number;
  45812. /**
  45813. * Occlusion Texture of the material (adding extra occlusion effects).
  45814. */
  45815. occlusionTexture: BaseTexture;
  45816. /**
  45817. * Defines the alpha limits in alpha test mode.
  45818. */
  45819. alphaCutOff: number;
  45820. /**
  45821. * Gets the current double sided mode.
  45822. */
  45823. /**
  45824. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45825. */
  45826. doubleSided: boolean;
  45827. /**
  45828. * Stores the pre-calculated light information of a mesh in a texture.
  45829. */
  45830. lightmapTexture: BaseTexture;
  45831. /**
  45832. * If true, the light map contains occlusion information instead of lighting info.
  45833. */
  45834. useLightmapAsShadowmap: boolean;
  45835. /**
  45836. * Return the active textures of the material.
  45837. */
  45838. getActiveTextures(): BaseTexture[];
  45839. hasTexture(texture: BaseTexture): boolean;
  45840. /**
  45841. * Instantiates a new PBRMaterial instance.
  45842. *
  45843. * @param name The material name
  45844. * @param scene The scene the material will be use in.
  45845. */
  45846. constructor(name: string, scene: Scene);
  45847. getClassName(): string;
  45848. }
  45849. }
  45850. declare module BABYLON {
  45851. /**
  45852. * The Physically based material of BJS.
  45853. *
  45854. * This offers the main features of a standard PBR material.
  45855. * For more information, please refer to the documentation :
  45856. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  45857. */
  45858. class PBRMaterial extends PBRBaseMaterial {
  45859. /**
  45860. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45861. */
  45862. static readonly PBRMATERIAL_OPAQUE: number;
  45863. /**
  45864. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45865. */
  45866. static readonly PBRMATERIAL_ALPHATEST: number;
  45867. /**
  45868. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45869. */
  45870. static readonly PBRMATERIAL_ALPHABLEND: number;
  45871. /**
  45872. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45873. * They are also discarded below the alpha cutoff threshold to improve performances.
  45874. */
  45875. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45876. /**
  45877. * Defines the default value of how much AO map is occluding the analytical lights
  45878. * (point spot...).
  45879. */
  45880. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45881. /**
  45882. * Intensity of the direct lights e.g. the four lights available in your scene.
  45883. * This impacts both the direct diffuse and specular highlights.
  45884. */
  45885. directIntensity: number;
  45886. /**
  45887. * Intensity of the emissive part of the material.
  45888. * This helps controlling the emissive effect without modifying the emissive color.
  45889. */
  45890. emissiveIntensity: number;
  45891. /**
  45892. * Intensity of the environment e.g. how much the environment will light the object
  45893. * either through harmonics for rough material or through the refelction for shiny ones.
  45894. */
  45895. environmentIntensity: number;
  45896. /**
  45897. * This is a special control allowing the reduction of the specular highlights coming from the
  45898. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45899. */
  45900. specularIntensity: number;
  45901. /**
  45902. * Debug Control allowing disabling the bump map on this material.
  45903. */
  45904. disableBumpMap: boolean;
  45905. /**
  45906. * AKA Diffuse Texture in standard nomenclature.
  45907. */
  45908. albedoTexture: BaseTexture;
  45909. /**
  45910. * AKA Occlusion Texture in other nomenclature.
  45911. */
  45912. ambientTexture: BaseTexture;
  45913. /**
  45914. * AKA Occlusion Texture Intensity in other nomenclature.
  45915. */
  45916. ambientTextureStrength: number;
  45917. /**
  45918. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45919. * 1 means it completely occludes it
  45920. * 0 mean it has no impact
  45921. */
  45922. ambientTextureImpactOnAnalyticalLights: number;
  45923. /**
  45924. * Stores the alpha values in a texture.
  45925. */
  45926. opacityTexture: BaseTexture;
  45927. /**
  45928. * Stores the reflection values in a texture.
  45929. */
  45930. reflectionTexture: Nullable<BaseTexture>;
  45931. /**
  45932. * Stores the emissive values in a texture.
  45933. */
  45934. emissiveTexture: BaseTexture;
  45935. /**
  45936. * AKA Specular texture in other nomenclature.
  45937. */
  45938. reflectivityTexture: BaseTexture;
  45939. /**
  45940. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45941. */
  45942. metallicTexture: BaseTexture;
  45943. /**
  45944. * Specifies the metallic scalar of the metallic/roughness workflow.
  45945. * Can also be used to scale the metalness values of the metallic texture.
  45946. */
  45947. metallic: Nullable<number>;
  45948. /**
  45949. * Specifies the roughness scalar of the metallic/roughness workflow.
  45950. * Can also be used to scale the roughness values of the metallic texture.
  45951. */
  45952. roughness: Nullable<number>;
  45953. /**
  45954. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45955. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45956. */
  45957. microSurfaceTexture: BaseTexture;
  45958. /**
  45959. * Stores surface normal data used to displace a mesh in a texture.
  45960. */
  45961. bumpTexture: BaseTexture;
  45962. /**
  45963. * Stores the pre-calculated light information of a mesh in a texture.
  45964. */
  45965. lightmapTexture: BaseTexture;
  45966. /**
  45967. * Stores the refracted light information in a texture.
  45968. */
  45969. refractionTexture: BaseTexture;
  45970. /**
  45971. * The color of a material in ambient lighting.
  45972. */
  45973. ambientColor: Color3;
  45974. /**
  45975. * AKA Diffuse Color in other nomenclature.
  45976. */
  45977. albedoColor: Color3;
  45978. /**
  45979. * AKA Specular Color in other nomenclature.
  45980. */
  45981. reflectivityColor: Color3;
  45982. /**
  45983. * The color reflected from the material.
  45984. */
  45985. reflectionColor: Color3;
  45986. /**
  45987. * The color emitted from the material.
  45988. */
  45989. emissiveColor: Color3;
  45990. /**
  45991. * AKA Glossiness in other nomenclature.
  45992. */
  45993. microSurface: number;
  45994. /**
  45995. * source material index of refraction (IOR)' / 'destination material IOR.
  45996. */
  45997. indexOfRefraction: number;
  45998. /**
  45999. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  46000. */
  46001. invertRefractionY: boolean;
  46002. /**
  46003. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  46004. * Materials half opaque for instance using refraction could benefit from this control.
  46005. */
  46006. linkRefractionWithTransparency: boolean;
  46007. /**
  46008. * If true, the light map contains occlusion information instead of lighting info.
  46009. */
  46010. useLightmapAsShadowmap: boolean;
  46011. /**
  46012. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  46013. */
  46014. useAlphaFromAlbedoTexture: boolean;
  46015. /**
  46016. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  46017. */
  46018. forceAlphaTest: boolean;
  46019. /**
  46020. * Defines the alpha limits in alpha test mode.
  46021. */
  46022. alphaCutOff: number;
  46023. /**
  46024. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  46025. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  46026. */
  46027. useSpecularOverAlpha: boolean;
  46028. /**
  46029. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  46030. */
  46031. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  46032. /**
  46033. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  46034. */
  46035. useRoughnessFromMetallicTextureAlpha: boolean;
  46036. /**
  46037. * Specifies if the metallic texture contains the roughness information in its green channel.
  46038. */
  46039. useRoughnessFromMetallicTextureGreen: boolean;
  46040. /**
  46041. * Specifies if the metallic texture contains the metallness information in its blue channel.
  46042. */
  46043. useMetallnessFromMetallicTextureBlue: boolean;
  46044. /**
  46045. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  46046. */
  46047. useAmbientOcclusionFromMetallicTextureRed: boolean;
  46048. /**
  46049. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  46050. */
  46051. useAmbientInGrayScale: boolean;
  46052. /**
  46053. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  46054. * The material will try to infer what glossiness each pixel should be.
  46055. */
  46056. useAutoMicroSurfaceFromReflectivityMap: boolean;
  46057. /**
  46058. * BJS is using an harcoded light falloff based on a manually sets up range.
  46059. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  46060. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  46061. */
  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. usePhysicalLightFalloff: boolean;
  46068. /**
  46069. * In order to support the falloff compatibility with gltf, a special mode has been added
  46070. * to reproduce the gltf light falloff.
  46071. */
  46072. /**
  46073. * In order to support the falloff compatibility with gltf, a special mode has been added
  46074. * to reproduce the gltf light falloff.
  46075. */
  46076. useGLTFLightFalloff: boolean;
  46077. /**
  46078. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  46079. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  46080. */
  46081. useRadianceOverAlpha: boolean;
  46082. /**
  46083. * Allows using an object space normal map (instead of tangent space).
  46084. */
  46085. useObjectSpaceNormalMap: boolean;
  46086. /**
  46087. * Allows using the bump map in parallax mode.
  46088. */
  46089. useParallax: boolean;
  46090. /**
  46091. * Allows using the bump map in parallax occlusion mode.
  46092. */
  46093. useParallaxOcclusion: boolean;
  46094. /**
  46095. * Controls the scale bias of the parallax mode.
  46096. */
  46097. parallaxScaleBias: number;
  46098. /**
  46099. * If sets to true, disables all the lights affecting the material.
  46100. */
  46101. disableLighting: boolean;
  46102. /**
  46103. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  46104. */
  46105. forceIrradianceInFragment: boolean;
  46106. /**
  46107. * Number of Simultaneous lights allowed on the material.
  46108. */
  46109. maxSimultaneousLights: number;
  46110. /**
  46111. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  46112. */
  46113. invertNormalMapX: boolean;
  46114. /**
  46115. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  46116. */
  46117. invertNormalMapY: boolean;
  46118. /**
  46119. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  46120. */
  46121. twoSidedLighting: boolean;
  46122. /**
  46123. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46124. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  46125. */
  46126. useAlphaFresnel: 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 stays linear to compute the fresnel)
  46130. */
  46131. useLinearAlphaFresnel: 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.
  46135. */
  46136. environmentBRDFTexture: Nullable<BaseTexture>;
  46137. /**
  46138. * Force normal to face away from face.
  46139. */
  46140. forceNormalForward: boolean;
  46141. /**
  46142. * Enables specular anti aliasing in the PBR shader.
  46143. * It will both interacts on the Geometry for analytical and IBL lighting.
  46144. * It also prefilter the roughness map based on the bump values.
  46145. */
  46146. enableSpecularAntiAliasing: boolean;
  46147. /**
  46148. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  46149. * makes the reflect vector face the model (under horizon).
  46150. */
  46151. useHorizonOcclusion: boolean;
  46152. /**
  46153. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  46154. * too much the area relying on ambient texture to define their ambient occlusion.
  46155. */
  46156. useRadianceOcclusion: boolean;
  46157. /**
  46158. * If set to true, no lighting calculations will be applied.
  46159. */
  46160. unlit: boolean;
  46161. /**
  46162. * Gets the image processing configuration used either in this material.
  46163. */
  46164. /**
  46165. * Sets the Default image processing configuration used either in the this material.
  46166. *
  46167. * If sets to null, the scene one is in use.
  46168. */
  46169. imageProcessingConfiguration: ImageProcessingConfiguration;
  46170. /**
  46171. * Gets wether the color curves effect is enabled.
  46172. */
  46173. /**
  46174. * Sets wether the color curves effect is enabled.
  46175. */
  46176. cameraColorCurvesEnabled: boolean;
  46177. /**
  46178. * Gets wether the color grading effect is enabled.
  46179. */
  46180. /**
  46181. * Gets wether the color grading effect is enabled.
  46182. */
  46183. cameraColorGradingEnabled: boolean;
  46184. /**
  46185. * Gets wether tonemapping is enabled or not.
  46186. */
  46187. /**
  46188. * Sets wether tonemapping is enabled or not
  46189. */
  46190. cameraToneMappingEnabled: boolean;
  46191. /**
  46192. * The camera exposure used on this material.
  46193. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46194. * This corresponds to a photographic exposure.
  46195. */
  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. cameraExposure: number;
  46202. /**
  46203. * Gets The camera contrast used on this material.
  46204. */
  46205. /**
  46206. * Sets The camera contrast used on this material.
  46207. */
  46208. cameraContrast: number;
  46209. /**
  46210. * Gets the Color Grading 2D Lookup Texture.
  46211. */
  46212. /**
  46213. * Sets the Color Grading 2D Lookup Texture.
  46214. */
  46215. cameraColorGradingTexture: Nullable<BaseTexture>;
  46216. /**
  46217. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46218. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46219. * 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;
  46220. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46221. */
  46222. /**
  46223. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46224. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46225. * 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;
  46226. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46227. */
  46228. cameraColorCurves: Nullable<ColorCurves>;
  46229. /**
  46230. * Instantiates a new PBRMaterial instance.
  46231. *
  46232. * @param name The material name
  46233. * @param scene The scene the material will be use in.
  46234. */
  46235. constructor(name: string, scene: Scene);
  46236. /**
  46237. * Returns the name of this material class.
  46238. */
  46239. getClassName(): string;
  46240. /**
  46241. * Returns an array of the actively used textures.
  46242. * @returns - Array of BaseTextures
  46243. */
  46244. getActiveTextures(): BaseTexture[];
  46245. /**
  46246. * Checks to see if a texture is used in the material.
  46247. * @param texture - Base texture to use.
  46248. * @returns - Boolean specifying if a texture is used in the material.
  46249. */
  46250. hasTexture(texture: BaseTexture): boolean;
  46251. /**
  46252. * Makes a duplicate of the current material.
  46253. * @param name - name to use for the new material.
  46254. */
  46255. clone(name: string): PBRMaterial;
  46256. /**
  46257. * Serializes this PBR Material.
  46258. * @returns - An object with the serialized material.
  46259. */
  46260. serialize(): any;
  46261. /**
  46262. * Parses a PBR Material from a serialized object.
  46263. * @param source - Serialized object.
  46264. * @param scene - BJS scene instance.
  46265. * @param rootUrl - url for the scene object
  46266. * @returns - PBRMaterial
  46267. */
  46268. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  46269. }
  46270. }
  46271. declare module BABYLON {
  46272. /**
  46273. * The PBR material of BJS following the metal roughness convention.
  46274. *
  46275. * This fits to the PBR convention in the GLTF definition:
  46276. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  46277. */
  46278. class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  46279. /**
  46280. * The base color has two different interpretations depending on the value of metalness.
  46281. * When the material is a metal, the base color is the specific measured reflectance value
  46282. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  46283. * of the material.
  46284. */
  46285. baseColor: Color3;
  46286. /**
  46287. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  46288. * well as opacity information in the alpha channel.
  46289. */
  46290. baseTexture: BaseTexture;
  46291. /**
  46292. * Specifies the metallic scalar value of the material.
  46293. * Can also be used to scale the metalness values of the metallic texture.
  46294. */
  46295. metallic: number;
  46296. /**
  46297. * Specifies the roughness scalar value of the material.
  46298. * Can also be used to scale the roughness values of the metallic texture.
  46299. */
  46300. roughness: number;
  46301. /**
  46302. * Texture containing both the metallic value in the B channel and the
  46303. * roughness value in the G channel to keep better precision.
  46304. */
  46305. metallicRoughnessTexture: BaseTexture;
  46306. /**
  46307. * Instantiates a new PBRMetalRoughnessMaterial instance.
  46308. *
  46309. * @param name The material name
  46310. * @param scene The scene the material will be use in.
  46311. */
  46312. constructor(name: string, scene: Scene);
  46313. /**
  46314. * Return the currrent class name of the material.
  46315. */
  46316. getClassName(): string;
  46317. /**
  46318. * Return the active textures of the material.
  46319. */
  46320. getActiveTextures(): BaseTexture[];
  46321. /**
  46322. * Checks to see if a texture is used in the material.
  46323. * @param texture - Base texture to use.
  46324. * @returns - Boolean specifying if a texture is used in the material.
  46325. */
  46326. hasTexture(texture: BaseTexture): boolean;
  46327. /**
  46328. * Makes a duplicate of the current material.
  46329. * @param name - name to use for the new material.
  46330. */
  46331. clone(name: string): PBRMetallicRoughnessMaterial;
  46332. /**
  46333. * Serialize the material to a parsable JSON object.
  46334. */
  46335. serialize(): any;
  46336. /**
  46337. * Parses a JSON object correponding to the serialize function.
  46338. */
  46339. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  46340. }
  46341. }
  46342. declare module BABYLON {
  46343. /**
  46344. * The PBR material of BJS following the specular glossiness convention.
  46345. *
  46346. * This fits to the PBR convention in the GLTF definition:
  46347. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  46348. */
  46349. class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  46350. /**
  46351. * Specifies the diffuse color of the material.
  46352. */
  46353. diffuseColor: Color3;
  46354. /**
  46355. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  46356. * channel.
  46357. */
  46358. diffuseTexture: BaseTexture;
  46359. /**
  46360. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  46361. */
  46362. specularColor: Color3;
  46363. /**
  46364. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  46365. */
  46366. glossiness: number;
  46367. /**
  46368. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  46369. */
  46370. specularGlossinessTexture: BaseTexture;
  46371. /**
  46372. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  46373. *
  46374. * @param name The material name
  46375. * @param scene The scene the material will be use in.
  46376. */
  46377. constructor(name: string, scene: Scene);
  46378. /**
  46379. * Return the currrent class name of the material.
  46380. */
  46381. getClassName(): string;
  46382. /**
  46383. * Return the active textures of the material.
  46384. */
  46385. getActiveTextures(): BaseTexture[];
  46386. /**
  46387. * Checks to see if a texture is used in the material.
  46388. * @param texture - Base texture to use.
  46389. * @returns - Boolean specifying if a texture is used in the material.
  46390. */
  46391. hasTexture(texture: BaseTexture): boolean;
  46392. /**
  46393. * Makes a duplicate of the current material.
  46394. * @param name - name to use for the new material.
  46395. */
  46396. clone(name: string): PBRSpecularGlossinessMaterial;
  46397. /**
  46398. * Serialize the material to a parsable JSON object.
  46399. */
  46400. serialize(): any;
  46401. /**
  46402. * Parses a JSON object correponding to the serialize function.
  46403. */
  46404. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  46405. }
  46406. }
  46407. declare module BABYLON {
  46408. /**
  46409. * Base class of all the textures in babylon.
  46410. * It groups all the common properties the materials, post process, lights... might need
  46411. * in order to make a correct use of the texture.
  46412. */
  46413. class BaseTexture {
  46414. /**
  46415. * Default anisotropic filtering level for the application.
  46416. * It is set to 4 as a good tradeoff between perf and quality.
  46417. */
  46418. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  46419. /**
  46420. * Gets or sets the unique id of the texture
  46421. */
  46422. uniqueId: number;
  46423. /**
  46424. * Define the name of the texture.
  46425. */
  46426. name: string;
  46427. /**
  46428. * Gets or sets an object used to store user defined information.
  46429. */
  46430. metadata: any;
  46431. /**
  46432. * For internal use only. Please do not use.
  46433. */
  46434. reservedDataStore: any;
  46435. private _hasAlpha;
  46436. /**
  46437. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  46438. */
  46439. hasAlpha: boolean;
  46440. /**
  46441. * Defines if the alpha value should be determined via the rgb values.
  46442. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  46443. */
  46444. getAlphaFromRGB: boolean;
  46445. /**
  46446. * Intensity or strength of the texture.
  46447. * It is commonly used by materials to fine tune the intensity of the texture
  46448. */
  46449. level: number;
  46450. /**
  46451. * Define the UV chanel to use starting from 0 and defaulting to 0.
  46452. * This is part of the texture as textures usually maps to one uv set.
  46453. */
  46454. coordinatesIndex: number;
  46455. private _coordinatesMode;
  46456. /**
  46457. * How a texture is mapped.
  46458. *
  46459. * | Value | Type | Description |
  46460. * | ----- | ----------------------------------- | ----------- |
  46461. * | 0 | EXPLICIT_MODE | |
  46462. * | 1 | SPHERICAL_MODE | |
  46463. * | 2 | PLANAR_MODE | |
  46464. * | 3 | CUBIC_MODE | |
  46465. * | 4 | PROJECTION_MODE | |
  46466. * | 5 | SKYBOX_MODE | |
  46467. * | 6 | INVCUBIC_MODE | |
  46468. * | 7 | EQUIRECTANGULAR_MODE | |
  46469. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  46470. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  46471. */
  46472. coordinatesMode: number;
  46473. /**
  46474. * | Value | Type | Description |
  46475. * | ----- | ------------------ | ----------- |
  46476. * | 0 | CLAMP_ADDRESSMODE | |
  46477. * | 1 | WRAP_ADDRESSMODE | |
  46478. * | 2 | MIRROR_ADDRESSMODE | |
  46479. */
  46480. wrapU: number;
  46481. /**
  46482. * | Value | Type | Description |
  46483. * | ----- | ------------------ | ----------- |
  46484. * | 0 | CLAMP_ADDRESSMODE | |
  46485. * | 1 | WRAP_ADDRESSMODE | |
  46486. * | 2 | MIRROR_ADDRESSMODE | |
  46487. */
  46488. wrapV: number;
  46489. /**
  46490. * | Value | Type | Description |
  46491. * | ----- | ------------------ | ----------- |
  46492. * | 0 | CLAMP_ADDRESSMODE | |
  46493. * | 1 | WRAP_ADDRESSMODE | |
  46494. * | 2 | MIRROR_ADDRESSMODE | |
  46495. */
  46496. wrapR: number;
  46497. /**
  46498. * With compliant hardware and browser (supporting anisotropic filtering)
  46499. * this defines the level of anisotropic filtering in the texture.
  46500. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  46501. */
  46502. anisotropicFilteringLevel: number;
  46503. /**
  46504. * Define if the texture is a cube texture or if false a 2d texture.
  46505. */
  46506. isCube: boolean;
  46507. /**
  46508. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  46509. */
  46510. is3D: boolean;
  46511. /**
  46512. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  46513. * HDR texture are usually stored in linear space.
  46514. * This only impacts the PBR and Background materials
  46515. */
  46516. gammaSpace: boolean;
  46517. /**
  46518. * Gets whether or not the texture contains RGBD data.
  46519. */
  46520. readonly isRGBD: boolean;
  46521. /**
  46522. * Is Z inverted in the texture (useful in a cube texture).
  46523. */
  46524. invertZ: boolean;
  46525. /**
  46526. * Are mip maps generated for this texture or not.
  46527. */
  46528. readonly noMipmap: boolean;
  46529. /**
  46530. * @hidden
  46531. */
  46532. lodLevelInAlpha: boolean;
  46533. /**
  46534. * With prefiltered texture, defined the offset used during the prefiltering steps.
  46535. */
  46536. lodGenerationOffset: number;
  46537. /**
  46538. * With prefiltered texture, defined the scale used during the prefiltering steps.
  46539. */
  46540. lodGenerationScale: number;
  46541. /**
  46542. * Define if the texture is a render target.
  46543. */
  46544. isRenderTarget: boolean;
  46545. /**
  46546. * Define the unique id of the texture in the scene.
  46547. */
  46548. readonly uid: string;
  46549. /**
  46550. * Return a string representation of the texture.
  46551. * @returns the texture as a string
  46552. */
  46553. toString(): string;
  46554. /**
  46555. * Get the class name of the texture.
  46556. * @returns "BaseTexture"
  46557. */
  46558. getClassName(): string;
  46559. /**
  46560. * Define the list of animation attached to the texture.
  46561. */
  46562. animations: Animation[];
  46563. /**
  46564. * An event triggered when the texture is disposed.
  46565. */
  46566. onDisposeObservable: Observable<BaseTexture>;
  46567. private _onDisposeObserver;
  46568. /**
  46569. * Callback triggered when the texture has been disposed.
  46570. * Kept for back compatibility, you can use the onDisposeObservable instead.
  46571. */
  46572. onDispose: () => void;
  46573. /**
  46574. * Define the current state of the loading sequence when in delayed load mode.
  46575. */
  46576. delayLoadState: number;
  46577. private _scene;
  46578. /** @hidden */
  46579. _texture: Nullable<InternalTexture>;
  46580. private _uid;
  46581. /**
  46582. * Define if the texture is preventinga material to render or not.
  46583. * If not and the texture is not ready, the engine will use a default black texture instead.
  46584. */
  46585. readonly isBlocking: boolean;
  46586. /**
  46587. * Instantiates a new BaseTexture.
  46588. * Base class of all the textures in babylon.
  46589. * It groups all the common properties the materials, post process, lights... might need
  46590. * in order to make a correct use of the texture.
  46591. * @param scene Define the scene the texture blongs to
  46592. */
  46593. constructor(scene: Nullable<Scene>);
  46594. /**
  46595. * Get the scene the texture belongs to.
  46596. * @returns the scene or null if undefined
  46597. */
  46598. getScene(): Nullable<Scene>;
  46599. /**
  46600. * Get the texture transform matrix used to offset tile the texture for istance.
  46601. * @returns the transformation matrix
  46602. */
  46603. getTextureMatrix(): Matrix;
  46604. /**
  46605. * Get the texture reflection matrix used to rotate/transform the reflection.
  46606. * @returns the reflection matrix
  46607. */
  46608. getReflectionTextureMatrix(): Matrix;
  46609. /**
  46610. * Get the underlying lower level texture from Babylon.
  46611. * @returns the insternal texture
  46612. */
  46613. getInternalTexture(): Nullable<InternalTexture>;
  46614. /**
  46615. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  46616. * @returns true if ready or not blocking
  46617. */
  46618. isReadyOrNotBlocking(): boolean;
  46619. /**
  46620. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  46621. * @returns true if fully ready
  46622. */
  46623. isReady(): boolean;
  46624. private _cachedSize;
  46625. /**
  46626. * Get the size of the texture.
  46627. * @returns the texture size.
  46628. */
  46629. getSize(): ISize;
  46630. /**
  46631. * Get the base size of the texture.
  46632. * It can be different from the size if the texture has been resized for POT for instance
  46633. * @returns the base size
  46634. */
  46635. getBaseSize(): ISize;
  46636. /**
  46637. * Update the sampling mode of the texture.
  46638. * Default is Trilinear mode.
  46639. *
  46640. * | Value | Type | Description |
  46641. * | ----- | ------------------ | ----------- |
  46642. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  46643. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  46644. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  46645. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  46646. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  46647. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  46648. * | 7 | NEAREST_LINEAR | |
  46649. * | 8 | NEAREST_NEAREST | |
  46650. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  46651. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  46652. * | 11 | LINEAR_LINEAR | |
  46653. * | 12 | LINEAR_NEAREST | |
  46654. *
  46655. * > _mag_: magnification filter (close to the viewer)
  46656. * > _min_: minification filter (far from the viewer)
  46657. * > _mip_: filter used between mip map levels
  46658. *@param samplingMode Define the new sampling mode of the texture
  46659. */
  46660. updateSamplingMode(samplingMode: number): void;
  46661. /**
  46662. * Scales the texture if is `canRescale()`
  46663. * @param ratio the resize factor we want to use to rescale
  46664. */
  46665. scale(ratio: number): void;
  46666. /**
  46667. * Get if the texture can rescale.
  46668. */
  46669. readonly canRescale: boolean;
  46670. /** @hidden */
  46671. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  46672. /** @hidden */
  46673. _rebuild(): void;
  46674. /**
  46675. * Triggers the load sequence in delayed load mode.
  46676. */
  46677. delayLoad(): void;
  46678. /**
  46679. * Clones the texture.
  46680. * @returns the cloned texture
  46681. */
  46682. clone(): Nullable<BaseTexture>;
  46683. /**
  46684. * Get the texture underlying type (INT, FLOAT...)
  46685. */
  46686. readonly textureType: number;
  46687. /**
  46688. * Get the texture underlying format (RGB, RGBA...)
  46689. */
  46690. readonly textureFormat: number;
  46691. /**
  46692. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  46693. * This will returns an RGBA array buffer containing either in values (0-255) or
  46694. * float values (0-1) depending of the underlying buffer type.
  46695. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  46696. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  46697. * @param buffer defines a user defined buffer to fill with data (can be null)
  46698. * @returns The Array buffer containing the pixels data.
  46699. */
  46700. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  46701. /**
  46702. * Release and destroy the underlying lower level texture aka internalTexture.
  46703. */
  46704. releaseInternalTexture(): void;
  46705. /**
  46706. * Get the polynomial representation of the texture data.
  46707. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  46708. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  46709. */
  46710. sphericalPolynomial: Nullable<SphericalPolynomial>;
  46711. /** @hidden */
  46712. readonly _lodTextureHigh: Nullable<BaseTexture>;
  46713. /** @hidden */
  46714. readonly _lodTextureMid: Nullable<BaseTexture>;
  46715. /** @hidden */
  46716. readonly _lodTextureLow: Nullable<BaseTexture>;
  46717. /**
  46718. * Dispose the texture and release its associated resources.
  46719. */
  46720. dispose(): void;
  46721. /**
  46722. * Serialize the texture into a JSON representation that can be parsed later on.
  46723. * @returns the JSON representation of the texture
  46724. */
  46725. serialize(): any;
  46726. /**
  46727. * Helper function to be called back once a list of texture contains only ready textures.
  46728. * @param textures Define the list of textures to wait for
  46729. * @param callback Define the callback triggered once the entire list will be ready
  46730. */
  46731. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  46732. }
  46733. }
  46734. declare module BABYLON {
  46735. /**
  46736. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  46737. * It can help converting any input color in a desired output one. This can then be used to create effects
  46738. * from sepia, black and white to sixties or futuristic rendering...
  46739. *
  46740. * The only supported format is currently 3dl.
  46741. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  46742. */
  46743. class ColorGradingTexture extends BaseTexture {
  46744. /**
  46745. * The current texture matrix. (will always be identity in color grading texture)
  46746. */
  46747. private _textureMatrix;
  46748. /**
  46749. * The texture URL.
  46750. */
  46751. url: string;
  46752. /**
  46753. * Empty line regex stored for GC.
  46754. */
  46755. private static _noneEmptyLineRegex;
  46756. private _engine;
  46757. /**
  46758. * Instantiates a ColorGradingTexture from the following parameters.
  46759. *
  46760. * @param url The location of the color gradind data (currently only supporting 3dl)
  46761. * @param scene The scene the texture will be used in
  46762. */
  46763. constructor(url: string, scene: Scene);
  46764. /**
  46765. * Returns the texture matrix used in most of the material.
  46766. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  46767. */
  46768. getTextureMatrix(): Matrix;
  46769. /**
  46770. * Occurs when the file being loaded is a .3dl LUT file.
  46771. */
  46772. private load3dlTexture;
  46773. /**
  46774. * Starts the loading process of the texture.
  46775. */
  46776. private loadTexture;
  46777. /**
  46778. * Clones the color gradind texture.
  46779. */
  46780. clone(): ColorGradingTexture;
  46781. /**
  46782. * Called during delayed load for textures.
  46783. */
  46784. delayLoad(): void;
  46785. /**
  46786. * Parses a color grading texture serialized by Babylon.
  46787. * @param parsedTexture The texture information being parsedTexture
  46788. * @param scene The scene to load the texture in
  46789. * @param rootUrl The root url of the data assets to load
  46790. * @return A color gradind texture
  46791. */
  46792. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<ColorGradingTexture>;
  46793. /**
  46794. * Serializes the LUT texture to json format.
  46795. */
  46796. serialize(): any;
  46797. }
  46798. }
  46799. declare module BABYLON {
  46800. /**
  46801. * Class for creating a cube texture
  46802. */
  46803. class CubeTexture extends BaseTexture {
  46804. private _delayedOnLoad;
  46805. /**
  46806. * The url of the texture
  46807. */
  46808. url: string;
  46809. /**
  46810. * Gets or sets the center of the bounding box associated with the cube texture.
  46811. * It must define where the camera used to render the texture was set
  46812. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  46813. */
  46814. boundingBoxPosition: Vector3;
  46815. private _boundingBoxSize;
  46816. /**
  46817. * Gets or sets the size of the bounding box associated with the cube texture
  46818. * When defined, the cubemap will switch to local mode
  46819. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  46820. * @example https://www.babylonjs-playground.com/#RNASML
  46821. */
  46822. /**
  46823. * Returns the bounding box size
  46824. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  46825. */
  46826. boundingBoxSize: Vector3;
  46827. protected _rotationY: number;
  46828. /**
  46829. * Sets texture matrix rotation angle around Y axis in radians.
  46830. */
  46831. /**
  46832. * Gets texture matrix rotation angle around Y axis radians.
  46833. */
  46834. rotationY: number;
  46835. /**
  46836. * Are mip maps generated for this texture or not.
  46837. */
  46838. readonly noMipmap: boolean;
  46839. private _noMipmap;
  46840. private _files;
  46841. private _extensions;
  46842. private _textureMatrix;
  46843. private _format;
  46844. private _createPolynomials;
  46845. /** @hidden */
  46846. _prefiltered: boolean;
  46847. /**
  46848. * Creates a cube texture from an array of image urls
  46849. * @param files defines an array of image urls
  46850. * @param scene defines the hosting scene
  46851. * @param noMipmap specifies if mip maps are not used
  46852. * @returns a cube texture
  46853. */
  46854. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  46855. /**
  46856. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  46857. * @param url defines the url of the prefiltered texture
  46858. * @param scene defines the scene the texture is attached to
  46859. * @param forcedExtension defines the extension of the file if different from the url
  46860. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  46861. * @return the prefiltered texture
  46862. */
  46863. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  46864. /**
  46865. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  46866. * as prefiltered data.
  46867. * @param rootUrl defines the url of the texture or the root name of the six images
  46868. * @param scene defines the scene the texture is attached to
  46869. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  46870. * @param noMipmap defines if mipmaps should be created or not
  46871. * @param files defines the six files to load for the different faces
  46872. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  46873. * @param onError defines a callback triggered in case of error during load
  46874. * @param format defines the internal format to use for the texture once loaded
  46875. * @param prefiltered defines whether or not the texture is created from prefiltered data
  46876. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  46877. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  46878. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  46879. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  46880. * @return the cube texture
  46881. */
  46882. 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);
  46883. /**
  46884. * Get the current class name of the texture useful for serialization or dynamic coding.
  46885. * @returns "CubeTexture"
  46886. */
  46887. getClassName(): string;
  46888. /**
  46889. * Update the url (and optional buffer) of this texture if url was null during construction.
  46890. * @param url the url of the texture
  46891. * @param forcedExtension defines the extension to use
  46892. * @param onLoad callback called when the texture is loaded (defaults to null)
  46893. */
  46894. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  46895. /**
  46896. * Delays loading of the cube texture
  46897. * @param forcedExtension defines the extension to use
  46898. */
  46899. delayLoad(forcedExtension?: string): void;
  46900. /**
  46901. * Returns the reflection texture matrix
  46902. * @returns the reflection texture matrix
  46903. */
  46904. getReflectionTextureMatrix(): Matrix;
  46905. /**
  46906. * Sets the reflection texture matrix
  46907. * @param value Reflection texture matrix
  46908. */
  46909. setReflectionTextureMatrix(value: Matrix): void;
  46910. /**
  46911. * Parses text to create a cube texture
  46912. * @param parsedTexture define the serialized text to read from
  46913. * @param scene defines the hosting scene
  46914. * @param rootUrl defines the root url of the cube texture
  46915. * @returns a cube texture
  46916. */
  46917. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  46918. /**
  46919. * Makes a clone, or deep copy, of the cube texture
  46920. * @returns a new cube texture
  46921. */
  46922. clone(): CubeTexture;
  46923. }
  46924. }
  46925. declare module BABYLON {
  46926. /**
  46927. * A class extending Texture allowing drawing on a texture
  46928. * @see http://doc.babylonjs.com/how_to/dynamictexture
  46929. */
  46930. class DynamicTexture extends Texture {
  46931. private _generateMipMaps;
  46932. private _canvas;
  46933. private _context;
  46934. private _engine;
  46935. /**
  46936. * Creates a DynamicTexture
  46937. * @param name defines the name of the texture
  46938. * @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
  46939. * @param scene defines the scene where you want the texture
  46940. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  46941. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  46942. * @param format defines the texture format to use (default is BABYLON.Engine.TEXTUREFORMAT_RGBA)
  46943. */
  46944. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  46945. /**
  46946. * Get the current class name of the texture useful for serialization or dynamic coding.
  46947. * @returns "DynamicTexture"
  46948. */
  46949. getClassName(): string;
  46950. /**
  46951. * Gets the current state of canRescale
  46952. */
  46953. readonly canRescale: boolean;
  46954. private _recreate;
  46955. /**
  46956. * Scales the texture
  46957. * @param ratio the scale factor to apply to both width and height
  46958. */
  46959. scale(ratio: number): void;
  46960. /**
  46961. * Resizes the texture
  46962. * @param width the new width
  46963. * @param height the new height
  46964. */
  46965. scaleTo(width: number, height: number): void;
  46966. /**
  46967. * Gets the context of the canvas used by the texture
  46968. * @returns the canvas context of the dynamic texture
  46969. */
  46970. getContext(): CanvasRenderingContext2D;
  46971. /**
  46972. * Clears the texture
  46973. */
  46974. clear(): void;
  46975. /**
  46976. * Updates the texture
  46977. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  46978. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  46979. */
  46980. update(invertY?: boolean, premulAlpha?: boolean): void;
  46981. /**
  46982. * Draws text onto the texture
  46983. * @param text defines the text to be drawn
  46984. * @param x defines the placement of the text from the left
  46985. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  46986. * @param font defines the font to be used with font-style, font-size, font-name
  46987. * @param color defines the color used for the text
  46988. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  46989. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  46990. * @param update defines whether texture is immediately update (default is true)
  46991. */
  46992. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  46993. /**
  46994. * Clones the texture
  46995. * @returns the clone of the texture.
  46996. */
  46997. clone(): DynamicTexture;
  46998. /**
  46999. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  47000. * @returns a serialized dynamic texture object
  47001. */
  47002. serialize(): any;
  47003. /** @hidden */
  47004. _rebuild(): void;
  47005. }
  47006. }
  47007. declare module BABYLON {
  47008. /**
  47009. * This represents a texture coming from an HDR input.
  47010. *
  47011. * The only supported format is currently panorama picture stored in RGBE format.
  47012. * Example of such files can be found on HDRLib: http://hdrlib.com/
  47013. */
  47014. class HDRCubeTexture extends BaseTexture {
  47015. private static _facesMapping;
  47016. private _generateHarmonics;
  47017. private _noMipmap;
  47018. private _textureMatrix;
  47019. private _size;
  47020. private _onLoad;
  47021. private _onError;
  47022. /**
  47023. * The texture URL.
  47024. */
  47025. url: string;
  47026. /**
  47027. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  47028. */
  47029. coordinatesMode: number;
  47030. protected _isBlocking: boolean;
  47031. /**
  47032. * Sets wether or not the texture is blocking during loading.
  47033. */
  47034. /**
  47035. * Gets wether or not the texture is blocking during loading.
  47036. */
  47037. isBlocking: boolean;
  47038. protected _rotationY: number;
  47039. /**
  47040. * Sets texture matrix rotation angle around Y axis in radians.
  47041. */
  47042. /**
  47043. * Gets texture matrix rotation angle around Y axis radians.
  47044. */
  47045. rotationY: number;
  47046. /**
  47047. * Gets or sets the center of the bounding box associated with the cube texture
  47048. * It must define where the camera used to render the texture was set
  47049. */
  47050. boundingBoxPosition: Vector3;
  47051. private _boundingBoxSize;
  47052. /**
  47053. * Gets or sets the size of the bounding box associated with the cube texture
  47054. * When defined, the cubemap will switch to local mode
  47055. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  47056. * @example https://www.babylonjs-playground.com/#RNASML
  47057. */
  47058. boundingBoxSize: Vector3;
  47059. /**
  47060. * Instantiates an HDRTexture from the following parameters.
  47061. *
  47062. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  47063. * @param scene The scene the texture will be used in
  47064. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  47065. * @param noMipmap Forces to not generate the mipmap if true
  47066. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  47067. * @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)
  47068. * @param reserved Reserved flag for internal use.
  47069. */
  47070. 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>);
  47071. /**
  47072. * Get the current class name of the texture useful for serialization or dynamic coding.
  47073. * @returns "HDRCubeTexture"
  47074. */
  47075. getClassName(): string;
  47076. /**
  47077. * Occurs when the file is raw .hdr file.
  47078. */
  47079. private loadTexture;
  47080. clone(): HDRCubeTexture;
  47081. delayLoad(): void;
  47082. /**
  47083. * Get the texture reflection matrix used to rotate/transform the reflection.
  47084. * @returns the reflection matrix
  47085. */
  47086. getReflectionTextureMatrix(): Matrix;
  47087. /**
  47088. * Set the texture reflection matrix used to rotate/transform the reflection.
  47089. * @param value Define the reflection matrix to set
  47090. */
  47091. setReflectionTextureMatrix(value: Matrix): void;
  47092. /**
  47093. * Parses a JSON representation of an HDR Texture in order to create the texture
  47094. * @param parsedTexture Define the JSON representation
  47095. * @param scene Define the scene the texture should be created in
  47096. * @param rootUrl Define the root url in case we need to load relative dependencies
  47097. * @returns the newly created texture after parsing
  47098. */
  47099. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  47100. serialize(): any;
  47101. }
  47102. }
  47103. declare module BABYLON {
  47104. /**
  47105. * Class used to store data associated with WebGL texture data for the engine
  47106. * This class should not be used directly
  47107. */
  47108. class InternalTexture implements IInternalTextureTracker {
  47109. /**
  47110. * The source of the texture data is unknown
  47111. */
  47112. static DATASOURCE_UNKNOWN: number;
  47113. /**
  47114. * Texture data comes from an URL
  47115. */
  47116. static DATASOURCE_URL: number;
  47117. /**
  47118. * Texture data is only used for temporary storage
  47119. */
  47120. static DATASOURCE_TEMP: number;
  47121. /**
  47122. * Texture data comes from raw data (ArrayBuffer)
  47123. */
  47124. static DATASOURCE_RAW: number;
  47125. /**
  47126. * Texture content is dynamic (video or dynamic texture)
  47127. */
  47128. static DATASOURCE_DYNAMIC: number;
  47129. /**
  47130. * Texture content is generated by rendering to it
  47131. */
  47132. static DATASOURCE_RENDERTARGET: number;
  47133. /**
  47134. * Texture content is part of a multi render target process
  47135. */
  47136. static DATASOURCE_MULTIRENDERTARGET: number;
  47137. /**
  47138. * Texture data comes from a cube data file
  47139. */
  47140. static DATASOURCE_CUBE: number;
  47141. /**
  47142. * Texture data comes from a raw cube data
  47143. */
  47144. static DATASOURCE_CUBERAW: number;
  47145. /**
  47146. * Texture data come from a prefiltered cube data file
  47147. */
  47148. static DATASOURCE_CUBEPREFILTERED: number;
  47149. /**
  47150. * Texture content is raw 3D data
  47151. */
  47152. static DATASOURCE_RAW3D: number;
  47153. /**
  47154. * Texture content is a depth texture
  47155. */
  47156. static DATASOURCE_DEPTHTEXTURE: number;
  47157. /**
  47158. * Texture data comes from a raw cube data encoded with RGBD
  47159. */
  47160. static DATASOURCE_CUBERAW_RGBD: number;
  47161. /**
  47162. * Defines if the texture is ready
  47163. */
  47164. isReady: boolean;
  47165. /**
  47166. * Defines if the texture is a cube texture
  47167. */
  47168. isCube: boolean;
  47169. /**
  47170. * Defines if the texture contains 3D data
  47171. */
  47172. is3D: boolean;
  47173. /**
  47174. * Gets the URL used to load this texture
  47175. */
  47176. url: string;
  47177. /**
  47178. * Gets the sampling mode of the texture
  47179. */
  47180. samplingMode: number;
  47181. /**
  47182. * Gets a boolean indicating if the texture needs mipmaps generation
  47183. */
  47184. generateMipMaps: boolean;
  47185. /**
  47186. * Gets the number of samples used by the texture (WebGL2+ only)
  47187. */
  47188. samples: number;
  47189. /**
  47190. * Gets the type of the texture (int, float...)
  47191. */
  47192. type: number;
  47193. /**
  47194. * Gets the format of the texture (RGB, RGBA...)
  47195. */
  47196. format: number;
  47197. /**
  47198. * Observable called when the texture is loaded
  47199. */
  47200. onLoadedObservable: Observable<InternalTexture>;
  47201. /**
  47202. * Gets the width of the texture
  47203. */
  47204. width: number;
  47205. /**
  47206. * Gets the height of the texture
  47207. */
  47208. height: number;
  47209. /**
  47210. * Gets the depth of the texture
  47211. */
  47212. depth: number;
  47213. /**
  47214. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  47215. */
  47216. baseWidth: number;
  47217. /**
  47218. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  47219. */
  47220. baseHeight: number;
  47221. /**
  47222. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  47223. */
  47224. baseDepth: number;
  47225. /**
  47226. * Gets a boolean indicating if the texture is inverted on Y axis
  47227. */
  47228. invertY: boolean;
  47229. /**
  47230. * Gets or set the previous tracker in the list
  47231. */
  47232. previous: Nullable<IInternalTextureTracker>;
  47233. /**
  47234. * Gets or set the next tracker in the list
  47235. */
  47236. next: Nullable<IInternalTextureTracker>;
  47237. /** @hidden */
  47238. _invertVScale: boolean;
  47239. /** @hidden */
  47240. _initialSlot: number;
  47241. /** @hidden */
  47242. _designatedSlot: number;
  47243. /** @hidden */
  47244. _dataSource: number;
  47245. /** @hidden */
  47246. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  47247. /** @hidden */
  47248. _bufferView: Nullable<ArrayBufferView>;
  47249. /** @hidden */
  47250. _bufferViewArray: Nullable<ArrayBufferView[]>;
  47251. /** @hidden */
  47252. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  47253. /** @hidden */
  47254. _size: number;
  47255. /** @hidden */
  47256. _extension: string;
  47257. /** @hidden */
  47258. _files: Nullable<string[]>;
  47259. /** @hidden */
  47260. _workingCanvas: HTMLCanvasElement;
  47261. /** @hidden */
  47262. _workingContext: CanvasRenderingContext2D;
  47263. /** @hidden */
  47264. _framebuffer: Nullable<WebGLFramebuffer>;
  47265. /** @hidden */
  47266. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  47267. /** @hidden */
  47268. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  47269. /** @hidden */
  47270. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  47271. /** @hidden */
  47272. _attachments: Nullable<number[]>;
  47273. /** @hidden */
  47274. _cachedCoordinatesMode: Nullable<number>;
  47275. /** @hidden */
  47276. _cachedWrapU: Nullable<number>;
  47277. /** @hidden */
  47278. _cachedWrapV: Nullable<number>;
  47279. /** @hidden */
  47280. _cachedWrapR: Nullable<number>;
  47281. /** @hidden */
  47282. _cachedAnisotropicFilteringLevel: Nullable<number>;
  47283. /** @hidden */
  47284. _isDisabled: boolean;
  47285. /** @hidden */
  47286. _compression: Nullable<string>;
  47287. /** @hidden */
  47288. _generateStencilBuffer: boolean;
  47289. /** @hidden */
  47290. _generateDepthBuffer: boolean;
  47291. /** @hidden */
  47292. _comparisonFunction: number;
  47293. /** @hidden */
  47294. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  47295. /** @hidden */
  47296. _lodGenerationScale: number;
  47297. /** @hidden */
  47298. _lodGenerationOffset: number;
  47299. /** @hidden */
  47300. _lodTextureHigh: BaseTexture;
  47301. /** @hidden */
  47302. _lodTextureMid: BaseTexture;
  47303. /** @hidden */
  47304. _lodTextureLow: BaseTexture;
  47305. /** @hidden */
  47306. _isRGBD: boolean;
  47307. /** @hidden */
  47308. _webGLTexture: Nullable<WebGLTexture>;
  47309. /** @hidden */
  47310. _references: number;
  47311. private _engine;
  47312. /**
  47313. * Gets the Engine the texture belongs to.
  47314. * @returns The babylon engine
  47315. */
  47316. getEngine(): Engine;
  47317. /**
  47318. * Gets the data source type of the texture (can be one of the BABYLON.InternalTexture.DATASOURCE_XXXX)
  47319. */
  47320. readonly dataSource: number;
  47321. /**
  47322. * Creates a new InternalTexture
  47323. * @param engine defines the engine to use
  47324. * @param dataSource defines the type of data that will be used
  47325. * @param delayAllocation if the texture allocation should be delayed (default: false)
  47326. */
  47327. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  47328. /**
  47329. * Increments the number of references (ie. the number of Texture that point to it)
  47330. */
  47331. incrementReferences(): void;
  47332. /**
  47333. * Change the size of the texture (not the size of the content)
  47334. * @param width defines the new width
  47335. * @param height defines the new height
  47336. * @param depth defines the new depth (1 by default)
  47337. */
  47338. updateSize(width: int, height: int, depth?: int): void;
  47339. /** @hidden */
  47340. _rebuild(): void;
  47341. /** @hidden */
  47342. _swapAndDie(target: InternalTexture): void;
  47343. /**
  47344. * Dispose the current allocated resources
  47345. */
  47346. dispose(): void;
  47347. }
  47348. }
  47349. declare module BABYLON {
  47350. /**
  47351. * This represents the required contract to create a new type of texture loader.
  47352. */
  47353. interface IInternalTextureLoader {
  47354. /**
  47355. * Defines wether the loader supports cascade loading the different faces.
  47356. */
  47357. supportCascades: boolean;
  47358. /**
  47359. * This returns if the loader support the current file information.
  47360. * @param extension defines the file extension of the file being loaded
  47361. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47362. * @param fallback defines the fallback internal texture if any
  47363. * @param isBase64 defines whether the texture is encoded as a base64
  47364. * @param isBuffer defines whether the texture data are stored as a buffer
  47365. * @returns true if the loader can load the specified file
  47366. */
  47367. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47368. /**
  47369. * Transform the url before loading if required.
  47370. * @param rootUrl the url of the texture
  47371. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47372. * @returns the transformed texture
  47373. */
  47374. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47375. /**
  47376. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47377. * @param rootUrl the url of the texture
  47378. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47379. * @returns the fallback texture
  47380. */
  47381. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47382. /**
  47383. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47384. * @param data contains the texture data
  47385. * @param texture defines the BabylonJS internal texture
  47386. * @param createPolynomials will be true if polynomials have been requested
  47387. * @param onLoad defines the callback to trigger once the texture is ready
  47388. * @param onError defines the callback to trigger in case of error
  47389. */
  47390. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47391. /**
  47392. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47393. * @param data contains the texture data
  47394. * @param texture defines the BabylonJS internal texture
  47395. * @param callback defines the method to call once ready to upload
  47396. */
  47397. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  47398. }
  47399. }
  47400. declare module BABYLON {
  47401. /**
  47402. * Internal interface used to track InternalTexture already bound to the GL context
  47403. */
  47404. interface IInternalTextureTracker {
  47405. /**
  47406. * Gets or set the previous tracker in the list
  47407. */
  47408. previous: Nullable<IInternalTextureTracker>;
  47409. /**
  47410. * Gets or set the next tracker in the list
  47411. */
  47412. next: Nullable<IInternalTextureTracker>;
  47413. }
  47414. /**
  47415. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  47416. */
  47417. class DummyInternalTextureTracker {
  47418. /**
  47419. * Gets or set the previous tracker in the list
  47420. */
  47421. previous: Nullable<IInternalTextureTracker>;
  47422. /**
  47423. * Gets or set the next tracker in the list
  47424. */
  47425. next: Nullable<IInternalTextureTracker>;
  47426. }
  47427. }
  47428. declare module BABYLON {
  47429. /**
  47430. * Mirror texture can be used to simulate the view from a mirror in a scene.
  47431. * It will dynamically be rendered every frame to adapt to the camera point of view.
  47432. * You can then easily use it as a reflectionTexture on a flat surface.
  47433. * In case the surface is not a plane, please consider relying on reflection probes.
  47434. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  47435. */
  47436. class MirrorTexture extends RenderTargetTexture {
  47437. private scene;
  47438. /**
  47439. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  47440. * 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.
  47441. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  47442. */
  47443. mirrorPlane: Plane;
  47444. /**
  47445. * Define the blur ratio used to blur the reflection if needed.
  47446. */
  47447. blurRatio: number;
  47448. /**
  47449. * Define the adaptive blur kernel used to blur the reflection if needed.
  47450. * This will autocompute the closest best match for the `blurKernel`
  47451. */
  47452. adaptiveBlurKernel: number;
  47453. /**
  47454. * Define the blur kernel used to blur the reflection if needed.
  47455. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  47456. */
  47457. blurKernel: number;
  47458. /**
  47459. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  47460. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  47461. */
  47462. blurKernelX: number;
  47463. /**
  47464. * Define the blur kernel on the Y 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. blurKernelY: number;
  47468. private _autoComputeBlurKernel;
  47469. protected _onRatioRescale(): void;
  47470. private _updateGammaSpace;
  47471. private _imageProcessingConfigChangeObserver;
  47472. private _transformMatrix;
  47473. private _mirrorMatrix;
  47474. private _savedViewMatrix;
  47475. private _blurX;
  47476. private _blurY;
  47477. private _adaptiveBlurKernel;
  47478. private _blurKernelX;
  47479. private _blurKernelY;
  47480. private _blurRatio;
  47481. /**
  47482. * Instantiates a Mirror Texture.
  47483. * Mirror texture can be used to simulate the view from a mirror in a scene.
  47484. * It will dynamically be rendered every frame to adapt to the camera point of view.
  47485. * You can then easily use it as a reflectionTexture on a flat surface.
  47486. * In case the surface is not a plane, please consider relying on reflection probes.
  47487. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  47488. * @param name
  47489. * @param size
  47490. * @param scene
  47491. * @param generateMipMaps
  47492. * @param type
  47493. * @param samplingMode
  47494. * @param generateDepthBuffer
  47495. */
  47496. constructor(name: string, size: number | {
  47497. width: number;
  47498. height: number;
  47499. } | {
  47500. ratio: number;
  47501. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  47502. private _preparePostProcesses;
  47503. /**
  47504. * Clone the mirror texture.
  47505. * @returns the cloned texture
  47506. */
  47507. clone(): MirrorTexture;
  47508. /**
  47509. * Serialize the texture to a JSON representation you could use in Parse later on
  47510. * @returns the serialized JSON representation
  47511. */
  47512. serialize(): any;
  47513. /**
  47514. * Dispose the texture and release its associated resources.
  47515. */
  47516. dispose(): void;
  47517. }
  47518. }
  47519. declare module BABYLON {
  47520. /**
  47521. * Creation options of the multi render target texture.
  47522. */
  47523. interface IMultiRenderTargetOptions {
  47524. /**
  47525. * Define if the texture needs to create mip maps after render.
  47526. */
  47527. generateMipMaps?: boolean;
  47528. /**
  47529. * Define the types of all the draw buffers we want to create
  47530. */
  47531. types?: number[];
  47532. /**
  47533. * Define the sampling modes of all the draw buffers we want to create
  47534. */
  47535. samplingModes?: number[];
  47536. /**
  47537. * Define if a depth buffer is required
  47538. */
  47539. generateDepthBuffer?: boolean;
  47540. /**
  47541. * Define if a stencil buffer is required
  47542. */
  47543. generateStencilBuffer?: boolean;
  47544. /**
  47545. * Define if a depth texture is required instead of a depth buffer
  47546. */
  47547. generateDepthTexture?: boolean;
  47548. /**
  47549. * Define the number of desired draw buffers
  47550. */
  47551. textureCount?: number;
  47552. /**
  47553. * Define if aspect ratio should be adapted to the texture or stay the scene one
  47554. */
  47555. doNotChangeAspectRatio?: boolean;
  47556. /**
  47557. * Define the default type of the buffers we are creating
  47558. */
  47559. defaultType?: number;
  47560. }
  47561. /**
  47562. * A multi render target, like a render target provides the ability to render to a texture.
  47563. * Unlike the render target, it can render to several draw buffers in one draw.
  47564. * This is specially interesting in deferred rendering or for any effects requiring more than
  47565. * just one color from a single pass.
  47566. */
  47567. class MultiRenderTarget extends RenderTargetTexture {
  47568. private _internalTextures;
  47569. private _textures;
  47570. private _multiRenderTargetOptions;
  47571. /**
  47572. * Get if draw buffers are currently supported by the used hardware and browser.
  47573. */
  47574. readonly isSupported: boolean;
  47575. /**
  47576. * Get the list of textures generated by the multi render target.
  47577. */
  47578. readonly textures: Texture[];
  47579. /**
  47580. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  47581. */
  47582. readonly depthTexture: Texture;
  47583. /**
  47584. * Set the wrapping mode on U of all the textures we are rendering to.
  47585. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47586. */
  47587. wrapU: number;
  47588. /**
  47589. * Set the wrapping mode on V of all the textures we are rendering to.
  47590. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47591. */
  47592. wrapV: number;
  47593. /**
  47594. * Instantiate a new multi render target texture.
  47595. * A multi render target, like a render target provides the ability to render to a texture.
  47596. * Unlike the render target, it can render to several draw buffers in one draw.
  47597. * This is specially interesting in deferred rendering or for any effects requiring more than
  47598. * just one color from a single pass.
  47599. * @param name Define the name of the texture
  47600. * @param size Define the size of the buffers to render to
  47601. * @param count Define the number of target we are rendering into
  47602. * @param scene Define the scene the texture belongs to
  47603. * @param options Define the options used to create the multi render target
  47604. */
  47605. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  47606. /** @hidden */
  47607. _rebuild(): void;
  47608. private _createInternalTextures;
  47609. private _createTextures;
  47610. /**
  47611. * Define the number of samples used if MSAA is enabled.
  47612. */
  47613. samples: number;
  47614. /**
  47615. * Resize all the textures in the multi render target.
  47616. * Be carrefull as it will recreate all the data in the new texture.
  47617. * @param size Define the new size
  47618. */
  47619. resize(size: any): void;
  47620. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  47621. /**
  47622. * Dispose the render targets and their associated resources
  47623. */
  47624. dispose(): void;
  47625. /**
  47626. * Release all the underlying texture used as draw buffers.
  47627. */
  47628. releaseInternalTextures(): void;
  47629. }
  47630. }
  47631. declare module BABYLON {
  47632. /**
  47633. * Raw cube texture where the raw buffers are passed in
  47634. */
  47635. class RawCubeTexture extends CubeTexture {
  47636. /**
  47637. * Creates a cube texture where the raw buffers are passed in.
  47638. * @param scene defines the scene the texture is attached to
  47639. * @param data defines the array of data to use to create each face
  47640. * @param size defines the size of the textures
  47641. * @param format defines the format of the data
  47642. * @param type defines the type of the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  47643. * @param generateMipMaps defines if the engine should generate the mip levels
  47644. * @param invertY defines if data must be stored with Y axis inverted
  47645. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  47646. * @param compression defines the compression used (null by default)
  47647. */
  47648. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  47649. /**
  47650. * Updates the raw cube texture.
  47651. * @param data defines the data to store
  47652. * @param format defines the data format
  47653. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  47654. * @param invertY defines if data must be stored with Y axis inverted
  47655. * @param compression defines the compression used (null by default)
  47656. * @param level defines which level of the texture to update
  47657. */
  47658. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  47659. /**
  47660. * Updates a raw cube texture with RGBD encoded data.
  47661. * @param data defines the array of data [mipmap][face] to use to create each face
  47662. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  47663. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  47664. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  47665. * @returns a promsie that resolves when the operation is complete
  47666. */
  47667. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  47668. /**
  47669. * Clones the raw cube texture.
  47670. * @return a new cube texture
  47671. */
  47672. clone(): CubeTexture;
  47673. /** @hidden */
  47674. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47675. }
  47676. }
  47677. declare module BABYLON {
  47678. /**
  47679. * Raw texture can help creating a texture directly from an array of data.
  47680. * This can be super useful if you either get the data from an uncompressed source or
  47681. * if you wish to create your texture pixel by pixel.
  47682. */
  47683. class RawTexture extends Texture {
  47684. /**
  47685. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  47686. */
  47687. format: number;
  47688. private _engine;
  47689. /**
  47690. * Instantiates a new RawTexture.
  47691. * Raw texture can help creating a texture directly from an array of data.
  47692. * This can be super useful if you either get the data from an uncompressed source or
  47693. * if you wish to create your texture pixel by pixel.
  47694. * @param data define the array of data to use to create the texture
  47695. * @param width define the width of the texture
  47696. * @param height define the height of the texture
  47697. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  47698. * @param scene define the scene the texture belongs to
  47699. * @param generateMipMaps define whether mip maps should be generated or not
  47700. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47701. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47702. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  47703. */
  47704. constructor(data: ArrayBufferView, width: number, height: number,
  47705. /**
  47706. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  47707. */
  47708. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  47709. /**
  47710. * Updates the texture underlying data.
  47711. * @param data Define the new data of the texture
  47712. */
  47713. update(data: ArrayBufferView): void;
  47714. /**
  47715. * Creates a luminance texture from some data.
  47716. * @param data Define the texture data
  47717. * @param width Define the width of the texture
  47718. * @param height Define the height of the texture
  47719. * @param scene Define the scene the texture belongs to
  47720. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47721. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47722. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47723. * @returns the luminance texture
  47724. */
  47725. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  47726. /**
  47727. * Creates a luminance alpha texture from some data.
  47728. * @param data Define the texture data
  47729. * @param width Define the width of the texture
  47730. * @param height Define the height of the texture
  47731. * @param scene Define the scene the texture belongs to
  47732. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47733. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47734. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47735. * @returns the luminance alpha texture
  47736. */
  47737. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  47738. /**
  47739. * Creates an alpha texture from some data.
  47740. * @param data Define the texture data
  47741. * @param width Define the width of the texture
  47742. * @param height Define the height of the texture
  47743. * @param scene Define the scene the texture belongs to
  47744. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47745. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47746. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47747. * @returns the alpha texture
  47748. */
  47749. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  47750. /**
  47751. * Creates a RGB texture from some data.
  47752. * @param data Define the texture data
  47753. * @param width Define the width of the texture
  47754. * @param height Define the height of the texture
  47755. * @param scene Define the scene the texture belongs to
  47756. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47757. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47758. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47759. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  47760. * @returns the RGB alpha texture
  47761. */
  47762. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  47763. /**
  47764. * Creates a RGBA texture from some data.
  47765. * @param data Define the texture data
  47766. * @param width Define the width of the texture
  47767. * @param height Define the height of the texture
  47768. * @param scene Define the scene the texture belongs to
  47769. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47770. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47771. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47772. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  47773. * @returns the RGBA texture
  47774. */
  47775. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  47776. /**
  47777. * Creates a R texture from some data.
  47778. * @param data Define the texture data
  47779. * @param width Define the width of the texture
  47780. * @param height Define the height of the texture
  47781. * @param scene Define the scene the texture belongs to
  47782. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47783. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47784. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47785. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  47786. * @returns the R texture
  47787. */
  47788. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  47789. }
  47790. }
  47791. declare module BABYLON {
  47792. /**
  47793. * Class used to store 3D textures containing user data
  47794. */
  47795. class RawTexture3D extends Texture {
  47796. /** Gets or sets the texture format to use */
  47797. format: number;
  47798. private _engine;
  47799. /**
  47800. * Create a new RawTexture3D
  47801. * @param data defines the data of the texture
  47802. * @param width defines the width of the texture
  47803. * @param height defines the height of the texture
  47804. * @param depth defines the depth of the texture
  47805. * @param format defines the texture format to use
  47806. * @param scene defines the hosting scene
  47807. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  47808. * @param invertY defines if texture must be stored with Y axis inverted
  47809. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  47810. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  47811. */
  47812. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  47813. /** Gets or sets the texture format to use */
  47814. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  47815. /**
  47816. * Update the texture with new data
  47817. * @param data defines the data to store in the texture
  47818. */
  47819. update(data: ArrayBufferView): void;
  47820. }
  47821. }
  47822. declare module BABYLON {
  47823. /**
  47824. * Creates a refraction texture used by refraction channel of the standard material.
  47825. * It is like a mirror but to see through a material.
  47826. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  47827. */
  47828. class RefractionTexture extends RenderTargetTexture {
  47829. /**
  47830. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  47831. * 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.
  47832. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  47833. */
  47834. refractionPlane: Plane;
  47835. /**
  47836. * Define how deep under the surface we should see.
  47837. */
  47838. depth: number;
  47839. /**
  47840. * Creates a refraction texture used by refraction channel of the standard material.
  47841. * It is like a mirror but to see through a material.
  47842. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  47843. * @param name Define the texture name
  47844. * @param size Define the size of the underlying texture
  47845. * @param scene Define the scene the refraction belongs to
  47846. * @param generateMipMaps Define if we need to generate mips level for the refraction
  47847. */
  47848. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  47849. /**
  47850. * Clone the refraction texture.
  47851. * @returns the cloned texture
  47852. */
  47853. clone(): RefractionTexture;
  47854. /**
  47855. * Serialize the texture to a JSON representation you could use in Parse later on
  47856. * @returns the serialized JSON representation
  47857. */
  47858. serialize(): any;
  47859. }
  47860. }
  47861. declare module BABYLON {
  47862. /**
  47863. * This Helps creating a texture that will be created from a camera in your scene.
  47864. * It is basically a dynamic texture that could be used to create special effects for instance.
  47865. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  47866. */
  47867. class RenderTargetTexture extends Texture {
  47868. isCube: boolean;
  47869. /**
  47870. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  47871. */
  47872. static readonly REFRESHRATE_RENDER_ONCE: number;
  47873. /**
  47874. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  47875. */
  47876. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  47877. /**
  47878. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  47879. * the central point of your effect and can save a lot of performances.
  47880. */
  47881. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  47882. /**
  47883. * Use this predicate to dynamically define the list of mesh you want to render.
  47884. * If set, the renderList property will be overwritten.
  47885. */
  47886. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  47887. private _renderList;
  47888. /**
  47889. * Use this list to define the list of mesh you want to render.
  47890. */
  47891. renderList: Nullable<Array<AbstractMesh>>;
  47892. private _hookArray;
  47893. /**
  47894. * Define if particles should be rendered in your texture.
  47895. */
  47896. renderParticles: boolean;
  47897. /**
  47898. * Define if sprites should be rendered in your texture.
  47899. */
  47900. renderSprites: boolean;
  47901. /**
  47902. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  47903. */
  47904. coordinatesMode: number;
  47905. /**
  47906. * Define the camera used to render the texture.
  47907. */
  47908. activeCamera: Nullable<Camera>;
  47909. /**
  47910. * Override the render function of the texture with your own one.
  47911. */
  47912. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  47913. /**
  47914. * Define if camera post processes should be use while rendering the texture.
  47915. */
  47916. useCameraPostProcesses: boolean;
  47917. /**
  47918. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  47919. */
  47920. ignoreCameraViewport: boolean;
  47921. private _postProcessManager;
  47922. private _postProcesses;
  47923. private _resizeObserver;
  47924. /**
  47925. * An event triggered when the texture is unbind.
  47926. */
  47927. onBeforeBindObservable: Observable<RenderTargetTexture>;
  47928. /**
  47929. * An event triggered when the texture is unbind.
  47930. */
  47931. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  47932. private _onAfterUnbindObserver;
  47933. /**
  47934. * Set a after unbind callback in the texture.
  47935. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  47936. */
  47937. onAfterUnbind: () => void;
  47938. /**
  47939. * An event triggered before rendering the texture
  47940. */
  47941. onBeforeRenderObservable: Observable<number>;
  47942. private _onBeforeRenderObserver;
  47943. /**
  47944. * Set a before render callback in the texture.
  47945. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  47946. */
  47947. onBeforeRender: (faceIndex: number) => void;
  47948. /**
  47949. * An event triggered after rendering the texture
  47950. */
  47951. onAfterRenderObservable: Observable<number>;
  47952. private _onAfterRenderObserver;
  47953. /**
  47954. * Set a after render callback in the texture.
  47955. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  47956. */
  47957. onAfterRender: (faceIndex: number) => void;
  47958. /**
  47959. * An event triggered after the texture clear
  47960. */
  47961. onClearObservable: Observable<Engine>;
  47962. private _onClearObserver;
  47963. /**
  47964. * Set a clear callback in the texture.
  47965. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  47966. */
  47967. onClear: (Engine: Engine) => void;
  47968. /**
  47969. * Define the clear color of the Render Target if it should be different from the scene.
  47970. */
  47971. clearColor: Color4;
  47972. protected _size: number | {
  47973. width: number;
  47974. height: number;
  47975. };
  47976. protected _initialSizeParameter: number | {
  47977. width: number;
  47978. height: number;
  47979. } | {
  47980. ratio: number;
  47981. };
  47982. protected _sizeRatio: Nullable<number>;
  47983. /** @hidden */
  47984. _generateMipMaps: boolean;
  47985. protected _renderingManager: RenderingManager;
  47986. /** @hidden */
  47987. _waitingRenderList: string[];
  47988. protected _doNotChangeAspectRatio: boolean;
  47989. protected _currentRefreshId: number;
  47990. protected _refreshRate: number;
  47991. protected _textureMatrix: Matrix;
  47992. protected _samples: number;
  47993. protected _renderTargetOptions: RenderTargetCreationOptions;
  47994. /**
  47995. * Gets render target creation options that were used.
  47996. */
  47997. readonly renderTargetOptions: RenderTargetCreationOptions;
  47998. protected _engine: Engine;
  47999. protected _onRatioRescale(): void;
  48000. /**
  48001. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  48002. * It must define where the camera used to render the texture is set
  48003. */
  48004. boundingBoxPosition: Vector3;
  48005. private _boundingBoxSize;
  48006. /**
  48007. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  48008. * When defined, the cubemap will switch to local mode
  48009. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  48010. * @example https://www.babylonjs-playground.com/#RNASML
  48011. */
  48012. boundingBoxSize: Vector3;
  48013. /**
  48014. * In case the RTT has been created with a depth texture, get the associated
  48015. * depth texture.
  48016. * Otherwise, return null.
  48017. */
  48018. depthStencilTexture: Nullable<InternalTexture>;
  48019. /**
  48020. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  48021. * or used a shadow, depth texture...
  48022. * @param name The friendly name of the texture
  48023. * @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)
  48024. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  48025. * @param generateMipMaps True if mip maps need to be generated after render.
  48026. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  48027. * @param type The type of the buffer in the RTT (int, half float, float...)
  48028. * @param isCube True if a cube texture needs to be created
  48029. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  48030. * @param generateDepthBuffer True to generate a depth buffer
  48031. * @param generateStencilBuffer True to generate a stencil buffer
  48032. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  48033. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  48034. * @param delayAllocation if the texture allocation should be delayed (default: false)
  48035. */
  48036. constructor(name: string, size: number | {
  48037. width: number;
  48038. height: number;
  48039. } | {
  48040. ratio: number;
  48041. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  48042. /**
  48043. * Creates a depth stencil texture.
  48044. * This is only available in WebGL 2 or with the depth texture extension available.
  48045. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  48046. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  48047. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  48048. */
  48049. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  48050. private _processSizeParameter;
  48051. /**
  48052. * Define the number of samples to use in case of MSAA.
  48053. * It defaults to one meaning no MSAA has been enabled.
  48054. */
  48055. samples: number;
  48056. /**
  48057. * Resets the refresh counter of the texture and start bak from scratch.
  48058. * Could be useful to regenerate the texture if it is setup to render only once.
  48059. */
  48060. resetRefreshCounter(): void;
  48061. /**
  48062. * Define the refresh rate of the texture or the rendering frequency.
  48063. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  48064. */
  48065. refreshRate: number;
  48066. /**
  48067. * Adds a post process to the render target rendering passes.
  48068. * @param postProcess define the post process to add
  48069. */
  48070. addPostProcess(postProcess: PostProcess): void;
  48071. /**
  48072. * Clear all the post processes attached to the render target
  48073. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  48074. */
  48075. clearPostProcesses(dispose?: boolean): void;
  48076. /**
  48077. * Remove one of the post process from the list of attached post processes to the texture
  48078. * @param postProcess define the post process to remove from the list
  48079. */
  48080. removePostProcess(postProcess: PostProcess): void;
  48081. /** @hidden */
  48082. _shouldRender(): boolean;
  48083. /**
  48084. * Gets the actual render size of the texture.
  48085. * @returns the width of the render size
  48086. */
  48087. getRenderSize(): number;
  48088. /**
  48089. * Gets the actual render width of the texture.
  48090. * @returns the width of the render size
  48091. */
  48092. getRenderWidth(): number;
  48093. /**
  48094. * Gets the actual render height of the texture.
  48095. * @returns the height of the render size
  48096. */
  48097. getRenderHeight(): number;
  48098. /**
  48099. * Get if the texture can be rescaled or not.
  48100. */
  48101. readonly canRescale: boolean;
  48102. /**
  48103. * Resize the texture using a ratio.
  48104. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  48105. */
  48106. scale(ratio: number): void;
  48107. /**
  48108. * Get the texture reflection matrix used to rotate/transform the reflection.
  48109. * @returns the reflection matrix
  48110. */
  48111. getReflectionTextureMatrix(): Matrix;
  48112. /**
  48113. * Resize the texture to a new desired size.
  48114. * Be carrefull as it will recreate all the data in the new texture.
  48115. * @param size Define the new size. It can be:
  48116. * - a number for squared texture,
  48117. * - an object containing { width: number, height: number }
  48118. * - or an object containing a ratio { ratio: number }
  48119. */
  48120. resize(size: number | {
  48121. width: number;
  48122. height: number;
  48123. } | {
  48124. ratio: number;
  48125. }): void;
  48126. /**
  48127. * Renders all the objects from the render list into the texture.
  48128. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  48129. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  48130. */
  48131. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  48132. private _bestReflectionRenderTargetDimension;
  48133. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  48134. private renderToTarget;
  48135. /**
  48136. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  48137. * This allowed control for front to back rendering or reversly depending of the special needs.
  48138. *
  48139. * @param renderingGroupId The rendering group id corresponding to its index
  48140. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  48141. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  48142. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  48143. */
  48144. 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;
  48145. /**
  48146. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  48147. *
  48148. * @param renderingGroupId The rendering group id corresponding to its index
  48149. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  48150. */
  48151. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  48152. /**
  48153. * Clones the texture.
  48154. * @returns the cloned texture
  48155. */
  48156. clone(): RenderTargetTexture;
  48157. /**
  48158. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  48159. * @returns The JSON representation of the texture
  48160. */
  48161. serialize(): any;
  48162. /**
  48163. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  48164. */
  48165. disposeFramebufferObjects(): void;
  48166. /**
  48167. * Dispose the texture and release its associated resources.
  48168. */
  48169. dispose(): void;
  48170. /** @hidden */
  48171. _rebuild(): void;
  48172. /**
  48173. * Clear the info related to rendering groups preventing retention point in material dispose.
  48174. */
  48175. freeRenderingGroups(): void;
  48176. }
  48177. }
  48178. declare module BABYLON {
  48179. /**
  48180. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  48181. * @see http://doc.babylonjs.com/babylon101/materials#texture
  48182. */
  48183. class Texture extends BaseTexture {
  48184. /** nearest is mag = nearest and min = nearest and mip = linear */
  48185. static readonly NEAREST_SAMPLINGMODE: number;
  48186. /** nearest is mag = nearest and min = nearest and mip = linear */
  48187. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  48188. /** Bilinear is mag = linear and min = linear and mip = nearest */
  48189. static readonly BILINEAR_SAMPLINGMODE: number;
  48190. /** Bilinear is mag = linear and min = linear and mip = nearest */
  48191. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  48192. /** Trilinear is mag = linear and min = linear and mip = linear */
  48193. static readonly TRILINEAR_SAMPLINGMODE: number;
  48194. /** Trilinear is mag = linear and min = linear and mip = linear */
  48195. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  48196. /** mag = nearest and min = nearest and mip = nearest */
  48197. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  48198. /** mag = nearest and min = linear and mip = nearest */
  48199. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  48200. /** mag = nearest and min = linear and mip = linear */
  48201. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  48202. /** mag = nearest and min = linear and mip = none */
  48203. static readonly NEAREST_LINEAR: number;
  48204. /** mag = nearest and min = nearest and mip = none */
  48205. static readonly NEAREST_NEAREST: number;
  48206. /** mag = linear and min = nearest and mip = nearest */
  48207. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  48208. /** mag = linear and min = nearest and mip = linear */
  48209. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  48210. /** mag = linear and min = linear and mip = none */
  48211. static readonly LINEAR_LINEAR: number;
  48212. /** mag = linear and min = nearest and mip = none */
  48213. static readonly LINEAR_NEAREST: number;
  48214. /** Explicit coordinates mode */
  48215. static readonly EXPLICIT_MODE: number;
  48216. /** Spherical coordinates mode */
  48217. static readonly SPHERICAL_MODE: number;
  48218. /** Planar coordinates mode */
  48219. static readonly PLANAR_MODE: number;
  48220. /** Cubic coordinates mode */
  48221. static readonly CUBIC_MODE: number;
  48222. /** Projection coordinates mode */
  48223. static readonly PROJECTION_MODE: number;
  48224. /** Inverse Cubic coordinates mode */
  48225. static readonly SKYBOX_MODE: number;
  48226. /** Inverse Cubic coordinates mode */
  48227. static readonly INVCUBIC_MODE: number;
  48228. /** Equirectangular coordinates mode */
  48229. static readonly EQUIRECTANGULAR_MODE: number;
  48230. /** Equirectangular Fixed coordinates mode */
  48231. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  48232. /** Equirectangular Fixed Mirrored coordinates mode */
  48233. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  48234. /** Texture is not repeating outside of 0..1 UVs */
  48235. static readonly CLAMP_ADDRESSMODE: number;
  48236. /** Texture is repeating outside of 0..1 UVs */
  48237. static readonly WRAP_ADDRESSMODE: number;
  48238. /** Texture is repeating and mirrored */
  48239. static readonly MIRROR_ADDRESSMODE: number;
  48240. /**
  48241. * 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
  48242. */
  48243. static UseSerializedUrlIfAny: boolean;
  48244. /**
  48245. * Define the url of the texture.
  48246. */
  48247. url: Nullable<string>;
  48248. /**
  48249. * Define an offset on the texture to offset the u coordinates of the UVs
  48250. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  48251. */
  48252. uOffset: number;
  48253. /**
  48254. * Define an offset on the texture to offset the v coordinates of the UVs
  48255. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  48256. */
  48257. vOffset: number;
  48258. /**
  48259. * Define an offset on the texture to scale the u coordinates of the UVs
  48260. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  48261. */
  48262. uScale: number;
  48263. /**
  48264. * Define an offset on the texture to scale the v coordinates of the UVs
  48265. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  48266. */
  48267. vScale: number;
  48268. /**
  48269. * Define an offset on the texture to rotate around the u coordinates of the UVs
  48270. * @see http://doc.babylonjs.com/how_to/more_materials
  48271. */
  48272. uAng: number;
  48273. /**
  48274. * Define an offset on the texture to rotate around the v coordinates of the UVs
  48275. * @see http://doc.babylonjs.com/how_to/more_materials
  48276. */
  48277. vAng: number;
  48278. /**
  48279. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  48280. * @see http://doc.babylonjs.com/how_to/more_materials
  48281. */
  48282. wAng: number;
  48283. /**
  48284. * Defines the center of rotation (U)
  48285. */
  48286. uRotationCenter: number;
  48287. /**
  48288. * Defines the center of rotation (V)
  48289. */
  48290. vRotationCenter: number;
  48291. /**
  48292. * Defines the center of rotation (W)
  48293. */
  48294. wRotationCenter: number;
  48295. /**
  48296. * Are mip maps generated for this texture or not.
  48297. */
  48298. readonly noMipmap: boolean;
  48299. private _noMipmap;
  48300. /** @hidden */
  48301. _invertY: boolean;
  48302. private _rowGenerationMatrix;
  48303. private _cachedTextureMatrix;
  48304. private _projectionModeMatrix;
  48305. private _t0;
  48306. private _t1;
  48307. private _t2;
  48308. private _cachedUOffset;
  48309. private _cachedVOffset;
  48310. private _cachedUScale;
  48311. private _cachedVScale;
  48312. private _cachedUAng;
  48313. private _cachedVAng;
  48314. private _cachedWAng;
  48315. private _cachedProjectionMatrixId;
  48316. private _cachedCoordinatesMode;
  48317. /** @hidden */
  48318. protected _initialSamplingMode: number;
  48319. /** @hidden */
  48320. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  48321. private _deleteBuffer;
  48322. protected _format: Nullable<number>;
  48323. private _delayedOnLoad;
  48324. private _delayedOnError;
  48325. /**
  48326. * Observable triggered once the texture has been loaded.
  48327. */
  48328. onLoadObservable: Observable<Texture>;
  48329. protected _isBlocking: boolean;
  48330. /**
  48331. * Is the texture preventing material to render while loading.
  48332. * If false, a default texture will be used instead of the loading one during the preparation step.
  48333. */
  48334. isBlocking: boolean;
  48335. /**
  48336. * Get the current sampling mode associated with the texture.
  48337. */
  48338. readonly samplingMode: number;
  48339. /**
  48340. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  48341. */
  48342. readonly invertY: boolean;
  48343. /**
  48344. * Instantiates a new texture.
  48345. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  48346. * @see http://doc.babylonjs.com/babylon101/materials#texture
  48347. * @param url define the url of the picture to load as a texture
  48348. * @param scene define the scene the texture will belong to
  48349. * @param noMipmap define if the texture will require mip maps or not
  48350. * @param invertY define if the texture needs to be inverted on the y axis during loading
  48351. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  48352. * @param onLoad define a callback triggered when the texture has been loaded
  48353. * @param onError define a callback triggered when an error occurred during the loading session
  48354. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  48355. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  48356. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  48357. */
  48358. 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);
  48359. /**
  48360. * Update the url (and optional buffer) of this texture if url was null during construction.
  48361. * @param url the url of the texture
  48362. * @param buffer the buffer of the texture (defaults to null)
  48363. * @param onLoad callback called when the texture is loaded (defaults to null)
  48364. */
  48365. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  48366. /**
  48367. * Finish the loading sequence of a texture flagged as delayed load.
  48368. * @hidden
  48369. */
  48370. delayLoad(): void;
  48371. private _prepareRowForTextureGeneration;
  48372. /**
  48373. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  48374. * @returns the transform matrix of the texture.
  48375. */
  48376. getTextureMatrix(): Matrix;
  48377. /**
  48378. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  48379. * @returns The reflection texture transform
  48380. */
  48381. getReflectionTextureMatrix(): Matrix;
  48382. /**
  48383. * Clones the texture.
  48384. * @returns the cloned texture
  48385. */
  48386. clone(): Texture;
  48387. /**
  48388. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  48389. * @returns The JSON representation of the texture
  48390. */
  48391. serialize(): any;
  48392. /**
  48393. * Get the current class name of the texture useful for serialization or dynamic coding.
  48394. * @returns "Texture"
  48395. */
  48396. getClassName(): string;
  48397. /**
  48398. * Dispose the texture and release its associated resources.
  48399. */
  48400. dispose(): void;
  48401. /**
  48402. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  48403. * @param parsedTexture Define the JSON representation of the texture
  48404. * @param scene Define the scene the parsed texture should be instantiated in
  48405. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  48406. * @returns The parsed texture if successful
  48407. */
  48408. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  48409. /**
  48410. * Creates a texture from its base 64 representation.
  48411. * @param data Define the base64 payload without the data: prefix
  48412. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  48413. * @param scene Define the scene the texture should belong to
  48414. * @param noMipmap Forces the texture to not create mip map information if true
  48415. * @param invertY define if the texture needs to be inverted on the y axis during loading
  48416. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  48417. * @param onLoad define a callback triggered when the texture has been loaded
  48418. * @param onError define a callback triggered when an error occurred during the loading session
  48419. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  48420. * @returns the created texture
  48421. */
  48422. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  48423. /**
  48424. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  48425. * @param data Define the base64 payload without the data: prefix
  48426. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  48427. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  48428. * @param scene Define the scene the texture should belong to
  48429. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  48430. * @param noMipmap Forces the texture to not create mip map information if true
  48431. * @param invertY define if the texture needs to be inverted on the y axis during loading
  48432. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  48433. * @param onLoad define a callback triggered when the texture has been loaded
  48434. * @param onError define a callback triggered when an error occurred during the loading session
  48435. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  48436. * @returns the created texture
  48437. */
  48438. 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;
  48439. }
  48440. }
  48441. declare module BABYLON {
  48442. /**
  48443. * Settings for finer control over video usage
  48444. */
  48445. interface VideoTextureSettings {
  48446. /**
  48447. * Applies `autoplay` to video, if specified
  48448. */
  48449. autoPlay?: boolean;
  48450. /**
  48451. * Applies `loop` to video, if specified
  48452. */
  48453. loop?: boolean;
  48454. /**
  48455. * Automatically updates internal texture from video at every frame in the render loop
  48456. */
  48457. autoUpdateTexture: boolean;
  48458. /**
  48459. * Image src displayed during the video loading or until the user interacts with the video.
  48460. */
  48461. poster?: string;
  48462. }
  48463. /**
  48464. * If you want to display a video in your scene, this is the special texture for that.
  48465. * This special texture works similar to other textures, with the exception of a few parameters.
  48466. * @see https://doc.babylonjs.com/how_to/video_texture
  48467. */
  48468. class VideoTexture extends Texture {
  48469. /**
  48470. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  48471. */
  48472. readonly autoUpdateTexture: boolean;
  48473. /**
  48474. * The video instance used by the texture internally
  48475. */
  48476. readonly video: HTMLVideoElement;
  48477. private _onUserActionRequestedObservable;
  48478. /**
  48479. * Event triggerd when a dom action is required by the user to play the video.
  48480. * This happens due to recent changes in browser policies preventing video to auto start.
  48481. */
  48482. readonly onUserActionRequestedObservable: Observable<Texture>;
  48483. private _generateMipMaps;
  48484. private _engine;
  48485. private _stillImageCaptured;
  48486. private _displayingPosterTexture;
  48487. private _settings;
  48488. private _createInternalTextureOnEvent;
  48489. /**
  48490. * Creates a video texture.
  48491. * If you want to display a video in your scene, this is the special texture for that.
  48492. * This special texture works similar to other textures, with the exception of a few parameters.
  48493. * @see https://doc.babylonjs.com/how_to/video_texture
  48494. * @param name optional name, will detect from video source, if not defined
  48495. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  48496. * @param scene is obviously the current scene.
  48497. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  48498. * @param invertY is false by default but can be used to invert video on Y axis
  48499. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  48500. * @param settings allows finer control over video usage
  48501. */
  48502. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  48503. private _getName;
  48504. private _getVideo;
  48505. private _createInternalTexture;
  48506. private reset;
  48507. /**
  48508. * @hidden Internal method to initiate `update`.
  48509. */
  48510. _rebuild(): void;
  48511. /**
  48512. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  48513. */
  48514. update(): void;
  48515. /**
  48516. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  48517. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  48518. */
  48519. updateTexture(isVisible: boolean): void;
  48520. protected _updateInternalTexture: (e?: Event | undefined) => void;
  48521. /**
  48522. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  48523. * @param url New url.
  48524. */
  48525. updateURL(url: string): void;
  48526. /**
  48527. * Dispose the texture and release its associated resources.
  48528. */
  48529. dispose(): void;
  48530. /**
  48531. * Creates a video texture straight from your WebCam video feed.
  48532. * @param scene Define the scene the texture should be created in
  48533. * @param onReady Define a callback to triggered once the texture will be ready
  48534. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  48535. */
  48536. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  48537. minWidth: number;
  48538. maxWidth: number;
  48539. minHeight: number;
  48540. maxHeight: number;
  48541. deviceId: string;
  48542. }): void;
  48543. }
  48544. }
  48545. declare module BABYLON {
  48546. }
  48547. declare var DracoDecoderModule: any;
  48548. declare var WebAssembly: any;
  48549. declare module BABYLON {
  48550. /**
  48551. * Configuration for Draco compression
  48552. */
  48553. interface IDracoCompressionConfiguration {
  48554. /**
  48555. * Configuration for the decoder.
  48556. */
  48557. decoder?: {
  48558. /**
  48559. * The url to the WebAssembly module.
  48560. */
  48561. wasmUrl?: string;
  48562. /**
  48563. * The url to the WebAssembly binary.
  48564. */
  48565. wasmBinaryUrl?: string;
  48566. /**
  48567. * The url to the fallback JavaScript module.
  48568. */
  48569. fallbackUrl?: string;
  48570. };
  48571. }
  48572. /**
  48573. * Draco compression (https://google.github.io/draco/)
  48574. *
  48575. * This class wraps the Draco module.
  48576. *
  48577. * **Encoder**
  48578. *
  48579. * The encoder is not currently implemented.
  48580. *
  48581. * **Decoder**
  48582. *
  48583. * By default, the configuration points to a copy of the Draco decoder files for glTF from the babylon.js preview cdn https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js.
  48584. *
  48585. * To update the configuration, use the following code:
  48586. * ```javascript
  48587. * BABYLON.DracoCompression.Configuration = {
  48588. * decoder: {
  48589. * wasmUrl: "<url to the WebAssembly library>",
  48590. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  48591. * fallbackUrl: "<url to the fallback JavaScript library>",
  48592. * }
  48593. * };
  48594. * ```
  48595. *
  48596. * Draco has two versions, one for WebAssembly and one for JavaScript. The decoder configuration can be set to only support Webssembly or only support the JavaScript version.
  48597. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  48598. * Use `BABYLON.DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  48599. *
  48600. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  48601. * ```javascript
  48602. * var dracoCompression = new BABYLON.DracoCompression();
  48603. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  48604. * [BABYLON.VertexBuffer.PositionKind]: 0
  48605. * });
  48606. * ```
  48607. *
  48608. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  48609. */
  48610. class DracoCompression implements IDisposable {
  48611. private static _DecoderModulePromise;
  48612. /**
  48613. * The configuration. Defaults to the following urls:
  48614. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  48615. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  48616. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  48617. */
  48618. static Configuration: IDracoCompressionConfiguration;
  48619. /**
  48620. * Returns true if the decoder is available.
  48621. */
  48622. static readonly DecoderAvailable: boolean;
  48623. /**
  48624. * Constructor
  48625. */
  48626. constructor();
  48627. /**
  48628. * Stop all async operations and release resources.
  48629. */
  48630. dispose(): void;
  48631. /**
  48632. * Decode Draco compressed mesh data to vertex data.
  48633. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  48634. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  48635. * @returns A promise that resolves with the decoded vertex data
  48636. */
  48637. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  48638. [kind: string]: number;
  48639. }): Promise<VertexData>;
  48640. private static _GetDecoderModule;
  48641. private static _LoadScriptAsync;
  48642. private static _LoadFileAsync;
  48643. }
  48644. }
  48645. declare module BABYLON {
  48646. /**
  48647. * Particle emitter emitting particles from the inside of a box.
  48648. * It emits the particles randomly between 2 given directions.
  48649. */
  48650. class BoxParticleEmitter implements IParticleEmitterType {
  48651. /**
  48652. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  48653. */
  48654. direction1: Vector3;
  48655. /**
  48656. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  48657. */
  48658. direction2: Vector3;
  48659. /**
  48660. * 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.
  48661. */
  48662. minEmitBox: Vector3;
  48663. /**
  48664. * 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.
  48665. */
  48666. maxEmitBox: Vector3;
  48667. /**
  48668. * Creates a new instance BoxParticleEmitter
  48669. */
  48670. constructor();
  48671. /**
  48672. * Called by the particle System when the direction is computed for the created particle.
  48673. * @param worldMatrix is the world matrix of the particle system
  48674. * @param directionToUpdate is the direction vector to update with the result
  48675. * @param particle is the particle we are computed the direction for
  48676. */
  48677. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48678. /**
  48679. * Called by the particle System when the position is computed for the created particle.
  48680. * @param worldMatrix is the world matrix of the particle system
  48681. * @param positionToUpdate is the position vector to update with the result
  48682. * @param particle is the particle we are computed the position for
  48683. */
  48684. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48685. /**
  48686. * Clones the current emitter and returns a copy of it
  48687. * @returns the new emitter
  48688. */
  48689. clone(): BoxParticleEmitter;
  48690. /**
  48691. * Called by the GPUParticleSystem to setup the update shader
  48692. * @param effect defines the update shader
  48693. */
  48694. applyToShader(effect: Effect): void;
  48695. /**
  48696. * Returns a string to use to update the GPU particles update shader
  48697. * @returns a string containng the defines string
  48698. */
  48699. getEffectDefines(): string;
  48700. /**
  48701. * Returns the string "BoxParticleEmitter"
  48702. * @returns a string containing the class name
  48703. */
  48704. getClassName(): string;
  48705. /**
  48706. * Serializes the particle system to a JSON object.
  48707. * @returns the JSON object
  48708. */
  48709. serialize(): any;
  48710. /**
  48711. * Parse properties from a JSON object
  48712. * @param serializationObject defines the JSON object
  48713. */
  48714. parse(serializationObject: any): void;
  48715. }
  48716. }
  48717. declare module BABYLON {
  48718. /**
  48719. * Particle emitter emitting particles from the inside of a cone.
  48720. * It emits the particles alongside the cone volume from the base to the particle.
  48721. * The emission direction might be randomized.
  48722. */
  48723. class ConeParticleEmitter implements IParticleEmitterType {
  48724. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  48725. directionRandomizer: number;
  48726. private _radius;
  48727. private _angle;
  48728. private _height;
  48729. /**
  48730. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  48731. */
  48732. radiusRange: number;
  48733. /**
  48734. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  48735. */
  48736. heightRange: number;
  48737. /**
  48738. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  48739. */
  48740. emitFromSpawnPointOnly: boolean;
  48741. /**
  48742. * Gets or sets the radius of the emission cone
  48743. */
  48744. radius: number;
  48745. /**
  48746. * Gets or sets the angle of the emission cone
  48747. */
  48748. angle: number;
  48749. private _buildHeight;
  48750. /**
  48751. * Creates a new instance ConeParticleEmitter
  48752. * @param radius the radius of the emission cone (1 by default)
  48753. * @param angles the cone base angle (PI by default)
  48754. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  48755. */
  48756. constructor(radius?: number, angle?: number,
  48757. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  48758. directionRandomizer?: number);
  48759. /**
  48760. * Called by the particle System when the direction is computed for the created particle.
  48761. * @param worldMatrix is the world matrix of the particle system
  48762. * @param directionToUpdate is the direction vector to update with the result
  48763. * @param particle is the particle we are computed the direction for
  48764. */
  48765. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48766. /**
  48767. * Called by the particle System when the position is computed for the created particle.
  48768. * @param worldMatrix is the world matrix of the particle system
  48769. * @param positionToUpdate is the position vector to update with the result
  48770. * @param particle is the particle we are computed the position for
  48771. */
  48772. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48773. /**
  48774. * Clones the current emitter and returns a copy of it
  48775. * @returns the new emitter
  48776. */
  48777. clone(): ConeParticleEmitter;
  48778. /**
  48779. * Called by the GPUParticleSystem to setup the update shader
  48780. * @param effect defines the update shader
  48781. */
  48782. applyToShader(effect: Effect): void;
  48783. /**
  48784. * Returns a string to use to update the GPU particles update shader
  48785. * @returns a string containng the defines string
  48786. */
  48787. getEffectDefines(): string;
  48788. /**
  48789. * Returns the string "ConeParticleEmitter"
  48790. * @returns a string containing the class name
  48791. */
  48792. getClassName(): string;
  48793. /**
  48794. * Serializes the particle system to a JSON object.
  48795. * @returns the JSON object
  48796. */
  48797. serialize(): any;
  48798. /**
  48799. * Parse properties from a JSON object
  48800. * @param serializationObject defines the JSON object
  48801. */
  48802. parse(serializationObject: any): void;
  48803. }
  48804. }
  48805. declare module BABYLON {
  48806. /**
  48807. * Particle emitter emitting particles from the inside of a cylinder.
  48808. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  48809. */
  48810. class CylinderParticleEmitter implements IParticleEmitterType {
  48811. /**
  48812. * The radius of the emission cylinder.
  48813. */
  48814. radius: number;
  48815. /**
  48816. * The height of the emission cylinder.
  48817. */
  48818. height: number;
  48819. /**
  48820. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  48821. */
  48822. radiusRange: number;
  48823. /**
  48824. * How much to randomize the particle direction [0-1].
  48825. */
  48826. directionRandomizer: number;
  48827. /**
  48828. * Creates a new instance CylinderParticleEmitter
  48829. * @param radius the radius of the emission cylinder (1 by default)
  48830. * @param height the height of the emission cylinder (1 by default)
  48831. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  48832. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  48833. */
  48834. constructor(
  48835. /**
  48836. * The radius of the emission cylinder.
  48837. */
  48838. radius?: number,
  48839. /**
  48840. * The height of the emission cylinder.
  48841. */
  48842. height?: number,
  48843. /**
  48844. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  48845. */
  48846. radiusRange?: number,
  48847. /**
  48848. * How much to randomize the particle direction [0-1].
  48849. */
  48850. directionRandomizer?: number);
  48851. /**
  48852. * Called by the particle System when the direction is computed for the created particle.
  48853. * @param worldMatrix is the world matrix of the particle system
  48854. * @param directionToUpdate is the direction vector to update with the result
  48855. * @param particle is the particle we are computed the direction for
  48856. */
  48857. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48858. /**
  48859. * Called by the particle System when the position is computed for the created particle.
  48860. * @param worldMatrix is the world matrix of the particle system
  48861. * @param positionToUpdate is the position vector to update with the result
  48862. * @param particle is the particle we are computed the position for
  48863. */
  48864. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48865. /**
  48866. * Clones the current emitter and returns a copy of it
  48867. * @returns the new emitter
  48868. */
  48869. clone(): CylinderParticleEmitter;
  48870. /**
  48871. * Called by the GPUParticleSystem to setup the update shader
  48872. * @param effect defines the update shader
  48873. */
  48874. applyToShader(effect: Effect): void;
  48875. /**
  48876. * Returns a string to use to update the GPU particles update shader
  48877. * @returns a string containng the defines string
  48878. */
  48879. getEffectDefines(): string;
  48880. /**
  48881. * Returns the string "CylinderParticleEmitter"
  48882. * @returns a string containing the class name
  48883. */
  48884. getClassName(): string;
  48885. /**
  48886. * Serializes the particle system to a JSON object.
  48887. * @returns the JSON object
  48888. */
  48889. serialize(): any;
  48890. /**
  48891. * Parse properties from a JSON object
  48892. * @param serializationObject defines the JSON object
  48893. */
  48894. parse(serializationObject: any): void;
  48895. }
  48896. /**
  48897. * Particle emitter emitting particles from the inside of a cylinder.
  48898. * It emits the particles randomly between two vectors.
  48899. */
  48900. class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  48901. /**
  48902. * The min limit of the emission direction.
  48903. */
  48904. direction1: Vector3;
  48905. /**
  48906. * The max limit of the emission direction.
  48907. */
  48908. direction2: Vector3;
  48909. /**
  48910. * Creates a new instance CylinderDirectedParticleEmitter
  48911. * @param radius the radius of the emission cylinder (1 by default)
  48912. * @param height the height of the emission cylinder (1 by default)
  48913. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  48914. * @param direction1 the min limit of the emission direction (up vector by default)
  48915. * @param direction2 the max limit of the emission direction (up vector by default)
  48916. */
  48917. constructor(radius?: number, height?: number, radiusRange?: number,
  48918. /**
  48919. * The min limit of the emission direction.
  48920. */
  48921. direction1?: Vector3,
  48922. /**
  48923. * The max limit of the emission direction.
  48924. */
  48925. direction2?: Vector3);
  48926. /**
  48927. * Called by the particle System when the direction is computed for the created particle.
  48928. * @param worldMatrix is the world matrix of the particle system
  48929. * @param directionToUpdate is the direction vector to update with the result
  48930. * @param particle is the particle we are computed the direction for
  48931. */
  48932. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48933. /**
  48934. * Clones the current emitter and returns a copy of it
  48935. * @returns the new emitter
  48936. */
  48937. clone(): CylinderDirectedParticleEmitter;
  48938. /**
  48939. * Called by the GPUParticleSystem to setup the update shader
  48940. * @param effect defines the update shader
  48941. */
  48942. applyToShader(effect: Effect): void;
  48943. /**
  48944. * Returns a string to use to update the GPU particles update shader
  48945. * @returns a string containng the defines string
  48946. */
  48947. getEffectDefines(): string;
  48948. /**
  48949. * Returns the string "CylinderDirectedParticleEmitter"
  48950. * @returns a string containing the class name
  48951. */
  48952. getClassName(): string;
  48953. /**
  48954. * Serializes the particle system to a JSON object.
  48955. * @returns the JSON object
  48956. */
  48957. serialize(): any;
  48958. /**
  48959. * Parse properties from a JSON object
  48960. * @param serializationObject defines the JSON object
  48961. */
  48962. parse(serializationObject: any): void;
  48963. }
  48964. }
  48965. declare module BABYLON {
  48966. /**
  48967. * Particle emitter emitting particles from the inside of a hemisphere.
  48968. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  48969. */
  48970. class HemisphericParticleEmitter implements IParticleEmitterType {
  48971. /**
  48972. * The radius of the emission hemisphere.
  48973. */
  48974. radius: number;
  48975. /**
  48976. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  48977. */
  48978. radiusRange: number;
  48979. /**
  48980. * How much to randomize the particle direction [0-1].
  48981. */
  48982. directionRandomizer: number;
  48983. /**
  48984. * Creates a new instance HemisphericParticleEmitter
  48985. * @param radius the radius of the emission hemisphere (1 by default)
  48986. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  48987. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  48988. */
  48989. constructor(
  48990. /**
  48991. * The radius of the emission hemisphere.
  48992. */
  48993. radius?: number,
  48994. /**
  48995. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  48996. */
  48997. radiusRange?: number,
  48998. /**
  48999. * How much to randomize the particle direction [0-1].
  49000. */
  49001. directionRandomizer?: number);
  49002. /**
  49003. * Called by the particle System when the direction is computed for the created particle.
  49004. * @param worldMatrix is the world matrix of the particle system
  49005. * @param directionToUpdate is the direction vector to update with the result
  49006. * @param particle is the particle we are computed the direction for
  49007. */
  49008. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  49009. /**
  49010. * Called by the particle System when the position is computed for the created particle.
  49011. * @param worldMatrix is the world matrix of the particle system
  49012. * @param positionToUpdate is the position vector to update with the result
  49013. * @param particle is the particle we are computed the position for
  49014. */
  49015. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  49016. /**
  49017. * Clones the current emitter and returns a copy of it
  49018. * @returns the new emitter
  49019. */
  49020. clone(): HemisphericParticleEmitter;
  49021. /**
  49022. * Called by the GPUParticleSystem to setup the update shader
  49023. * @param effect defines the update shader
  49024. */
  49025. applyToShader(effect: Effect): void;
  49026. /**
  49027. * Returns a string to use to update the GPU particles update shader
  49028. * @returns a string containng the defines string
  49029. */
  49030. getEffectDefines(): string;
  49031. /**
  49032. * Returns the string "HemisphericParticleEmitter"
  49033. * @returns a string containing the class name
  49034. */
  49035. getClassName(): string;
  49036. /**
  49037. * Serializes the particle system to a JSON object.
  49038. * @returns the JSON object
  49039. */
  49040. serialize(): any;
  49041. /**
  49042. * Parse properties from a JSON object
  49043. * @param serializationObject defines the JSON object
  49044. */
  49045. parse(serializationObject: any): void;
  49046. }
  49047. }
  49048. declare module BABYLON {
  49049. /**
  49050. * Particle emitter represents a volume emitting particles.
  49051. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  49052. */
  49053. interface IParticleEmitterType {
  49054. /**
  49055. * Called by the particle System when the direction is computed for the created particle.
  49056. * @param worldMatrix is the world matrix of the particle system
  49057. * @param directionToUpdate is the direction vector to update with the result
  49058. * @param particle is the particle we are computed the direction for
  49059. */
  49060. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  49061. /**
  49062. * Called by the particle System when the position is computed for the created particle.
  49063. * @param worldMatrix is the world matrix of the particle system
  49064. * @param positionToUpdate is the position vector to update with the result
  49065. * @param particle is the particle we are computed the position for
  49066. */
  49067. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  49068. /**
  49069. * Clones the current emitter and returns a copy of it
  49070. * @returns the new emitter
  49071. */
  49072. clone(): IParticleEmitterType;
  49073. /**
  49074. * Called by the GPUParticleSystem to setup the update shader
  49075. * @param effect defines the update shader
  49076. */
  49077. applyToShader(effect: Effect): void;
  49078. /**
  49079. * Returns a string to use to update the GPU particles update shader
  49080. * @returns the effect defines string
  49081. */
  49082. getEffectDefines(): string;
  49083. /**
  49084. * Returns a string representing the class name
  49085. * @returns a string containing the class name
  49086. */
  49087. getClassName(): string;
  49088. /**
  49089. * Serializes the particle system to a JSON object.
  49090. * @returns the JSON object
  49091. */
  49092. serialize(): any;
  49093. /**
  49094. * Parse properties from a JSON object
  49095. * @param serializationObject defines the JSON object
  49096. */
  49097. parse(serializationObject: any): void;
  49098. }
  49099. }
  49100. declare module BABYLON {
  49101. /**
  49102. * Particle emitter emitting particles from a point.
  49103. * It emits the particles randomly between 2 given directions.
  49104. */
  49105. class PointParticleEmitter implements IParticleEmitterType {
  49106. /**
  49107. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  49108. */
  49109. direction1: Vector3;
  49110. /**
  49111. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  49112. */
  49113. direction2: Vector3;
  49114. /**
  49115. * Creates a new instance PointParticleEmitter
  49116. */
  49117. constructor();
  49118. /**
  49119. * Called by the particle System when the direction is computed for the created particle.
  49120. * @param worldMatrix is the world matrix of the particle system
  49121. * @param directionToUpdate is the direction vector to update with the result
  49122. * @param particle is the particle we are computed the direction for
  49123. */
  49124. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  49125. /**
  49126. * Called by the particle System when the position is computed for the created particle.
  49127. * @param worldMatrix is the world matrix of the particle system
  49128. * @param positionToUpdate is the position vector to update with the result
  49129. * @param particle is the particle we are computed the position for
  49130. */
  49131. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  49132. /**
  49133. * Clones the current emitter and returns a copy of it
  49134. * @returns the new emitter
  49135. */
  49136. clone(): PointParticleEmitter;
  49137. /**
  49138. * Called by the GPUParticleSystem to setup the update shader
  49139. * @param effect defines the update shader
  49140. */
  49141. applyToShader(effect: Effect): void;
  49142. /**
  49143. * Returns a string to use to update the GPU particles update shader
  49144. * @returns a string containng the defines string
  49145. */
  49146. getEffectDefines(): string;
  49147. /**
  49148. * Returns the string "PointParticleEmitter"
  49149. * @returns a string containing the class name
  49150. */
  49151. getClassName(): string;
  49152. /**
  49153. * Serializes the particle system to a JSON object.
  49154. * @returns the JSON object
  49155. */
  49156. serialize(): any;
  49157. /**
  49158. * Parse properties from a JSON object
  49159. * @param serializationObject defines the JSON object
  49160. */
  49161. parse(serializationObject: any): void;
  49162. }
  49163. }
  49164. declare module BABYLON {
  49165. /**
  49166. * Particle emitter emitting particles from the inside of a sphere.
  49167. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  49168. */
  49169. class SphereParticleEmitter implements IParticleEmitterType {
  49170. /**
  49171. * The radius of the emission sphere.
  49172. */
  49173. radius: number;
  49174. /**
  49175. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  49176. */
  49177. radiusRange: number;
  49178. /**
  49179. * How much to randomize the particle direction [0-1].
  49180. */
  49181. directionRandomizer: number;
  49182. /**
  49183. * Creates a new instance SphereParticleEmitter
  49184. * @param radius the radius of the emission sphere (1 by default)
  49185. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  49186. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  49187. */
  49188. constructor(
  49189. /**
  49190. * The radius of the emission sphere.
  49191. */
  49192. radius?: number,
  49193. /**
  49194. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  49195. */
  49196. radiusRange?: number,
  49197. /**
  49198. * How much to randomize the particle direction [0-1].
  49199. */
  49200. directionRandomizer?: number);
  49201. /**
  49202. * Called by the particle System when the direction is computed for the created particle.
  49203. * @param worldMatrix is the world matrix of the particle system
  49204. * @param directionToUpdate is the direction vector to update with the result
  49205. * @param particle is the particle we are computed the direction for
  49206. */
  49207. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  49208. /**
  49209. * Called by the particle System when the position is computed for the created particle.
  49210. * @param worldMatrix is the world matrix of the particle system
  49211. * @param positionToUpdate is the position vector to update with the result
  49212. * @param particle is the particle we are computed the position for
  49213. */
  49214. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  49215. /**
  49216. * Clones the current emitter and returns a copy of it
  49217. * @returns the new emitter
  49218. */
  49219. clone(): SphereParticleEmitter;
  49220. /**
  49221. * Called by the GPUParticleSystem to setup the update shader
  49222. * @param effect defines the update shader
  49223. */
  49224. applyToShader(effect: Effect): void;
  49225. /**
  49226. * Returns a string to use to update the GPU particles update shader
  49227. * @returns a string containng the defines string
  49228. */
  49229. getEffectDefines(): string;
  49230. /**
  49231. * Returns the string "SphereParticleEmitter"
  49232. * @returns a string containing the class name
  49233. */
  49234. getClassName(): string;
  49235. /**
  49236. * Serializes the particle system to a JSON object.
  49237. * @returns the JSON object
  49238. */
  49239. serialize(): any;
  49240. /**
  49241. * Parse properties from a JSON object
  49242. * @param serializationObject defines the JSON object
  49243. */
  49244. parse(serializationObject: any): void;
  49245. }
  49246. /**
  49247. * Particle emitter emitting particles from the inside of a sphere.
  49248. * It emits the particles randomly between two vectors.
  49249. */
  49250. class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  49251. /**
  49252. * The min limit of the emission direction.
  49253. */
  49254. direction1: Vector3;
  49255. /**
  49256. * The max limit of the emission direction.
  49257. */
  49258. direction2: Vector3;
  49259. /**
  49260. * Creates a new instance SphereDirectedParticleEmitter
  49261. * @param radius the radius of the emission sphere (1 by default)
  49262. * @param direction1 the min limit of the emission direction (up vector by default)
  49263. * @param direction2 the max limit of the emission direction (up vector by default)
  49264. */
  49265. constructor(radius?: number,
  49266. /**
  49267. * The min limit of the emission direction.
  49268. */
  49269. direction1?: Vector3,
  49270. /**
  49271. * The max limit of the emission direction.
  49272. */
  49273. direction2?: Vector3);
  49274. /**
  49275. * Called by the particle System when the direction is computed for the created particle.
  49276. * @param worldMatrix is the world matrix of the particle system
  49277. * @param directionToUpdate is the direction vector to update with the result
  49278. * @param particle is the particle we are computed the direction for
  49279. */
  49280. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  49281. /**
  49282. * Clones the current emitter and returns a copy of it
  49283. * @returns the new emitter
  49284. */
  49285. clone(): SphereDirectedParticleEmitter;
  49286. /**
  49287. * Called by the GPUParticleSystem to setup the update shader
  49288. * @param effect defines the update shader
  49289. */
  49290. applyToShader(effect: Effect): void;
  49291. /**
  49292. * Returns a string to use to update the GPU particles update shader
  49293. * @returns a string containng the defines string
  49294. */
  49295. getEffectDefines(): string;
  49296. /**
  49297. * Returns the string "SphereDirectedParticleEmitter"
  49298. * @returns a string containing the class name
  49299. */
  49300. getClassName(): string;
  49301. /**
  49302. * Serializes the particle system to a JSON object.
  49303. * @returns the JSON object
  49304. */
  49305. serialize(): any;
  49306. /**
  49307. * Parse properties from a JSON object
  49308. * @param serializationObject defines the JSON object
  49309. */
  49310. parse(serializationObject: any): void;
  49311. }
  49312. }
  49313. declare module BABYLON {
  49314. /**
  49315. * AmmoJS Physics plugin
  49316. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  49317. * @see https://github.com/kripken/ammo.js/
  49318. */
  49319. class AmmoJSPlugin implements IPhysicsEnginePlugin {
  49320. private _useDeltaForWorldStep;
  49321. /**
  49322. * Reference to the Ammo library
  49323. */
  49324. bjsAMMO: any;
  49325. /**
  49326. * Created ammoJS world which physics bodies are added to
  49327. */
  49328. world: any;
  49329. /**
  49330. * Name of the plugin
  49331. */
  49332. name: string;
  49333. private _timeStep;
  49334. private _fixedTimeStep;
  49335. private _maxSteps;
  49336. private _tmpQuaternion;
  49337. private _tmpAmmoTransform;
  49338. private _tmpAmmoQuaternion;
  49339. private _tmpAmmoConcreteContactResultCallback;
  49340. private _collisionConfiguration;
  49341. private _dispatcher;
  49342. private _overlappingPairCache;
  49343. private _solver;
  49344. private _tmpAmmoVectorA;
  49345. private _tmpAmmoVectorB;
  49346. private _tmpAmmoVectorC;
  49347. private _tmpContactCallbackResult;
  49348. private static readonly DISABLE_COLLISION_FLAG;
  49349. private static readonly KINEMATIC_FLAG;
  49350. private static readonly DISABLE_DEACTIVATION_FLAG;
  49351. /**
  49352. * Initializes the ammoJS plugin
  49353. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  49354. */
  49355. constructor(_useDeltaForWorldStep?: boolean);
  49356. /**
  49357. * Sets the gravity of the physics world (m/(s^2))
  49358. * @param gravity Gravity to set
  49359. */
  49360. setGravity(gravity: Vector3): void;
  49361. /**
  49362. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  49363. * @param timeStep timestep to use in seconds
  49364. */
  49365. setTimeStep(timeStep: number): void;
  49366. /**
  49367. * 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)
  49368. * @param fixedTimeStep fixedTimeStep to use in seconds
  49369. */
  49370. setFixedTimeStep(fixedTimeStep: number): void;
  49371. /**
  49372. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  49373. * @param maxSteps the maximum number of steps by the physics engine per frame
  49374. */
  49375. setMaxSteps(maxSteps: number): void;
  49376. /**
  49377. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  49378. * @returns the current timestep in seconds
  49379. */
  49380. getTimeStep(): number;
  49381. private _isImpostorInContact;
  49382. private _isImpostorPairInContact;
  49383. private _stepSimulation;
  49384. /**
  49385. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  49386. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  49387. * After the step the babylon meshes are set to the position of the physics imposters
  49388. * @param delta amount of time to step forward
  49389. * @param impostors array of imposters to update before/after the step
  49390. */
  49391. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  49392. /**
  49393. * Applies an implulse on the imposter
  49394. * @param impostor imposter to apply impulse
  49395. * @param force amount of force to be applied to the imposter
  49396. * @param contactPoint the location to apply the impulse on the imposter
  49397. */
  49398. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49399. /**
  49400. * Applies a force on the imposter
  49401. * @param impostor imposter to apply force
  49402. * @param force amount of force to be applied to the imposter
  49403. * @param contactPoint the location to apply the force on the imposter
  49404. */
  49405. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49406. /**
  49407. * Creates a physics body using the plugin
  49408. * @param impostor the imposter to create the physics body on
  49409. */
  49410. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49411. /**
  49412. * Removes the physics body from the imposter and disposes of the body's memory
  49413. * @param impostor imposter to remove the physics body from
  49414. */
  49415. removePhysicsBody(impostor: PhysicsImpostor): void;
  49416. /**
  49417. * Generates a joint
  49418. * @param impostorJoint the imposter joint to create the joint with
  49419. */
  49420. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49421. /**
  49422. * Removes a joint
  49423. * @param impostorJoint the imposter joint to remove the joint from
  49424. */
  49425. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49426. private _addMeshVerts;
  49427. private _createShape;
  49428. /**
  49429. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  49430. * @param impostor imposter containing the physics body and babylon object
  49431. */
  49432. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49433. /**
  49434. * Sets the babylon object's position/rotation from the physics body's position/rotation
  49435. * @param impostor imposter containing the physics body and babylon object
  49436. * @param newPosition new position
  49437. * @param newRotation new rotation
  49438. */
  49439. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49440. /**
  49441. * If this plugin is supported
  49442. * @returns true if its supported
  49443. */
  49444. isSupported(): boolean;
  49445. /**
  49446. * Sets the linear velocity of the physics body
  49447. * @param impostor imposter to set the velocity on
  49448. * @param velocity velocity to set
  49449. */
  49450. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49451. /**
  49452. * Sets the angular velocity of the physics body
  49453. * @param impostor imposter to set the velocity on
  49454. * @param velocity velocity to set
  49455. */
  49456. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49457. /**
  49458. * gets the linear velocity
  49459. * @param impostor imposter to get linear velocity from
  49460. * @returns linear velocity
  49461. */
  49462. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49463. /**
  49464. * gets the angular velocity
  49465. * @param impostor imposter to get angular velocity from
  49466. * @returns angular velocity
  49467. */
  49468. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49469. /**
  49470. * Sets the mass of physics body
  49471. * @param impostor imposter to set the mass on
  49472. * @param mass mass to set
  49473. */
  49474. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49475. /**
  49476. * Gets the mass of the physics body
  49477. * @param impostor imposter to get the mass from
  49478. * @returns mass
  49479. */
  49480. getBodyMass(impostor: PhysicsImpostor): number;
  49481. /**
  49482. * Gets friction of the impostor
  49483. * @param impostor impostor to get friction from
  49484. * @returns friction value
  49485. */
  49486. getBodyFriction(impostor: PhysicsImpostor): number;
  49487. /**
  49488. * Sets friction of the impostor
  49489. * @param impostor impostor to set friction on
  49490. * @param friction friction value
  49491. */
  49492. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49493. /**
  49494. * Gets restitution of the impostor
  49495. * @param impostor impostor to get restitution from
  49496. * @returns restitution value
  49497. */
  49498. getBodyRestitution(impostor: PhysicsImpostor): number;
  49499. /**
  49500. * Sets resitution of the impostor
  49501. * @param impostor impostor to set resitution on
  49502. * @param restitution resitution value
  49503. */
  49504. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49505. /**
  49506. * Sleeps the physics body and stops it from being active
  49507. * @param impostor impostor to sleep
  49508. */
  49509. sleepBody(impostor: PhysicsImpostor): void;
  49510. /**
  49511. * Activates the physics body
  49512. * @param impostor impostor to activate
  49513. */
  49514. wakeUpBody(impostor: PhysicsImpostor): void;
  49515. /**
  49516. * Updates the distance parameters of the joint
  49517. * @param joint joint to update
  49518. * @param maxDistance maximum distance of the joint
  49519. * @param minDistance minimum distance of the joint
  49520. */
  49521. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  49522. /**
  49523. * Sets a motor on the joint
  49524. * @param joint joint to set motor on
  49525. * @param speed speed of the motor
  49526. * @param maxForce maximum force of the motor
  49527. * @param motorIndex index of the motor
  49528. */
  49529. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  49530. /**
  49531. * Sets the motors limit
  49532. * @param joint joint to set limit on
  49533. * @param upperLimit upper limit
  49534. * @param lowerLimit lower limit
  49535. */
  49536. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  49537. /**
  49538. * Syncs the position and rotation of a mesh with the impostor
  49539. * @param mesh mesh to sync
  49540. * @param impostor impostor to update the mesh with
  49541. */
  49542. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49543. /**
  49544. * Gets the radius of the impostor
  49545. * @param impostor impostor to get radius from
  49546. * @returns the radius
  49547. */
  49548. getRadius(impostor: PhysicsImpostor): number;
  49549. /**
  49550. * Gets the box size of the impostor
  49551. * @param impostor impostor to get box size from
  49552. * @param result the resulting box size
  49553. */
  49554. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49555. /**
  49556. * Disposes of the impostor
  49557. */
  49558. dispose(): void;
  49559. }
  49560. }
  49561. declare module BABYLON {
  49562. /** @hidden */
  49563. class CannonJSPlugin implements IPhysicsEnginePlugin {
  49564. private _useDeltaForWorldStep;
  49565. world: any;
  49566. name: string;
  49567. private _physicsMaterials;
  49568. private _fixedTimeStep;
  49569. BJSCANNON: any;
  49570. constructor(_useDeltaForWorldStep?: boolean, iterations?: number);
  49571. setGravity(gravity: Vector3): void;
  49572. setTimeStep(timeStep: number): void;
  49573. getTimeStep(): number;
  49574. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  49575. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49576. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49577. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49578. private _processChildMeshes;
  49579. removePhysicsBody(impostor: PhysicsImpostor): void;
  49580. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49581. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49582. private _addMaterial;
  49583. private _checkWithEpsilon;
  49584. private _createShape;
  49585. private _createHeightmap;
  49586. private _minus90X;
  49587. private _plus90X;
  49588. private _tmpPosition;
  49589. private _tmpDeltaPosition;
  49590. private _tmpUnityRotation;
  49591. private _updatePhysicsBodyTransformation;
  49592. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49593. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49594. isSupported(): boolean;
  49595. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49596. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49597. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49598. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49599. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49600. getBodyMass(impostor: PhysicsImpostor): number;
  49601. getBodyFriction(impostor: PhysicsImpostor): number;
  49602. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49603. getBodyRestitution(impostor: PhysicsImpostor): number;
  49604. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49605. sleepBody(impostor: PhysicsImpostor): void;
  49606. wakeUpBody(impostor: PhysicsImpostor): void;
  49607. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  49608. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  49609. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  49610. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49611. getRadius(impostor: PhysicsImpostor): number;
  49612. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49613. dispose(): void;
  49614. private _extendNamespace;
  49615. }
  49616. }
  49617. declare module BABYLON {
  49618. /** @hidden */
  49619. class OimoJSPlugin implements IPhysicsEnginePlugin {
  49620. world: any;
  49621. name: string;
  49622. BJSOIMO: any;
  49623. constructor(iterations?: number);
  49624. setGravity(gravity: Vector3): void;
  49625. setTimeStep(timeStep: number): void;
  49626. getTimeStep(): number;
  49627. private _tmpImpostorsArray;
  49628. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  49629. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49630. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49631. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49632. private _tmpPositionVector;
  49633. removePhysicsBody(impostor: PhysicsImpostor): void;
  49634. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49635. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49636. isSupported(): boolean;
  49637. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49638. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49639. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49640. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49641. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49642. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49643. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49644. getBodyMass(impostor: PhysicsImpostor): number;
  49645. getBodyFriction(impostor: PhysicsImpostor): number;
  49646. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49647. getBodyRestitution(impostor: PhysicsImpostor): number;
  49648. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49649. sleepBody(impostor: PhysicsImpostor): void;
  49650. wakeUpBody(impostor: PhysicsImpostor): void;
  49651. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  49652. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  49653. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  49654. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49655. getRadius(impostor: PhysicsImpostor): number;
  49656. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49657. dispose(): void;
  49658. }
  49659. }
  49660. declare module BABYLON {
  49661. /**
  49662. * This represents a set of one or more post processes in Babylon.
  49663. * A post process can be used to apply a shader to a texture after it is rendered.
  49664. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49665. */
  49666. class PostProcessRenderEffect {
  49667. private _postProcesses;
  49668. private _getPostProcesses;
  49669. private _singleInstance;
  49670. private _cameras;
  49671. private _indicesForCamera;
  49672. /**
  49673. * Name of the effect
  49674. * @hidden
  49675. */
  49676. _name: string;
  49677. /**
  49678. * Instantiates a post process render effect.
  49679. * A post process can be used to apply a shader to a texture after it is rendered.
  49680. * @param engine The engine the effect is tied to
  49681. * @param name The name of the effect
  49682. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  49683. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  49684. */
  49685. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  49686. /**
  49687. * Checks if all the post processes in the effect are supported.
  49688. */
  49689. readonly isSupported: boolean;
  49690. /**
  49691. * Updates the current state of the effect
  49692. * @hidden
  49693. */
  49694. _update(): void;
  49695. /**
  49696. * Attaches the effect on cameras
  49697. * @param cameras The camera to attach to.
  49698. * @hidden
  49699. */
  49700. _attachCameras(cameras: Camera): void;
  49701. /**
  49702. * Attaches the effect on cameras
  49703. * @param cameras The camera to attach to.
  49704. * @hidden
  49705. */
  49706. _attachCameras(cameras: Camera[]): void;
  49707. /**
  49708. * Detatches the effect on cameras
  49709. * @param cameras The camera to detatch from.
  49710. * @hidden
  49711. */
  49712. _detachCameras(cameras: Camera): void;
  49713. /**
  49714. * Detatches the effect on cameras
  49715. * @param cameras The camera to detatch from.
  49716. * @hidden
  49717. */
  49718. _detachCameras(cameras: Camera[]): void;
  49719. /**
  49720. * Enables the effect on given cameras
  49721. * @param cameras The camera to enable.
  49722. * @hidden
  49723. */
  49724. _enable(cameras: Camera): void;
  49725. /**
  49726. * Enables the effect on given cameras
  49727. * @param cameras The camera to enable.
  49728. * @hidden
  49729. */
  49730. _enable(cameras: Nullable<Camera[]>): void;
  49731. /**
  49732. * Disables the effect on the given cameras
  49733. * @param cameras The camera to disable.
  49734. * @hidden
  49735. */
  49736. _disable(cameras: Camera): void;
  49737. /**
  49738. * Disables the effect on the given cameras
  49739. * @param cameras The camera to disable.
  49740. * @hidden
  49741. */
  49742. _disable(cameras: Nullable<Camera[]>): void;
  49743. /**
  49744. * Gets a list of the post processes contained in the effect.
  49745. * @param camera The camera to get the post processes on.
  49746. * @returns The list of the post processes in the effect.
  49747. */
  49748. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  49749. }
  49750. }
  49751. declare module BABYLON {
  49752. /**
  49753. * PostProcessRenderPipeline
  49754. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49755. */
  49756. class PostProcessRenderPipeline {
  49757. private engine;
  49758. private _renderEffects;
  49759. private _renderEffectsForIsolatedPass;
  49760. /**
  49761. * @hidden
  49762. */
  49763. protected _cameras: Camera[];
  49764. /** @hidden */
  49765. _name: string;
  49766. /**
  49767. * Initializes a PostProcessRenderPipeline
  49768. * @param engine engine to add the pipeline to
  49769. * @param name name of the pipeline
  49770. */
  49771. constructor(engine: Engine, name: string);
  49772. /**
  49773. * "PostProcessRenderPipeline"
  49774. * @returns "PostProcessRenderPipeline"
  49775. */
  49776. getClassName(): string;
  49777. /**
  49778. * If all the render effects in the pipeline are support
  49779. */
  49780. readonly isSupported: boolean;
  49781. /**
  49782. * Adds an effect to the pipeline
  49783. * @param renderEffect the effect to add
  49784. */
  49785. addEffect(renderEffect: PostProcessRenderEffect): void;
  49786. /** @hidden */
  49787. _rebuild(): void;
  49788. /** @hidden */
  49789. _enableEffect(renderEffectName: string, cameras: Camera): void;
  49790. /** @hidden */
  49791. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  49792. /** @hidden */
  49793. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  49794. /** @hidden */
  49795. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  49796. /** @hidden */
  49797. _attachCameras(cameras: Camera, unique: boolean): void;
  49798. /** @hidden */
  49799. _attachCameras(cameras: Camera[], unique: boolean): void;
  49800. /** @hidden */
  49801. _detachCameras(cameras: Camera): void;
  49802. /** @hidden */
  49803. _detachCameras(cameras: Nullable<Camera[]>): void;
  49804. /** @hidden */
  49805. _update(): void;
  49806. /** @hidden */
  49807. _reset(): void;
  49808. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  49809. /**
  49810. * Disposes of the pipeline
  49811. */
  49812. dispose(): void;
  49813. }
  49814. }
  49815. declare module BABYLON {
  49816. /**
  49817. * PostProcessRenderPipelineManager class
  49818. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49819. */
  49820. class PostProcessRenderPipelineManager {
  49821. private _renderPipelines;
  49822. /**
  49823. * Initializes a PostProcessRenderPipelineManager
  49824. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49825. */
  49826. constructor();
  49827. /**
  49828. * Adds a pipeline to the manager
  49829. * @param renderPipeline The pipeline to add
  49830. */
  49831. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  49832. /**
  49833. * Attaches a camera to the pipeline
  49834. * @param renderPipelineName The name of the pipeline to attach to
  49835. * @param cameras the camera to attach
  49836. * @param unique if the camera can be attached multiple times to the pipeline
  49837. */
  49838. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  49839. /**
  49840. * Detaches a camera from the pipeline
  49841. * @param renderPipelineName The name of the pipeline to detach from
  49842. * @param cameras the camera to detach
  49843. */
  49844. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  49845. /**
  49846. * Enables an effect by name on a pipeline
  49847. * @param renderPipelineName the name of the pipeline to enable the effect in
  49848. * @param renderEffectName the name of the effect to enable
  49849. * @param cameras the cameras that the effect should be enabled on
  49850. */
  49851. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  49852. /**
  49853. * Disables an effect by name on a pipeline
  49854. * @param renderPipelineName the name of the pipeline to disable the effect in
  49855. * @param renderEffectName the name of the effect to disable
  49856. * @param cameras the cameras that the effect should be disabled on
  49857. */
  49858. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  49859. /**
  49860. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  49861. */
  49862. update(): void;
  49863. /** @hidden */
  49864. _rebuild(): void;
  49865. /**
  49866. * Disposes of the manager and pipelines
  49867. */
  49868. dispose(): void;
  49869. }
  49870. }
  49871. declare module BABYLON {
  49872. interface Scene {
  49873. /** @hidden (Backing field) */
  49874. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  49875. /**
  49876. * Gets the postprocess render pipeline manager
  49877. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49878. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  49879. */
  49880. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  49881. }
  49882. /**
  49883. * Defines the Render Pipeline scene component responsible to rendering pipelines
  49884. */
  49885. class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  49886. /**
  49887. * The component name helpfull to identify the component in the list of scene components.
  49888. */
  49889. readonly name: string;
  49890. /**
  49891. * The scene the component belongs to.
  49892. */
  49893. scene: Scene;
  49894. /**
  49895. * Creates a new instance of the component for the given scene
  49896. * @param scene Defines the scene to register the component in
  49897. */
  49898. constructor(scene: Scene);
  49899. /**
  49900. * Registers the component in a given scene
  49901. */
  49902. register(): void;
  49903. /**
  49904. * Rebuilds the elements related to this component in case of
  49905. * context lost for instance.
  49906. */
  49907. rebuild(): void;
  49908. /**
  49909. * Disposes the component and the associated ressources
  49910. */
  49911. dispose(): void;
  49912. private _gatherRenderTargets;
  49913. }
  49914. }
  49915. declare module BABYLON {
  49916. /**
  49917. * Helper class dealing with the extraction of spherical polynomial dataArray
  49918. * from a cube map.
  49919. */
  49920. class CubeMapToSphericalPolynomialTools {
  49921. private static FileFaces;
  49922. /**
  49923. * Converts a texture to the according Spherical Polynomial data.
  49924. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49925. *
  49926. * @param texture The texture to extract the information from.
  49927. * @return The Spherical Polynomial data.
  49928. */
  49929. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  49930. /**
  49931. * Converts a cubemap to the according Spherical Polynomial data.
  49932. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49933. *
  49934. * @param cubeInfo The Cube map to extract the information from.
  49935. * @return The Spherical Polynomial data.
  49936. */
  49937. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  49938. }
  49939. }
  49940. declare module BABYLON {
  49941. /**
  49942. * Header information of HDR texture files.
  49943. */
  49944. interface HDRInfo {
  49945. /**
  49946. * The height of the texture in pixels.
  49947. */
  49948. height: number;
  49949. /**
  49950. * The width of the texture in pixels.
  49951. */
  49952. width: number;
  49953. /**
  49954. * The index of the beginning of the data in the binary file.
  49955. */
  49956. dataPosition: number;
  49957. }
  49958. /**
  49959. * This groups tools to convert HDR texture to native colors array.
  49960. */
  49961. class HDRTools {
  49962. private static Ldexp;
  49963. private static Rgbe2float;
  49964. private static readStringLine;
  49965. /**
  49966. * Reads header information from an RGBE texture stored in a native array.
  49967. * More information on this format are available here:
  49968. * https://en.wikipedia.org/wiki/RGBE_image_format
  49969. *
  49970. * @param uint8array The binary file stored in native array.
  49971. * @return The header information.
  49972. */
  49973. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  49974. /**
  49975. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  49976. * This RGBE texture needs to store the information as a panorama.
  49977. *
  49978. * More information on this format are available here:
  49979. * https://en.wikipedia.org/wiki/RGBE_image_format
  49980. *
  49981. * @param buffer The binary file stored in an array buffer.
  49982. * @param size The expected size of the extracted cubemap.
  49983. * @return The Cube Map information.
  49984. */
  49985. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  49986. /**
  49987. * Returns the pixels data extracted from an RGBE texture.
  49988. * This pixels will be stored left to right up to down in the R G B order in one array.
  49989. *
  49990. * More information on this format are available here:
  49991. * https://en.wikipedia.org/wiki/RGBE_image_format
  49992. *
  49993. * @param uint8array The binary file stored in an array buffer.
  49994. * @param hdrInfo The header information of the file.
  49995. * @return The pixels data in RGB right to left up to down order.
  49996. */
  49997. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  49998. private static RGBE_ReadPixels_RLE;
  49999. }
  50000. }
  50001. declare module BABYLON {
  50002. /**
  50003. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  50004. */
  50005. interface CubeMapInfo {
  50006. /**
  50007. * The pixel array for the front face.
  50008. * This is stored in format, left to right, up to down format.
  50009. */
  50010. front: Nullable<ArrayBufferView>;
  50011. /**
  50012. * The pixel array for the back face.
  50013. * This is stored in format, left to right, up to down format.
  50014. */
  50015. back: Nullable<ArrayBufferView>;
  50016. /**
  50017. * The pixel array for the left face.
  50018. * This is stored in format, left to right, up to down format.
  50019. */
  50020. left: Nullable<ArrayBufferView>;
  50021. /**
  50022. * The pixel array for the right face.
  50023. * This is stored in format, left to right, up to down format.
  50024. */
  50025. right: Nullable<ArrayBufferView>;
  50026. /**
  50027. * The pixel array for the up face.
  50028. * This is stored in format, left to right, up to down format.
  50029. */
  50030. up: Nullable<ArrayBufferView>;
  50031. /**
  50032. * The pixel array for the down face.
  50033. * This is stored in format, left to right, up to down format.
  50034. */
  50035. down: Nullable<ArrayBufferView>;
  50036. /**
  50037. * The size of the cubemap stored.
  50038. *
  50039. * Each faces will be size * size pixels.
  50040. */
  50041. size: number;
  50042. /**
  50043. * The format of the texture.
  50044. *
  50045. * RGBA, RGB.
  50046. */
  50047. format: number;
  50048. /**
  50049. * The type of the texture data.
  50050. *
  50051. * UNSIGNED_INT, FLOAT.
  50052. */
  50053. type: number;
  50054. /**
  50055. * Specifies whether the texture is in gamma space.
  50056. */
  50057. gammaSpace: boolean;
  50058. }
  50059. /**
  50060. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  50061. */
  50062. class PanoramaToCubeMapTools {
  50063. private static FACE_FRONT;
  50064. private static FACE_BACK;
  50065. private static FACE_RIGHT;
  50066. private static FACE_LEFT;
  50067. private static FACE_DOWN;
  50068. private static FACE_UP;
  50069. /**
  50070. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  50071. *
  50072. * @param float32Array The source data.
  50073. * @param inputWidth The width of the input panorama.
  50074. * @param inputHeight The height of the input panorama.
  50075. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  50076. * @return The cubemap data
  50077. */
  50078. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  50079. private static CreateCubemapTexture;
  50080. private static CalcProjectionSpherical;
  50081. }
  50082. }
  50083. declare module BABYLON {
  50084. }
  50085. declare module BABYLON {
  50086. }
  50087. declare module BABYLON {
  50088. }
  50089. declare module BABYLON {
  50090. }
  50091. declare module BABYLON {
  50092. /**
  50093. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  50094. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  50095. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  50096. */
  50097. class CustomProceduralTexture extends ProceduralTexture {
  50098. private _animate;
  50099. private _time;
  50100. private _config;
  50101. private _texturePath;
  50102. /**
  50103. * Instantiates a new Custom Procedural Texture.
  50104. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  50105. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  50106. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  50107. * @param name Define the name of the texture
  50108. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  50109. * @param size Define the size of the texture to create
  50110. * @param scene Define the scene the texture belongs to
  50111. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  50112. * @param generateMipMaps Define if the texture should creates mip maps or not
  50113. */
  50114. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  50115. private _loadJson;
  50116. /**
  50117. * Is the texture ready to be used ? (rendered at least once)
  50118. * @returns true if ready, otherwise, false.
  50119. */
  50120. isReady(): boolean;
  50121. /**
  50122. * Render the texture to its associated render target.
  50123. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  50124. */
  50125. render(useCameraPostProcess?: boolean): void;
  50126. /**
  50127. * Update the list of dependant textures samplers in the shader.
  50128. */
  50129. updateTextures(): void;
  50130. /**
  50131. * Update the uniform values of the procedural texture in the shader.
  50132. */
  50133. updateShaderUniforms(): void;
  50134. /**
  50135. * Define if the texture animates or not.
  50136. */
  50137. animate: boolean;
  50138. }
  50139. }
  50140. declare module BABYLON {
  50141. /**
  50142. * Class used to generate noise procedural textures
  50143. */
  50144. class NoiseProceduralTexture extends ProceduralTexture {
  50145. private _time;
  50146. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  50147. brightness: number;
  50148. /** Defines the number of octaves to process */
  50149. octaves: number;
  50150. /** Defines the level of persistence (0.8 by default) */
  50151. persistence: number;
  50152. /** Gets or sets animation speed factor (default is 1) */
  50153. animationSpeedFactor: number;
  50154. /**
  50155. * Creates a new NoiseProceduralTexture
  50156. * @param name defines the name fo the texture
  50157. * @param size defines the size of the texture (default is 256)
  50158. * @param scene defines the hosting scene
  50159. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  50160. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  50161. */
  50162. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  50163. private _updateShaderUniforms;
  50164. protected _getDefines(): string;
  50165. /** Generate the current state of the procedural texture */
  50166. render(useCameraPostProcess?: boolean): void;
  50167. /**
  50168. * Serializes this noise procedural texture
  50169. * @returns a serialized noise procedural texture object
  50170. */
  50171. serialize(): any;
  50172. /**
  50173. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  50174. * @param parsedTexture defines parsed texture data
  50175. * @param scene defines the current scene
  50176. * @param rootUrl defines the root URL containing noise procedural texture information
  50177. * @returns a parsed NoiseProceduralTexture
  50178. */
  50179. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): NoiseProceduralTexture;
  50180. }
  50181. }
  50182. declare module BABYLON {
  50183. /**
  50184. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  50185. * This is the base class of any Procedural texture and contains most of the shareable code.
  50186. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  50187. */
  50188. class ProceduralTexture extends Texture {
  50189. isCube: boolean;
  50190. /**
  50191. * Define if the texture is enabled or not (disabled texture will not render)
  50192. */
  50193. isEnabled: boolean;
  50194. /**
  50195. * Define if the texture must be cleared before rendering (default is true)
  50196. */
  50197. autoClear: boolean;
  50198. /**
  50199. * Callback called when the texture is generated
  50200. */
  50201. onGenerated: () => void;
  50202. /**
  50203. * Event raised when the texture is generated
  50204. */
  50205. onGeneratedObservable: Observable<ProceduralTexture>;
  50206. /** @hidden */
  50207. _generateMipMaps: boolean;
  50208. /** @hidden **/
  50209. _effect: Effect;
  50210. /** @hidden */
  50211. _textures: {
  50212. [key: string]: Texture;
  50213. };
  50214. private _size;
  50215. private _currentRefreshId;
  50216. private _refreshRate;
  50217. private _vertexBuffers;
  50218. private _indexBuffer;
  50219. private _uniforms;
  50220. private _samplers;
  50221. private _fragment;
  50222. private _floats;
  50223. private _ints;
  50224. private _floatsArrays;
  50225. private _colors3;
  50226. private _colors4;
  50227. private _vectors2;
  50228. private _vectors3;
  50229. private _matrices;
  50230. private _fallbackTexture;
  50231. private _fallbackTextureUsed;
  50232. private _engine;
  50233. private _cachedDefines;
  50234. private _contentUpdateId;
  50235. private _contentData;
  50236. /**
  50237. * Instantiates a new procedural texture.
  50238. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  50239. * This is the base class of any Procedural texture and contains most of the shareable code.
  50240. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  50241. * @param name Define the name of the texture
  50242. * @param size Define the size of the texture to create
  50243. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  50244. * @param scene Define the scene the texture belongs to
  50245. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  50246. * @param generateMipMaps Define if the texture should creates mip maps or not
  50247. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  50248. */
  50249. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  50250. /**
  50251. * The effect that is created when initializing the post process.
  50252. * @returns The created effect corrisponding the the postprocess.
  50253. */
  50254. getEffect(): Effect;
  50255. /**
  50256. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  50257. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  50258. */
  50259. getContent(): Nullable<ArrayBufferView>;
  50260. private _createIndexBuffer;
  50261. /** @hidden */
  50262. _rebuild(): void;
  50263. /**
  50264. * Resets the texture in order to recreate its associated resources.
  50265. * This can be called in case of context loss
  50266. */
  50267. reset(): void;
  50268. protected _getDefines(): string;
  50269. /**
  50270. * Is the texture ready to be used ? (rendered at least once)
  50271. * @returns true if ready, otherwise, false.
  50272. */
  50273. isReady(): boolean;
  50274. /**
  50275. * Resets the refresh counter of the texture and start bak from scratch.
  50276. * Could be useful to regenerate the texture if it is setup to render only once.
  50277. */
  50278. resetRefreshCounter(): void;
  50279. /**
  50280. * Set the fragment shader to use in order to render the texture.
  50281. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  50282. */
  50283. setFragment(fragment: any): void;
  50284. /**
  50285. * Define the refresh rate of the texture or the rendering frequency.
  50286. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  50287. */
  50288. refreshRate: number;
  50289. /** @hidden */
  50290. _shouldRender(): boolean;
  50291. /**
  50292. * Get the size the texture is rendering at.
  50293. * @returns the size (texture is always squared)
  50294. */
  50295. getRenderSize(): number;
  50296. /**
  50297. * Resize the texture to new value.
  50298. * @param size Define the new size the texture should have
  50299. * @param generateMipMaps Define whether the new texture should create mip maps
  50300. */
  50301. resize(size: number, generateMipMaps: boolean): void;
  50302. private _checkUniform;
  50303. /**
  50304. * Set a texture in the shader program used to render.
  50305. * @param name Define the name of the uniform samplers as defined in the shader
  50306. * @param texture Define the texture to bind to this sampler
  50307. * @return the texture itself allowing "fluent" like uniform updates
  50308. */
  50309. setTexture(name: string, texture: Texture): ProceduralTexture;
  50310. /**
  50311. * Set a float in the shader.
  50312. * @param name Define the name of the uniform as defined in the shader
  50313. * @param value Define the value to give to the uniform
  50314. * @return the texture itself allowing "fluent" like uniform updates
  50315. */
  50316. setFloat(name: string, value: number): ProceduralTexture;
  50317. /**
  50318. * Set a int in the shader.
  50319. * @param name Define the name of the uniform as defined in the shader
  50320. * @param value Define the value to give to the uniform
  50321. * @return the texture itself allowing "fluent" like uniform updates
  50322. */
  50323. setInt(name: string, value: number): ProceduralTexture;
  50324. /**
  50325. * Set an array of floats in the shader.
  50326. * @param name Define the name of the uniform as defined in the shader
  50327. * @param value Define the value to give to the uniform
  50328. * @return the texture itself allowing "fluent" like uniform updates
  50329. */
  50330. setFloats(name: string, value: number[]): ProceduralTexture;
  50331. /**
  50332. * Set a vec3 in the shader from a Color3.
  50333. * @param name Define the name of the uniform as defined in the shader
  50334. * @param value Define the value to give to the uniform
  50335. * @return the texture itself allowing "fluent" like uniform updates
  50336. */
  50337. setColor3(name: string, value: Color3): ProceduralTexture;
  50338. /**
  50339. * Set a vec4 in the shader from a Color4.
  50340. * @param name Define the name of the uniform as defined in the shader
  50341. * @param value Define the value to give to the uniform
  50342. * @return the texture itself allowing "fluent" like uniform updates
  50343. */
  50344. setColor4(name: string, value: Color4): ProceduralTexture;
  50345. /**
  50346. * Set a vec2 in the shader from a Vector2.
  50347. * @param name Define the name of the uniform as defined in the shader
  50348. * @param value Define the value to give to the uniform
  50349. * @return the texture itself allowing "fluent" like uniform updates
  50350. */
  50351. setVector2(name: string, value: Vector2): ProceduralTexture;
  50352. /**
  50353. * Set a vec3 in the shader from a Vector3.
  50354. * @param name Define the name of the uniform as defined in the shader
  50355. * @param value Define the value to give to the uniform
  50356. * @return the texture itself allowing "fluent" like uniform updates
  50357. */
  50358. setVector3(name: string, value: Vector3): ProceduralTexture;
  50359. /**
  50360. * Set a mat4 in the shader from a MAtrix.
  50361. * @param name Define the name of the uniform as defined in the shader
  50362. * @param value Define the value to give to the uniform
  50363. * @return the texture itself allowing "fluent" like uniform updates
  50364. */
  50365. setMatrix(name: string, value: Matrix): ProceduralTexture;
  50366. /**
  50367. * Render the texture to its associated render target.
  50368. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  50369. */
  50370. render(useCameraPostProcess?: boolean): void;
  50371. /**
  50372. * Clone the texture.
  50373. * @returns the cloned texture
  50374. */
  50375. clone(): ProceduralTexture;
  50376. /**
  50377. * Dispose the texture and release its asoociated resources.
  50378. */
  50379. dispose(): void;
  50380. }
  50381. }
  50382. declare module BABYLON {
  50383. interface AbstractScene {
  50384. /**
  50385. * The list of procedural textures added to the scene
  50386. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  50387. */
  50388. proceduralTextures: Array<ProceduralTexture>;
  50389. }
  50390. /**
  50391. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  50392. * in a given scene.
  50393. */
  50394. class ProceduralTextureSceneComponent implements ISceneComponent {
  50395. /**
  50396. * The component name helpfull to identify the component in the list of scene components.
  50397. */
  50398. readonly name: string;
  50399. /**
  50400. * The scene the component belongs to.
  50401. */
  50402. scene: Scene;
  50403. /**
  50404. * Creates a new instance of the component for the given scene
  50405. * @param scene Defines the scene to register the component in
  50406. */
  50407. constructor(scene: Scene);
  50408. /**
  50409. * Registers the component in a given scene
  50410. */
  50411. register(): void;
  50412. /**
  50413. * Rebuilds the elements related to this component in case of
  50414. * context lost for instance.
  50415. */
  50416. rebuild(): void;
  50417. /**
  50418. * Disposes the component and the associated ressources.
  50419. */
  50420. dispose(): void;
  50421. private _beforeClear;
  50422. }
  50423. }
  50424. declare module BABYLON {
  50425. /**
  50426. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  50427. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  50428. */
  50429. class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  50430. private _scene;
  50431. private _camerasToBeAttached;
  50432. /**
  50433. * ID of the sharpen post process,
  50434. */
  50435. private readonly SharpenPostProcessId;
  50436. /**
  50437. * @ignore
  50438. * ID of the image processing post process;
  50439. */
  50440. readonly ImageProcessingPostProcessId: string;
  50441. /**
  50442. * @ignore
  50443. * ID of the Fast Approximate Anti-Aliasing post process;
  50444. */
  50445. readonly FxaaPostProcessId: string;
  50446. /**
  50447. * ID of the chromatic aberration post process,
  50448. */
  50449. private readonly ChromaticAberrationPostProcessId;
  50450. /**
  50451. * ID of the grain post process
  50452. */
  50453. private readonly GrainPostProcessId;
  50454. /**
  50455. * Sharpen post process which will apply a sharpen convolution to enhance edges
  50456. */
  50457. sharpen: SharpenPostProcess;
  50458. private _sharpenEffect;
  50459. private bloom;
  50460. /**
  50461. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  50462. */
  50463. depthOfField: DepthOfFieldEffect;
  50464. /**
  50465. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  50466. */
  50467. fxaa: FxaaPostProcess;
  50468. /**
  50469. * Image post processing pass used to perform operations such as tone mapping or color grading.
  50470. */
  50471. imageProcessing: ImageProcessingPostProcess;
  50472. /**
  50473. * Chromatic aberration post process which will shift rgb colors in the image
  50474. */
  50475. chromaticAberration: ChromaticAberrationPostProcess;
  50476. private _chromaticAberrationEffect;
  50477. /**
  50478. * Grain post process which add noise to the image
  50479. */
  50480. grain: GrainPostProcess;
  50481. private _grainEffect;
  50482. /**
  50483. * Glow post process which adds a glow to emmisive areas of the image
  50484. */
  50485. private _glowLayer;
  50486. /**
  50487. * Animations which can be used to tweak settings over a period of time
  50488. */
  50489. animations: Animation[];
  50490. private _imageProcessingConfigurationObserver;
  50491. private _sharpenEnabled;
  50492. private _bloomEnabled;
  50493. private _depthOfFieldEnabled;
  50494. private _depthOfFieldBlurLevel;
  50495. private _fxaaEnabled;
  50496. private _imageProcessingEnabled;
  50497. private _defaultPipelineTextureType;
  50498. private _bloomScale;
  50499. private _chromaticAberrationEnabled;
  50500. private _grainEnabled;
  50501. private _buildAllowed;
  50502. /**
  50503. * Enable or disable the sharpen process from the pipeline
  50504. */
  50505. sharpenEnabled: boolean;
  50506. private _resizeObserver;
  50507. private _hardwareScaleLevel;
  50508. private _bloomKernel;
  50509. /**
  50510. * Specifies the size of the bloom blur kernel, relative to the final output size
  50511. */
  50512. bloomKernel: number;
  50513. /**
  50514. * Specifies the weight of the bloom in the final rendering
  50515. */
  50516. private _bloomWeight;
  50517. /**
  50518. * Specifies the luma threshold for the area that will be blurred by the bloom
  50519. */
  50520. private _bloomThreshold;
  50521. private _hdr;
  50522. /**
  50523. * The strength of the bloom.
  50524. */
  50525. bloomWeight: number;
  50526. /**
  50527. * The strength of the bloom.
  50528. */
  50529. bloomThreshold: number;
  50530. /**
  50531. * The scale of the bloom, lower value will provide better performance.
  50532. */
  50533. bloomScale: number;
  50534. /**
  50535. * Enable or disable the bloom from the pipeline
  50536. */
  50537. bloomEnabled: boolean;
  50538. private _rebuildBloom;
  50539. /**
  50540. * If the depth of field is enabled.
  50541. */
  50542. depthOfFieldEnabled: boolean;
  50543. /**
  50544. * Blur level of the depth of field effect. (Higher blur will effect performance)
  50545. */
  50546. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  50547. /**
  50548. * If the anti aliasing is enabled.
  50549. */
  50550. fxaaEnabled: boolean;
  50551. private _samples;
  50552. /**
  50553. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  50554. */
  50555. samples: number;
  50556. /**
  50557. * If image processing is enabled.
  50558. */
  50559. imageProcessingEnabled: boolean;
  50560. /**
  50561. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  50562. */
  50563. glowLayerEnabled: boolean;
  50564. /**
  50565. * Enable or disable the chromaticAberration process from the pipeline
  50566. */
  50567. chromaticAberrationEnabled: boolean;
  50568. /**
  50569. * Enable or disable the grain process from the pipeline
  50570. */
  50571. grainEnabled: boolean;
  50572. /**
  50573. * @constructor
  50574. * @param name - The rendering pipeline name (default: "")
  50575. * @param hdr - If high dynamic range textures should be used (default: true)
  50576. * @param scene - The scene linked to this pipeline (default: the last created scene)
  50577. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  50578. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  50579. */
  50580. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  50581. /**
  50582. * Force the compilation of the entire pipeline.
  50583. */
  50584. prepare(): void;
  50585. private _hasCleared;
  50586. private _prevPostProcess;
  50587. private _prevPrevPostProcess;
  50588. private _setAutoClearAndTextureSharing;
  50589. private _depthOfFieldSceneObserver;
  50590. private _buildPipeline;
  50591. private _disposePostProcesses;
  50592. /**
  50593. * Adds a camera to the pipeline
  50594. * @param camera the camera to be added
  50595. */
  50596. addCamera(camera: Camera): void;
  50597. /**
  50598. * Removes a camera from the pipeline
  50599. * @param camera the camera to remove
  50600. */
  50601. removeCamera(camera: Camera): void;
  50602. /**
  50603. * Dispose of the pipeline and stop all post processes
  50604. */
  50605. dispose(): void;
  50606. /**
  50607. * Serialize the rendering pipeline (Used when exporting)
  50608. * @returns the serialized object
  50609. */
  50610. serialize(): any;
  50611. /**
  50612. * Parse the serialized pipeline
  50613. * @param source Source pipeline.
  50614. * @param scene The scene to load the pipeline to.
  50615. * @param rootUrl The URL of the serialized pipeline.
  50616. * @returns An instantiated pipeline from the serialized object.
  50617. */
  50618. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  50619. }
  50620. }
  50621. declare module BABYLON {
  50622. /**
  50623. * BABYLON.JS Chromatic Aberration GLSL Shader
  50624. * Author: Olivier Guyot
  50625. * Separates very slightly R, G and B colors on the edges of the screen
  50626. * Inspired by Francois Tarlier & Martins Upitis
  50627. */
  50628. class LensRenderingPipeline extends PostProcessRenderPipeline {
  50629. /**
  50630. * @ignore
  50631. * The chromatic aberration PostProcess id in the pipeline
  50632. */
  50633. LensChromaticAberrationEffect: string;
  50634. /**
  50635. * @ignore
  50636. * The highlights enhancing PostProcess id in the pipeline
  50637. */
  50638. HighlightsEnhancingEffect: string;
  50639. /**
  50640. * @ignore
  50641. * The depth-of-field PostProcess id in the pipeline
  50642. */
  50643. LensDepthOfFieldEffect: string;
  50644. private _scene;
  50645. private _depthTexture;
  50646. private _grainTexture;
  50647. private _chromaticAberrationPostProcess;
  50648. private _highlightsPostProcess;
  50649. private _depthOfFieldPostProcess;
  50650. private _edgeBlur;
  50651. private _grainAmount;
  50652. private _chromaticAberration;
  50653. private _distortion;
  50654. private _highlightsGain;
  50655. private _highlightsThreshold;
  50656. private _dofDistance;
  50657. private _dofAperture;
  50658. private _dofDarken;
  50659. private _dofPentagon;
  50660. private _blurNoise;
  50661. /**
  50662. * @constructor
  50663. *
  50664. * Effect parameters are as follow:
  50665. * {
  50666. * chromatic_aberration: number; // from 0 to x (1 for realism)
  50667. * edge_blur: number; // from 0 to x (1 for realism)
  50668. * distortion: number; // from 0 to x (1 for realism)
  50669. * grain_amount: number; // from 0 to 1
  50670. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  50671. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  50672. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  50673. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  50674. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  50675. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  50676. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  50677. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  50678. * }
  50679. * Note: if an effect parameter is unset, effect is disabled
  50680. *
  50681. * @param name The rendering pipeline name
  50682. * @param parameters - An object containing all parameters (see above)
  50683. * @param scene The scene linked to this pipeline
  50684. * @param ratio The size of the postprocesses (0.5 means that your postprocess will have a width = canvas.width 0.5 and a height = canvas.height 0.5)
  50685. * @param cameras The array of cameras that the rendering pipeline will be attached to
  50686. */
  50687. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  50688. /**
  50689. * Sets the amount of blur at the edges
  50690. * @param amount blur amount
  50691. */
  50692. setEdgeBlur(amount: number): void;
  50693. /**
  50694. * Sets edge blur to 0
  50695. */
  50696. disableEdgeBlur(): void;
  50697. /**
  50698. * Sets the amout of grain
  50699. * @param amount Amount of grain
  50700. */
  50701. setGrainAmount(amount: number): void;
  50702. /**
  50703. * Set grain amount to 0
  50704. */
  50705. disableGrain(): void;
  50706. /**
  50707. * Sets the chromatic aberration amount
  50708. * @param amount amount of chromatic aberration
  50709. */
  50710. setChromaticAberration(amount: number): void;
  50711. /**
  50712. * Sets chromatic aberration amount to 0
  50713. */
  50714. disableChromaticAberration(): void;
  50715. /**
  50716. * Sets the EdgeDistortion amount
  50717. * @param amount amount of EdgeDistortion
  50718. */
  50719. setEdgeDistortion(amount: number): void;
  50720. /**
  50721. * Sets edge distortion to 0
  50722. */
  50723. disableEdgeDistortion(): void;
  50724. /**
  50725. * Sets the FocusDistance amount
  50726. * @param amount amount of FocusDistance
  50727. */
  50728. setFocusDistance(amount: number): void;
  50729. /**
  50730. * Disables depth of field
  50731. */
  50732. disableDepthOfField(): void;
  50733. /**
  50734. * Sets the Aperture amount
  50735. * @param amount amount of Aperture
  50736. */
  50737. setAperture(amount: number): void;
  50738. /**
  50739. * Sets the DarkenOutOfFocus amount
  50740. * @param amount amount of DarkenOutOfFocus
  50741. */
  50742. setDarkenOutOfFocus(amount: number): void;
  50743. /**
  50744. * Creates a pentagon bokeh effect
  50745. */
  50746. enablePentagonBokeh(): void;
  50747. /**
  50748. * Disables the pentagon bokeh effect
  50749. */
  50750. disablePentagonBokeh(): void;
  50751. /**
  50752. * Enables noise blur
  50753. */
  50754. enableNoiseBlur(): void;
  50755. /**
  50756. * Disables noise blur
  50757. */
  50758. disableNoiseBlur(): void;
  50759. /**
  50760. * Sets the HighlightsGain amount
  50761. * @param amount amount of HighlightsGain
  50762. */
  50763. setHighlightsGain(amount: number): void;
  50764. /**
  50765. * Sets the HighlightsThreshold amount
  50766. * @param amount amount of HighlightsThreshold
  50767. */
  50768. setHighlightsThreshold(amount: number): void;
  50769. /**
  50770. * Disables highlights
  50771. */
  50772. disableHighlights(): void;
  50773. /**
  50774. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  50775. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  50776. */
  50777. dispose(disableDepthRender?: boolean): void;
  50778. private _createChromaticAberrationPostProcess;
  50779. private _createHighlightsPostProcess;
  50780. private _createDepthOfFieldPostProcess;
  50781. private _createGrainTexture;
  50782. }
  50783. }
  50784. declare module BABYLON {
  50785. /**
  50786. * Render pipeline to produce ssao effect
  50787. */
  50788. class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  50789. /**
  50790. * @ignore
  50791. * The PassPostProcess id in the pipeline that contains the original scene color
  50792. */
  50793. SSAOOriginalSceneColorEffect: string;
  50794. /**
  50795. * @ignore
  50796. * The SSAO PostProcess id in the pipeline
  50797. */
  50798. SSAORenderEffect: string;
  50799. /**
  50800. * @ignore
  50801. * The horizontal blur PostProcess id in the pipeline
  50802. */
  50803. SSAOBlurHRenderEffect: string;
  50804. /**
  50805. * @ignore
  50806. * The vertical blur PostProcess id in the pipeline
  50807. */
  50808. SSAOBlurVRenderEffect: string;
  50809. /**
  50810. * @ignore
  50811. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  50812. */
  50813. SSAOCombineRenderEffect: string;
  50814. /**
  50815. * The output strength of the SSAO post-process. Default value is 1.0.
  50816. */
  50817. totalStrength: number;
  50818. /**
  50819. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  50820. */
  50821. maxZ: number;
  50822. /**
  50823. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  50824. */
  50825. minZAspect: number;
  50826. private _samples;
  50827. /**
  50828. * Number of samples used for the SSAO calculations. Default value is 8
  50829. */
  50830. samples: number;
  50831. private _textureSamples;
  50832. /**
  50833. * Number of samples to use for antialiasing
  50834. */
  50835. textureSamples: number;
  50836. /**
  50837. * Ratio object used for SSAO ratio and blur ratio
  50838. */
  50839. private _ratio;
  50840. /**
  50841. * Dynamically generated sphere sampler.
  50842. */
  50843. private _sampleSphere;
  50844. /**
  50845. * Blur filter offsets
  50846. */
  50847. private _samplerOffsets;
  50848. private _expensiveBlur;
  50849. /**
  50850. * If bilateral blur should be used
  50851. */
  50852. expensiveBlur: boolean;
  50853. /**
  50854. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  50855. */
  50856. radius: number;
  50857. /**
  50858. * The base color of the SSAO post-process
  50859. * The final result is "base + ssao" between [0, 1]
  50860. */
  50861. base: number;
  50862. /**
  50863. * Support test.
  50864. */
  50865. static readonly IsSupported: boolean;
  50866. private _scene;
  50867. private _depthTexture;
  50868. private _normalTexture;
  50869. private _randomTexture;
  50870. private _originalColorPostProcess;
  50871. private _ssaoPostProcess;
  50872. private _blurHPostProcess;
  50873. private _blurVPostProcess;
  50874. private _ssaoCombinePostProcess;
  50875. private _firstUpdate;
  50876. /**
  50877. * @constructor
  50878. * @param name The rendering pipeline name
  50879. * @param scene The scene linked to this pipeline
  50880. * @param ratio The size of the postprocesses. Can be a number shared between passes or an object for more precision: { ssaoRatio: 0.5, blurRatio: 1.0 }
  50881. * @param cameras The array of cameras that the rendering pipeline will be attached to
  50882. */
  50883. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  50884. /**
  50885. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  50886. */
  50887. dispose(disableGeometryBufferRenderer?: boolean): void;
  50888. private _createBlurPostProcess;
  50889. /** @hidden */
  50890. _rebuild(): void;
  50891. private _bits;
  50892. private _radicalInverse_VdC;
  50893. private _hammersley;
  50894. private _hemisphereSample_uniform;
  50895. private _generateHemisphere;
  50896. private _createSSAOPostProcess;
  50897. private _createSSAOCombinePostProcess;
  50898. private _createRandomTexture;
  50899. /**
  50900. * Serialize the rendering pipeline (Used when exporting)
  50901. * @returns the serialized object
  50902. */
  50903. serialize(): any;
  50904. /**
  50905. * Parse the serialized pipeline
  50906. * @param source Source pipeline.
  50907. * @param scene The scene to load the pipeline to.
  50908. * @param rootUrl The URL of the serialized pipeline.
  50909. * @returns An instantiated pipeline from the serialized object.
  50910. */
  50911. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  50912. }
  50913. }
  50914. declare module BABYLON {
  50915. /**
  50916. * Render pipeline to produce ssao effect
  50917. */
  50918. class SSAORenderingPipeline extends PostProcessRenderPipeline {
  50919. /**
  50920. * @ignore
  50921. * The PassPostProcess id in the pipeline that contains the original scene color
  50922. */
  50923. SSAOOriginalSceneColorEffect: string;
  50924. /**
  50925. * @ignore
  50926. * The SSAO PostProcess id in the pipeline
  50927. */
  50928. SSAORenderEffect: string;
  50929. /**
  50930. * @ignore
  50931. * The horizontal blur PostProcess id in the pipeline
  50932. */
  50933. SSAOBlurHRenderEffect: string;
  50934. /**
  50935. * @ignore
  50936. * The vertical blur PostProcess id in the pipeline
  50937. */
  50938. SSAOBlurVRenderEffect: string;
  50939. /**
  50940. * @ignore
  50941. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  50942. */
  50943. SSAOCombineRenderEffect: string;
  50944. /**
  50945. * The output strength of the SSAO post-process. Default value is 1.0.
  50946. */
  50947. totalStrength: number;
  50948. /**
  50949. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  50950. */
  50951. radius: number;
  50952. /**
  50953. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  50954. * Must not be equal to fallOff and superior to fallOff.
  50955. * Default value is 0.975
  50956. */
  50957. area: number;
  50958. /**
  50959. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  50960. * Must not be equal to area and inferior to area.
  50961. * Default value is 0.0
  50962. */
  50963. fallOff: number;
  50964. /**
  50965. * The base color of the SSAO post-process
  50966. * The final result is "base + ssao" between [0, 1]
  50967. */
  50968. base: number;
  50969. private _scene;
  50970. private _depthTexture;
  50971. private _randomTexture;
  50972. private _originalColorPostProcess;
  50973. private _ssaoPostProcess;
  50974. private _blurHPostProcess;
  50975. private _blurVPostProcess;
  50976. private _ssaoCombinePostProcess;
  50977. private _firstUpdate;
  50978. /**
  50979. * @constructor
  50980. * @param name - The rendering pipeline name
  50981. * @param scene - The scene linked to this pipeline
  50982. * @param ratio - The size of the postprocesses. Can be a number shared between passes or an object for more precision: { ssaoRatio: 0.5, combineRatio: 1.0 }
  50983. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  50984. */
  50985. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  50986. /**
  50987. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  50988. */
  50989. dispose(disableDepthRender?: boolean): void;
  50990. private _createBlurPostProcess;
  50991. /** @hidden */
  50992. _rebuild(): void;
  50993. private _createSSAOPostProcess;
  50994. private _createSSAOCombinePostProcess;
  50995. private _createRandomTexture;
  50996. }
  50997. }
  50998. declare module BABYLON {
  50999. /**
  51000. * Standard rendering pipeline
  51001. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  51002. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  51003. */
  51004. class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  51005. /**
  51006. * Public members
  51007. */
  51008. /**
  51009. * Post-process which contains the original scene color before the pipeline applies all the effects
  51010. */
  51011. originalPostProcess: Nullable<PostProcess>;
  51012. /**
  51013. * Post-process used to down scale an image x4
  51014. */
  51015. downSampleX4PostProcess: Nullable<PostProcess>;
  51016. /**
  51017. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  51018. */
  51019. brightPassPostProcess: Nullable<PostProcess>;
  51020. /**
  51021. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  51022. */
  51023. blurHPostProcesses: PostProcess[];
  51024. /**
  51025. * Post-process array storing all the vertical blur post-processes used by the pipeline
  51026. */
  51027. blurVPostProcesses: PostProcess[];
  51028. /**
  51029. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  51030. */
  51031. textureAdderPostProcess: Nullable<PostProcess>;
  51032. /**
  51033. * Post-process used to create volumetric lighting effect
  51034. */
  51035. volumetricLightPostProcess: Nullable<PostProcess>;
  51036. /**
  51037. * Post-process used to smooth the previous volumetric light post-process on the X axis
  51038. */
  51039. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  51040. /**
  51041. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  51042. */
  51043. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  51044. /**
  51045. * Post-process used to merge the volumetric light effect and the real scene color
  51046. */
  51047. volumetricLightMergePostProces: Nullable<PostProcess>;
  51048. /**
  51049. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  51050. */
  51051. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  51052. /**
  51053. * Base post-process used to calculate the average luminance of the final image for HDR
  51054. */
  51055. luminancePostProcess: Nullable<PostProcess>;
  51056. /**
  51057. * Post-processes used to create down sample post-processes in order to get
  51058. * the average luminance of the final image for HDR
  51059. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  51060. */
  51061. luminanceDownSamplePostProcesses: PostProcess[];
  51062. /**
  51063. * Post-process used to create a HDR effect (light adaptation)
  51064. */
  51065. hdrPostProcess: Nullable<PostProcess>;
  51066. /**
  51067. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  51068. */
  51069. textureAdderFinalPostProcess: Nullable<PostProcess>;
  51070. /**
  51071. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  51072. */
  51073. lensFlareFinalPostProcess: Nullable<PostProcess>;
  51074. /**
  51075. * Post-process used to merge the final HDR post-process and the real scene color
  51076. */
  51077. hdrFinalPostProcess: Nullable<PostProcess>;
  51078. /**
  51079. * Post-process used to create a lens flare effect
  51080. */
  51081. lensFlarePostProcess: Nullable<PostProcess>;
  51082. /**
  51083. * Post-process that merges the result of the lens flare post-process and the real scene color
  51084. */
  51085. lensFlareComposePostProcess: Nullable<PostProcess>;
  51086. /**
  51087. * Post-process used to create a motion blur effect
  51088. */
  51089. motionBlurPostProcess: Nullable<PostProcess>;
  51090. /**
  51091. * Post-process used to create a depth of field effect
  51092. */
  51093. depthOfFieldPostProcess: Nullable<PostProcess>;
  51094. /**
  51095. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  51096. */
  51097. fxaaPostProcess: Nullable<FxaaPostProcess>;
  51098. /**
  51099. * Represents the brightness threshold in order to configure the illuminated surfaces
  51100. */
  51101. brightThreshold: number;
  51102. /**
  51103. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  51104. */
  51105. blurWidth: number;
  51106. /**
  51107. * Sets if the blur for highlighted surfaces must be only horizontal
  51108. */
  51109. horizontalBlur: boolean;
  51110. /**
  51111. * Sets the overall exposure used by the pipeline
  51112. */
  51113. exposure: number;
  51114. /**
  51115. * Texture used typically to simulate "dirty" on camera lens
  51116. */
  51117. lensTexture: Nullable<Texture>;
  51118. /**
  51119. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  51120. */
  51121. volumetricLightCoefficient: number;
  51122. /**
  51123. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  51124. */
  51125. volumetricLightPower: number;
  51126. /**
  51127. * Used the set the blur intensity to smooth the volumetric lights
  51128. */
  51129. volumetricLightBlurScale: number;
  51130. /**
  51131. * Light (spot or directional) used to generate the volumetric lights rays
  51132. * The source light must have a shadow generate so the pipeline can get its
  51133. * depth map
  51134. */
  51135. sourceLight: Nullable<SpotLight | DirectionalLight>;
  51136. /**
  51137. * For eye adaptation, represents the minimum luminance the eye can see
  51138. */
  51139. hdrMinimumLuminance: number;
  51140. /**
  51141. * For eye adaptation, represents the decrease luminance speed
  51142. */
  51143. hdrDecreaseRate: number;
  51144. /**
  51145. * For eye adaptation, represents the increase luminance speed
  51146. */
  51147. hdrIncreaseRate: number;
  51148. /**
  51149. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  51150. */
  51151. lensColorTexture: Nullable<Texture>;
  51152. /**
  51153. * The overall strengh for the lens flare effect
  51154. */
  51155. lensFlareStrength: number;
  51156. /**
  51157. * Dispersion coefficient for lens flare ghosts
  51158. */
  51159. lensFlareGhostDispersal: number;
  51160. /**
  51161. * Main lens flare halo width
  51162. */
  51163. lensFlareHaloWidth: number;
  51164. /**
  51165. * Based on the lens distortion effect, defines how much the lens flare result
  51166. * is distorted
  51167. */
  51168. lensFlareDistortionStrength: number;
  51169. /**
  51170. * Lens star texture must be used to simulate rays on the flares and is available
  51171. * in the documentation
  51172. */
  51173. lensStarTexture: Nullable<Texture>;
  51174. /**
  51175. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  51176. * flare effect by taking account of the dirt texture
  51177. */
  51178. lensFlareDirtTexture: Nullable<Texture>;
  51179. /**
  51180. * Represents the focal length for the depth of field effect
  51181. */
  51182. depthOfFieldDistance: number;
  51183. /**
  51184. * Represents the blur intensity for the blurred part of the depth of field effect
  51185. */
  51186. depthOfFieldBlurWidth: number;
  51187. /**
  51188. * For motion blur, defines how much the image is blurred by the movement
  51189. */
  51190. motionStrength: number;
  51191. /**
  51192. * List of animations for the pipeline (IAnimatable implementation)
  51193. */
  51194. animations: Animation[];
  51195. /**
  51196. * Private members
  51197. */
  51198. private _scene;
  51199. private _currentDepthOfFieldSource;
  51200. private _basePostProcess;
  51201. private _hdrCurrentLuminance;
  51202. private _floatTextureType;
  51203. private _ratio;
  51204. private _bloomEnabled;
  51205. private _depthOfFieldEnabled;
  51206. private _vlsEnabled;
  51207. private _lensFlareEnabled;
  51208. private _hdrEnabled;
  51209. private _motionBlurEnabled;
  51210. private _fxaaEnabled;
  51211. private _motionBlurSamples;
  51212. private _volumetricLightStepsCount;
  51213. private _samples;
  51214. /**
  51215. * @ignore
  51216. * Specifies if the bloom pipeline is enabled
  51217. */
  51218. BloomEnabled: boolean;
  51219. /**
  51220. * @ignore
  51221. * Specifies if the depth of field pipeline is enabed
  51222. */
  51223. DepthOfFieldEnabled: boolean;
  51224. /**
  51225. * @ignore
  51226. * Specifies if the lens flare pipeline is enabed
  51227. */
  51228. LensFlareEnabled: boolean;
  51229. /**
  51230. * @ignore
  51231. * Specifies if the HDR pipeline is enabled
  51232. */
  51233. HDREnabled: boolean;
  51234. /**
  51235. * @ignore
  51236. * Specifies if the volumetric lights scattering effect is enabled
  51237. */
  51238. VLSEnabled: boolean;
  51239. /**
  51240. * @ignore
  51241. * Specifies if the motion blur effect is enabled
  51242. */
  51243. MotionBlurEnabled: boolean;
  51244. /**
  51245. * Specifies if anti-aliasing is enabled
  51246. */
  51247. fxaaEnabled: boolean;
  51248. /**
  51249. * Specifies the number of steps used to calculate the volumetric lights
  51250. * Typically in interval [50, 200]
  51251. */
  51252. volumetricLightStepsCount: number;
  51253. /**
  51254. * Specifies the number of samples used for the motion blur effect
  51255. * Typically in interval [16, 64]
  51256. */
  51257. motionBlurSamples: number;
  51258. /**
  51259. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  51260. */
  51261. samples: number;
  51262. /**
  51263. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  51264. * @constructor
  51265. * @param name The rendering pipeline name
  51266. * @param scene The scene linked to this pipeline
  51267. * @param ratio The size of the postprocesses (0.5 means that your postprocess will have a width = canvas.width 0.5 and a height = canvas.height 0.5)
  51268. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  51269. * @param cameras The array of cameras that the rendering pipeline will be attached to
  51270. */
  51271. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  51272. private _buildPipeline;
  51273. private _createDownSampleX4PostProcess;
  51274. private _createBrightPassPostProcess;
  51275. private _createBlurPostProcesses;
  51276. private _createTextureAdderPostProcess;
  51277. private _createVolumetricLightPostProcess;
  51278. private _createLuminancePostProcesses;
  51279. private _createHdrPostProcess;
  51280. private _createLensFlarePostProcess;
  51281. private _createDepthOfFieldPostProcess;
  51282. private _createMotionBlurPostProcess;
  51283. private _getDepthTexture;
  51284. private _disposePostProcesses;
  51285. /**
  51286. * Dispose of the pipeline and stop all post processes
  51287. */
  51288. dispose(): void;
  51289. /**
  51290. * Serialize the rendering pipeline (Used when exporting)
  51291. * @returns the serialized object
  51292. */
  51293. serialize(): any;
  51294. /**
  51295. * Parse the serialized pipeline
  51296. * @param source Source pipeline.
  51297. * @param scene The scene to load the pipeline to.
  51298. * @param rootUrl The URL of the serialized pipeline.
  51299. * @returns An instantiated pipeline from the serialized object.
  51300. */
  51301. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  51302. /**
  51303. * Luminance steps
  51304. */
  51305. static LuminanceSteps: number;
  51306. }
  51307. }