babylon.d.ts 2.1 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603
  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 Id
  711. * It will improve performance when the number of geometries becomes important.
  712. */
  713. useGeometryIdsMap?: 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 geometriesById;
  1526. /**
  1527. * Creates a new Scene
  1528. * @param engine defines the engine to use to render this scene
  1529. */
  1530. constructor(engine: Engine, options?: SceneOptions);
  1531. private _defaultMeshCandidates;
  1532. /**
  1533. * @hidden
  1534. */
  1535. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  1536. private _defaultSubMeshCandidates;
  1537. /**
  1538. * @hidden
  1539. */
  1540. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  1541. /**
  1542. * Sets the default candidate providers for the scene.
  1543. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  1544. * and getCollidingSubMeshCandidates to their default function
  1545. */
  1546. setDefaultCandidateProviders(): void;
  1547. /**
  1548. * Gets a boolean indicating if collisions are processed on a web worker
  1549. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#web-worker-based-collision-system-since-21
  1550. */
  1551. workerCollisions: boolean;
  1552. /**
  1553. * Gets the mesh that is currently under the pointer
  1554. */
  1555. readonly meshUnderPointer: Nullable<AbstractMesh>;
  1556. /**
  1557. * Gets the current on-screen X position of the pointer
  1558. */
  1559. readonly pointerX: number;
  1560. /**
  1561. * Gets the current on-screen Y position of the pointer
  1562. */
  1563. readonly pointerY: number;
  1564. /**
  1565. * Gets the cached material (ie. the latest rendered one)
  1566. * @returns the cached material
  1567. */
  1568. getCachedMaterial(): Nullable<Material>;
  1569. /**
  1570. * Gets the cached effect (ie. the latest rendered one)
  1571. * @returns the cached effect
  1572. */
  1573. getCachedEffect(): Nullable<Effect>;
  1574. /**
  1575. * Gets the cached visibility state (ie. the latest rendered one)
  1576. * @returns the cached visibility state
  1577. */
  1578. getCachedVisibility(): Nullable<number>;
  1579. /**
  1580. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  1581. * @param material defines the current material
  1582. * @param effect defines the current effect
  1583. * @param visibility defines the current visibility state
  1584. * @returns true if one parameter is not cached
  1585. */
  1586. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  1587. /**
  1588. * Gets the engine associated with the scene
  1589. * @returns an Engine
  1590. */
  1591. getEngine(): Engine;
  1592. /**
  1593. * Gets the total number of vertices rendered per frame
  1594. * @returns the total number of vertices rendered per frame
  1595. */
  1596. getTotalVertices(): number;
  1597. /**
  1598. * Gets the performance counter for total vertices
  1599. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1600. */
  1601. readonly totalVerticesPerfCounter: PerfCounter;
  1602. /**
  1603. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  1604. * @returns the total number of active indices rendered per frame
  1605. */
  1606. getActiveIndices(): number;
  1607. /**
  1608. * Gets the performance counter for active indices
  1609. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1610. */
  1611. readonly totalActiveIndicesPerfCounter: PerfCounter;
  1612. /**
  1613. * Gets the total number of active particles rendered per frame
  1614. * @returns the total number of active particles rendered per frame
  1615. */
  1616. getActiveParticles(): number;
  1617. /**
  1618. * Gets the performance counter for active particles
  1619. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1620. */
  1621. readonly activeParticlesPerfCounter: PerfCounter;
  1622. /**
  1623. * Gets the total number of active bones rendered per frame
  1624. * @returns the total number of active bones rendered per frame
  1625. */
  1626. getActiveBones(): number;
  1627. /**
  1628. * Gets the performance counter for active bones
  1629. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1630. */
  1631. readonly activeBonesPerfCounter: PerfCounter;
  1632. /**
  1633. * Gets the array of active meshes
  1634. * @returns an array of AbstractMesh
  1635. */
  1636. getActiveMeshes(): SmartArray<AbstractMesh>;
  1637. /**
  1638. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  1639. * @returns a number
  1640. */
  1641. getAnimationRatio(): number;
  1642. /**
  1643. * Gets an unique Id for the current render phase
  1644. * @returns a number
  1645. */
  1646. getRenderId(): number;
  1647. /**
  1648. * Gets an unique Id for the current frame
  1649. * @returns a number
  1650. */
  1651. getFrameId(): number;
  1652. /** Call this function if you want to manually increment the render Id*/
  1653. incrementRenderId(): void;
  1654. private _updatePointerPosition;
  1655. private _createUbo;
  1656. private _createAlternateUbo;
  1657. private _setRayOnPointerInfo;
  1658. /**
  1659. * Use this method to simulate a pointer move on a mesh
  1660. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1661. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1662. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1663. * @returns the current scene
  1664. */
  1665. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1666. private _processPointerMove;
  1667. private _checkPrePointerObservable;
  1668. /**
  1669. * Use this method to simulate a pointer down on a mesh
  1670. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1671. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1672. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1673. * @returns the current scene
  1674. */
  1675. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1676. private _processPointerDown;
  1677. /**
  1678. * Use this method to simulate a pointer up on a mesh
  1679. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1680. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1681. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1682. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  1683. * @returns the current scene
  1684. */
  1685. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  1686. private _processPointerUp;
  1687. /**
  1688. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  1689. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  1690. * @returns true if the pointer was captured
  1691. */
  1692. isPointerCaptured(pointerId?: number): boolean;
  1693. /** @hidden */
  1694. _isPointerSwiping(): boolean;
  1695. /**
  1696. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  1697. * @param attachUp defines if you want to attach events to pointerup
  1698. * @param attachDown defines if you want to attach events to pointerdown
  1699. * @param attachMove defines if you want to attach events to pointermove
  1700. */
  1701. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  1702. /** Detaches all event handlers*/
  1703. detachControl(): void;
  1704. /**
  1705. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  1706. * Delay loaded resources are not taking in account
  1707. * @return true if all required resources are ready
  1708. */
  1709. isReady(): boolean;
  1710. /** Resets all cached information relative to material (including effect and visibility) */
  1711. resetCachedMaterial(): void;
  1712. /**
  1713. * Registers a function to be called before every frame render
  1714. * @param func defines the function to register
  1715. */
  1716. registerBeforeRender(func: () => void): void;
  1717. /**
  1718. * Unregisters a function called before every frame render
  1719. * @param func defines the function to unregister
  1720. */
  1721. unregisterBeforeRender(func: () => void): void;
  1722. /**
  1723. * Registers a function to be called after every frame render
  1724. * @param func defines the function to register
  1725. */
  1726. registerAfterRender(func: () => void): void;
  1727. /**
  1728. * Unregisters a function called after every frame render
  1729. * @param func defines the function to unregister
  1730. */
  1731. unregisterAfterRender(func: () => void): void;
  1732. private _executeOnceBeforeRender;
  1733. /**
  1734. * The provided function will run before render once and will be disposed afterwards.
  1735. * A timeout delay can be provided so that the function will be executed in N ms.
  1736. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  1737. * @param func The function to be executed.
  1738. * @param timeout optional delay in ms
  1739. */
  1740. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  1741. /** @hidden */
  1742. _addPendingData(data: any): void;
  1743. /** @hidden */
  1744. _removePendingData(data: any): void;
  1745. /**
  1746. * Returns the number of items waiting to be loaded
  1747. * @returns the number of items waiting to be loaded
  1748. */
  1749. getWaitingItemsCount(): number;
  1750. /**
  1751. * Returns a boolean indicating if the scene is still loading data
  1752. */
  1753. readonly isLoading: boolean;
  1754. /**
  1755. * Registers a function to be executed when the scene is ready
  1756. * @param {Function} func - the function to be executed
  1757. */
  1758. executeWhenReady(func: () => void): void;
  1759. /**
  1760. * Returns a promise that resolves when the scene is ready
  1761. * @returns A promise that resolves when the scene is ready
  1762. */
  1763. whenReadyAsync(): Promise<void>;
  1764. /** @hidden */
  1765. _checkIsReady(): void;
  1766. /**
  1767. * Will start the animation sequence of a given target
  1768. * @param target defines the target
  1769. * @param from defines from which frame should animation start
  1770. * @param to defines until which frame should animation run.
  1771. * @param weight defines the weight to apply to the animation (1.0 by default)
  1772. * @param loop defines if the animation loops
  1773. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1774. * @param onAnimationEnd defines the function to be executed when the animation ends
  1775. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1776. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  1777. * @param onAnimationLoop defines the callback to call when an animation loops
  1778. * @returns the animatable object created for this animation
  1779. */
  1780. beginWeightedAnimation(target: any, from: number, to: number, weight?: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  1781. /**
  1782. * Will start the animation sequence of a given target
  1783. * @param target defines the target
  1784. * @param from defines from which frame should animation start
  1785. * @param to defines until which frame should animation run.
  1786. * @param loop defines if the animation loops
  1787. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1788. * @param onAnimationEnd defines the function to be executed when the animation ends
  1789. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1790. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  1791. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  1792. * @param onAnimationLoop defines the callback to call when an animation loops
  1793. * @returns the animatable object created for this animation
  1794. */
  1795. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  1796. /**
  1797. * Will start the animation sequence of a given target and its hierarchy
  1798. * @param target defines the target
  1799. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  1800. * @param from defines from which frame should animation start
  1801. * @param to defines until which frame should animation run.
  1802. * @param loop defines if the animation loops
  1803. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1804. * @param onAnimationEnd defines the function to be executed when the animation ends
  1805. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1806. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  1807. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  1808. * @param onAnimationLoop defines the callback to call when an animation loops
  1809. * @returns the list of created animatables
  1810. */
  1811. beginHierarchyAnimation(target: any, directDescendantsOnly: boolean, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable[];
  1812. /**
  1813. * Begin a new animation on a given node
  1814. * @param target defines the target where the animation will take place
  1815. * @param animations defines the list of animations to start
  1816. * @param from defines the initial value
  1817. * @param to defines the final value
  1818. * @param loop defines if you want animation to loop (off by default)
  1819. * @param speedRatio defines the speed ratio to apply to all animations
  1820. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1821. * @param onAnimationLoop defines the callback to call when an animation loops
  1822. * @returns the list of created animatables
  1823. */
  1824. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  1825. /**
  1826. * Begin a new animation on a given node and its hierarchy
  1827. * @param target defines the root node where the animation will take place
  1828. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  1829. * @param animations defines the list of animations to start
  1830. * @param from defines the initial value
  1831. * @param to defines the final value
  1832. * @param loop defines if you want animation to loop (off by default)
  1833. * @param speedRatio defines the speed ratio to apply to all animations
  1834. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1835. * @param onAnimationLoop defines the callback to call when an animation loops
  1836. * @returns the list of animatables created for all nodes
  1837. */
  1838. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  1839. /**
  1840. * Gets the animatable associated with a specific target
  1841. * @param target defines the target of the animatable
  1842. * @returns the required animatable if found
  1843. */
  1844. getAnimatableByTarget(target: any): Nullable<Animatable>;
  1845. /**
  1846. * Gets all animatables associated with a given target
  1847. * @param target defines the target to look animatables for
  1848. * @returns an array of Animatables
  1849. */
  1850. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  1851. /**
  1852. * Gets all animatable attached to the scene
  1853. */
  1854. readonly animatables: Animatable[];
  1855. /**
  1856. * Will stop the animation of the given target
  1857. * @param target - the target
  1858. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  1859. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  1860. */
  1861. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  1862. /**
  1863. * Stops and removes all animations that have been applied to the scene
  1864. */
  1865. stopAllAnimations(): void;
  1866. private _animate;
  1867. /** @hidden */
  1868. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  1869. private _processLateAnimationBindingsForMatrices;
  1870. private _processLateAnimationBindingsForQuaternions;
  1871. private _processLateAnimationBindings;
  1872. /** @hidden */
  1873. _switchToAlternateCameraConfiguration(active: boolean): void;
  1874. /**
  1875. * Gets the current view matrix
  1876. * @returns a Matrix
  1877. */
  1878. getViewMatrix(): Matrix;
  1879. /**
  1880. * Gets the current projection matrix
  1881. * @returns a Matrix
  1882. */
  1883. getProjectionMatrix(): Matrix;
  1884. /**
  1885. * Gets the current transform matrix
  1886. * @returns a Matrix made of View * Projection
  1887. */
  1888. getTransformMatrix(): Matrix;
  1889. /**
  1890. * Sets the current transform matrix
  1891. * @param view defines the View matrix to use
  1892. * @param projection defines the Projection matrix to use
  1893. */
  1894. setTransformMatrix(view: Matrix, projection: Matrix): void;
  1895. /** @hidden */
  1896. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  1897. /**
  1898. * Gets the uniform buffer used to store scene data
  1899. * @returns a UniformBuffer
  1900. */
  1901. getSceneUniformBuffer(): UniformBuffer;
  1902. /**
  1903. * Gets an unique (relatively to the current scene) Id
  1904. * @returns an unique number for the scene
  1905. */
  1906. getUniqueId(): number;
  1907. /**
  1908. * Add a mesh to the list of scene's meshes
  1909. * @param newMesh defines the mesh to add
  1910. * @param recursive if all child meshes should also be added to the scene
  1911. */
  1912. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  1913. /**
  1914. * Remove a mesh for the list of scene's meshes
  1915. * @param toRemove defines the mesh to remove
  1916. * @param recursive if all child meshes should also be removed from the scene
  1917. * @returns the index where the mesh was in the mesh list
  1918. */
  1919. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  1920. /**
  1921. * Add a transform node to the list of scene's transform nodes
  1922. * @param newTransformNode defines the transform node to add
  1923. */
  1924. addTransformNode(newTransformNode: TransformNode): void;
  1925. /**
  1926. * Remove a transform node for the list of scene's transform nodes
  1927. * @param toRemove defines the transform node to remove
  1928. * @returns the index where the transform node was in the transform node list
  1929. */
  1930. removeTransformNode(toRemove: TransformNode): number;
  1931. /**
  1932. * Remove a skeleton for the list of scene's skeletons
  1933. * @param toRemove defines the skeleton to remove
  1934. * @returns the index where the skeleton was in the skeleton list
  1935. */
  1936. removeSkeleton(toRemove: Skeleton): number;
  1937. /**
  1938. * Remove a morph target for the list of scene's morph targets
  1939. * @param toRemove defines the morph target to remove
  1940. * @returns the index where the morph target was in the morph target list
  1941. */
  1942. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  1943. /**
  1944. * Remove a light for the list of scene's lights
  1945. * @param toRemove defines the light to remove
  1946. * @returns the index where the light was in the light list
  1947. */
  1948. removeLight(toRemove: Light): number;
  1949. /**
  1950. * Remove a camera for the list of scene's cameras
  1951. * @param toRemove defines the camera to remove
  1952. * @returns the index where the camera was in the camera list
  1953. */
  1954. removeCamera(toRemove: Camera): number;
  1955. /**
  1956. * Remove a particle system for the list of scene's particle systems
  1957. * @param toRemove defines the particle system to remove
  1958. * @returns the index where the particle system was in the particle system list
  1959. */
  1960. removeParticleSystem(toRemove: IParticleSystem): number;
  1961. /**
  1962. * Remove a animation for the list of scene's animations
  1963. * @param toRemove defines the animation to remove
  1964. * @returns the index where the animation was in the animation list
  1965. */
  1966. removeAnimation(toRemove: Animation): number;
  1967. /**
  1968. * Removes the given animation group from this scene.
  1969. * @param toRemove The animation group to remove
  1970. * @returns The index of the removed animation group
  1971. */
  1972. removeAnimationGroup(toRemove: AnimationGroup): number;
  1973. /**
  1974. * Removes the given multi-material from this scene.
  1975. * @param toRemove The multi-material to remove
  1976. * @returns The index of the removed multi-material
  1977. */
  1978. removeMultiMaterial(toRemove: MultiMaterial): number;
  1979. /**
  1980. * Removes the given material from this scene.
  1981. * @param toRemove The material to remove
  1982. * @returns The index of the removed material
  1983. */
  1984. removeMaterial(toRemove: Material): number;
  1985. /**
  1986. * Removes the given action manager from this scene.
  1987. * @param toRemove The action manager to remove
  1988. * @returns The index of the removed action manager
  1989. */
  1990. removeActionManager(toRemove: ActionManager): number;
  1991. /**
  1992. * Removes the given texture from this scene.
  1993. * @param toRemove The texture to remove
  1994. * @returns The index of the removed texture
  1995. */
  1996. removeTexture(toRemove: BaseTexture): number;
  1997. /**
  1998. * Adds the given light to this scene
  1999. * @param newLight The light to add
  2000. */
  2001. addLight(newLight: Light): void;
  2002. /**
  2003. * Sorts the list list based on light priorities
  2004. */
  2005. sortLightsByPriority(): void;
  2006. /**
  2007. * Adds the given camera to this scene
  2008. * @param newCamera The camera to add
  2009. */
  2010. addCamera(newCamera: Camera): void;
  2011. /**
  2012. * Adds the given skeleton to this scene
  2013. * @param newSkeleton The skeleton to add
  2014. */
  2015. addSkeleton(newSkeleton: Skeleton): void;
  2016. /**
  2017. * Adds the given particle system to this scene
  2018. * @param newParticleSystem The particle system to add
  2019. */
  2020. addParticleSystem(newParticleSystem: IParticleSystem): void;
  2021. /**
  2022. * Adds the given animation to this scene
  2023. * @param newAnimation The animation to add
  2024. */
  2025. addAnimation(newAnimation: Animation): void;
  2026. /**
  2027. * Adds the given animation group to this scene.
  2028. * @param newAnimationGroup The animation group to add
  2029. */
  2030. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  2031. /**
  2032. * Adds the given multi-material to this scene
  2033. * @param newMultiMaterial The multi-material to add
  2034. */
  2035. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  2036. /**
  2037. * Adds the given material to this scene
  2038. * @param newMaterial The material to add
  2039. */
  2040. addMaterial(newMaterial: Material): void;
  2041. /**
  2042. * Adds the given morph target to this scene
  2043. * @param newMorphTargetManager The morph target to add
  2044. */
  2045. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  2046. /**
  2047. * Adds the given geometry to this scene
  2048. * @param newGeometry The geometry to add
  2049. */
  2050. addGeometry(newGeometry: Geometry): void;
  2051. /**
  2052. * Adds the given action manager to this scene
  2053. * @param newActionManager The action manager to add
  2054. */
  2055. addActionManager(newActionManager: ActionManager): void;
  2056. /**
  2057. * Adds the given texture to this scene.
  2058. * @param newTexture The texture to add
  2059. */
  2060. addTexture(newTexture: BaseTexture): void;
  2061. /**
  2062. * Switch active camera
  2063. * @param newCamera defines the new active camera
  2064. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  2065. */
  2066. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  2067. /**
  2068. * sets the active camera of the scene using its ID
  2069. * @param id defines the camera's ID
  2070. * @return the new active camera or null if none found.
  2071. */
  2072. setActiveCameraByID(id: string): Nullable<Camera>;
  2073. /**
  2074. * sets the active camera of the scene using its name
  2075. * @param name defines the camera's name
  2076. * @returns the new active camera or null if none found.
  2077. */
  2078. setActiveCameraByName(name: string): Nullable<Camera>;
  2079. /**
  2080. * get an animation group using its name
  2081. * @param name defines the material's name
  2082. * @return the animation group or null if none found.
  2083. */
  2084. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  2085. /**
  2086. * get a material using its id
  2087. * @param id defines the material's ID
  2088. * @return the material or null if none found.
  2089. */
  2090. getMaterialByID(id: string): Nullable<Material>;
  2091. /**
  2092. * Gets a material using its name
  2093. * @param name defines the material's name
  2094. * @return the material or null if none found.
  2095. */
  2096. getMaterialByName(name: string): Nullable<Material>;
  2097. /**
  2098. * Gets a camera using its id
  2099. * @param id defines the id to look for
  2100. * @returns the camera or null if not found
  2101. */
  2102. getCameraByID(id: string): Nullable<Camera>;
  2103. /**
  2104. * Gets a camera using its unique id
  2105. * @param uniqueId defines the unique id to look for
  2106. * @returns the camera or null if not found
  2107. */
  2108. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  2109. /**
  2110. * Gets a camera using its name
  2111. * @param name defines the camera's name
  2112. * @return the camera or null if none found.
  2113. */
  2114. getCameraByName(name: string): Nullable<Camera>;
  2115. /**
  2116. * Gets a bone using its id
  2117. * @param id defines the bone's id
  2118. * @return the bone or null if not found
  2119. */
  2120. getBoneByID(id: string): Nullable<Bone>;
  2121. /**
  2122. * Gets a bone using its id
  2123. * @param name defines the bone's name
  2124. * @return the bone or null if not found
  2125. */
  2126. getBoneByName(name: string): Nullable<Bone>;
  2127. /**
  2128. * Gets a light node using its name
  2129. * @param name defines the the light's name
  2130. * @return the light or null if none found.
  2131. */
  2132. getLightByName(name: string): Nullable<Light>;
  2133. /**
  2134. * Gets a light node using its id
  2135. * @param id defines the light's id
  2136. * @return the light or null if none found.
  2137. */
  2138. getLightByID(id: string): Nullable<Light>;
  2139. /**
  2140. * Gets a light node using its scene-generated unique ID
  2141. * @param uniqueId defines the light's unique id
  2142. * @return the light or null if none found.
  2143. */
  2144. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  2145. /**
  2146. * Gets a particle system by id
  2147. * @param id defines the particle system id
  2148. * @return the corresponding system or null if none found
  2149. */
  2150. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  2151. /**
  2152. * Gets a geometry using its ID
  2153. * @param id defines the geometry's id
  2154. * @return the geometry or null if none found.
  2155. */
  2156. getGeometryByID(id: string): Nullable<Geometry>;
  2157. private _getGeometryByUniqueID;
  2158. /**
  2159. * Add a new geometry to this scene
  2160. * @param geometry defines the geometry to be added to the scene.
  2161. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  2162. * @return a boolean defining if the geometry was added or not
  2163. */
  2164. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  2165. /**
  2166. * Removes an existing geometry
  2167. * @param geometry defines the geometry to be removed from the scene
  2168. * @return a boolean defining if the geometry was removed or not
  2169. */
  2170. removeGeometry(geometry: Geometry): boolean;
  2171. /**
  2172. * Gets the list of geometries attached to the scene
  2173. * @returns an array of Geometry
  2174. */
  2175. getGeometries(): Geometry[];
  2176. /**
  2177. * Gets the first added mesh found of a given ID
  2178. * @param id defines the id to search for
  2179. * @return the mesh found or null if not found at all
  2180. */
  2181. getMeshByID(id: string): Nullable<AbstractMesh>;
  2182. /**
  2183. * Gets a list of meshes using their id
  2184. * @param id defines the id to search for
  2185. * @returns a list of meshes
  2186. */
  2187. getMeshesByID(id: string): Array<AbstractMesh>;
  2188. /**
  2189. * Gets the first added transform node found of a given ID
  2190. * @param id defines the id to search for
  2191. * @return the found transform node or null if not found at all.
  2192. */
  2193. getTransformNodeByID(id: string): Nullable<TransformNode>;
  2194. /**
  2195. * Gets a list of transform nodes using their id
  2196. * @param id defines the id to search for
  2197. * @returns a list of transform nodes
  2198. */
  2199. getTransformNodesByID(id: string): Array<TransformNode>;
  2200. /**
  2201. * Gets a mesh with its auto-generated unique id
  2202. * @param uniqueId defines the unique id to search for
  2203. * @return the found mesh or null if not found at all.
  2204. */
  2205. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  2206. /**
  2207. * Gets a the last added mesh using a given id
  2208. * @param id defines the id to search for
  2209. * @return the found mesh or null if not found at all.
  2210. */
  2211. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  2212. /**
  2213. * Gets a the last added node (Mesh, Camera, Light) using a given id
  2214. * @param id defines the id to search for
  2215. * @return the found node or null if not found at all
  2216. */
  2217. getLastEntryByID(id: string): Nullable<Node>;
  2218. /**
  2219. * Gets a node (Mesh, Camera, Light) using a given id
  2220. * @param id defines the id to search for
  2221. * @return the found node or null if not found at all
  2222. */
  2223. getNodeByID(id: string): Nullable<Node>;
  2224. /**
  2225. * Gets a node (Mesh, Camera, Light) using a given name
  2226. * @param name defines the name to search for
  2227. * @return the found node or null if not found at all.
  2228. */
  2229. getNodeByName(name: string): Nullable<Node>;
  2230. /**
  2231. * Gets a mesh using a given name
  2232. * @param name defines the name to search for
  2233. * @return the found mesh or null if not found at all.
  2234. */
  2235. getMeshByName(name: string): Nullable<AbstractMesh>;
  2236. /**
  2237. * Gets a transform node using a given name
  2238. * @param name defines the name to search for
  2239. * @return the found transform node or null if not found at all.
  2240. */
  2241. getTransformNodeByName(name: string): Nullable<TransformNode>;
  2242. /**
  2243. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  2244. * @param id defines the id to search for
  2245. * @return the found skeleton or null if not found at all.
  2246. */
  2247. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  2248. /**
  2249. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  2250. * @param id defines the id to search for
  2251. * @return the found skeleton or null if not found at all.
  2252. */
  2253. getSkeletonById(id: string): Nullable<Skeleton>;
  2254. /**
  2255. * Gets a skeleton using a given name
  2256. * @param name defines the name to search for
  2257. * @return the found skeleton or null if not found at all.
  2258. */
  2259. getSkeletonByName(name: string): Nullable<Skeleton>;
  2260. /**
  2261. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  2262. * @param id defines the id to search for
  2263. * @return the found morph target manager or null if not found at all.
  2264. */
  2265. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  2266. /**
  2267. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  2268. * @param id defines the id to search for
  2269. * @return the found morph target or null if not found at all.
  2270. */
  2271. getMorphTargetById(id: string): Nullable<MorphTarget>;
  2272. /**
  2273. * Gets a boolean indicating if the given mesh is active
  2274. * @param mesh defines the mesh to look for
  2275. * @returns true if the mesh is in the active list
  2276. */
  2277. isActiveMesh(mesh: AbstractMesh): boolean;
  2278. /**
  2279. * Return a unique id as a string which can serve as an identifier for the scene
  2280. */
  2281. readonly uid: string;
  2282. /**
  2283. * Add an externaly attached data from its key.
  2284. * This method call will fail and return false, if such key already exists.
  2285. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  2286. * @param key the unique key that identifies the data
  2287. * @param data the data object to associate to the key for this Engine instance
  2288. * @return true if no such key were already present and the data was added successfully, false otherwise
  2289. */
  2290. addExternalData<T>(key: string, data: T): boolean;
  2291. /**
  2292. * Get an externaly attached data from its key
  2293. * @param key the unique key that identifies the data
  2294. * @return the associated data, if present (can be null), or undefined if not present
  2295. */
  2296. getExternalData<T>(key: string): Nullable<T>;
  2297. /**
  2298. * Get an externaly attached data from its key, create it using a factory if it's not already present
  2299. * @param key the unique key that identifies the data
  2300. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  2301. * @return the associated data, can be null if the factory returned null.
  2302. */
  2303. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  2304. /**
  2305. * Remove an externaly attached data from the Engine instance
  2306. * @param key the unique key that identifies the data
  2307. * @return true if the data was successfully removed, false if it doesn't exist
  2308. */
  2309. removeExternalData(key: string): boolean;
  2310. private _evaluateSubMesh;
  2311. /**
  2312. * Clear the processed materials smart array preventing retention point in material dispose.
  2313. */
  2314. freeProcessedMaterials(): void;
  2315. private _preventFreeActiveMeshesAndRenderingGroups;
  2316. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  2317. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  2318. * when disposing several meshes in a row or a hierarchy of meshes.
  2319. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  2320. */
  2321. blockfreeActiveMeshesAndRenderingGroups: boolean;
  2322. /**
  2323. * Clear the active meshes smart array preventing retention point in mesh dispose.
  2324. */
  2325. freeActiveMeshes(): void;
  2326. /**
  2327. * Clear the info related to rendering groups preventing retention points during dispose.
  2328. */
  2329. freeRenderingGroups(): void;
  2330. /** @hidden */
  2331. _isInIntermediateRendering(): boolean;
  2332. /**
  2333. * Lambda returning the list of potentially active meshes.
  2334. */
  2335. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  2336. /**
  2337. * Lambda returning the list of potentially active sub meshes.
  2338. */
  2339. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  2340. /**
  2341. * Lambda returning the list of potentially intersecting sub meshes.
  2342. */
  2343. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  2344. /**
  2345. * Lambda returning the list of potentially colliding sub meshes.
  2346. */
  2347. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  2348. private _activeMeshesFrozen;
  2349. /**
  2350. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  2351. * @returns the current scene
  2352. */
  2353. freezeActiveMeshes(): Scene;
  2354. /**
  2355. * Use this function to restart evaluating active meshes on every frame
  2356. * @returns the current scene
  2357. */
  2358. unfreezeActiveMeshes(): Scene;
  2359. private _evaluateActiveMeshes;
  2360. private _activeMesh;
  2361. /**
  2362. * Update the transform matrix to update from the current active camera
  2363. * @param force defines a boolean used to force the update even if cache is up to date
  2364. */
  2365. updateTransformMatrix(force?: boolean): void;
  2366. /**
  2367. * Defines an alternate camera (used mostly in VR-like scenario where two cameras can render the same scene from a slightly different point of view)
  2368. * @param alternateCamera defines the camera to use
  2369. */
  2370. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  2371. /** @hidden */
  2372. _allowPostProcessClearColor: boolean;
  2373. private _renderForCamera;
  2374. private _processSubCameras;
  2375. private _checkIntersections;
  2376. /** @hidden */
  2377. _advancePhysicsEngineStep(step: number): void;
  2378. /**
  2379. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  2380. */
  2381. getDeterministicFrameTime: () => number;
  2382. /**
  2383. * Render the scene
  2384. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  2385. */
  2386. render(updateCameras?: boolean): void;
  2387. /**
  2388. * Freeze all materials
  2389. * A frozen material will not be updatable but should be faster to render
  2390. */
  2391. freezeMaterials(): void;
  2392. /**
  2393. * Unfreeze all materials
  2394. * A frozen material will not be updatable but should be faster to render
  2395. */
  2396. unfreezeMaterials(): void;
  2397. /**
  2398. * Releases all held ressources
  2399. */
  2400. dispose(): void;
  2401. /**
  2402. * Gets if the scene is already disposed
  2403. */
  2404. readonly isDisposed: boolean;
  2405. /**
  2406. * Call this function to reduce memory footprint of the scene.
  2407. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  2408. */
  2409. clearCachedVertexData(): void;
  2410. /**
  2411. * This function will remove the local cached buffer data from texture.
  2412. * It will save memory but will prevent the texture from being rebuilt
  2413. */
  2414. cleanCachedTextureBuffer(): void;
  2415. /**
  2416. * Get the world extend vectors with an optional filter
  2417. *
  2418. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  2419. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  2420. */
  2421. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  2422. min: Vector3;
  2423. max: Vector3;
  2424. };
  2425. /**
  2426. * Creates a ray that can be used to pick in the scene
  2427. * @param x defines the x coordinate of the origin (on-screen)
  2428. * @param y defines the y coordinate of the origin (on-screen)
  2429. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2430. * @param camera defines the camera to use for the picking
  2431. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2432. * @returns a Ray
  2433. */
  2434. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  2435. /**
  2436. * Creates a ray that can be used to pick in the scene
  2437. * @param x defines the x coordinate of the origin (on-screen)
  2438. * @param y defines the y coordinate of the origin (on-screen)
  2439. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2440. * @param result defines the ray where to store the picking ray
  2441. * @param camera defines the camera to use for the picking
  2442. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2443. * @returns the current scene
  2444. */
  2445. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  2446. /**
  2447. * Creates a ray that can be used to pick in the scene
  2448. * @param x defines the x coordinate of the origin (on-screen)
  2449. * @param y defines the y coordinate of the origin (on-screen)
  2450. * @param camera defines the camera to use for the picking
  2451. * @returns a Ray
  2452. */
  2453. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  2454. /**
  2455. * Creates a ray that can be used to pick in the scene
  2456. * @param x defines the x coordinate of the origin (on-screen)
  2457. * @param y defines the y coordinate of the origin (on-screen)
  2458. * @param result defines the ray where to store the picking ray
  2459. * @param camera defines the camera to use for the picking
  2460. * @returns the current scene
  2461. */
  2462. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  2463. private _internalPick;
  2464. private _internalMultiPick;
  2465. private _tempPickingRay;
  2466. /** Launch a ray to try to pick a mesh in the scene
  2467. * @param x position on screen
  2468. * @param y position on screen
  2469. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  2470. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  2471. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2472. * @returns a PickingInfo
  2473. */
  2474. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  2475. private _cachedRayForTransform;
  2476. /** Use the given ray to pick a mesh in the scene
  2477. * @param ray The ray to use to pick meshes
  2478. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must have isPickable set to true
  2479. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  2480. * @returns a PickingInfo
  2481. */
  2482. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  2483. /**
  2484. * Launch a ray to try to pick a mesh in the scene
  2485. * @param x X position on screen
  2486. * @param y Y position on screen
  2487. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  2488. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2489. * @returns an array of PickingInfo
  2490. */
  2491. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  2492. /**
  2493. * Launch a ray to try to pick a mesh in the scene
  2494. * @param ray Ray to use
  2495. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  2496. * @returns an array of PickingInfo
  2497. */
  2498. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  2499. /**
  2500. * Force the value of meshUnderPointer
  2501. * @param mesh defines the mesh to use
  2502. */
  2503. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  2504. /**
  2505. * Gets the mesh under the pointer
  2506. * @returns a Mesh or null if no mesh is under the pointer
  2507. */
  2508. getPointerOverMesh(): Nullable<AbstractMesh>;
  2509. /** @hidden */
  2510. _rebuildGeometries(): void;
  2511. /** @hidden */
  2512. _rebuildTextures(): void;
  2513. private _getByTags;
  2514. /**
  2515. * Get a list of meshes by tags
  2516. * @param tagsQuery defines the tags query to use
  2517. * @param forEach defines a predicate used to filter results
  2518. * @returns an array of Mesh
  2519. */
  2520. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  2521. /**
  2522. * Get a list of cameras by tags
  2523. * @param tagsQuery defines the tags query to use
  2524. * @param forEach defines a predicate used to filter results
  2525. * @returns an array of Camera
  2526. */
  2527. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  2528. /**
  2529. * Get a list of lights by tags
  2530. * @param tagsQuery defines the tags query to use
  2531. * @param forEach defines a predicate used to filter results
  2532. * @returns an array of Light
  2533. */
  2534. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  2535. /**
  2536. * Get a list of materials by tags
  2537. * @param tagsQuery defines the tags query to use
  2538. * @param forEach defines a predicate used to filter results
  2539. * @returns an array of Material
  2540. */
  2541. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  2542. /**
  2543. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  2544. * This allowed control for front to back rendering or reversly depending of the special needs.
  2545. *
  2546. * @param renderingGroupId The rendering group id corresponding to its index
  2547. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  2548. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  2549. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  2550. */
  2551. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  2552. /**
  2553. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  2554. *
  2555. * @param renderingGroupId The rendering group id corresponding to its index
  2556. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  2557. * @param depth Automatically clears depth between groups if true and autoClear is true.
  2558. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  2559. */
  2560. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  2561. /**
  2562. * Gets the current auto clear configuration for one rendering group of the rendering
  2563. * manager.
  2564. * @param index the rendering group index to get the information for
  2565. * @returns The auto clear setup for the requested rendering group
  2566. */
  2567. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  2568. private _blockMaterialDirtyMechanism;
  2569. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  2570. blockMaterialDirtyMechanism: boolean;
  2571. /**
  2572. * Will flag all materials as dirty to trigger new shader compilation
  2573. * @param flag defines the flag used to specify which material part must be marked as dirty
  2574. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  2575. */
  2576. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  2577. /** @hidden */
  2578. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  2579. /** @hidden */
  2580. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  2581. }
  2582. }
  2583. declare module BABYLON {
  2584. /**
  2585. * Groups all the scene component constants in one place to ease maintenance.
  2586. * @hidden
  2587. */
  2588. class SceneComponentConstants {
  2589. static readonly NAME_EFFECTLAYER: string;
  2590. static readonly NAME_LAYER: string;
  2591. static readonly NAME_LENSFLARESYSTEM: string;
  2592. static readonly NAME_BOUNDINGBOXRENDERER: string;
  2593. static readonly NAME_PARTICLESYSTEM: string;
  2594. static readonly NAME_GAMEPAD: string;
  2595. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  2596. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  2597. static readonly NAME_DEPTHRENDERER: string;
  2598. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  2599. static readonly NAME_SPRITE: string;
  2600. static readonly NAME_OUTLINERENDERER: string;
  2601. static readonly NAME_PROCEDURALTEXTURE: string;
  2602. static readonly NAME_SHADOWGENERATOR: string;
  2603. static readonly NAME_OCTREE: string;
  2604. static readonly NAME_PHYSICSENGINE: string;
  2605. static readonly NAME_AUDIO: string;
  2606. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  2607. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  2608. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  2609. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  2610. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  2611. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  2612. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  2613. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  2614. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  2615. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  2616. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  2617. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  2618. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  2619. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  2620. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  2621. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  2622. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  2623. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  2624. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  2625. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  2626. static readonly STEP_AFTERRENDER_AUDIO: number;
  2627. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  2628. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  2629. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  2630. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  2631. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  2632. static readonly STEP_POINTERMOVE_SPRITE: number;
  2633. static readonly STEP_POINTERDOWN_SPRITE: number;
  2634. static readonly STEP_POINTERUP_SPRITE: number;
  2635. }
  2636. /**
  2637. * This represents a scene component.
  2638. *
  2639. * This is used to decouple the dependency the scene is having on the different workloads like
  2640. * layers, post processes...
  2641. */
  2642. interface ISceneComponent {
  2643. /**
  2644. * The name of the component. Each component must have a unique name.
  2645. */
  2646. name: string;
  2647. /**
  2648. * The scene the component belongs to.
  2649. */
  2650. scene: Scene;
  2651. /**
  2652. * Register the component to one instance of a scene.
  2653. */
  2654. register(): void;
  2655. /**
  2656. * Rebuilds the elements related to this component in case of
  2657. * context lost for instance.
  2658. */
  2659. rebuild(): void;
  2660. /**
  2661. * Disposes the component and the associated ressources.
  2662. */
  2663. dispose(): void;
  2664. }
  2665. /**
  2666. * This represents a SERIALIZABLE scene component.
  2667. *
  2668. * This extends Scene Component to add Serialization methods on top.
  2669. */
  2670. interface ISceneSerializableComponent extends ISceneComponent {
  2671. /**
  2672. * Adds all the element from the container to the scene
  2673. * @param container the container holding the elements
  2674. */
  2675. addFromContainer(container: AbstractScene): void;
  2676. /**
  2677. * Removes all the elements in the container from the scene
  2678. * @param container contains the elements to remove
  2679. */
  2680. removeFromContainer(container: AbstractScene): void;
  2681. /**
  2682. * Serializes the component data to the specified json object
  2683. * @param serializationObject The object to serialize to
  2684. */
  2685. serialize(serializationObject: any): void;
  2686. }
  2687. /**
  2688. * Strong typing of a Mesh related stage step action
  2689. */
  2690. type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  2691. /**
  2692. * Strong typing of a Evaluate Sub Mesh related stage step action
  2693. */
  2694. type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  2695. /**
  2696. * Strong typing of a Active Mesh related stage step action
  2697. */
  2698. type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  2699. /**
  2700. * Strong typing of a Camera related stage step action
  2701. */
  2702. type CameraStageAction = (camera: Camera) => void;
  2703. /**
  2704. * Strong typing of a Render Target related stage step action
  2705. */
  2706. type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  2707. /**
  2708. * Strong typing of a RenderingGroup related stage step action
  2709. */
  2710. type RenderingGroupStageAction = (renderingGroupId: number) => void;
  2711. /**
  2712. * Strong typing of a Mesh Render related stage step action
  2713. */
  2714. type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  2715. /**
  2716. * Strong typing of a simple stage step action
  2717. */
  2718. type SimpleStageAction = () => void;
  2719. /**
  2720. * Strong typing of a render target action.
  2721. */
  2722. type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  2723. /**
  2724. * Strong typing of a pointer move action.
  2725. */
  2726. type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  2727. /**
  2728. * Strong typing of a pointer up/down action.
  2729. */
  2730. type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  2731. /**
  2732. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  2733. * @hidden
  2734. */
  2735. class Stage<T extends Function> extends Array<{
  2736. index: number;
  2737. component: ISceneComponent;
  2738. action: T;
  2739. }> {
  2740. /**
  2741. * Hide ctor from the rest of the world.
  2742. * @param items The items to add.
  2743. */
  2744. private constructor();
  2745. /**
  2746. * Creates a new Stage.
  2747. * @returns A new instance of a Stage
  2748. */
  2749. static Create<T extends Function>(): Stage<T>;
  2750. /**
  2751. * Registers a step in an ordered way in the targeted stage.
  2752. * @param index Defines the position to register the step in
  2753. * @param component Defines the component attached to the step
  2754. * @param action Defines the action to launch during the step
  2755. */
  2756. registerStep(index: number, component: ISceneComponent, action: T): void;
  2757. /**
  2758. * Clears all the steps from the stage.
  2759. */
  2760. clear(): void;
  2761. }
  2762. }
  2763. declare module BABYLON {
  2764. /** Alias type for value that can be null */
  2765. type Nullable<T> = T | null;
  2766. /**
  2767. * Alias type for number that are floats
  2768. * @ignorenaming
  2769. */
  2770. type float = number;
  2771. /**
  2772. * Alias type for number that are doubles.
  2773. * @ignorenaming
  2774. */
  2775. type double = number;
  2776. /**
  2777. * Alias type for number that are integer
  2778. * @ignorenaming
  2779. */
  2780. type int = number;
  2781. /** Alias type for number array or Float32Array */
  2782. type FloatArray = number[] | Float32Array;
  2783. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  2784. type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  2785. /**
  2786. * Alias for types that can be used by a Buffer or VertexBuffer.
  2787. */
  2788. type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  2789. /**
  2790. * Alias type for primitive types
  2791. * @ignorenaming
  2792. */
  2793. type Primitive = undefined | null | boolean | string | number | Function;
  2794. /**
  2795. * Type modifier to make all the properties of an object Readonly
  2796. */
  2797. type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  2798. /**
  2799. * Type modifier to make all the properties of an object Readonly recursively
  2800. */
  2801. type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  2802. /** @hidden */
  2803. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  2804. }
  2805. /** @hidden */
  2806. /** @hidden */
  2807. type DeepImmutableObject<T> = {
  2808. readonly [K in keyof T]: DeepImmutable<T[K]>;
  2809. };
  2810. }
  2811. declare module BABYLON {
  2812. /**
  2813. * The action to be carried out following a trigger
  2814. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  2815. */
  2816. class Action {
  2817. /** the trigger, with or without parameters, for the action */
  2818. triggerOptions: any;
  2819. /**
  2820. * Trigger for the action
  2821. */
  2822. trigger: number;
  2823. /**
  2824. * Internal only - manager for action
  2825. * @hidden
  2826. */
  2827. _actionManager: ActionManager;
  2828. private _nextActiveAction;
  2829. private _child;
  2830. private _condition?;
  2831. private _triggerParameter;
  2832. /**
  2833. * An event triggered prior to action being executed.
  2834. */
  2835. onBeforeExecuteObservable: Observable<Action>;
  2836. /**
  2837. * Creates a new Action
  2838. * @param triggerOptions the trigger, with or without parameters, for the action
  2839. * @param condition an optional determinant of action
  2840. */
  2841. constructor(
  2842. /** the trigger, with or without parameters, for the action */
  2843. triggerOptions: any, condition?: Condition);
  2844. /**
  2845. * Internal only
  2846. * @hidden
  2847. */
  2848. _prepare(): void;
  2849. /**
  2850. * Gets the trigger parameters
  2851. * @returns the trigger parameters
  2852. */
  2853. getTriggerParameter(): any;
  2854. /**
  2855. * Internal only - executes current action event
  2856. * @hidden
  2857. */
  2858. _executeCurrent(evt?: ActionEvent): void;
  2859. /**
  2860. * Execute placeholder for child classes
  2861. * @param evt optional action event
  2862. */
  2863. execute(evt?: ActionEvent): void;
  2864. /**
  2865. * Skips to next active action
  2866. */
  2867. skipToNextActiveAction(): void;
  2868. /**
  2869. * Adds action to chain of actions, may be a DoNothingAction
  2870. * @param action defines the next action to execute
  2871. * @returns The action passed in
  2872. * @see https://www.babylonjs-playground.com/#1T30HR#0
  2873. */
  2874. then(action: Action): Action;
  2875. /**
  2876. * Internal only
  2877. * @hidden
  2878. */
  2879. _getProperty(propertyPath: string): string;
  2880. /**
  2881. * Internal only
  2882. * @hidden
  2883. */
  2884. _getEffectiveTarget(target: any, propertyPath: string): any;
  2885. /**
  2886. * Serialize placeholder for child classes
  2887. * @param parent of child
  2888. * @returns the serialized object
  2889. */
  2890. serialize(parent: any): any;
  2891. /**
  2892. * Internal only called by serialize
  2893. * @hidden
  2894. */
  2895. protected _serialize(serializedAction: any, parent?: any): any;
  2896. /**
  2897. * Internal only
  2898. * @hidden
  2899. */
  2900. static _SerializeValueAsString: (value: any) => string;
  2901. /**
  2902. * Internal only
  2903. * @hidden
  2904. */
  2905. static _GetTargetProperty: (target: Scene | Node) => {
  2906. name: string;
  2907. targetType: string;
  2908. value: string;
  2909. };
  2910. }
  2911. }
  2912. declare module BABYLON {
  2913. /**
  2914. * ActionEvent is the event being sent when an action is triggered.
  2915. */
  2916. class ActionEvent {
  2917. /** The mesh or sprite that triggered the action */
  2918. source: any;
  2919. /** The X mouse cursor position at the time of the event */
  2920. pointerX: number;
  2921. /** The Y mouse cursor position at the time of the event */
  2922. pointerY: number;
  2923. /** The mesh that is currently pointed at (can be null) */
  2924. meshUnderPointer: Nullable<AbstractMesh>;
  2925. /** the original (browser) event that triggered the ActionEvent */
  2926. sourceEvent?: any;
  2927. /** additional data for the event */
  2928. additionalData?: any;
  2929. /**
  2930. * Creates a new ActionEvent
  2931. * @param source The mesh or sprite that triggered the action
  2932. * @param pointerX The X mouse cursor position at the time of the event
  2933. * @param pointerY The Y mouse cursor position at the time of the event
  2934. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  2935. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  2936. * @param additionalData additional data for the event
  2937. */
  2938. constructor(
  2939. /** The mesh or sprite that triggered the action */
  2940. source: any,
  2941. /** The X mouse cursor position at the time of the event */
  2942. pointerX: number,
  2943. /** The Y mouse cursor position at the time of the event */
  2944. pointerY: number,
  2945. /** The mesh that is currently pointed at (can be null) */
  2946. meshUnderPointer: Nullable<AbstractMesh>,
  2947. /** the original (browser) event that triggered the ActionEvent */
  2948. sourceEvent?: any,
  2949. /** additional data for the event */
  2950. additionalData?: any);
  2951. /**
  2952. * Helper function to auto-create an ActionEvent from a source mesh.
  2953. * @param source The source mesh that triggered the event
  2954. * @param evt The original (browser) event
  2955. * @param additionalData additional data for the event
  2956. * @returns the new ActionEvent
  2957. */
  2958. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  2959. /**
  2960. * Helper function to auto-create an ActionEvent from a source sprite
  2961. * @param source The source sprite that triggered the event
  2962. * @param scene Scene associated with the sprite
  2963. * @param evt The original (browser) event
  2964. * @param additionalData additional data for the event
  2965. * @returns the new ActionEvent
  2966. */
  2967. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  2968. /**
  2969. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  2970. * @param scene the scene where the event occurred
  2971. * @param evt The original (browser) event
  2972. * @returns the new ActionEvent
  2973. */
  2974. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  2975. /**
  2976. * Helper function to auto-create an ActionEvent from a primitive
  2977. * @param prim defines the target primitive
  2978. * @param pointerPos defines the pointer position
  2979. * @param evt The original (browser) event
  2980. * @param additionalData additional data for the event
  2981. * @returns the new ActionEvent
  2982. */
  2983. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  2984. }
  2985. /**
  2986. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  2987. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  2988. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  2989. */
  2990. class ActionManager {
  2991. /**
  2992. * Nothing
  2993. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2994. */
  2995. static readonly NothingTrigger: number;
  2996. /**
  2997. * On pick
  2998. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2999. */
  3000. static readonly OnPickTrigger: number;
  3001. /**
  3002. * On left pick
  3003. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3004. */
  3005. static readonly OnLeftPickTrigger: number;
  3006. /**
  3007. * On right pick
  3008. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3009. */
  3010. static readonly OnRightPickTrigger: number;
  3011. /**
  3012. * On center pick
  3013. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3014. */
  3015. static readonly OnCenterPickTrigger: number;
  3016. /**
  3017. * On pick down
  3018. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3019. */
  3020. static readonly OnPickDownTrigger: number;
  3021. /**
  3022. * On double pick
  3023. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3024. */
  3025. static readonly OnDoublePickTrigger: number;
  3026. /**
  3027. * On pick up
  3028. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3029. */
  3030. static readonly OnPickUpTrigger: number;
  3031. /**
  3032. * On pick out.
  3033. * This trigger will only be raised if you also declared a OnPickDown
  3034. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3035. */
  3036. static readonly OnPickOutTrigger: number;
  3037. /**
  3038. * On long press
  3039. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3040. */
  3041. static readonly OnLongPressTrigger: number;
  3042. /**
  3043. * On pointer over
  3044. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3045. */
  3046. static readonly OnPointerOverTrigger: number;
  3047. /**
  3048. * On pointer out
  3049. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3050. */
  3051. static readonly OnPointerOutTrigger: number;
  3052. /**
  3053. * On every frame
  3054. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3055. */
  3056. static readonly OnEveryFrameTrigger: number;
  3057. /**
  3058. * On intersection enter
  3059. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3060. */
  3061. static readonly OnIntersectionEnterTrigger: number;
  3062. /**
  3063. * On intersection exit
  3064. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3065. */
  3066. static readonly OnIntersectionExitTrigger: number;
  3067. /**
  3068. * On key down
  3069. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3070. */
  3071. static readonly OnKeyDownTrigger: number;
  3072. /**
  3073. * On key up
  3074. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3075. */
  3076. static readonly OnKeyUpTrigger: number;
  3077. /** Gets the list of active triggers */
  3078. static Triggers: {
  3079. [key: string]: number;
  3080. };
  3081. /** Gets the list of actions */
  3082. actions: Action[];
  3083. /** Gets the cursor to use when hovering items */
  3084. hoverCursor: string;
  3085. private _scene;
  3086. /**
  3087. * Creates a new action manager
  3088. * @param scene defines the hosting scene
  3089. */
  3090. constructor(scene: Scene);
  3091. /**
  3092. * Releases all associated resources
  3093. */
  3094. dispose(): void;
  3095. /**
  3096. * Gets hosting scene
  3097. * @returns the hosting scene
  3098. */
  3099. getScene(): Scene;
  3100. /**
  3101. * Does this action manager handles actions of any of the given triggers
  3102. * @param triggers defines the triggers to be tested
  3103. * @return a boolean indicating whether one (or more) of the triggers is handled
  3104. */
  3105. hasSpecificTriggers(triggers: number[]): boolean;
  3106. /**
  3107. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  3108. * speed.
  3109. * @param triggerA defines the trigger to be tested
  3110. * @param triggerB defines the trigger to be tested
  3111. * @return a boolean indicating whether one (or more) of the triggers is handled
  3112. */
  3113. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  3114. /**
  3115. * Does this action manager handles actions of a given trigger
  3116. * @param trigger defines the trigger to be tested
  3117. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  3118. * @return whether the trigger is handled
  3119. */
  3120. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  3121. /**
  3122. * Does this action manager has pointer triggers
  3123. */
  3124. readonly hasPointerTriggers: boolean;
  3125. /**
  3126. * Does this action manager has pick triggers
  3127. */
  3128. readonly hasPickTriggers: boolean;
  3129. /**
  3130. * Does exist one action manager with at least one trigger
  3131. **/
  3132. static readonly HasTriggers: boolean;
  3133. /**
  3134. * Does exist one action manager with at least one pick trigger
  3135. **/
  3136. static readonly HasPickTriggers: boolean;
  3137. /**
  3138. * Does exist one action manager that handles actions of a given trigger
  3139. * @param trigger defines the trigger to be tested
  3140. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  3141. **/
  3142. static HasSpecificTrigger(trigger: number): boolean;
  3143. /**
  3144. * Registers an action to this action manager
  3145. * @param action defines the action to be registered
  3146. * @return the action amended (prepared) after registration
  3147. */
  3148. registerAction(action: Action): Nullable<Action>;
  3149. /**
  3150. * Unregisters an action to this action manager
  3151. * @param action defines the action to be unregistered
  3152. * @return a boolean indicating whether the action has been unregistered
  3153. */
  3154. unregisterAction(action: Action): Boolean;
  3155. /**
  3156. * Process a specific trigger
  3157. * @param trigger defines the trigger to process
  3158. * @param evt defines the event details to be processed
  3159. */
  3160. processTrigger(trigger: number, evt?: ActionEvent): void;
  3161. /** @hidden */
  3162. _getEffectiveTarget(target: any, propertyPath: string): any;
  3163. /** @hidden */
  3164. _getProperty(propertyPath: string): string;
  3165. /**
  3166. * Serialize this manager to a JSON object
  3167. * @param name defines the property name to store this manager
  3168. * @returns a JSON representation of this manager
  3169. */
  3170. serialize(name: string): any;
  3171. /**
  3172. * Creates a new ActionManager from a JSON data
  3173. * @param parsedActions defines the JSON data to read from
  3174. * @param object defines the hosting mesh
  3175. * @param scene defines the hosting scene
  3176. */
  3177. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  3178. /**
  3179. * Get a trigger name by index
  3180. * @param trigger defines the trigger index
  3181. * @returns a trigger name
  3182. */
  3183. static GetTriggerName(trigger: number): string;
  3184. }
  3185. }
  3186. declare module BABYLON {
  3187. /**
  3188. * A Condition applied to an Action
  3189. */
  3190. class Condition {
  3191. /**
  3192. * Internal only - manager for action
  3193. * @hidden
  3194. */
  3195. _actionManager: ActionManager;
  3196. /**
  3197. * Internal only
  3198. * @hidden
  3199. */
  3200. _evaluationId: number;
  3201. /**
  3202. * Internal only
  3203. * @hidden
  3204. */
  3205. _currentResult: boolean;
  3206. /**
  3207. * Creates a new Condition
  3208. * @param actionManager the manager of the action the condition is applied to
  3209. */
  3210. constructor(actionManager: ActionManager);
  3211. /**
  3212. * Check if the current condition is valid
  3213. * @returns a boolean
  3214. */
  3215. isValid(): boolean;
  3216. /**
  3217. * Internal only
  3218. * @hidden
  3219. */
  3220. _getProperty(propertyPath: string): string;
  3221. /**
  3222. * Internal only
  3223. * @hidden
  3224. */
  3225. _getEffectiveTarget(target: any, propertyPath: string): any;
  3226. /**
  3227. * Serialize placeholder for child classes
  3228. * @returns the serialized object
  3229. */
  3230. serialize(): any;
  3231. /**
  3232. * Internal only
  3233. * @hidden
  3234. */
  3235. protected _serialize(serializedCondition: any): any;
  3236. }
  3237. /**
  3238. * Defines specific conditional operators as extensions of Condition
  3239. */
  3240. class ValueCondition extends Condition {
  3241. /** path to specify the property of the target the conditional operator uses */
  3242. propertyPath: string;
  3243. /** the value compared by the conditional operator against the current value of the property */
  3244. value: any;
  3245. /** the conditional operator, default ValueCondition.IsEqual */
  3246. operator: number;
  3247. /**
  3248. * Internal only
  3249. * @hidden
  3250. */
  3251. private static _IsEqual;
  3252. /**
  3253. * Internal only
  3254. * @hidden
  3255. */
  3256. private static _IsDifferent;
  3257. /**
  3258. * Internal only
  3259. * @hidden
  3260. */
  3261. private static _IsGreater;
  3262. /**
  3263. * Internal only
  3264. * @hidden
  3265. */
  3266. private static _IsLesser;
  3267. /**
  3268. * returns the number for IsEqual
  3269. */
  3270. static readonly IsEqual: number;
  3271. /**
  3272. * Returns the number for IsDifferent
  3273. */
  3274. static readonly IsDifferent: number;
  3275. /**
  3276. * Returns the number for IsGreater
  3277. */
  3278. static readonly IsGreater: number;
  3279. /**
  3280. * Returns the number for IsLesser
  3281. */
  3282. static readonly IsLesser: number;
  3283. /**
  3284. * Internal only The action manager for the condition
  3285. * @hidden
  3286. */
  3287. _actionManager: ActionManager;
  3288. /**
  3289. * Internal only
  3290. * @hidden
  3291. */
  3292. private _target;
  3293. /**
  3294. * Internal only
  3295. * @hidden
  3296. */
  3297. private _effectiveTarget;
  3298. /**
  3299. * Internal only
  3300. * @hidden
  3301. */
  3302. private _property;
  3303. /**
  3304. * Creates a new ValueCondition
  3305. * @param actionManager manager for the action the condition applies to
  3306. * @param target for the action
  3307. * @param propertyPath path to specify the property of the target the conditional operator uses
  3308. * @param value the value compared by the conditional operator against the current value of the property
  3309. * @param operator the conditional operator, default ValueCondition.IsEqual
  3310. */
  3311. constructor(actionManager: ActionManager, target: any,
  3312. /** path to specify the property of the target the conditional operator uses */
  3313. propertyPath: string,
  3314. /** the value compared by the conditional operator against the current value of the property */
  3315. value: any,
  3316. /** the conditional operator, default ValueCondition.IsEqual */
  3317. operator?: number);
  3318. /**
  3319. * Compares the given value with the property value for the specified conditional operator
  3320. * @returns the result of the comparison
  3321. */
  3322. isValid(): boolean;
  3323. /**
  3324. * Serialize the ValueCondition into a JSON compatible object
  3325. * @returns serialization object
  3326. */
  3327. serialize(): any;
  3328. /**
  3329. * Gets the name of the conditional operator for the ValueCondition
  3330. * @param operator the conditional operator
  3331. * @returns the name
  3332. */
  3333. static GetOperatorName(operator: number): string;
  3334. }
  3335. /**
  3336. * Defines a predicate condition as an extension of Condition
  3337. */
  3338. class PredicateCondition extends Condition {
  3339. /** defines the predicate function used to validate the condition */
  3340. predicate: () => boolean;
  3341. /**
  3342. * Internal only - manager for action
  3343. * @hidden
  3344. */
  3345. _actionManager: ActionManager;
  3346. /**
  3347. * Creates a new PredicateCondition
  3348. * @param actionManager manager for the action the condition applies to
  3349. * @param predicate defines the predicate function used to validate the condition
  3350. */
  3351. constructor(actionManager: ActionManager,
  3352. /** defines the predicate function used to validate the condition */
  3353. predicate: () => boolean);
  3354. /**
  3355. * @returns the validity of the predicate condition
  3356. */
  3357. isValid(): boolean;
  3358. }
  3359. /**
  3360. * Defines a state condition as an extension of Condition
  3361. */
  3362. class StateCondition extends Condition {
  3363. /** Value to compare with target state */
  3364. value: string;
  3365. /**
  3366. * Internal only - manager for action
  3367. * @hidden
  3368. */
  3369. _actionManager: ActionManager;
  3370. /**
  3371. * Internal only
  3372. * @hidden
  3373. */
  3374. private _target;
  3375. /**
  3376. * Creates a new StateCondition
  3377. * @param actionManager manager for the action the condition applies to
  3378. * @param target of the condition
  3379. * @param value to compare with target state
  3380. */
  3381. constructor(actionManager: ActionManager, target: any,
  3382. /** Value to compare with target state */
  3383. value: string);
  3384. /**
  3385. * Gets a boolean indicating if the current condition is met
  3386. * @returns the validity of the state
  3387. */
  3388. isValid(): boolean;
  3389. /**
  3390. * Serialize the StateCondition into a JSON compatible object
  3391. * @returns serialization object
  3392. */
  3393. serialize(): any;
  3394. }
  3395. }
  3396. declare module BABYLON {
  3397. /**
  3398. * This defines an action responsible to toggle a boolean once triggered.
  3399. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3400. */
  3401. class SwitchBooleanAction extends Action {
  3402. /**
  3403. * The path to the boolean property in the target object
  3404. */
  3405. propertyPath: string;
  3406. private _target;
  3407. private _effectiveTarget;
  3408. private _property;
  3409. /**
  3410. * Instantiate the action
  3411. * @param triggerOptions defines the trigger options
  3412. * @param target defines the object containing the boolean
  3413. * @param propertyPath defines the path to the boolean property in the target object
  3414. * @param condition defines the trigger related conditions
  3415. */
  3416. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  3417. /** @hidden */
  3418. _prepare(): void;
  3419. /**
  3420. * Execute the action toggle the boolean value.
  3421. */
  3422. execute(): void;
  3423. /**
  3424. * Serializes the actions and its related information.
  3425. * @param parent defines the object to serialize in
  3426. * @returns the serialized object
  3427. */
  3428. serialize(parent: any): any;
  3429. }
  3430. /**
  3431. * This defines an action responsible to set a the state field of the target
  3432. * to a desired value once triggered.
  3433. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3434. */
  3435. class SetStateAction extends Action {
  3436. /**
  3437. * The value to store in the state field.
  3438. */
  3439. value: string;
  3440. private _target;
  3441. /**
  3442. * Instantiate the action
  3443. * @param triggerOptions defines the trigger options
  3444. * @param target defines the object containing the state property
  3445. * @param value defines the value to store in the state field
  3446. * @param condition defines the trigger related conditions
  3447. */
  3448. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  3449. /**
  3450. * Execute the action and store the value on the target state property.
  3451. */
  3452. execute(): void;
  3453. /**
  3454. * Serializes the actions and its related information.
  3455. * @param parent defines the object to serialize in
  3456. * @returns the serialized object
  3457. */
  3458. serialize(parent: any): any;
  3459. }
  3460. /**
  3461. * This defines an action responsible to set a property of the target
  3462. * to a desired value once triggered.
  3463. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3464. */
  3465. class SetValueAction extends Action {
  3466. /**
  3467. * The path of the property to set in the target.
  3468. */
  3469. propertyPath: string;
  3470. /**
  3471. * The value to set in the property
  3472. */
  3473. value: any;
  3474. private _target;
  3475. private _effectiveTarget;
  3476. private _property;
  3477. /**
  3478. * Instantiate the action
  3479. * @param triggerOptions defines the trigger options
  3480. * @param target defines the object containing the property
  3481. * @param propertyPath defines the path of the property to set in the target
  3482. * @param value defines the value to set in the property
  3483. * @param condition defines the trigger related conditions
  3484. */
  3485. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3486. /** @hidden */
  3487. _prepare(): void;
  3488. /**
  3489. * Execute the action and set the targetted property to the desired value.
  3490. */
  3491. execute(): void;
  3492. /**
  3493. * Serializes the actions and its related information.
  3494. * @param parent defines the object to serialize in
  3495. * @returns the serialized object
  3496. */
  3497. serialize(parent: any): any;
  3498. }
  3499. /**
  3500. * This defines an action responsible to increment the target value
  3501. * to a desired value once triggered.
  3502. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3503. */
  3504. class IncrementValueAction extends Action {
  3505. /**
  3506. * The path of the property to increment in the target.
  3507. */
  3508. propertyPath: string;
  3509. /**
  3510. * The value we should increment the property by.
  3511. */
  3512. value: any;
  3513. private _target;
  3514. private _effectiveTarget;
  3515. private _property;
  3516. /**
  3517. * Instantiate the action
  3518. * @param triggerOptions defines the trigger options
  3519. * @param target defines the object containing the property
  3520. * @param propertyPath defines the path of the property to increment in the target
  3521. * @param value defines the value value we should increment the property by
  3522. * @param condition defines the trigger related conditions
  3523. */
  3524. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3525. /** @hidden */
  3526. _prepare(): void;
  3527. /**
  3528. * Execute the action and increment the target of the value amount.
  3529. */
  3530. execute(): void;
  3531. /**
  3532. * Serializes the actions and its related information.
  3533. * @param parent defines the object to serialize in
  3534. * @returns the serialized object
  3535. */
  3536. serialize(parent: any): any;
  3537. }
  3538. /**
  3539. * This defines an action responsible to start an animation once triggered.
  3540. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3541. */
  3542. class PlayAnimationAction extends Action {
  3543. /**
  3544. * Where the animation should start (animation frame)
  3545. */
  3546. from: number;
  3547. /**
  3548. * Where the animation should stop (animation frame)
  3549. */
  3550. to: number;
  3551. /**
  3552. * Define if the animation should loop or stop after the first play.
  3553. */
  3554. loop?: boolean;
  3555. private _target;
  3556. /**
  3557. * Instantiate the action
  3558. * @param triggerOptions defines the trigger options
  3559. * @param target defines the target animation or animation name
  3560. * @param from defines from where the animation should start (animation frame)
  3561. * @param end defines where the animation should stop (animation frame)
  3562. * @param loop defines if the animation should loop or stop after the first play
  3563. * @param condition defines the trigger related conditions
  3564. */
  3565. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  3566. /** @hidden */
  3567. _prepare(): void;
  3568. /**
  3569. * Execute the action and play the animation.
  3570. */
  3571. execute(): void;
  3572. /**
  3573. * Serializes the actions and its related information.
  3574. * @param parent defines the object to serialize in
  3575. * @returns the serialized object
  3576. */
  3577. serialize(parent: any): any;
  3578. }
  3579. /**
  3580. * This defines an action responsible to stop an animation once triggered.
  3581. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3582. */
  3583. class StopAnimationAction extends Action {
  3584. private _target;
  3585. /**
  3586. * Instantiate the action
  3587. * @param triggerOptions defines the trigger options
  3588. * @param target defines the target animation or animation name
  3589. * @param condition defines the trigger related conditions
  3590. */
  3591. constructor(triggerOptions: any, target: any, condition?: Condition);
  3592. /** @hidden */
  3593. _prepare(): void;
  3594. /**
  3595. * Execute the action and stop the animation.
  3596. */
  3597. execute(): void;
  3598. /**
  3599. * Serializes the actions and its related information.
  3600. * @param parent defines the object to serialize in
  3601. * @returns the serialized object
  3602. */
  3603. serialize(parent: any): any;
  3604. }
  3605. /**
  3606. * This defines an action responsible that does nothing once triggered.
  3607. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3608. */
  3609. class DoNothingAction extends Action {
  3610. /**
  3611. * Instantiate the action
  3612. * @param triggerOptions defines the trigger options
  3613. * @param condition defines the trigger related conditions
  3614. */
  3615. constructor(triggerOptions?: any, condition?: Condition);
  3616. /**
  3617. * Execute the action and do nothing.
  3618. */
  3619. execute(): void;
  3620. /**
  3621. * Serializes the actions and its related information.
  3622. * @param parent defines the object to serialize in
  3623. * @returns the serialized object
  3624. */
  3625. serialize(parent: any): any;
  3626. }
  3627. /**
  3628. * This defines an action responsible to trigger several actions once triggered.
  3629. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3630. */
  3631. class CombineAction extends Action {
  3632. /**
  3633. * The list of aggregated animations to run.
  3634. */
  3635. children: Action[];
  3636. /**
  3637. * Instantiate the action
  3638. * @param triggerOptions defines the trigger options
  3639. * @param children defines the list of aggregated animations to run
  3640. * @param condition defines the trigger related conditions
  3641. */
  3642. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  3643. /** @hidden */
  3644. _prepare(): void;
  3645. /**
  3646. * Execute the action and executes all the aggregated actions.
  3647. */
  3648. execute(evt: ActionEvent): void;
  3649. /**
  3650. * Serializes the actions and its related information.
  3651. * @param parent defines the object to serialize in
  3652. * @returns the serialized object
  3653. */
  3654. serialize(parent: any): any;
  3655. }
  3656. /**
  3657. * This defines an action responsible to run code (external event) once triggered.
  3658. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3659. */
  3660. class ExecuteCodeAction extends Action {
  3661. /**
  3662. * The callback function to run.
  3663. */
  3664. func: (evt: ActionEvent) => void;
  3665. /**
  3666. * Instantiate the action
  3667. * @param triggerOptions defines the trigger options
  3668. * @param func defines the callback function to run
  3669. * @param condition defines the trigger related conditions
  3670. */
  3671. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  3672. /**
  3673. * Execute the action and run the attached code.
  3674. */
  3675. execute(evt: ActionEvent): void;
  3676. }
  3677. /**
  3678. * This defines an action responsible to set the parent property of the target once triggered.
  3679. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3680. */
  3681. class SetParentAction extends Action {
  3682. private _parent;
  3683. private _target;
  3684. /**
  3685. * Instantiate the action
  3686. * @param triggerOptions defines the trigger options
  3687. * @param target defines the target containing the parent property
  3688. * @param parent defines from where the animation should start (animation frame)
  3689. * @param condition defines the trigger related conditions
  3690. */
  3691. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  3692. /** @hidden */
  3693. _prepare(): void;
  3694. /**
  3695. * Execute the action and set the parent property.
  3696. */
  3697. execute(): void;
  3698. /**
  3699. * Serializes the actions and its related information.
  3700. * @param parent defines the object to serialize in
  3701. * @returns the serialized object
  3702. */
  3703. serialize(parent: any): any;
  3704. }
  3705. }
  3706. declare module BABYLON {
  3707. /**
  3708. * This defines an action helpful to play a defined sound on a triggered action.
  3709. */
  3710. class PlaySoundAction extends Action {
  3711. private _sound;
  3712. /**
  3713. * Instantiate the action
  3714. * @param triggerOptions defines the trigger options
  3715. * @param sound defines the sound to play
  3716. * @param condition defines the trigger related conditions
  3717. */
  3718. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3719. /** @hidden */
  3720. _prepare(): void;
  3721. /**
  3722. * Execute the action and play the sound.
  3723. */
  3724. execute(): void;
  3725. /**
  3726. * Serializes the actions and its related information.
  3727. * @param parent defines the object to serialize in
  3728. * @returns the serialized object
  3729. */
  3730. serialize(parent: any): any;
  3731. }
  3732. /**
  3733. * This defines an action helpful to stop a defined sound on a triggered action.
  3734. */
  3735. class StopSoundAction extends Action {
  3736. private _sound;
  3737. /**
  3738. * Instantiate the action
  3739. * @param triggerOptions defines the trigger options
  3740. * @param sound defines the sound to stop
  3741. * @param condition defines the trigger related conditions
  3742. */
  3743. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3744. /** @hidden */
  3745. _prepare(): void;
  3746. /**
  3747. * Execute the action and stop the sound.
  3748. */
  3749. execute(): void;
  3750. /**
  3751. * Serializes the actions and its related information.
  3752. * @param parent defines the object to serialize in
  3753. * @returns the serialized object
  3754. */
  3755. serialize(parent: any): any;
  3756. }
  3757. }
  3758. declare module BABYLON {
  3759. /**
  3760. * This defines an action responsible to change the value of a property
  3761. * by interpolating between its current value and the newly set one once triggered.
  3762. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3763. */
  3764. class InterpolateValueAction extends Action {
  3765. /**
  3766. * Defines the path of the property where the value should be interpolated
  3767. */
  3768. propertyPath: string;
  3769. /**
  3770. * Defines the target value at the end of the interpolation.
  3771. */
  3772. value: any;
  3773. /**
  3774. * Defines the time it will take for the property to interpolate to the value.
  3775. */
  3776. duration: number;
  3777. /**
  3778. * Defines if the other scene animations should be stopped when the action has been triggered
  3779. */
  3780. stopOtherAnimations?: boolean;
  3781. /**
  3782. * Defines a callback raised once the interpolation animation has been done.
  3783. */
  3784. onInterpolationDone?: () => void;
  3785. /**
  3786. * Observable triggered once the interpolation animation has been done.
  3787. */
  3788. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  3789. private _target;
  3790. private _effectiveTarget;
  3791. private _property;
  3792. /**
  3793. * Instantiate the action
  3794. * @param triggerOptions defines the trigger options
  3795. * @param target defines the object containing the value to interpolate
  3796. * @param propertyPath defines the path to the property in the target object
  3797. * @param value defines the target value at the end of the interpolation
  3798. * @param duration deines the time it will take for the property to interpolate to the value.
  3799. * @param condition defines the trigger related conditions
  3800. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  3801. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  3802. */
  3803. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  3804. /** @hidden */
  3805. _prepare(): void;
  3806. /**
  3807. * Execute the action starts the value interpolation.
  3808. */
  3809. execute(): void;
  3810. /**
  3811. * Serializes the actions and its related information.
  3812. * @param parent defines the object to serialize in
  3813. * @returns the serialized object
  3814. */
  3815. serialize(parent: any): any;
  3816. }
  3817. }
  3818. declare module BABYLON {
  3819. /**
  3820. * Class used to store an actual running animation
  3821. */
  3822. class Animatable {
  3823. /** defines the target object */
  3824. target: any;
  3825. /** defines the starting frame number (default is 0) */
  3826. fromFrame: number;
  3827. /** defines the ending frame number (default is 100) */
  3828. toFrame: number;
  3829. /** defines if the animation must loop (default is false) */
  3830. loopAnimation: boolean;
  3831. /** defines a callback to call when animation ends if it is not looping */
  3832. onAnimationEnd?: (() => void) | null | undefined;
  3833. /** defines a callback to call when animation loops */
  3834. onAnimationLoop?: (() => void) | null | undefined;
  3835. private _localDelayOffset;
  3836. private _pausedDelay;
  3837. private _runtimeAnimations;
  3838. private _paused;
  3839. private _scene;
  3840. private _speedRatio;
  3841. private _weight;
  3842. private _syncRoot;
  3843. /**
  3844. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  3845. * This will only apply for non looping animation (default is true)
  3846. */
  3847. disposeOnEnd: boolean;
  3848. /**
  3849. * Gets a boolean indicating if the animation has started
  3850. */
  3851. animationStarted: boolean;
  3852. /**
  3853. * Observer raised when the animation ends
  3854. */
  3855. onAnimationEndObservable: Observable<Animatable>;
  3856. /**
  3857. * Observer raised when the animation loops
  3858. */
  3859. onAnimationLoopObservable: Observable<Animatable>;
  3860. /**
  3861. * Gets the root Animatable used to synchronize and normalize animations
  3862. */
  3863. readonly syncRoot: Animatable;
  3864. /**
  3865. * Gets the current frame of the first RuntimeAnimation
  3866. * Used to synchronize Animatables
  3867. */
  3868. readonly masterFrame: number;
  3869. /**
  3870. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  3871. */
  3872. weight: number;
  3873. /**
  3874. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  3875. */
  3876. speedRatio: number;
  3877. /**
  3878. * Creates a new Animatable
  3879. * @param scene defines the hosting scene
  3880. * @param target defines the target object
  3881. * @param fromFrame defines the starting frame number (default is 0)
  3882. * @param toFrame defines the ending frame number (default is 100)
  3883. * @param loopAnimation defines if the animation must loop (default is false)
  3884. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  3885. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  3886. * @param animations defines a group of animation to add to the new Animatable
  3887. * @param onAnimationLoop defines a callback to call when animation loops
  3888. */
  3889. constructor(scene: Scene,
  3890. /** defines the target object */
  3891. target: any,
  3892. /** defines the starting frame number (default is 0) */
  3893. fromFrame?: number,
  3894. /** defines the ending frame number (default is 100) */
  3895. toFrame?: number,
  3896. /** defines if the animation must loop (default is false) */
  3897. loopAnimation?: boolean, speedRatio?: number,
  3898. /** defines a callback to call when animation ends if it is not looping */
  3899. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  3900. /** defines a callback to call when animation loops */
  3901. onAnimationLoop?: (() => void) | null | undefined);
  3902. /**
  3903. * Synchronize and normalize current Animatable with a source Animatable
  3904. * This is useful when using animation weights and when animations are not of the same length
  3905. * @param root defines the root Animatable to synchronize with
  3906. * @returns the current Animatable
  3907. */
  3908. syncWith(root: Animatable): Animatable;
  3909. /**
  3910. * Gets the list of runtime animations
  3911. * @returns an array of RuntimeAnimation
  3912. */
  3913. getAnimations(): RuntimeAnimation[];
  3914. /**
  3915. * Adds more animations to the current animatable
  3916. * @param target defines the target of the animations
  3917. * @param animations defines the new animations to add
  3918. */
  3919. appendAnimations(target: any, animations: Animation[]): void;
  3920. /**
  3921. * Gets the source animation for a specific property
  3922. * @param property defines the propertyu to look for
  3923. * @returns null or the source animation for the given property
  3924. */
  3925. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  3926. /**
  3927. * Gets the runtime animation for a specific property
  3928. * @param property defines the propertyu to look for
  3929. * @returns null or the runtime animation for the given property
  3930. */
  3931. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  3932. /**
  3933. * Resets the animatable to its original state
  3934. */
  3935. reset(): void;
  3936. /**
  3937. * Allows the animatable to blend with current running animations
  3938. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  3939. * @param blendingSpeed defines the blending speed to use
  3940. */
  3941. enableBlending(blendingSpeed: number): void;
  3942. /**
  3943. * Disable animation blending
  3944. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  3945. */
  3946. disableBlending(): void;
  3947. /**
  3948. * Jump directly to a given frame
  3949. * @param frame defines the frame to jump to
  3950. */
  3951. goToFrame(frame: number): void;
  3952. /**
  3953. * Pause the animation
  3954. */
  3955. pause(): void;
  3956. /**
  3957. * Restart the animation
  3958. */
  3959. restart(): void;
  3960. private _raiseOnAnimationEnd;
  3961. /**
  3962. * Stop and delete the current animation
  3963. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  3964. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  3965. */
  3966. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  3967. /**
  3968. * Wait asynchronously for the animation to end
  3969. * @returns a promise which will be fullfilled when the animation ends
  3970. */
  3971. waitAsync(): Promise<Animatable>;
  3972. /** @hidden */
  3973. _animate(delay: number): boolean;
  3974. }
  3975. }
  3976. declare module BABYLON {
  3977. /**
  3978. * Represents the range of an animation
  3979. */
  3980. class AnimationRange {
  3981. /**The name of the animation range**/
  3982. name: string;
  3983. /**The starting frame of the animation */
  3984. from: number;
  3985. /**The ending frame of the animation*/
  3986. to: number;
  3987. /**
  3988. * Initializes the range of an animation
  3989. * @param name The name of the animation range
  3990. * @param from The starting frame of the animation
  3991. * @param to The ending frame of the animation
  3992. */
  3993. constructor(
  3994. /**The name of the animation range**/
  3995. name: string,
  3996. /**The starting frame of the animation */
  3997. from: number,
  3998. /**The ending frame of the animation*/
  3999. to: number);
  4000. /**
  4001. * Makes a copy of the animation range
  4002. * @returns A copy of the animation range
  4003. */
  4004. clone(): AnimationRange;
  4005. }
  4006. /**
  4007. * Composed of a frame, and an action function
  4008. */
  4009. class AnimationEvent {
  4010. /** The frame for which the event is triggered **/
  4011. frame: number;
  4012. /** The event to perform when triggered **/
  4013. action: (currentFrame: number) => void;
  4014. /** Specifies if the event should be triggered only once**/
  4015. onlyOnce?: boolean | undefined;
  4016. /**
  4017. * Specifies if the animation event is done
  4018. */
  4019. isDone: boolean;
  4020. /**
  4021. * Initializes the animation event
  4022. * @param frame The frame for which the event is triggered
  4023. * @param action The event to perform when triggered
  4024. * @param onlyOnce Specifies if the event should be triggered only once
  4025. */
  4026. constructor(
  4027. /** The frame for which the event is triggered **/
  4028. frame: number,
  4029. /** The event to perform when triggered **/
  4030. action: (currentFrame: number) => void,
  4031. /** Specifies if the event should be triggered only once**/
  4032. onlyOnce?: boolean | undefined);
  4033. /** @hidden */
  4034. _clone(): AnimationEvent;
  4035. }
  4036. /**
  4037. * A cursor which tracks a point on a path
  4038. */
  4039. class PathCursor {
  4040. private path;
  4041. /**
  4042. * Stores path cursor callbacks for when an onchange event is triggered
  4043. */
  4044. private _onchange;
  4045. /**
  4046. * The value of the path cursor
  4047. */
  4048. value: number;
  4049. /**
  4050. * The animation array of the path cursor
  4051. */
  4052. animations: Animation[];
  4053. /**
  4054. * Initializes the path cursor
  4055. * @param path The path to track
  4056. */
  4057. constructor(path: Path2);
  4058. /**
  4059. * Gets the cursor point on the path
  4060. * @returns A point on the path cursor at the cursor location
  4061. */
  4062. getPoint(): Vector3;
  4063. /**
  4064. * Moves the cursor ahead by the step amount
  4065. * @param step The amount to move the cursor forward
  4066. * @returns This path cursor
  4067. */
  4068. moveAhead(step?: number): PathCursor;
  4069. /**
  4070. * Moves the cursor behind by the step amount
  4071. * @param step The amount to move the cursor back
  4072. * @returns This path cursor
  4073. */
  4074. moveBack(step?: number): PathCursor;
  4075. /**
  4076. * Moves the cursor by the step amount
  4077. * If the step amount is greater than one, an exception is thrown
  4078. * @param step The amount to move the cursor
  4079. * @returns This path cursor
  4080. */
  4081. move(step: number): PathCursor;
  4082. /**
  4083. * Ensures that the value is limited between zero and one
  4084. * @returns This path cursor
  4085. */
  4086. private ensureLimits;
  4087. /**
  4088. * Runs onchange callbacks on change (used by the animation engine)
  4089. * @returns This path cursor
  4090. */
  4091. private raiseOnChange;
  4092. /**
  4093. * Executes a function on change
  4094. * @param f A path cursor onchange callback
  4095. * @returns This path cursor
  4096. */
  4097. onchange(f: (cursor: PathCursor) => void): PathCursor;
  4098. }
  4099. /**
  4100. * Defines an interface which represents an animation key frame
  4101. */
  4102. interface IAnimationKey {
  4103. /**
  4104. * Frame of the key frame
  4105. */
  4106. frame: number;
  4107. /**
  4108. * Value at the specifies key frame
  4109. */
  4110. value: any;
  4111. /**
  4112. * The input tangent for the cubic hermite spline
  4113. */
  4114. inTangent?: any;
  4115. /**
  4116. * The output tangent for the cubic hermite spline
  4117. */
  4118. outTangent?: any;
  4119. /**
  4120. * The animation interpolation type
  4121. */
  4122. interpolation?: AnimationKeyInterpolation;
  4123. }
  4124. /**
  4125. * Enum for the animation key frame interpolation type
  4126. */
  4127. enum AnimationKeyInterpolation {
  4128. /**
  4129. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  4130. */
  4131. STEP = 1
  4132. }
  4133. /**
  4134. * Class used to store any kind of animation
  4135. */
  4136. class Animation {
  4137. /**Name of the animation */
  4138. name: string;
  4139. /**Property to animate */
  4140. targetProperty: string;
  4141. /**The frames per second of the animation */
  4142. framePerSecond: number;
  4143. /**The data type of the animation */
  4144. dataType: number;
  4145. /**The loop mode of the animation */
  4146. loopMode?: number | undefined;
  4147. /**Specifies if blending should be enabled */
  4148. enableBlending?: boolean | undefined;
  4149. /**
  4150. * Use matrix interpolation instead of using direct key value when animating matrices
  4151. */
  4152. static AllowMatricesInterpolation: boolean;
  4153. /**
  4154. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  4155. */
  4156. static AllowMatrixDecomposeForInterpolation: boolean;
  4157. /**
  4158. * Stores the key frames of the animation
  4159. */
  4160. private _keys;
  4161. /**
  4162. * Stores the easing function of the animation
  4163. */
  4164. private _easingFunction;
  4165. /**
  4166. * @hidden Internal use only
  4167. */
  4168. _runtimeAnimations: RuntimeAnimation[];
  4169. /**
  4170. * The set of event that will be linked to this animation
  4171. */
  4172. private _events;
  4173. /**
  4174. * Stores an array of target property paths
  4175. */
  4176. targetPropertyPath: string[];
  4177. /**
  4178. * Stores the blending speed of the animation
  4179. */
  4180. blendingSpeed: number;
  4181. /**
  4182. * Stores the animation ranges for the animation
  4183. */
  4184. private _ranges;
  4185. /**
  4186. * @hidden Internal use
  4187. */
  4188. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  4189. /**
  4190. * Sets up an animation
  4191. * @param property The property to animate
  4192. * @param animationType The animation type to apply
  4193. * @param framePerSecond The frames per second of the animation
  4194. * @param easingFunction The easing function used in the animation
  4195. * @returns The created animation
  4196. */
  4197. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  4198. /**
  4199. * Create and start an animation on a node
  4200. * @param name defines the name of the global animation that will be run on all nodes
  4201. * @param node defines the root node where the animation will take place
  4202. * @param targetProperty defines property to animate
  4203. * @param framePerSecond defines the number of frame per second yo use
  4204. * @param totalFrame defines the number of frames in total
  4205. * @param from defines the initial value
  4206. * @param to defines the final value
  4207. * @param loopMode defines which loop mode you want to use (off by default)
  4208. * @param easingFunction defines the easing function to use (linear by default)
  4209. * @param onAnimationEnd defines the callback to call when animation end
  4210. * @returns the animatable created for this animation
  4211. */
  4212. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  4213. /**
  4214. * Create and start an animation on a node and its descendants
  4215. * @param name defines the name of the global animation that will be run on all nodes
  4216. * @param node defines the root node where the animation will take place
  4217. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used
  4218. * @param targetProperty defines property to animate
  4219. * @param framePerSecond defines the number of frame per second to use
  4220. * @param totalFrame defines the number of frames in total
  4221. * @param from defines the initial value
  4222. * @param to defines the final value
  4223. * @param loopMode defines which loop mode you want to use (off by default)
  4224. * @param easingFunction defines the easing function to use (linear by default)
  4225. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  4226. * @returns the list of animatables created for all nodes
  4227. * @example https://www.babylonjs-playground.com/#MH0VLI
  4228. */
  4229. static CreateAndStartHierarchyAnimation(name: string, node: Node, directDescendantsOnly: boolean, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable[]>;
  4230. /**
  4231. * Creates a new animation, merges it with the existing animations and starts it
  4232. * @param name Name of the animation
  4233. * @param node Node which contains the scene that begins the animations
  4234. * @param targetProperty Specifies which property to animate
  4235. * @param framePerSecond The frames per second of the animation
  4236. * @param totalFrame The total number of frames
  4237. * @param from The frame at the beginning of the animation
  4238. * @param to The frame at the end of the animation
  4239. * @param loopMode Specifies the loop mode of the animation
  4240. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  4241. * @param onAnimationEnd Callback to run once the animation is complete
  4242. * @returns Nullable animation
  4243. */
  4244. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  4245. /**
  4246. * Transition property of an host to the target Value
  4247. * @param property The property to transition
  4248. * @param targetValue The target Value of the property
  4249. * @param host The object where the property to animate belongs
  4250. * @param scene Scene used to run the animation
  4251. * @param frameRate Framerate (in frame/s) to use
  4252. * @param transition The transition type we want to use
  4253. * @param duration The duration of the animation, in milliseconds
  4254. * @param onAnimationEnd Callback trigger at the end of the animation
  4255. * @returns Nullable animation
  4256. */
  4257. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  4258. /**
  4259. * Return the array of runtime animations currently using this animation
  4260. */
  4261. readonly runtimeAnimations: RuntimeAnimation[];
  4262. /**
  4263. * Specifies if any of the runtime animations are currently running
  4264. */
  4265. readonly hasRunningRuntimeAnimations: boolean;
  4266. /**
  4267. * Initializes the animation
  4268. * @param name Name of the animation
  4269. * @param targetProperty Property to animate
  4270. * @param framePerSecond The frames per second of the animation
  4271. * @param dataType The data type of the animation
  4272. * @param loopMode The loop mode of the animation
  4273. * @param enableBlendings Specifies if blending should be enabled
  4274. */
  4275. constructor(
  4276. /**Name of the animation */
  4277. name: string,
  4278. /**Property to animate */
  4279. targetProperty: string,
  4280. /**The frames per second of the animation */
  4281. framePerSecond: number,
  4282. /**The data type of the animation */
  4283. dataType: number,
  4284. /**The loop mode of the animation */
  4285. loopMode?: number | undefined,
  4286. /**Specifies if blending should be enabled */
  4287. enableBlending?: boolean | undefined);
  4288. /**
  4289. * Converts the animation to a string
  4290. * @param fullDetails support for multiple levels of logging within scene loading
  4291. * @returns String form of the animation
  4292. */
  4293. toString(fullDetails?: boolean): string;
  4294. /**
  4295. * Add an event to this animation
  4296. * @param event Event to add
  4297. */
  4298. addEvent(event: AnimationEvent): void;
  4299. /**
  4300. * Remove all events found at the given frame
  4301. * @param frame The frame to remove events from
  4302. */
  4303. removeEvents(frame: number): void;
  4304. /**
  4305. * Retrieves all the events from the animation
  4306. * @returns Events from the animation
  4307. */
  4308. getEvents(): AnimationEvent[];
  4309. /**
  4310. * Creates an animation range
  4311. * @param name Name of the animation range
  4312. * @param from Starting frame of the animation range
  4313. * @param to Ending frame of the animation
  4314. */
  4315. createRange(name: string, from: number, to: number): void;
  4316. /**
  4317. * Deletes an animation range by name
  4318. * @param name Name of the animation range to delete
  4319. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  4320. */
  4321. deleteRange(name: string, deleteFrames?: boolean): void;
  4322. /**
  4323. * Gets the animation range by name, or null if not defined
  4324. * @param name Name of the animation range
  4325. * @returns Nullable animation range
  4326. */
  4327. getRange(name: string): Nullable<AnimationRange>;
  4328. /**
  4329. * Gets the key frames from the animation
  4330. * @returns The key frames of the animation
  4331. */
  4332. getKeys(): Array<IAnimationKey>;
  4333. /**
  4334. * Gets the highest frame rate of the animation
  4335. * @returns Highest frame rate of the animation
  4336. */
  4337. getHighestFrame(): number;
  4338. /**
  4339. * Gets the easing function of the animation
  4340. * @returns Easing function of the animation
  4341. */
  4342. getEasingFunction(): IEasingFunction;
  4343. /**
  4344. * Sets the easing function of the animation
  4345. * @param easingFunction A custom mathematical formula for animation
  4346. */
  4347. setEasingFunction(easingFunction: EasingFunction): void;
  4348. /**
  4349. * Interpolates a scalar linearly
  4350. * @param startValue Start value of the animation curve
  4351. * @param endValue End value of the animation curve
  4352. * @param gradient Scalar amount to interpolate
  4353. * @returns Interpolated scalar value
  4354. */
  4355. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  4356. /**
  4357. * Interpolates a scalar cubically
  4358. * @param startValue Start value of the animation curve
  4359. * @param outTangent End tangent of the animation
  4360. * @param endValue End value of the animation curve
  4361. * @param inTangent Start tangent of the animation curve
  4362. * @param gradient Scalar amount to interpolate
  4363. * @returns Interpolated scalar value
  4364. */
  4365. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  4366. /**
  4367. * Interpolates a quaternion using a spherical linear interpolation
  4368. * @param startValue Start value of the animation curve
  4369. * @param endValue End value of the animation curve
  4370. * @param gradient Scalar amount to interpolate
  4371. * @returns Interpolated quaternion value
  4372. */
  4373. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  4374. /**
  4375. * Interpolates a quaternion cubically
  4376. * @param startValue Start value of the animation curve
  4377. * @param outTangent End tangent of the animation curve
  4378. * @param endValue End value of the animation curve
  4379. * @param inTangent Start tangent of the animation curve
  4380. * @param gradient Scalar amount to interpolate
  4381. * @returns Interpolated quaternion value
  4382. */
  4383. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  4384. /**
  4385. * Interpolates a Vector3 linearl
  4386. * @param startValue Start value of the animation curve
  4387. * @param endValue End value of the animation curve
  4388. * @param gradient Scalar amount to interpolate
  4389. * @returns Interpolated scalar value
  4390. */
  4391. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  4392. /**
  4393. * Interpolates a Vector3 cubically
  4394. * @param startValue Start value of the animation curve
  4395. * @param outTangent End tangent of the animation
  4396. * @param endValue End value of the animation curve
  4397. * @param inTangent Start tangent of the animation curve
  4398. * @param gradient Scalar amount to interpolate
  4399. * @returns InterpolatedVector3 value
  4400. */
  4401. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  4402. /**
  4403. * Interpolates a Vector2 linearly
  4404. * @param startValue Start value of the animation curve
  4405. * @param endValue End value of the animation curve
  4406. * @param gradient Scalar amount to interpolate
  4407. * @returns Interpolated Vector2 value
  4408. */
  4409. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  4410. /**
  4411. * Interpolates a Vector2 cubically
  4412. * @param startValue Start value of the animation curve
  4413. * @param outTangent End tangent of the animation
  4414. * @param endValue End value of the animation curve
  4415. * @param inTangent Start tangent of the animation curve
  4416. * @param gradient Scalar amount to interpolate
  4417. * @returns Interpolated Vector2 value
  4418. */
  4419. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  4420. /**
  4421. * Interpolates a size linearly
  4422. * @param startValue Start value of the animation curve
  4423. * @param endValue End value of the animation curve
  4424. * @param gradient Scalar amount to interpolate
  4425. * @returns Interpolated Size value
  4426. */
  4427. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  4428. /**
  4429. * Interpolates a Color3 linearly
  4430. * @param startValue Start value of the animation curve
  4431. * @param endValue End value of the animation curve
  4432. * @param gradient Scalar amount to interpolate
  4433. * @returns Interpolated Color3 value
  4434. */
  4435. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  4436. /**
  4437. * @hidden Internal use only
  4438. */
  4439. _getKeyValue(value: any): any;
  4440. /**
  4441. * @hidden Internal use only
  4442. */
  4443. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  4444. /**
  4445. * Defines the function to use to interpolate matrices
  4446. * @param startValue defines the start matrix
  4447. * @param endValue defines the end matrix
  4448. * @param gradient defines the gradient between both matrices
  4449. * @param result defines an optional target matrix where to store the interpolation
  4450. * @returns the interpolated matrix
  4451. */
  4452. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  4453. /**
  4454. * Makes a copy of the animation
  4455. * @returns Cloned animation
  4456. */
  4457. clone(): Animation;
  4458. /**
  4459. * Sets the key frames of the animation
  4460. * @param values The animation key frames to set
  4461. */
  4462. setKeys(values: Array<IAnimationKey>): void;
  4463. /**
  4464. * Serializes the animation to an object
  4465. * @returns Serialized object
  4466. */
  4467. serialize(): any;
  4468. /**
  4469. * Float animation type
  4470. */
  4471. private static _ANIMATIONTYPE_FLOAT;
  4472. /**
  4473. * Vector3 animation type
  4474. */
  4475. private static _ANIMATIONTYPE_VECTOR3;
  4476. /**
  4477. * Quaternion animation type
  4478. */
  4479. private static _ANIMATIONTYPE_QUATERNION;
  4480. /**
  4481. * Matrix animation type
  4482. */
  4483. private static _ANIMATIONTYPE_MATRIX;
  4484. /**
  4485. * Color3 animation type
  4486. */
  4487. private static _ANIMATIONTYPE_COLOR3;
  4488. /**
  4489. * Vector2 animation type
  4490. */
  4491. private static _ANIMATIONTYPE_VECTOR2;
  4492. /**
  4493. * Size animation type
  4494. */
  4495. private static _ANIMATIONTYPE_SIZE;
  4496. /**
  4497. * Relative Loop Mode
  4498. */
  4499. private static _ANIMATIONLOOPMODE_RELATIVE;
  4500. /**
  4501. * Cycle Loop Mode
  4502. */
  4503. private static _ANIMATIONLOOPMODE_CYCLE;
  4504. /**
  4505. * Constant Loop Mode
  4506. */
  4507. private static _ANIMATIONLOOPMODE_CONSTANT;
  4508. /**
  4509. * Get the float animation type
  4510. */
  4511. static readonly ANIMATIONTYPE_FLOAT: number;
  4512. /**
  4513. * Get the Vector3 animation type
  4514. */
  4515. static readonly ANIMATIONTYPE_VECTOR3: number;
  4516. /**
  4517. * Get the Vector2 animation type
  4518. */
  4519. static readonly ANIMATIONTYPE_VECTOR2: number;
  4520. /**
  4521. * Get the Size animation type
  4522. */
  4523. static readonly ANIMATIONTYPE_SIZE: number;
  4524. /**
  4525. * Get the Quaternion animation type
  4526. */
  4527. static readonly ANIMATIONTYPE_QUATERNION: number;
  4528. /**
  4529. * Get the Matrix animation type
  4530. */
  4531. static readonly ANIMATIONTYPE_MATRIX: number;
  4532. /**
  4533. * Get the Color3 animation type
  4534. */
  4535. static readonly ANIMATIONTYPE_COLOR3: number;
  4536. /**
  4537. * Get the Relative Loop Mode
  4538. */
  4539. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  4540. /**
  4541. * Get the Cycle Loop Mode
  4542. */
  4543. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  4544. /**
  4545. * Get the Constant Loop Mode
  4546. */
  4547. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  4548. /** @hidden */
  4549. static _UniversalLerp(left: any, right: any, amount: number): any;
  4550. /**
  4551. * Parses an animation object and creates an animation
  4552. * @param parsedAnimation Parsed animation object
  4553. * @returns Animation object
  4554. */
  4555. static Parse(parsedAnimation: any): Animation;
  4556. /**
  4557. * Appends the serialized animations from the source animations
  4558. * @param source Source containing the animations
  4559. * @param destination Target to store the animations
  4560. */
  4561. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  4562. }
  4563. }
  4564. declare module BABYLON {
  4565. /**
  4566. * This class defines the direct association between an animation and a target
  4567. */
  4568. class TargetedAnimation {
  4569. /**
  4570. * Animation to perform
  4571. */
  4572. animation: Animation;
  4573. /**
  4574. * Target to animate
  4575. */
  4576. target: any;
  4577. }
  4578. /**
  4579. * Use this class to create coordinated animations on multiple targets
  4580. */
  4581. class AnimationGroup implements IDisposable {
  4582. /** The name of the animation group */
  4583. name: string;
  4584. private _scene;
  4585. private _targetedAnimations;
  4586. private _animatables;
  4587. private _from;
  4588. private _to;
  4589. private _isStarted;
  4590. private _isPaused;
  4591. private _speedRatio;
  4592. /**
  4593. * Gets or sets the unique id of the node
  4594. */
  4595. uniqueId: number;
  4596. /**
  4597. * This observable will notify when one animation have ended
  4598. */
  4599. onAnimationEndObservable: Observable<TargetedAnimation>;
  4600. /**
  4601. * Observer raised when one animation loops
  4602. */
  4603. onAnimationLoopObservable: Observable<TargetedAnimation>;
  4604. /**
  4605. * This observable will notify when all animations have ended.
  4606. */
  4607. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  4608. /**
  4609. * This observable will notify when all animations have paused.
  4610. */
  4611. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  4612. /**
  4613. * This observable will notify when all animations are playing.
  4614. */
  4615. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  4616. /**
  4617. * Gets the first frame
  4618. */
  4619. readonly from: number;
  4620. /**
  4621. * Gets the last frame
  4622. */
  4623. readonly to: number;
  4624. /**
  4625. * Define if the animations are started
  4626. */
  4627. readonly isStarted: boolean;
  4628. /**
  4629. * Gets a value indicating that the current group is playing
  4630. */
  4631. readonly isPlaying: boolean;
  4632. /**
  4633. * Gets or sets the speed ratio to use for all animations
  4634. */
  4635. /**
  4636. * Gets or sets the speed ratio to use for all animations
  4637. */
  4638. speedRatio: number;
  4639. /**
  4640. * Gets the targeted animations for this animation group
  4641. */
  4642. readonly targetedAnimations: Array<TargetedAnimation>;
  4643. /**
  4644. * returning the list of animatables controlled by this animation group.
  4645. */
  4646. readonly animatables: Array<Animatable>;
  4647. /**
  4648. * Instantiates a new Animation Group.
  4649. * This helps managing several animations at once.
  4650. * @see http://doc.babylonjs.com/how_to/group
  4651. * @param name Defines the name of the group
  4652. * @param scene Defines the scene the group belongs to
  4653. */
  4654. constructor(
  4655. /** The name of the animation group */
  4656. name: string, scene?: Nullable<Scene>);
  4657. /**
  4658. * Add an animation (with its target) in the group
  4659. * @param animation defines the animation we want to add
  4660. * @param target defines the target of the animation
  4661. * @returns the TargetedAnimation object
  4662. */
  4663. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  4664. /**
  4665. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  4666. * It can add constant keys at begin or end
  4667. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  4668. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  4669. * @returns the animation group
  4670. */
  4671. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  4672. /**
  4673. * Start all animations on given targets
  4674. * @param loop defines if animations must loop
  4675. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  4676. * @param from defines the from key (optional)
  4677. * @param to defines the to key (optional)
  4678. * @returns the current animation group
  4679. */
  4680. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  4681. /**
  4682. * Pause all animations
  4683. * @returns the animation group
  4684. */
  4685. pause(): AnimationGroup;
  4686. /**
  4687. * Play all animations to initial state
  4688. * This function will start() the animations if they were not started or will restart() them if they were paused
  4689. * @param loop defines if animations must loop
  4690. * @returns the animation group
  4691. */
  4692. play(loop?: boolean): AnimationGroup;
  4693. /**
  4694. * Reset all animations to initial state
  4695. * @returns the animation group
  4696. */
  4697. reset(): AnimationGroup;
  4698. /**
  4699. * Restart animations from key 0
  4700. * @returns the animation group
  4701. */
  4702. restart(): AnimationGroup;
  4703. /**
  4704. * Stop all animations
  4705. * @returns the animation group
  4706. */
  4707. stop(): AnimationGroup;
  4708. /**
  4709. * Set animation weight for all animatables
  4710. * @param weight defines the weight to use
  4711. * @return the animationGroup
  4712. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4713. */
  4714. setWeightForAllAnimatables(weight: number): AnimationGroup;
  4715. /**
  4716. * Synchronize and normalize all animatables with a source animatable
  4717. * @param root defines the root animatable to synchronize with
  4718. * @return the animationGroup
  4719. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4720. */
  4721. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  4722. /**
  4723. * Goes to a specific frame in this animation group
  4724. * @param frame the frame number to go to
  4725. * @return the animationGroup
  4726. */
  4727. goToFrame(frame: number): AnimationGroup;
  4728. /**
  4729. * Dispose all associated resources
  4730. */
  4731. dispose(): void;
  4732. private _checkAnimationGroupEnded;
  4733. /**
  4734. * Returns a new AnimationGroup object parsed from the source provided.
  4735. * @param parsedAnimationGroup defines the source
  4736. * @param scene defines the scene that will receive the animationGroup
  4737. * @returns a new AnimationGroup
  4738. */
  4739. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  4740. /**
  4741. * Returns the string "AnimationGroup"
  4742. * @returns "AnimationGroup"
  4743. */
  4744. getClassName(): string;
  4745. /**
  4746. * Creates a detailled string about the object
  4747. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  4748. * @returns a string representing the object
  4749. */
  4750. toString(fullDetails?: boolean): string;
  4751. }
  4752. }
  4753. declare module BABYLON {
  4754. /**
  4755. * Class used to override all child animations of a given target
  4756. */
  4757. class AnimationPropertiesOverride {
  4758. /**
  4759. * Gets or sets a value indicating if animation blending must be used
  4760. */
  4761. enableBlending: boolean;
  4762. /**
  4763. * Gets or sets the blending speed to use when enableBlending is true
  4764. */
  4765. blendingSpeed: number;
  4766. /**
  4767. * Gets or sets the default loop mode to use
  4768. */
  4769. loopMode: number;
  4770. }
  4771. }
  4772. declare module BABYLON {
  4773. /**
  4774. * This represents the main contract an easing function should follow.
  4775. * Easing functions are used throughout the animation system.
  4776. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4777. */
  4778. interface IEasingFunction {
  4779. /**
  4780. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4781. * of the easing function.
  4782. * The link below provides some of the most common examples of easing functions.
  4783. * @see https://easings.net/
  4784. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4785. * @returns the corresponding value on the curve defined by the easing function
  4786. */
  4787. ease(gradient: number): number;
  4788. }
  4789. /**
  4790. * Base class used for every default easing function.
  4791. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4792. */
  4793. class EasingFunction implements IEasingFunction {
  4794. /**
  4795. * Interpolation follows the mathematical formula associated with the easing function.
  4796. */
  4797. static readonly EASINGMODE_EASEIN: number;
  4798. /**
  4799. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  4800. */
  4801. static readonly EASINGMODE_EASEOUT: number;
  4802. /**
  4803. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  4804. */
  4805. static readonly EASINGMODE_EASEINOUT: number;
  4806. private _easingMode;
  4807. /**
  4808. * Sets the easing mode of the current function.
  4809. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  4810. */
  4811. setEasingMode(easingMode: number): void;
  4812. /**
  4813. * Gets the current easing mode.
  4814. * @returns the easing mode
  4815. */
  4816. getEasingMode(): number;
  4817. /**
  4818. * @hidden
  4819. */
  4820. easeInCore(gradient: number): number;
  4821. /**
  4822. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4823. * of the easing function.
  4824. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4825. * @returns the corresponding value on the curve defined by the easing function
  4826. */
  4827. ease(gradient: number): number;
  4828. }
  4829. /**
  4830. * Easing function with a circle shape (see link below).
  4831. * @see https://easings.net/#easeInCirc
  4832. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4833. */
  4834. class CircleEase extends EasingFunction implements IEasingFunction {
  4835. /** @hidden */
  4836. easeInCore(gradient: number): number;
  4837. }
  4838. /**
  4839. * Easing function with a ease back shape (see link below).
  4840. * @see https://easings.net/#easeInBack
  4841. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4842. */
  4843. class BackEase extends EasingFunction implements IEasingFunction {
  4844. /** Defines the amplitude of the function */
  4845. amplitude: number;
  4846. /**
  4847. * Instantiates a back ease easing
  4848. * @see https://easings.net/#easeInBack
  4849. * @param amplitude Defines the amplitude of the function
  4850. */
  4851. constructor(
  4852. /** Defines the amplitude of the function */
  4853. amplitude?: number);
  4854. /** @hidden */
  4855. easeInCore(gradient: number): number;
  4856. }
  4857. /**
  4858. * Easing function with a bouncing shape (see link below).
  4859. * @see https://easings.net/#easeInBounce
  4860. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4861. */
  4862. class BounceEase extends EasingFunction implements IEasingFunction {
  4863. /** Defines the number of bounces */
  4864. bounces: number;
  4865. /** Defines the amplitude of the bounce */
  4866. bounciness: number;
  4867. /**
  4868. * Instantiates a bounce easing
  4869. * @see https://easings.net/#easeInBounce
  4870. * @param bounces Defines the number of bounces
  4871. * @param bounciness Defines the amplitude of the bounce
  4872. */
  4873. constructor(
  4874. /** Defines the number of bounces */
  4875. bounces?: number,
  4876. /** Defines the amplitude of the bounce */
  4877. bounciness?: number);
  4878. /** @hidden */
  4879. easeInCore(gradient: number): number;
  4880. }
  4881. /**
  4882. * Easing function with a power of 3 shape (see link below).
  4883. * @see https://easings.net/#easeInCubic
  4884. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4885. */
  4886. class CubicEase extends EasingFunction implements IEasingFunction {
  4887. /** @hidden */
  4888. easeInCore(gradient: number): number;
  4889. }
  4890. /**
  4891. * Easing function with an elastic shape (see link below).
  4892. * @see https://easings.net/#easeInElastic
  4893. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4894. */
  4895. class ElasticEase extends EasingFunction implements IEasingFunction {
  4896. /** Defines the number of oscillations*/
  4897. oscillations: number;
  4898. /** Defines the amplitude of the oscillations*/
  4899. springiness: number;
  4900. /**
  4901. * Instantiates an elastic easing function
  4902. * @see https://easings.net/#easeInElastic
  4903. * @param oscillations Defines the number of oscillations
  4904. * @param springiness Defines the amplitude of the oscillations
  4905. */
  4906. constructor(
  4907. /** Defines the number of oscillations*/
  4908. oscillations?: number,
  4909. /** Defines the amplitude of the oscillations*/
  4910. springiness?: number);
  4911. /** @hidden */
  4912. easeInCore(gradient: number): number;
  4913. }
  4914. /**
  4915. * Easing function with an exponential shape (see link below).
  4916. * @see https://easings.net/#easeInExpo
  4917. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4918. */
  4919. class ExponentialEase extends EasingFunction implements IEasingFunction {
  4920. /** Defines the exponent of the function */
  4921. exponent: number;
  4922. /**
  4923. * Instantiates an exponential easing function
  4924. * @see https://easings.net/#easeInExpo
  4925. * @param exponent Defines the exponent of the function
  4926. */
  4927. constructor(
  4928. /** Defines the exponent of the function */
  4929. exponent?: number);
  4930. /** @hidden */
  4931. easeInCore(gradient: number): number;
  4932. }
  4933. /**
  4934. * Easing function with a power shape (see link below).
  4935. * @see https://easings.net/#easeInQuad
  4936. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4937. */
  4938. class PowerEase extends EasingFunction implements IEasingFunction {
  4939. /** Defines the power of the function */
  4940. power: number;
  4941. /**
  4942. * Instantiates an power base easing function
  4943. * @see https://easings.net/#easeInQuad
  4944. * @param power Defines the power of the function
  4945. */
  4946. constructor(
  4947. /** Defines the power of the function */
  4948. power?: number);
  4949. /** @hidden */
  4950. easeInCore(gradient: number): number;
  4951. }
  4952. /**
  4953. * Easing function with a power of 2 shape (see link below).
  4954. * @see https://easings.net/#easeInQuad
  4955. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4956. */
  4957. class QuadraticEase extends EasingFunction implements IEasingFunction {
  4958. /** @hidden */
  4959. easeInCore(gradient: number): number;
  4960. }
  4961. /**
  4962. * Easing function with a power of 4 shape (see link below).
  4963. * @see https://easings.net/#easeInQuart
  4964. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4965. */
  4966. class QuarticEase extends EasingFunction implements IEasingFunction {
  4967. /** @hidden */
  4968. easeInCore(gradient: number): number;
  4969. }
  4970. /**
  4971. * Easing function with a power of 5 shape (see link below).
  4972. * @see https://easings.net/#easeInQuint
  4973. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4974. */
  4975. class QuinticEase extends EasingFunction implements IEasingFunction {
  4976. /** @hidden */
  4977. easeInCore(gradient: number): number;
  4978. }
  4979. /**
  4980. * Easing function with a sin shape (see link below).
  4981. * @see https://easings.net/#easeInSine
  4982. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4983. */
  4984. class SineEase extends EasingFunction implements IEasingFunction {
  4985. /** @hidden */
  4986. easeInCore(gradient: number): number;
  4987. }
  4988. /**
  4989. * Easing function with a bezier shape (see link below).
  4990. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  4991. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4992. */
  4993. class BezierCurveEase extends EasingFunction implements IEasingFunction {
  4994. /** Defines the x component of the start tangent in the bezier curve */
  4995. x1: number;
  4996. /** Defines the y component of the start tangent in the bezier curve */
  4997. y1: number;
  4998. /** Defines the x component of the end tangent in the bezier curve */
  4999. x2: number;
  5000. /** Defines the y component of the end tangent in the bezier curve */
  5001. y2: number;
  5002. /**
  5003. * Instantiates a bezier function
  5004. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5005. * @param x1 Defines the x component of the start tangent in the bezier curve
  5006. * @param y1 Defines the y component of the start tangent in the bezier curve
  5007. * @param x2 Defines the x component of the end tangent in the bezier curve
  5008. * @param y2 Defines the y component of the end tangent in the bezier curve
  5009. */
  5010. constructor(
  5011. /** Defines the x component of the start tangent in the bezier curve */
  5012. x1?: number,
  5013. /** Defines the y component of the start tangent in the bezier curve */
  5014. y1?: number,
  5015. /** Defines the x component of the end tangent in the bezier curve */
  5016. x2?: number,
  5017. /** Defines the y component of the end tangent in the bezier curve */
  5018. y2?: number);
  5019. /** @hidden */
  5020. easeInCore(gradient: number): number;
  5021. }
  5022. }
  5023. declare module BABYLON {
  5024. /**
  5025. * Defines a runtime animation
  5026. */
  5027. class RuntimeAnimation {
  5028. private _events;
  5029. /**
  5030. * The current frame of the runtime animation
  5031. */
  5032. private _currentFrame;
  5033. /**
  5034. * The animation used by the runtime animation
  5035. */
  5036. private _animation;
  5037. /**
  5038. * The target of the runtime animation
  5039. */
  5040. private _target;
  5041. /**
  5042. * The initiating animatable
  5043. */
  5044. private _host;
  5045. /**
  5046. * The original value of the runtime animation
  5047. */
  5048. private _originalValue;
  5049. /**
  5050. * The original blend value of the runtime animation
  5051. */
  5052. private _originalBlendValue;
  5053. /**
  5054. * The offsets cache of the runtime animation
  5055. */
  5056. private _offsetsCache;
  5057. /**
  5058. * The high limits cache of the runtime animation
  5059. */
  5060. private _highLimitsCache;
  5061. /**
  5062. * Specifies if the runtime animation has been stopped
  5063. */
  5064. private _stopped;
  5065. /**
  5066. * The blending factor of the runtime animation
  5067. */
  5068. private _blendingFactor;
  5069. /**
  5070. * The BabylonJS scene
  5071. */
  5072. private _scene;
  5073. /**
  5074. * The current value of the runtime animation
  5075. */
  5076. private _currentValue;
  5077. /** @hidden */
  5078. _workValue: any;
  5079. /**
  5080. * The active target of the runtime animation
  5081. */
  5082. private _activeTarget;
  5083. /**
  5084. * The target path of the runtime animation
  5085. */
  5086. private _targetPath;
  5087. /**
  5088. * The weight of the runtime animation
  5089. */
  5090. private _weight;
  5091. /**
  5092. * The ratio offset of the runtime animation
  5093. */
  5094. private _ratioOffset;
  5095. /**
  5096. * The previous delay of the runtime animation
  5097. */
  5098. private _previousDelay;
  5099. /**
  5100. * The previous ratio of the runtime animation
  5101. */
  5102. private _previousRatio;
  5103. /**
  5104. * Gets the current frame of the runtime animation
  5105. */
  5106. readonly currentFrame: number;
  5107. /**
  5108. * Gets the weight of the runtime animation
  5109. */
  5110. readonly weight: number;
  5111. /**
  5112. * Gets the current value of the runtime animation
  5113. */
  5114. readonly currentValue: any;
  5115. /**
  5116. * Gets the target path of the runtime animation
  5117. */
  5118. readonly targetPath: string;
  5119. /**
  5120. * Gets the actual target of the runtime animation
  5121. */
  5122. readonly target: any;
  5123. /**
  5124. * Create a new RuntimeAnimation object
  5125. * @param target defines the target of the animation
  5126. * @param animation defines the source animation object
  5127. * @param scene defines the hosting scene
  5128. * @param host defines the initiating Animatable
  5129. */
  5130. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  5131. /**
  5132. * Gets the animation from the runtime animation
  5133. */
  5134. readonly animation: Animation;
  5135. /**
  5136. * Resets the runtime animation to the beginning
  5137. * @param restoreOriginal defines whether to restore the target property to the original value
  5138. */
  5139. reset(restoreOriginal?: boolean): void;
  5140. /**
  5141. * Specifies if the runtime animation is stopped
  5142. * @returns Boolean specifying if the runtime animation is stopped
  5143. */
  5144. isStopped(): boolean;
  5145. /**
  5146. * Disposes of the runtime animation
  5147. */
  5148. dispose(): void;
  5149. /**
  5150. * Interpolates the animation from the current frame
  5151. * @param currentFrame The frame to interpolate the animation to
  5152. * @param repeatCount The number of times that the animation should loop
  5153. * @param loopMode The type of looping mode to use
  5154. * @param offsetValue Animation offset value
  5155. * @param highLimitValue The high limit value
  5156. * @returns The interpolated value
  5157. */
  5158. private _interpolate;
  5159. /**
  5160. * Apply the interpolated value to the target
  5161. * @param currentValue defines the value computed by the animation
  5162. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  5163. */
  5164. setValue(currentValue: any, weight?: number): void;
  5165. private _setValue;
  5166. /**
  5167. * Gets the loop pmode of the runtime animation
  5168. * @returns Loop Mode
  5169. */
  5170. private _getCorrectLoopMode;
  5171. /**
  5172. * Move the current animation to a given frame
  5173. * @param frame defines the frame to move to
  5174. */
  5175. goToFrame(frame: number): void;
  5176. /**
  5177. * @hidden Internal use only
  5178. */
  5179. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  5180. /**
  5181. * Execute the current animation
  5182. * @param delay defines the delay to add to the current frame
  5183. * @param from defines the lower bound of the animation range
  5184. * @param to defines the upper bound of the animation range
  5185. * @param loop defines if the current animation must loop
  5186. * @param speedRatio defines the current speed ratio
  5187. * @param weight defines the weight of the animation (default is -1 so no weight)
  5188. * @param onLoop optional callback called when animation loops
  5189. * @returns a boolean indicating if the animation is running
  5190. */
  5191. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  5192. }
  5193. }
  5194. declare module BABYLON {
  5195. /**
  5196. * Class used to work with sound analyzer using fast fourier transform (FFT)
  5197. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5198. */
  5199. class Analyser {
  5200. /**
  5201. * Gets or sets the smoothing
  5202. * @ignorenaming
  5203. */
  5204. SMOOTHING: number;
  5205. /**
  5206. * Gets or sets the FFT table size
  5207. * @ignorenaming
  5208. */
  5209. FFT_SIZE: number;
  5210. /**
  5211. * Gets or sets the bar graph amplitude
  5212. * @ignorenaming
  5213. */
  5214. BARGRAPHAMPLITUDE: number;
  5215. /**
  5216. * Gets or sets the position of the debug canvas
  5217. * @ignorenaming
  5218. */
  5219. DEBUGCANVASPOS: {
  5220. x: number;
  5221. y: number;
  5222. };
  5223. /**
  5224. * Gets or sets the debug canvas size
  5225. * @ignorenaming
  5226. */
  5227. DEBUGCANVASSIZE: {
  5228. width: number;
  5229. height: number;
  5230. };
  5231. private _byteFreqs;
  5232. private _byteTime;
  5233. private _floatFreqs;
  5234. private _webAudioAnalyser;
  5235. private _debugCanvas;
  5236. private _debugCanvasContext;
  5237. private _scene;
  5238. private _registerFunc;
  5239. private _audioEngine;
  5240. /**
  5241. * Creates a new analyser
  5242. * @param scene defines hosting scene
  5243. */
  5244. constructor(scene: Scene);
  5245. /**
  5246. * Get the number of data values you will have to play with for the visualization
  5247. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  5248. * @returns a number
  5249. */
  5250. getFrequencyBinCount(): number;
  5251. /**
  5252. * Gets the current frequency data as a byte array
  5253. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  5254. * @returns a Uint8Array
  5255. */
  5256. getByteFrequencyData(): Uint8Array;
  5257. /**
  5258. * Gets the current waveform as a byte array
  5259. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  5260. * @returns a Uint8Array
  5261. */
  5262. getByteTimeDomainData(): Uint8Array;
  5263. /**
  5264. * Gets the current frequency data as a float array
  5265. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  5266. * @returns a Float32Array
  5267. */
  5268. getFloatFrequencyData(): Float32Array;
  5269. /**
  5270. * Renders the debug canvas
  5271. */
  5272. drawDebugCanvas(): void;
  5273. /**
  5274. * Stops rendering the debug canvas and removes it
  5275. */
  5276. stopDebugCanvas(): void;
  5277. /**
  5278. * Connects two audio nodes
  5279. * @param inputAudioNode defines first node to connect
  5280. * @param outputAudioNode defines second node to connect
  5281. */
  5282. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  5283. /**
  5284. * Releases all associated resources
  5285. */
  5286. dispose(): void;
  5287. }
  5288. }
  5289. declare module BABYLON {
  5290. /**
  5291. * This represents an audio engine and it is responsible
  5292. * to play, synchronize and analyse sounds throughout the application.
  5293. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5294. */
  5295. interface IAudioEngine extends IDisposable {
  5296. /**
  5297. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  5298. */
  5299. readonly canUseWebAudio: boolean;
  5300. /**
  5301. * Gets the current AudioContext if available.
  5302. */
  5303. readonly audioContext: Nullable<AudioContext>;
  5304. /**
  5305. * The master gain node defines the global audio volume of your audio engine.
  5306. */
  5307. readonly masterGain: GainNode;
  5308. /**
  5309. * Gets whether or not mp3 are supported by your browser.
  5310. */
  5311. readonly isMP3supported: boolean;
  5312. /**
  5313. * Gets whether or not ogg are supported by your browser.
  5314. */
  5315. readonly isOGGsupported: boolean;
  5316. /**
  5317. * Defines if Babylon should emit a warning if WebAudio is not supported.
  5318. * @ignoreNaming
  5319. */
  5320. WarnedWebAudioUnsupported: boolean;
  5321. /**
  5322. * Defines if the audio engine relies on a custom unlocked button.
  5323. * In this case, the embedded button will not be displayed.
  5324. */
  5325. useCustomUnlockedButton: boolean;
  5326. /**
  5327. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  5328. */
  5329. readonly unlocked: boolean;
  5330. /**
  5331. * Event raised when audio has been unlocked on the browser.
  5332. */
  5333. onAudioUnlockedObservable: Observable<AudioEngine>;
  5334. /**
  5335. * Event raised when audio has been locked on the browser.
  5336. */
  5337. onAudioLockedObservable: Observable<AudioEngine>;
  5338. /**
  5339. * Flags the audio engine in Locked state.
  5340. * This happens due to new browser policies preventing audio to autoplay.
  5341. */
  5342. lock(): void;
  5343. /**
  5344. * Unlocks the audio engine once a user action has been done on the dom.
  5345. * This is helpful to resume play once browser policies have been satisfied.
  5346. */
  5347. unlock(): void;
  5348. }
  5349. /**
  5350. * This represents the default audio engine used in babylon.
  5351. * It is responsible to play, synchronize and analyse sounds throughout the application.
  5352. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5353. */
  5354. class AudioEngine implements IAudioEngine {
  5355. private _audioContext;
  5356. private _audioContextInitialized;
  5357. private _muteButton;
  5358. private _hostElement;
  5359. /**
  5360. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  5361. */
  5362. canUseWebAudio: boolean;
  5363. /**
  5364. * The master gain node defines the global audio volume of your audio engine.
  5365. */
  5366. masterGain: GainNode;
  5367. /**
  5368. * Defines if Babylon should emit a warning if WebAudio is not supported.
  5369. * @ignoreNaming
  5370. */
  5371. WarnedWebAudioUnsupported: boolean;
  5372. /**
  5373. * Gets whether or not mp3 are supported by your browser.
  5374. */
  5375. isMP3supported: boolean;
  5376. /**
  5377. * Gets whether or not ogg are supported by your browser.
  5378. */
  5379. isOGGsupported: boolean;
  5380. /**
  5381. * Gets whether audio has been unlocked on the device.
  5382. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  5383. * a user interaction has happened.
  5384. */
  5385. unlocked: boolean;
  5386. /**
  5387. * Defines if the audio engine relies on a custom unlocked button.
  5388. * In this case, the embedded button will not be displayed.
  5389. */
  5390. useCustomUnlockedButton: boolean;
  5391. /**
  5392. * Event raised when audio has been unlocked on the browser.
  5393. */
  5394. onAudioUnlockedObservable: Observable<AudioEngine>;
  5395. /**
  5396. * Event raised when audio has been locked on the browser.
  5397. */
  5398. onAudioLockedObservable: Observable<AudioEngine>;
  5399. /**
  5400. * Gets the current AudioContext if available.
  5401. */
  5402. readonly audioContext: Nullable<AudioContext>;
  5403. private _connectedAnalyser;
  5404. /**
  5405. * Instantiates a new audio engine.
  5406. *
  5407. * There should be only one per page as some browsers restrict the number
  5408. * of audio contexts you can create.
  5409. * @param hostElement defines the host element where to display the mute icon if necessary
  5410. */
  5411. constructor(hostElement?: Nullable<HTMLElement>);
  5412. /**
  5413. * Flags the audio engine in Locked state.
  5414. * This happens due to new browser policies preventing audio to autoplay.
  5415. */
  5416. lock(): void;
  5417. /**
  5418. * Unlocks the audio engine once a user action has been done on the dom.
  5419. * This is helpful to resume play once browser policies have been satisfied.
  5420. */
  5421. unlock(): void;
  5422. private _resumeAudioContext;
  5423. private _initializeAudioContext;
  5424. private _tryToRun;
  5425. private _triggerRunningState;
  5426. private _triggerSuspendedState;
  5427. private _displayMuteButton;
  5428. private _moveButtonToTopLeft;
  5429. private _onResize;
  5430. private _hideMuteButton;
  5431. /**
  5432. * Destroy and release the resources associated with the audio ccontext.
  5433. */
  5434. dispose(): void;
  5435. /**
  5436. * Gets the global volume sets on the master gain.
  5437. * @returns the global volume if set or -1 otherwise
  5438. */
  5439. getGlobalVolume(): number;
  5440. /**
  5441. * Sets the global volume of your experience (sets on the master gain).
  5442. * @param newVolume Defines the new global volume of the application
  5443. */
  5444. setGlobalVolume(newVolume: number): void;
  5445. /**
  5446. * Connect the audio engine to an audio analyser allowing some amazing
  5447. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  5448. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  5449. * @param analyser The analyser to connect to the engine
  5450. */
  5451. connectToAnalyser(analyser: Analyser): void;
  5452. }
  5453. }
  5454. declare module BABYLON {
  5455. interface AbstractScene {
  5456. /**
  5457. * The list of sounds used in the scene.
  5458. */
  5459. sounds: Nullable<Array<Sound>>;
  5460. }
  5461. interface Scene {
  5462. /**
  5463. * @hidden
  5464. * Backing field
  5465. */
  5466. _mainSoundTrack: SoundTrack;
  5467. /**
  5468. * The main sound track played by the scene.
  5469. * It cotains your primary collection of sounds.
  5470. */
  5471. mainSoundTrack: SoundTrack;
  5472. /**
  5473. * The list of sound tracks added to the scene
  5474. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5475. */
  5476. soundTracks: Nullable<Array<SoundTrack>>;
  5477. /**
  5478. * Gets a sound using a given name
  5479. * @param name defines the name to search for
  5480. * @return the found sound or null if not found at all.
  5481. */
  5482. getSoundByName(name: string): Nullable<Sound>;
  5483. /**
  5484. * Gets or sets if audio support is enabled
  5485. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5486. */
  5487. audioEnabled: boolean;
  5488. /**
  5489. * Gets or sets if audio will be output to headphones
  5490. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5491. */
  5492. headphone: boolean;
  5493. }
  5494. /**
  5495. * Defines the sound scene component responsible to manage any sounds
  5496. * in a given scene.
  5497. */
  5498. class AudioSceneComponent implements ISceneSerializableComponent {
  5499. /**
  5500. * The component name helpfull to identify the component in the list of scene components.
  5501. */
  5502. readonly name: string;
  5503. /**
  5504. * The scene the component belongs to.
  5505. */
  5506. scene: Scene;
  5507. private _audioEnabled;
  5508. /**
  5509. * Gets whether audio is enabled or not.
  5510. * Please use related enable/disable method to switch state.
  5511. */
  5512. readonly audioEnabled: boolean;
  5513. private _headphone;
  5514. /**
  5515. * Gets whether audio is outputing to headphone or not.
  5516. * Please use the according Switch methods to change output.
  5517. */
  5518. readonly headphone: boolean;
  5519. /**
  5520. * Creates a new instance of the component for the given scene
  5521. * @param scene Defines the scene to register the component in
  5522. */
  5523. constructor(scene: Scene);
  5524. /**
  5525. * Registers the component in a given scene
  5526. */
  5527. register(): void;
  5528. /**
  5529. * Rebuilds the elements related to this component in case of
  5530. * context lost for instance.
  5531. */
  5532. rebuild(): void;
  5533. /**
  5534. * Serializes the component data to the specified json object
  5535. * @param serializationObject The object to serialize to
  5536. */
  5537. serialize(serializationObject: any): void;
  5538. /**
  5539. * Adds all the element from the container to the scene
  5540. * @param container the container holding the elements
  5541. */
  5542. addFromContainer(container: AbstractScene): void;
  5543. /**
  5544. * Removes all the elements in the container from the scene
  5545. * @param container contains the elements to remove
  5546. */
  5547. removeFromContainer(container: AbstractScene): void;
  5548. /**
  5549. * Disposes the component and the associated ressources.
  5550. */
  5551. dispose(): void;
  5552. /**
  5553. * Disables audio in the associated scene.
  5554. */
  5555. disableAudio(): void;
  5556. /**
  5557. * Enables audio in the associated scene.
  5558. */
  5559. enableAudio(): void;
  5560. /**
  5561. * Switch audio to headphone output.
  5562. */
  5563. switchAudioModeForHeadphones(): void;
  5564. /**
  5565. * Switch audio to normal speakers.
  5566. */
  5567. switchAudioModeForNormalSpeakers(): void;
  5568. private _afterRender;
  5569. }
  5570. }
  5571. declare module BABYLON {
  5572. /**
  5573. * Defines a sound that can be played in the application.
  5574. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  5575. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5576. */
  5577. class Sound {
  5578. /**
  5579. * The name of the sound in the scene.
  5580. */
  5581. name: string;
  5582. /**
  5583. * Does the sound autoplay once loaded.
  5584. */
  5585. autoplay: boolean;
  5586. /**
  5587. * Does the sound loop after it finishes playing once.
  5588. */
  5589. loop: boolean;
  5590. /**
  5591. * Does the sound use a custom attenuation curve to simulate the falloff
  5592. * happening when the source gets further away from the camera.
  5593. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  5594. */
  5595. useCustomAttenuation: boolean;
  5596. /**
  5597. * The sound track id this sound belongs to.
  5598. */
  5599. soundTrackId: number;
  5600. /**
  5601. * Is this sound currently played.
  5602. */
  5603. isPlaying: boolean;
  5604. /**
  5605. * Is this sound currently paused.
  5606. */
  5607. isPaused: boolean;
  5608. /**
  5609. * Does this sound enables spatial sound.
  5610. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5611. */
  5612. spatialSound: boolean;
  5613. /**
  5614. * Define the reference distance the sound should be heard perfectly.
  5615. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5616. */
  5617. refDistance: number;
  5618. /**
  5619. * Define the roll off factor of spatial sounds.
  5620. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5621. */
  5622. rolloffFactor: number;
  5623. /**
  5624. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  5625. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5626. */
  5627. maxDistance: number;
  5628. /**
  5629. * Define the distance attenuation model the sound will follow.
  5630. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5631. */
  5632. distanceModel: string;
  5633. /**
  5634. * @hidden
  5635. * Back Compat
  5636. **/
  5637. onended: () => any;
  5638. /**
  5639. * Observable event when the current playing sound finishes.
  5640. */
  5641. onEndedObservable: Observable<Sound>;
  5642. private _panningModel;
  5643. private _playbackRate;
  5644. private _streaming;
  5645. private _startTime;
  5646. private _startOffset;
  5647. private _position;
  5648. /** @hidden */
  5649. _positionInEmitterSpace: boolean;
  5650. private _localDirection;
  5651. private _volume;
  5652. private _isReadyToPlay;
  5653. private _isDirectional;
  5654. private _readyToPlayCallback;
  5655. private _audioBuffer;
  5656. private _soundSource;
  5657. private _streamingSource;
  5658. private _soundPanner;
  5659. private _soundGain;
  5660. private _inputAudioNode;
  5661. private _outputAudioNode;
  5662. private _coneInnerAngle;
  5663. private _coneOuterAngle;
  5664. private _coneOuterGain;
  5665. private _scene;
  5666. private _connectedTransformNode;
  5667. private _customAttenuationFunction;
  5668. private _registerFunc;
  5669. private _isOutputConnected;
  5670. private _htmlAudioElement;
  5671. private _urlType;
  5672. /**
  5673. * Create a sound and attach it to a scene
  5674. * @param name Name of your sound
  5675. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  5676. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  5677. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  5678. */
  5679. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  5680. /**
  5681. * Release the sound and its associated resources
  5682. */
  5683. dispose(): void;
  5684. /**
  5685. * Gets if the sounds is ready to be played or not.
  5686. * @returns true if ready, otherwise false
  5687. */
  5688. isReady(): boolean;
  5689. private _soundLoaded;
  5690. /**
  5691. * Sets the data of the sound from an audiobuffer
  5692. * @param audioBuffer The audioBuffer containing the data
  5693. */
  5694. setAudioBuffer(audioBuffer: AudioBuffer): void;
  5695. /**
  5696. * Updates the current sounds options such as maxdistance, loop...
  5697. * @param options A JSON object containing values named as the object properties
  5698. */
  5699. updateOptions(options: any): void;
  5700. private _createSpatialParameters;
  5701. private _updateSpatialParameters;
  5702. /**
  5703. * Switch the panning model to HRTF:
  5704. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  5705. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5706. */
  5707. switchPanningModelToHRTF(): void;
  5708. /**
  5709. * Switch the panning model to Equal Power:
  5710. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  5711. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5712. */
  5713. switchPanningModelToEqualPower(): void;
  5714. private _switchPanningModel;
  5715. /**
  5716. * Connect this sound to a sound track audio node like gain...
  5717. * @param soundTrackAudioNode the sound track audio node to connect to
  5718. */
  5719. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  5720. /**
  5721. * Transform this sound into a directional source
  5722. * @param coneInnerAngle Size of the inner cone in degree
  5723. * @param coneOuterAngle Size of the outer cone in degree
  5724. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  5725. */
  5726. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  5727. /**
  5728. * Gets or sets the inner angle for the directional cone.
  5729. */
  5730. /**
  5731. * Gets or sets the inner angle for the directional cone.
  5732. */
  5733. directionalConeInnerAngle: number;
  5734. /**
  5735. * Gets or sets the outer angle for the directional cone.
  5736. */
  5737. /**
  5738. * Gets or sets the outer angle for the directional cone.
  5739. */
  5740. directionalConeOuterAngle: number;
  5741. /**
  5742. * Sets the position of the emitter if spatial sound is enabled
  5743. * @param newPosition Defines the new posisiton
  5744. */
  5745. setPosition(newPosition: Vector3): void;
  5746. /**
  5747. * Sets the local direction of the emitter if spatial sound is enabled
  5748. * @param newLocalDirection Defines the new local direction
  5749. */
  5750. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  5751. private _updateDirection;
  5752. /** @hidden */
  5753. updateDistanceFromListener(): void;
  5754. /**
  5755. * Sets a new custom attenuation function for the sound.
  5756. * @param callback Defines the function used for the attenuation
  5757. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  5758. */
  5759. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  5760. /**
  5761. * Play the sound
  5762. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  5763. * @param offset (optional) Start the sound setting it at a specific time
  5764. */
  5765. play(time?: number, offset?: number): void;
  5766. private _onended;
  5767. /**
  5768. * Stop the sound
  5769. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  5770. */
  5771. stop(time?: number): void;
  5772. /**
  5773. * Put the sound in pause
  5774. */
  5775. pause(): void;
  5776. /**
  5777. * Sets a dedicated volume for this sounds
  5778. * @param newVolume Define the new volume of the sound
  5779. * @param time Define in how long the sound should be at this value
  5780. */
  5781. setVolume(newVolume: number, time?: number): void;
  5782. /**
  5783. * Set the sound play back rate
  5784. * @param newPlaybackRate Define the playback rate the sound should be played at
  5785. */
  5786. setPlaybackRate(newPlaybackRate: number): void;
  5787. /**
  5788. * Gets the volume of the sound.
  5789. * @returns the volume of the sound
  5790. */
  5791. getVolume(): number;
  5792. /**
  5793. * Attach the sound to a dedicated mesh
  5794. * @param transformNode The transform node to connect the sound with
  5795. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  5796. */
  5797. attachToMesh(transformNode: TransformNode): void;
  5798. /**
  5799. * Detach the sound from the previously attached mesh
  5800. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  5801. */
  5802. detachFromMesh(): void;
  5803. private _onRegisterAfterWorldMatrixUpdate;
  5804. /**
  5805. * Clone the current sound in the scene.
  5806. * @returns the new sound clone
  5807. */
  5808. clone(): Nullable<Sound>;
  5809. /**
  5810. * Gets the current underlying audio buffer containing the data
  5811. * @returns the audio buffer
  5812. */
  5813. getAudioBuffer(): Nullable<AudioBuffer>;
  5814. /**
  5815. * Serializes the Sound in a JSON representation
  5816. * @returns the JSON representation of the sound
  5817. */
  5818. serialize(): any;
  5819. /**
  5820. * Parse a JSON representation of a sound to innstantiate in a given scene
  5821. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  5822. * @param scene Define the scene the new parsed sound should be created in
  5823. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  5824. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  5825. * @returns the newly parsed sound
  5826. */
  5827. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  5828. }
  5829. }
  5830. declare module BABYLON {
  5831. /**
  5832. * Options allowed during the creation of a sound track.
  5833. */
  5834. interface ISoundTrackOptions {
  5835. /**
  5836. * The volume the sound track should take during creation
  5837. */
  5838. volume?: number;
  5839. /**
  5840. * Define if the sound track is the main sound track of the scene
  5841. */
  5842. mainTrack?: boolean;
  5843. }
  5844. /**
  5845. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  5846. * It will be also used in a future release to apply effects on a specific track.
  5847. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  5848. */
  5849. class SoundTrack {
  5850. /**
  5851. * The unique identifier of the sound track in the scene.
  5852. */
  5853. id: number;
  5854. /**
  5855. * The list of sounds included in the sound track.
  5856. */
  5857. soundCollection: Array<Sound>;
  5858. private _outputAudioNode;
  5859. private _scene;
  5860. private _isMainTrack;
  5861. private _connectedAnalyser;
  5862. private _options;
  5863. private _isInitialized;
  5864. /**
  5865. * Creates a new sound track.
  5866. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  5867. * @param scene Define the scene the sound track belongs to
  5868. * @param options
  5869. */
  5870. constructor(scene: Scene, options?: ISoundTrackOptions);
  5871. private _initializeSoundTrackAudioGraph;
  5872. /**
  5873. * Release the sound track and its associated resources
  5874. */
  5875. dispose(): void;
  5876. /**
  5877. * Adds a sound to this sound track
  5878. * @param sound define the cound to add
  5879. * @ignoreNaming
  5880. */
  5881. AddSound(sound: Sound): void;
  5882. /**
  5883. * Removes a sound to this sound track
  5884. * @param sound define the cound to remove
  5885. * @ignoreNaming
  5886. */
  5887. RemoveSound(sound: Sound): void;
  5888. /**
  5889. * Set a global volume for the full sound track.
  5890. * @param newVolume Define the new volume of the sound track
  5891. */
  5892. setVolume(newVolume: number): void;
  5893. /**
  5894. * Switch the panning model to HRTF:
  5895. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  5896. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5897. */
  5898. switchPanningModelToHRTF(): void;
  5899. /**
  5900. * Switch the panning model to Equal Power:
  5901. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  5902. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5903. */
  5904. switchPanningModelToEqualPower(): void;
  5905. /**
  5906. * Connect the sound track to an audio analyser allowing some amazing
  5907. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  5908. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  5909. * @param analyser The analyser to connect to the engine
  5910. */
  5911. connectToAnalyser(analyser: Analyser): void;
  5912. }
  5913. }
  5914. declare module BABYLON {
  5915. /**
  5916. * Wraps one or more Sound objects and selects one with random weight for playback.
  5917. */
  5918. class WeightedSound {
  5919. /** When true a Sound will be selected and played when the current playing Sound completes. */
  5920. loop: boolean;
  5921. private _coneInnerAngle;
  5922. private _coneOuterAngle;
  5923. private _volume;
  5924. /** A Sound is currently playing. */
  5925. isPlaying: boolean;
  5926. /** A Sound is currently paused. */
  5927. isPaused: boolean;
  5928. private _sounds;
  5929. private _weights;
  5930. private _currentIndex?;
  5931. /**
  5932. * Creates a new WeightedSound from the list of sounds given.
  5933. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  5934. * @param sounds Array of Sounds that will be selected from.
  5935. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  5936. */
  5937. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  5938. /**
  5939. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  5940. */
  5941. /**
  5942. * The size of cone in degress for a directional sound in which there will be no attenuation.
  5943. */
  5944. directionalConeInnerAngle: number;
  5945. /**
  5946. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  5947. * Listener angles between innerAngle and outerAngle will falloff linearly.
  5948. */
  5949. /**
  5950. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  5951. * Listener angles between innerAngle and outerAngle will falloff linearly.
  5952. */
  5953. directionalConeOuterAngle: number;
  5954. /**
  5955. * Playback volume.
  5956. */
  5957. /**
  5958. * Playback volume.
  5959. */
  5960. volume: number;
  5961. private _onended;
  5962. /**
  5963. * Suspend playback
  5964. */
  5965. pause(): void;
  5966. /**
  5967. * Stop playback
  5968. */
  5969. stop(): void;
  5970. /**
  5971. * Start playback.
  5972. * @param startOffset Position the clip head at a specific time in seconds.
  5973. */
  5974. play(startOffset?: number): void;
  5975. }
  5976. }
  5977. declare module BABYLON {
  5978. /**
  5979. * Interface used to define a behavior
  5980. */
  5981. interface Behavior<T> {
  5982. /** gets or sets behavior's name */
  5983. name: string;
  5984. /**
  5985. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5986. */
  5987. init(): void;
  5988. /**
  5989. * Called when the behavior is attached to a target
  5990. * @param target defines the target where the behavior is attached to
  5991. */
  5992. attach(target: T): void;
  5993. /**
  5994. * Called when the behavior is detached from its target
  5995. */
  5996. detach(): void;
  5997. }
  5998. /**
  5999. * Interface implemented by classes supporting behaviors
  6000. */
  6001. interface IBehaviorAware<T> {
  6002. /**
  6003. * Attach a behavior
  6004. * @param behavior defines the behavior to attach
  6005. * @returns the current host
  6006. */
  6007. addBehavior(behavior: Behavior<T>): T;
  6008. /**
  6009. * Remove a behavior from the current object
  6010. * @param behavior defines the behavior to detach
  6011. * @returns the current host
  6012. */
  6013. removeBehavior(behavior: Behavior<T>): T;
  6014. /**
  6015. * Gets a behavior using its name to search
  6016. * @param name defines the name to search
  6017. * @returns the behavior or null if not found
  6018. */
  6019. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6020. }
  6021. }
  6022. declare module BABYLON {
  6023. /**
  6024. * Class used to store bone information
  6025. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  6026. */
  6027. class Bone extends Node {
  6028. /**
  6029. * defines the bone name
  6030. */
  6031. name: string;
  6032. private static _tmpVecs;
  6033. private static _tmpQuat;
  6034. private static _tmpMats;
  6035. /**
  6036. * Gets the list of child bones
  6037. */
  6038. children: Bone[];
  6039. /** Gets the animations associated with this bone */
  6040. animations: Animation[];
  6041. /**
  6042. * Gets or sets bone length
  6043. */
  6044. length: number;
  6045. /**
  6046. * @hidden Internal only
  6047. * Set this value to map this bone to a different index in the transform matrices
  6048. * Set this value to -1 to exclude the bone from the transform matrices
  6049. */
  6050. _index: Nullable<number>;
  6051. private _skeleton;
  6052. private _localMatrix;
  6053. private _restPose;
  6054. private _baseMatrix;
  6055. private _absoluteTransform;
  6056. private _invertedAbsoluteTransform;
  6057. private _parent;
  6058. private _scalingDeterminant;
  6059. private _worldTransform;
  6060. private _localScaling;
  6061. private _localRotation;
  6062. private _localPosition;
  6063. private _needToDecompose;
  6064. private _needToCompose;
  6065. /** @hidden */
  6066. _linkedTransformNode: Nullable<TransformNode>;
  6067. /** @hidden */
  6068. /** @hidden */
  6069. _matrix: Matrix;
  6070. /**
  6071. * Create a new bone
  6072. * @param name defines the bone name
  6073. * @param skeleton defines the parent skeleton
  6074. * @param parentBone defines the parent (can be null if the bone is the root)
  6075. * @param localMatrix defines the local matrix
  6076. * @param restPose defines the rest pose matrix
  6077. * @param baseMatrix defines the base matrix
  6078. * @param index defines index of the bone in the hiearchy
  6079. */
  6080. constructor(
  6081. /**
  6082. * defines the bone name
  6083. */
  6084. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  6085. /**
  6086. * Gets the parent skeleton
  6087. * @returns a skeleton
  6088. */
  6089. getSkeleton(): Skeleton;
  6090. /**
  6091. * Gets parent bone
  6092. * @returns a bone or null if the bone is the root of the bone hierarchy
  6093. */
  6094. getParent(): Nullable<Bone>;
  6095. /**
  6096. * Sets the parent bone
  6097. * @param parent defines the parent (can be null if the bone is the root)
  6098. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  6099. */
  6100. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  6101. /**
  6102. * Gets the local matrix
  6103. * @returns a matrix
  6104. */
  6105. getLocalMatrix(): Matrix;
  6106. /**
  6107. * Gets the base matrix (initial matrix which remains unchanged)
  6108. * @returns a matrix
  6109. */
  6110. getBaseMatrix(): Matrix;
  6111. /**
  6112. * Gets the rest pose matrix
  6113. * @returns a matrix
  6114. */
  6115. getRestPose(): Matrix;
  6116. /**
  6117. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  6118. */
  6119. getWorldMatrix(): Matrix;
  6120. /**
  6121. * Sets the local matrix to rest pose matrix
  6122. */
  6123. returnToRest(): void;
  6124. /**
  6125. * Gets the inverse of the absolute transform matrix.
  6126. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  6127. * @returns a matrix
  6128. */
  6129. getInvertedAbsoluteTransform(): Matrix;
  6130. /**
  6131. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  6132. * @returns a matrix
  6133. */
  6134. getAbsoluteTransform(): Matrix;
  6135. /**
  6136. * Links with the given transform node.
  6137. * The local matrix of this bone is copied from the transform node every frame.
  6138. * @param transformNode defines the transform node to link to
  6139. */
  6140. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  6141. /** Gets or sets current position (in local space) */
  6142. position: Vector3;
  6143. /** Gets or sets current rotation (in local space) */
  6144. rotation: Vector3;
  6145. /** Gets or sets current rotation quaternion (in local space) */
  6146. rotationQuaternion: Quaternion;
  6147. /** Gets or sets current scaling (in local space) */
  6148. scaling: Vector3;
  6149. /**
  6150. * Gets the animation properties override
  6151. */
  6152. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  6153. private _decompose;
  6154. private _compose;
  6155. /**
  6156. * Update the base and local matrices
  6157. * @param matrix defines the new base or local matrix
  6158. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  6159. * @param updateLocalMatrix defines if the local matrix should be updated
  6160. */
  6161. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  6162. /** @hidden */
  6163. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  6164. /**
  6165. * Flag the bone as dirty (Forcing it to update everything)
  6166. */
  6167. markAsDirty(): void;
  6168. private _markAsDirtyAndCompose;
  6169. private _markAsDirtyAndDecompose;
  6170. /**
  6171. * Copy an animation range from another bone
  6172. * @param source defines the source bone
  6173. * @param rangeName defines the range name to copy
  6174. * @param frameOffset defines the frame offset
  6175. * @param rescaleAsRequired defines if rescaling must be applied if required
  6176. * @param skelDimensionsRatio defines the scaling ratio
  6177. * @returns true if operation was successful
  6178. */
  6179. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired?: boolean, skelDimensionsRatio?: Nullable<Vector3>): boolean;
  6180. /**
  6181. * Translate the bone in local or world space
  6182. * @param vec The amount to translate the bone
  6183. * @param space The space that the translation is in
  6184. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6185. */
  6186. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  6187. /**
  6188. * Set the postion of the bone in local or world space
  6189. * @param position The position to set the bone
  6190. * @param space The space that the position is in
  6191. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6192. */
  6193. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  6194. /**
  6195. * Set the absolute position of the bone (world space)
  6196. * @param position The position to set the bone
  6197. * @param mesh The mesh that this bone is attached to
  6198. */
  6199. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  6200. /**
  6201. * Scale the bone on the x, y and z axes (in local space)
  6202. * @param x The amount to scale the bone on the x axis
  6203. * @param y The amount to scale the bone on the y axis
  6204. * @param z The amount to scale the bone on the z axis
  6205. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  6206. */
  6207. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  6208. /**
  6209. * Set the bone scaling in local space
  6210. * @param scale defines the scaling vector
  6211. */
  6212. setScale(scale: Vector3): void;
  6213. /**
  6214. * Gets the current scaling in local space
  6215. * @returns the current scaling vector
  6216. */
  6217. getScale(): Vector3;
  6218. /**
  6219. * Gets the current scaling in local space and stores it in a target vector
  6220. * @param result defines the target vector
  6221. */
  6222. getScaleToRef(result: Vector3): void;
  6223. /**
  6224. * Set the yaw, pitch, and roll of the bone in local or world space
  6225. * @param yaw The rotation of the bone on the y axis
  6226. * @param pitch The rotation of the bone on the x axis
  6227. * @param roll The rotation of the bone on the z axis
  6228. * @param space The space that the axes of rotation are in
  6229. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6230. */
  6231. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  6232. /**
  6233. * Add a rotation to the bone on an axis in local or world space
  6234. * @param axis The axis to rotate the bone on
  6235. * @param amount The amount to rotate the bone
  6236. * @param space The space that the axis is in
  6237. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6238. */
  6239. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  6240. /**
  6241. * Set the rotation of the bone to a particular axis angle in local or world space
  6242. * @param axis The axis to rotate the bone on
  6243. * @param angle The angle that the bone should be rotated to
  6244. * @param space The space that the axis is in
  6245. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6246. */
  6247. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  6248. /**
  6249. * Set the euler rotation of the bone in local of world space
  6250. * @param rotation The euler rotation that the bone should be set to
  6251. * @param space The space that the rotation is in
  6252. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6253. */
  6254. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  6255. /**
  6256. * Set the quaternion rotation of the bone in local of world space
  6257. * @param quat The quaternion rotation that the bone should be set to
  6258. * @param space The space that the rotation is in
  6259. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6260. */
  6261. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  6262. /**
  6263. * Set the rotation matrix of the bone in local of world space
  6264. * @param rotMat The rotation matrix that the bone should be set to
  6265. * @param space The space that the rotation is in
  6266. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6267. */
  6268. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  6269. private _rotateWithMatrix;
  6270. private _getNegativeRotationToRef;
  6271. /**
  6272. * Get the position of the bone in local or world space
  6273. * @param space The space that the returned position is in
  6274. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6275. * @returns The position of the bone
  6276. */
  6277. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  6278. /**
  6279. * Copy the position of the bone to a vector3 in local or world space
  6280. * @param space The space that the returned position is in
  6281. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6282. * @param result The vector3 to copy the position to
  6283. */
  6284. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  6285. /**
  6286. * Get the absolute position of the bone (world space)
  6287. * @param mesh The mesh that this bone is attached to
  6288. * @returns The absolute position of the bone
  6289. */
  6290. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  6291. /**
  6292. * Copy the absolute position of the bone (world space) to the result param
  6293. * @param mesh The mesh that this bone is attached to
  6294. * @param result The vector3 to copy the absolute position to
  6295. */
  6296. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  6297. /**
  6298. * Compute the absolute transforms of this bone and its children
  6299. */
  6300. computeAbsoluteTransforms(): void;
  6301. /**
  6302. * Get the world direction from an axis that is in the local space of the bone
  6303. * @param localAxis The local direction that is used to compute the world direction
  6304. * @param mesh The mesh that this bone is attached to
  6305. * @returns The world direction
  6306. */
  6307. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  6308. /**
  6309. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  6310. * @param localAxis The local direction that is used to compute the world direction
  6311. * @param mesh The mesh that this bone is attached to
  6312. * @param result The vector3 that the world direction will be copied to
  6313. */
  6314. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6315. /**
  6316. * Get the euler rotation of the bone in local or world space
  6317. * @param space The space that the rotation should be in
  6318. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6319. * @returns The euler rotation
  6320. */
  6321. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  6322. /**
  6323. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  6324. * @param space The space that the rotation should be in
  6325. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6326. * @param result The vector3 that the rotation should be copied to
  6327. */
  6328. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6329. /**
  6330. * Get the quaternion rotation of the bone in either local or world space
  6331. * @param space The space that the rotation should be in
  6332. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6333. * @returns The quaternion rotation
  6334. */
  6335. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  6336. /**
  6337. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  6338. * @param space The space that the rotation should be in
  6339. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6340. * @param result The quaternion that the rotation should be copied to
  6341. */
  6342. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  6343. /**
  6344. * Get the rotation matrix of the bone in local or world space
  6345. * @param space The space that the rotation should be in
  6346. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6347. * @returns The rotation matrix
  6348. */
  6349. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  6350. /**
  6351. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  6352. * @param space The space that the rotation should be in
  6353. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6354. * @param result The quaternion that the rotation should be copied to
  6355. */
  6356. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  6357. /**
  6358. * Get the world position of a point that is in the local space of the bone
  6359. * @param position The local position
  6360. * @param mesh The mesh that this bone is attached to
  6361. * @returns The world position
  6362. */
  6363. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  6364. /**
  6365. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  6366. * @param position The local position
  6367. * @param mesh The mesh that this bone is attached to
  6368. * @param result The vector3 that the world position should be copied to
  6369. */
  6370. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6371. /**
  6372. * Get the local position of a point that is in world space
  6373. * @param position The world position
  6374. * @param mesh The mesh that this bone is attached to
  6375. * @returns The local position
  6376. */
  6377. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  6378. /**
  6379. * Get the local position of a point that is in world space and copy it to the result param
  6380. * @param position The world position
  6381. * @param mesh The mesh that this bone is attached to
  6382. * @param result The vector3 that the local position should be copied to
  6383. */
  6384. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6385. }
  6386. }
  6387. declare module BABYLON {
  6388. /**
  6389. * Class used to apply inverse kinematics to bones
  6390. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  6391. */
  6392. class BoneIKController {
  6393. private static _tmpVecs;
  6394. private static _tmpQuat;
  6395. private static _tmpMats;
  6396. /**
  6397. * Gets or sets the target mesh
  6398. */
  6399. targetMesh: AbstractMesh;
  6400. /** Gets or sets the mesh used as pole */
  6401. poleTargetMesh: AbstractMesh;
  6402. /**
  6403. * Gets or sets the bone used as pole
  6404. */
  6405. poleTargetBone: Nullable<Bone>;
  6406. /**
  6407. * Gets or sets the target position
  6408. */
  6409. targetPosition: Vector3;
  6410. /**
  6411. * Gets or sets the pole target position
  6412. */
  6413. poleTargetPosition: Vector3;
  6414. /**
  6415. * Gets or sets the pole target local offset
  6416. */
  6417. poleTargetLocalOffset: Vector3;
  6418. /**
  6419. * Gets or sets the pole angle
  6420. */
  6421. poleAngle: number;
  6422. /**
  6423. * Gets or sets the mesh associated with the controller
  6424. */
  6425. mesh: AbstractMesh;
  6426. /**
  6427. * The amount to slerp (spherical linear interpolation) to the target. Set this to a value between 0 and 1 (a value of 1 disables slerp)
  6428. */
  6429. slerpAmount: number;
  6430. private _bone1Quat;
  6431. private _bone1Mat;
  6432. private _bone2Ang;
  6433. private _bone1;
  6434. private _bone2;
  6435. private _bone1Length;
  6436. private _bone2Length;
  6437. private _maxAngle;
  6438. private _maxReach;
  6439. private _rightHandedSystem;
  6440. private _bendAxis;
  6441. private _slerping;
  6442. private _adjustRoll;
  6443. /**
  6444. * Gets or sets maximum allowed angle
  6445. */
  6446. maxAngle: number;
  6447. /**
  6448. * Creates a new BoneIKController
  6449. * @param mesh defines the mesh to control
  6450. * @param bone defines the bone to control
  6451. * @param options defines options to set up the controller
  6452. */
  6453. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  6454. targetMesh?: AbstractMesh;
  6455. poleTargetMesh?: AbstractMesh;
  6456. poleTargetBone?: Bone;
  6457. poleTargetLocalOffset?: Vector3;
  6458. poleAngle?: number;
  6459. bendAxis?: Vector3;
  6460. maxAngle?: number;
  6461. slerpAmount?: number;
  6462. });
  6463. private _setMaxAngle;
  6464. /**
  6465. * Force the controller to update the bones
  6466. */
  6467. update(): void;
  6468. }
  6469. }
  6470. declare module BABYLON {
  6471. /**
  6472. * Class used to make a bone look toward a point in space
  6473. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  6474. */
  6475. class BoneLookController {
  6476. private static _tmpVecs;
  6477. private static _tmpQuat;
  6478. private static _tmpMats;
  6479. /**
  6480. * The target Vector3 that the bone will look at
  6481. */
  6482. target: Vector3;
  6483. /**
  6484. * The mesh that the bone is attached to
  6485. */
  6486. mesh: AbstractMesh;
  6487. /**
  6488. * The bone that will be looking to the target
  6489. */
  6490. bone: Bone;
  6491. /**
  6492. * The up axis of the coordinate system that is used when the bone is rotated
  6493. */
  6494. upAxis: Vector3;
  6495. /**
  6496. * The space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD
  6497. */
  6498. upAxisSpace: Space;
  6499. /**
  6500. * Used to make an adjustment to the yaw of the bone
  6501. */
  6502. adjustYaw: number;
  6503. /**
  6504. * Used to make an adjustment to the pitch of the bone
  6505. */
  6506. adjustPitch: number;
  6507. /**
  6508. * Used to make an adjustment to the roll of the bone
  6509. */
  6510. adjustRoll: number;
  6511. /**
  6512. * The amount to slerp (spherical linear interpolation) to the target. Set this to a value between 0 and 1 (a value of 1 disables slerp)
  6513. */
  6514. slerpAmount: number;
  6515. private _minYaw;
  6516. private _maxYaw;
  6517. private _minPitch;
  6518. private _maxPitch;
  6519. private _minYawSin;
  6520. private _minYawCos;
  6521. private _maxYawSin;
  6522. private _maxYawCos;
  6523. private _midYawConstraint;
  6524. private _minPitchTan;
  6525. private _maxPitchTan;
  6526. private _boneQuat;
  6527. private _slerping;
  6528. private _transformYawPitch;
  6529. private _transformYawPitchInv;
  6530. private _firstFrameSkipped;
  6531. private _yawRange;
  6532. private _fowardAxis;
  6533. /**
  6534. * Gets or sets the minimum yaw angle that the bone can look to
  6535. */
  6536. minYaw: number;
  6537. /**
  6538. * Gets or sets the maximum yaw angle that the bone can look to
  6539. */
  6540. maxYaw: number;
  6541. /**
  6542. * Gets or sets the minimum pitch angle that the bone can look to
  6543. */
  6544. minPitch: number;
  6545. /**
  6546. * Gets or sets the maximum pitch angle that the bone can look to
  6547. */
  6548. maxPitch: number;
  6549. /**
  6550. * Create a BoneLookController
  6551. * @param mesh the mesh that the bone belongs to
  6552. * @param bone the bone that will be looking to the target
  6553. * @param target the target Vector3 to look at
  6554. * @param settings optional settings:
  6555. * * maxYaw: the maximum angle the bone will yaw to
  6556. * * minYaw: the minimum angle the bone will yaw to
  6557. * * maxPitch: the maximum angle the bone will pitch to
  6558. * * minPitch: the minimum angle the bone will yaw to
  6559. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  6560. * * upAxis: the up axis of the coordinate system
  6561. * * upAxisSpace: the space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD.
  6562. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  6563. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  6564. * * adjustYaw: used to make an adjustment to the yaw of the bone
  6565. * * adjustPitch: used to make an adjustment to the pitch of the bone
  6566. * * adjustRoll: used to make an adjustment to the roll of the bone
  6567. **/
  6568. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  6569. maxYaw?: number;
  6570. minYaw?: number;
  6571. maxPitch?: number;
  6572. minPitch?: number;
  6573. slerpAmount?: number;
  6574. upAxis?: Vector3;
  6575. upAxisSpace?: Space;
  6576. yawAxis?: Vector3;
  6577. pitchAxis?: Vector3;
  6578. adjustYaw?: number;
  6579. adjustPitch?: number;
  6580. adjustRoll?: number;
  6581. });
  6582. /**
  6583. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  6584. */
  6585. update(): void;
  6586. private _getAngleDiff;
  6587. private _getAngleBetween;
  6588. private _isAngleBetween;
  6589. }
  6590. }
  6591. declare module BABYLON {
  6592. /**
  6593. * Class used to handle skinning animations
  6594. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  6595. */
  6596. class Skeleton implements IAnimatable {
  6597. /** defines the skeleton name */
  6598. name: string;
  6599. /** defines the skeleton Id */
  6600. id: string;
  6601. /**
  6602. * Defines the list of child bones
  6603. */
  6604. bones: Bone[];
  6605. /**
  6606. * Defines an estimate of the dimension of the skeleton at rest
  6607. */
  6608. dimensionsAtRest: Vector3;
  6609. /**
  6610. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  6611. */
  6612. needInitialSkinMatrix: boolean;
  6613. /**
  6614. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  6615. */
  6616. overrideMesh: Nullable<AbstractMesh>;
  6617. /**
  6618. * Gets the list of animations attached to this skeleton
  6619. */
  6620. animations: Array<Animation>;
  6621. private _scene;
  6622. private _isDirty;
  6623. private _transformMatrices;
  6624. private _transformMatrixTexture;
  6625. private _meshesWithPoseMatrix;
  6626. private _animatables;
  6627. private _identity;
  6628. private _synchronizedWithMesh;
  6629. private _ranges;
  6630. private _lastAbsoluteTransformsUpdateId;
  6631. private _canUseTextureForBones;
  6632. /** @hidden */
  6633. _numBonesWithLinkedTransformNode: number;
  6634. /**
  6635. * Specifies if the skeleton should be serialized
  6636. */
  6637. doNotSerialize: boolean;
  6638. /**
  6639. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  6640. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  6641. */
  6642. useTextureToStoreBoneMatrices: boolean;
  6643. private _animationPropertiesOverride;
  6644. /**
  6645. * Gets or sets the animation properties override
  6646. */
  6647. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  6648. /**
  6649. * An observable triggered before computing the skeleton's matrices
  6650. */
  6651. onBeforeComputeObservable: Observable<Skeleton>;
  6652. /**
  6653. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  6654. */
  6655. readonly isUsingTextureForMatrices: boolean;
  6656. /**
  6657. * Creates a new skeleton
  6658. * @param name defines the skeleton name
  6659. * @param id defines the skeleton Id
  6660. * @param scene defines the hosting scene
  6661. */
  6662. constructor(
  6663. /** defines the skeleton name */
  6664. name: string,
  6665. /** defines the skeleton Id */
  6666. id: string, scene: Scene);
  6667. /**
  6668. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  6669. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  6670. * @returns a Float32Array containing matrices data
  6671. */
  6672. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  6673. /**
  6674. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  6675. * @returns a raw texture containing the data
  6676. */
  6677. getTransformMatrixTexture(): Nullable<RawTexture>;
  6678. /**
  6679. * Gets the current hosting scene
  6680. * @returns a scene object
  6681. */
  6682. getScene(): Scene;
  6683. /**
  6684. * Gets a string representing the current skeleton data
  6685. * @param fullDetails defines a boolean indicating if we want a verbose version
  6686. * @returns a string representing the current skeleton data
  6687. */
  6688. toString(fullDetails?: boolean): string;
  6689. /**
  6690. * Get bone's index searching by name
  6691. * @param name defines bone's name to search for
  6692. * @return the indice of the bone. Returns -1 if not found
  6693. */
  6694. getBoneIndexByName(name: string): number;
  6695. /**
  6696. * Creater a new animation range
  6697. * @param name defines the name of the range
  6698. * @param from defines the start key
  6699. * @param to defines the end key
  6700. */
  6701. createAnimationRange(name: string, from: number, to: number): void;
  6702. /**
  6703. * Delete a specific animation range
  6704. * @param name defines the name of the range
  6705. * @param deleteFrames defines if frames must be removed as well
  6706. */
  6707. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  6708. /**
  6709. * Gets a specific animation range
  6710. * @param name defines the name of the range to look for
  6711. * @returns the requested animation range or null if not found
  6712. */
  6713. getAnimationRange(name: string): Nullable<AnimationRange>;
  6714. /**
  6715. * Gets the list of all animation ranges defined on this skeleton
  6716. * @returns an array
  6717. */
  6718. getAnimationRanges(): Nullable<AnimationRange>[];
  6719. /**
  6720. * Copy animation range from a source skeleton.
  6721. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  6722. * @param source defines the source skeleton
  6723. * @param name defines the name of the range to copy
  6724. * @param rescaleAsRequired defines if rescaling must be applied if required
  6725. * @returns true if operation was successful
  6726. */
  6727. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  6728. /**
  6729. * Forces the skeleton to go to rest pose
  6730. */
  6731. returnToRest(): void;
  6732. private _getHighestAnimationFrame;
  6733. /**
  6734. * Begin a specific animation range
  6735. * @param name defines the name of the range to start
  6736. * @param loop defines if looping must be turned on (false by default)
  6737. * @param speedRatio defines the speed ratio to apply (1 by default)
  6738. * @param onAnimationEnd defines a callback which will be called when animation will end
  6739. * @returns a new animatable
  6740. */
  6741. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  6742. /** @hidden */
  6743. _markAsDirty(): void;
  6744. /** @hidden */
  6745. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  6746. /** @hidden */
  6747. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  6748. private _computeTransformMatrices;
  6749. /**
  6750. * Build all resources required to render a skeleton
  6751. */
  6752. prepare(): void;
  6753. /**
  6754. * Gets the list of animatables currently running for this skeleton
  6755. * @returns an array of animatables
  6756. */
  6757. getAnimatables(): IAnimatable[];
  6758. /**
  6759. * Clone the current skeleton
  6760. * @param name defines the name of the new skeleton
  6761. * @param id defines the id of the enw skeleton
  6762. * @returns the new skeleton
  6763. */
  6764. clone(name: string, id: string): Skeleton;
  6765. /**
  6766. * Enable animation blending for this skeleton
  6767. * @param blendingSpeed defines the blending speed to apply
  6768. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  6769. */
  6770. enableBlending(blendingSpeed?: number): void;
  6771. /**
  6772. * Releases all resources associated with the current skeleton
  6773. */
  6774. dispose(): void;
  6775. /**
  6776. * Serialize the skeleton in a JSON object
  6777. * @returns a JSON object
  6778. */
  6779. serialize(): any;
  6780. /**
  6781. * Creates a new skeleton from serialized data
  6782. * @param parsedSkeleton defines the serialized data
  6783. * @param scene defines the hosting scene
  6784. * @returns a new skeleton
  6785. */
  6786. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  6787. /**
  6788. * Compute all node absolute transforms
  6789. * @param forceUpdate defines if computation must be done even if cache is up to date
  6790. */
  6791. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  6792. /**
  6793. * Gets the root pose matrix
  6794. * @returns a matrix
  6795. */
  6796. getPoseMatrix(): Nullable<Matrix>;
  6797. /**
  6798. * Sorts bones per internal index
  6799. */
  6800. sortBones(): void;
  6801. private _sortBones;
  6802. }
  6803. }
  6804. declare module BABYLON {
  6805. /**
  6806. * Class used to store bounding box information
  6807. */
  6808. class BoundingBox implements ICullable {
  6809. /**
  6810. * Gets the 8 vectors representing the bounding box in local space
  6811. */
  6812. readonly vectors: Vector3[];
  6813. /**
  6814. * Gets the center of the bounding box in local space
  6815. */
  6816. readonly center: Vector3;
  6817. /**
  6818. * Gets the center of the bounding box in world space
  6819. */
  6820. readonly centerWorld: Vector3;
  6821. /**
  6822. * Gets the extend size in local space
  6823. */
  6824. readonly extendSize: Vector3;
  6825. /**
  6826. * Gets the extend size in world space
  6827. */
  6828. readonly extendSizeWorld: Vector3;
  6829. /**
  6830. * Gets the OBB (object bounding box) directions
  6831. */
  6832. readonly directions: Vector3[];
  6833. /**
  6834. * Gets the 8 vectors representing the bounding box in world space
  6835. */
  6836. readonly vectorsWorld: Vector3[];
  6837. /**
  6838. * Gets the minimum vector in world space
  6839. */
  6840. readonly minimumWorld: Vector3;
  6841. /**
  6842. * Gets the maximum vector in world space
  6843. */
  6844. readonly maximumWorld: Vector3;
  6845. /**
  6846. * Gets the minimum vector in local space
  6847. */
  6848. readonly minimum: Vector3;
  6849. /**
  6850. * Gets the maximum vector in local space
  6851. */
  6852. readonly maximum: Vector3;
  6853. private _worldMatrix;
  6854. private static readonly TmpVector3;
  6855. /**
  6856. * @hidden
  6857. */
  6858. _tag: number;
  6859. /**
  6860. * Creates a new bounding box
  6861. * @param min defines the minimum vector (in local space)
  6862. * @param max defines the maximum vector (in local space)
  6863. * @param worldMatrix defines the new world matrix
  6864. */
  6865. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6866. /**
  6867. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6868. * @param min defines the new minimum vector (in local space)
  6869. * @param max defines the new maximum vector (in local space)
  6870. * @param worldMatrix defines the new world matrix
  6871. */
  6872. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6873. /**
  6874. * Scale the current bounding box by applying a scale factor
  6875. * @param factor defines the scale factor to apply
  6876. * @returns the current bounding box
  6877. */
  6878. scale(factor: number): BoundingBox;
  6879. /**
  6880. * Gets the world matrix of the bounding box
  6881. * @returns a matrix
  6882. */
  6883. getWorldMatrix(): DeepImmutable<Matrix>;
  6884. /** @hidden */
  6885. _update(world: DeepImmutable<Matrix>): void;
  6886. /**
  6887. * Tests if the bounding box is intersecting the frustum planes
  6888. * @param frustumPlanes defines the frustum planes to test
  6889. * @returns true if there is an intersection
  6890. */
  6891. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6892. /**
  6893. * Tests if the bounding box is entirely inside the frustum planes
  6894. * @param frustumPlanes defines the frustum planes to test
  6895. * @returns true if there is an inclusion
  6896. */
  6897. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6898. /**
  6899. * Tests if a point is inside the bounding box
  6900. * @param point defines the point to test
  6901. * @returns true if the point is inside the bounding box
  6902. */
  6903. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6904. /**
  6905. * Tests if the bounding box intersects with a bounding sphere
  6906. * @param sphere defines the sphere to test
  6907. * @returns true if there is an intersection
  6908. */
  6909. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6910. /**
  6911. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6912. * @param min defines the min vector to use
  6913. * @param max defines the max vector to use
  6914. * @returns true if there is an intersection
  6915. */
  6916. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6917. /**
  6918. * Tests if two bounding boxes are intersections
  6919. * @param box0 defines the first box to test
  6920. * @param box1 defines the second box to test
  6921. * @returns true if there is an intersection
  6922. */
  6923. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6924. /**
  6925. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6926. * @param minPoint defines the minimum vector of the bounding box
  6927. * @param maxPoint defines the maximum vector of the bounding box
  6928. * @param sphereCenter defines the sphere center
  6929. * @param sphereRadius defines the sphere radius
  6930. * @returns true if there is an intersection
  6931. */
  6932. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6933. /**
  6934. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6935. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6936. * @param frustumPlanes defines the frustum planes to test
  6937. * @return true if there is an inclusion
  6938. */
  6939. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6940. /**
  6941. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6942. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6943. * @param frustumPlanes defines the frustum planes to test
  6944. * @return true if there is an intersection
  6945. */
  6946. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6947. }
  6948. }
  6949. declare module BABYLON {
  6950. /**
  6951. * Interface for cullable objects
  6952. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  6953. */
  6954. interface ICullable {
  6955. /**
  6956. * Checks if the object or part of the object is in the frustum
  6957. * @param frustumPlanes Camera near/planes
  6958. * @returns true if the object is in frustum otherwise false
  6959. */
  6960. isInFrustum(frustumPlanes: Plane[]): boolean;
  6961. /**
  6962. * Checks if a cullable object (mesh...) is in the camera frustum
  6963. * Unlike isInFrustum this cheks the full bounding box
  6964. * @param frustumPlanes Camera near/planes
  6965. * @returns true if the object is in frustum otherwise false
  6966. */
  6967. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6968. }
  6969. /**
  6970. * Info for a bounding data of a mesh
  6971. */
  6972. class BoundingInfo implements ICullable {
  6973. /**
  6974. * Bounding box for the mesh
  6975. */
  6976. readonly boundingBox: BoundingBox;
  6977. /**
  6978. * Bounding sphere for the mesh
  6979. */
  6980. readonly boundingSphere: BoundingSphere;
  6981. private _isLocked;
  6982. private static readonly TmpVector3;
  6983. /**
  6984. * Constructs bounding info
  6985. * @param minimum min vector of the bounding box/sphere
  6986. * @param maximum max vector of the bounding box/sphere
  6987. * @param worldMatrix defines the new world matrix
  6988. */
  6989. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6990. /**
  6991. * Recreates the entire bounding info from scratch as if we call the constructor in place
  6992. * @param min defines the new minimum vector (in local space)
  6993. * @param max defines the new maximum vector (in local space)
  6994. * @param worldMatrix defines the new world matrix
  6995. */
  6996. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6997. /**
  6998. * min vector of the bounding box/sphere
  6999. */
  7000. readonly minimum: Vector3;
  7001. /**
  7002. * max vector of the bounding box/sphere
  7003. */
  7004. readonly maximum: Vector3;
  7005. /**
  7006. * If the info is locked and won't be updated to avoid perf overhead
  7007. */
  7008. isLocked: boolean;
  7009. /**
  7010. * Updates the bounding sphere and box
  7011. * @param world world matrix to be used to update
  7012. */
  7013. update(world: DeepImmutable<Matrix>): void;
  7014. /**
  7015. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7016. * @param center New center of the bounding info
  7017. * @param extend New extend of the bounding info
  7018. * @returns the current bounding info
  7019. */
  7020. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7021. /**
  7022. * Scale the current bounding info by applying a scale factor
  7023. * @param factor defines the scale factor to apply
  7024. * @returns the current bounding info
  7025. */
  7026. scale(factor: number): BoundingInfo;
  7027. /**
  7028. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7029. * @param frustumPlanes defines the frustum to test
  7030. * @param strategy defines the strategy to use for the culling (default is BABYLON.Scene.CULLINGSTRATEGY_STANDARD)
  7031. * @returns true if the bounding info is in the frustum planes
  7032. */
  7033. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7034. /**
  7035. * Gets the world distance between the min and max points of the bounding box
  7036. */
  7037. readonly diagonalLength: number;
  7038. /**
  7039. * Checks if a cullable object (mesh...) is in the camera frustum
  7040. * Unlike isInFrustum this cheks the full bounding box
  7041. * @param frustumPlanes Camera near/planes
  7042. * @returns true if the object is in frustum otherwise false
  7043. */
  7044. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7045. /** @hidden */
  7046. _checkCollision(collider: Collider): boolean;
  7047. /**
  7048. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7049. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7050. * @param point the point to check intersection with
  7051. * @returns if the point intersects
  7052. */
  7053. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7054. /**
  7055. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7056. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7057. * @param boundingInfo the bounding info to check intersection with
  7058. * @param precise if the intersection should be done using OBB
  7059. * @returns if the bounding info intersects
  7060. */
  7061. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7062. }
  7063. }
  7064. declare module BABYLON {
  7065. /**
  7066. * Class used to store bounding sphere information
  7067. */
  7068. class BoundingSphere {
  7069. /**
  7070. * Gets the center of the bounding sphere in local space
  7071. */
  7072. readonly center: Vector3;
  7073. /**
  7074. * Radius of the bounding sphere in local space
  7075. */
  7076. radius: number;
  7077. /**
  7078. * Gets the center of the bounding sphere in world space
  7079. */
  7080. readonly centerWorld: Vector3;
  7081. /**
  7082. * Radius of the bounding sphere in world space
  7083. */
  7084. radiusWorld: number;
  7085. /**
  7086. * Gets the minimum vector in local space
  7087. */
  7088. readonly minimum: Vector3;
  7089. /**
  7090. * Gets the maximum vector in local space
  7091. */
  7092. readonly maximum: Vector3;
  7093. private _worldMatrix;
  7094. private static readonly TmpVector3;
  7095. /**
  7096. * Creates a new bounding sphere
  7097. * @param min defines the minimum vector (in local space)
  7098. * @param max defines the maximum vector (in local space)
  7099. * @param worldMatrix defines the new world matrix
  7100. */
  7101. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7102. /**
  7103. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  7104. * @param min defines the new minimum vector (in local space)
  7105. * @param max defines the new maximum vector (in local space)
  7106. * @param worldMatrix defines the new world matrix
  7107. */
  7108. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7109. /**
  7110. * Scale the current bounding sphere by applying a scale factor
  7111. * @param factor defines the scale factor to apply
  7112. * @returns the current bounding box
  7113. */
  7114. scale(factor: number): BoundingSphere;
  7115. /**
  7116. * Gets the world matrix of the bounding box
  7117. * @returns a matrix
  7118. */
  7119. getWorldMatrix(): DeepImmutable<Matrix>;
  7120. /** @hidden */
  7121. _update(worldMatrix: DeepImmutable<Matrix>): void;
  7122. /**
  7123. * Tests if the bounding sphere is intersecting the frustum planes
  7124. * @param frustumPlanes defines the frustum planes to test
  7125. * @returns true if there is an intersection
  7126. */
  7127. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7128. /**
  7129. * Tests if a point is inside the bounding sphere
  7130. * @param point defines the point to test
  7131. * @returns true if the point is inside the bounding sphere
  7132. */
  7133. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7134. /**
  7135. * Checks if two sphere intersct
  7136. * @param sphere0 sphere 0
  7137. * @param sphere1 sphere 1
  7138. * @returns true if the speres intersect
  7139. */
  7140. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7141. }
  7142. }
  7143. declare module BABYLON {
  7144. /**
  7145. * Class representing a ray with position and direction
  7146. */
  7147. class Ray {
  7148. /** origin point */
  7149. origin: Vector3;
  7150. /** direction */
  7151. direction: Vector3;
  7152. /** length of the ray */
  7153. length: number;
  7154. private static readonly TmpVector3;
  7155. private _tmpRay;
  7156. /**
  7157. * Creates a new ray
  7158. * @param origin origin point
  7159. * @param direction direction
  7160. * @param length length of the ray
  7161. */
  7162. constructor(
  7163. /** origin point */
  7164. origin: Vector3,
  7165. /** direction */
  7166. direction: Vector3,
  7167. /** length of the ray */
  7168. length?: number);
  7169. /**
  7170. * Checks if the ray intersects a box
  7171. * @param minimum bound of the box
  7172. * @param maximum bound of the box
  7173. * @param intersectionTreshold extra extend to be added to the box in all direction
  7174. * @returns if the box was hit
  7175. */
  7176. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  7177. /**
  7178. * Checks if the ray intersects a box
  7179. * @param box the bounding box to check
  7180. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  7181. * @returns if the box was hit
  7182. */
  7183. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  7184. /**
  7185. * If the ray hits a sphere
  7186. * @param sphere the bounding sphere to check
  7187. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  7188. * @returns true if it hits the sphere
  7189. */
  7190. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  7191. /**
  7192. * If the ray hits a triange
  7193. * @param vertex0 triangle vertex
  7194. * @param vertex1 triangle vertex
  7195. * @param vertex2 triangle vertex
  7196. * @returns intersection information if hit
  7197. */
  7198. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  7199. /**
  7200. * Checks if ray intersects a plane
  7201. * @param plane the plane to check
  7202. * @returns the distance away it was hit
  7203. */
  7204. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  7205. /**
  7206. * Checks if ray intersects a mesh
  7207. * @param mesh the mesh to check
  7208. * @param fastCheck if only the bounding box should checked
  7209. * @returns picking info of the intersecton
  7210. */
  7211. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  7212. /**
  7213. * Checks if ray intersects a mesh
  7214. * @param meshes the meshes to check
  7215. * @param fastCheck if only the bounding box should checked
  7216. * @param results array to store result in
  7217. * @returns Array of picking infos
  7218. */
  7219. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  7220. private _comparePickingInfo;
  7221. private static smallnum;
  7222. private static rayl;
  7223. /**
  7224. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  7225. * @param sega the first point of the segment to test the intersection against
  7226. * @param segb the second point of the segment to test the intersection against
  7227. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  7228. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  7229. */
  7230. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  7231. /**
  7232. * Update the ray from viewport position
  7233. * @param x position
  7234. * @param y y position
  7235. * @param viewportWidth viewport width
  7236. * @param viewportHeight viewport height
  7237. * @param world world matrix
  7238. * @param view view matrix
  7239. * @param projection projection matrix
  7240. * @returns this ray updated
  7241. */
  7242. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  7243. /**
  7244. * Creates a ray with origin and direction of 0,0,0
  7245. * @returns the new ray
  7246. */
  7247. static Zero(): Ray;
  7248. /**
  7249. * Creates a new ray from screen space and viewport
  7250. * @param x position
  7251. * @param y y position
  7252. * @param viewportWidth viewport width
  7253. * @param viewportHeight viewport height
  7254. * @param world world matrix
  7255. * @param view view matrix
  7256. * @param projection projection matrix
  7257. * @returns new ray
  7258. */
  7259. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  7260. /**
  7261. * 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
  7262. * transformed to the given world matrix.
  7263. * @param origin The origin point
  7264. * @param end The end point
  7265. * @param world a matrix to transform the ray to. Default is the identity matrix.
  7266. * @returns the new ray
  7267. */
  7268. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  7269. /**
  7270. * Transforms a ray by a matrix
  7271. * @param ray ray to transform
  7272. * @param matrix matrix to apply
  7273. * @returns the resulting new ray
  7274. */
  7275. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  7276. /**
  7277. * Transforms a ray by a matrix
  7278. * @param ray ray to transform
  7279. * @param matrix matrix to apply
  7280. * @param result ray to store result in
  7281. */
  7282. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  7283. }
  7284. }
  7285. declare module BABYLON {
  7286. /**
  7287. * This represents an orbital type of camera.
  7288. *
  7289. * 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.
  7290. * 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.
  7291. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  7292. */
  7293. class ArcRotateCamera extends TargetCamera {
  7294. /**
  7295. * Defines the rotation angle of the camera along the longitudinal axis.
  7296. */
  7297. alpha: number;
  7298. /**
  7299. * Defines the rotation angle of the camera along the latitudinal axis.
  7300. */
  7301. beta: number;
  7302. /**
  7303. * Defines the radius of the camera from it s target point.
  7304. */
  7305. radius: number;
  7306. protected _target: Vector3;
  7307. protected _targetHost: Nullable<AbstractMesh>;
  7308. /**
  7309. * Defines the target point of the camera.
  7310. * The camera looks towards it form the radius distance.
  7311. */
  7312. target: Vector3;
  7313. /**
  7314. * Current inertia value on the longitudinal axis.
  7315. * The bigger this number the longer it will take for the camera to stop.
  7316. */
  7317. inertialAlphaOffset: number;
  7318. /**
  7319. * Current inertia value on the latitudinal axis.
  7320. * The bigger this number the longer it will take for the camera to stop.
  7321. */
  7322. inertialBetaOffset: number;
  7323. /**
  7324. * Current inertia value on the radius axis.
  7325. * The bigger this number the longer it will take for the camera to stop.
  7326. */
  7327. inertialRadiusOffset: number;
  7328. /**
  7329. * Minimum allowed angle on the longitudinal axis.
  7330. * This can help limiting how the Camera is able to move in the scene.
  7331. */
  7332. lowerAlphaLimit: Nullable<number>;
  7333. /**
  7334. * Maximum allowed angle on the longitudinal axis.
  7335. * This can help limiting how the Camera is able to move in the scene.
  7336. */
  7337. upperAlphaLimit: Nullable<number>;
  7338. /**
  7339. * Minimum allowed angle on the latitudinal axis.
  7340. * This can help limiting how the Camera is able to move in the scene.
  7341. */
  7342. lowerBetaLimit: number;
  7343. /**
  7344. * Maximum allowed angle on the latitudinal axis.
  7345. * This can help limiting how the Camera is able to move in the scene.
  7346. */
  7347. upperBetaLimit: number;
  7348. /**
  7349. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  7350. * This can help limiting how the Camera is able to move in the scene.
  7351. */
  7352. lowerRadiusLimit: Nullable<number>;
  7353. /**
  7354. * Maximum allowed distance of the camera to the target (The camera can not get further).
  7355. * This can help limiting how the Camera is able to move in the scene.
  7356. */
  7357. upperRadiusLimit: Nullable<number>;
  7358. /**
  7359. * Defines the current inertia value used during panning of the camera along the X axis.
  7360. */
  7361. inertialPanningX: number;
  7362. /**
  7363. * Defines the current inertia value used during panning of the camera along the Y axis.
  7364. */
  7365. inertialPanningY: number;
  7366. /**
  7367. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  7368. * Basically if your fingers moves away from more than this distance you will be considered
  7369. * in pinch mode.
  7370. */
  7371. pinchToPanMaxDistance: number;
  7372. /**
  7373. * Defines the maximum distance the camera can pan.
  7374. * This could help keeping the cammera always in your scene.
  7375. */
  7376. panningDistanceLimit: Nullable<number>;
  7377. /**
  7378. * Defines the target of the camera before paning.
  7379. */
  7380. panningOriginTarget: Vector3;
  7381. /**
  7382. * Defines the value of the inertia used during panning.
  7383. * 0 would mean stop inertia and one would mean no decelleration at all.
  7384. */
  7385. panningInertia: number;
  7386. /**
  7387. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  7388. */
  7389. angularSensibilityX: number;
  7390. /**
  7391. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  7392. */
  7393. angularSensibilityY: number;
  7394. /**
  7395. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  7396. */
  7397. pinchPrecision: number;
  7398. /**
  7399. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  7400. * It will be used instead of pinchDeltaPrecision if different from 0.
  7401. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  7402. */
  7403. pinchDeltaPercentage: number;
  7404. /**
  7405. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  7406. */
  7407. panningSensibility: number;
  7408. /**
  7409. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  7410. */
  7411. keysUp: number[];
  7412. /**
  7413. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  7414. */
  7415. keysDown: number[];
  7416. /**
  7417. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  7418. */
  7419. keysLeft: number[];
  7420. /**
  7421. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  7422. */
  7423. keysRight: number[];
  7424. /**
  7425. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  7426. */
  7427. wheelPrecision: number;
  7428. /**
  7429. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  7430. * It will be used instead of pinchDeltaPrecision if different from 0.
  7431. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  7432. */
  7433. wheelDeltaPercentage: number;
  7434. /**
  7435. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  7436. */
  7437. zoomOnFactor: number;
  7438. /**
  7439. * Defines a screen offset for the camera position.
  7440. */
  7441. targetScreenOffset: Vector2;
  7442. /**
  7443. * Allows the camera to be completely reversed.
  7444. * If false the camera can not arrive upside down.
  7445. */
  7446. allowUpsideDown: boolean;
  7447. /**
  7448. * Define if double tap/click is used to restore the previously saved state of the camera.
  7449. */
  7450. useInputToRestoreState: boolean;
  7451. /** @hidden */
  7452. _viewMatrix: Matrix;
  7453. /** @hidden */
  7454. _useCtrlForPanning: boolean;
  7455. /** @hidden */
  7456. _panningMouseButton: number;
  7457. /**
  7458. * Defines the inpute associated to the camera.
  7459. */
  7460. inputs: ArcRotateCameraInputsManager;
  7461. /** @hidden */
  7462. _reset: () => void;
  7463. /**
  7464. * Defines the allowed panning axis.
  7465. */
  7466. panningAxis: Vector3;
  7467. protected _localDirection: Vector3;
  7468. protected _transformedDirection: Vector3;
  7469. private _bouncingBehavior;
  7470. /**
  7471. * Gets the bouncing behavior of the camera if it has been enabled.
  7472. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  7473. */
  7474. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  7475. /**
  7476. * Defines if the bouncing behavior of the camera is enabled on the camera.
  7477. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  7478. */
  7479. useBouncingBehavior: boolean;
  7480. private _framingBehavior;
  7481. /**
  7482. * Gets the framing behavior of the camera if it has been enabled.
  7483. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  7484. */
  7485. readonly framingBehavior: Nullable<FramingBehavior>;
  7486. /**
  7487. * Defines if the framing behavior of the camera is enabled on the camera.
  7488. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  7489. */
  7490. useFramingBehavior: boolean;
  7491. private _autoRotationBehavior;
  7492. /**
  7493. * Gets the auto rotation behavior of the camera if it has been enabled.
  7494. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  7495. */
  7496. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  7497. /**
  7498. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  7499. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  7500. */
  7501. useAutoRotationBehavior: boolean;
  7502. /**
  7503. * Observable triggered when the mesh target has been changed on the camera.
  7504. */
  7505. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  7506. /**
  7507. * Event raised when the camera is colliding with a mesh.
  7508. */
  7509. onCollide: (collidedMesh: AbstractMesh) => void;
  7510. /**
  7511. * Defines whether the camera should check collision with the objects oh the scene.
  7512. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  7513. */
  7514. checkCollisions: boolean;
  7515. /**
  7516. * Defines the collision radius of the camera.
  7517. * This simulates a sphere around the camera.
  7518. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  7519. */
  7520. collisionRadius: Vector3;
  7521. protected _collider: Collider;
  7522. protected _previousPosition: Vector3;
  7523. protected _collisionVelocity: Vector3;
  7524. protected _newPosition: Vector3;
  7525. protected _previousAlpha: number;
  7526. protected _previousBeta: number;
  7527. protected _previousRadius: number;
  7528. protected _collisionTriggered: boolean;
  7529. protected _targetBoundingCenter: Nullable<Vector3>;
  7530. private _computationVector;
  7531. private _tempAxisVector;
  7532. private _tempAxisRotationMatrix;
  7533. /**
  7534. * Instantiates a new ArcRotateCamera in a given scene
  7535. * @param name Defines the name of the camera
  7536. * @param alpha Defines the camera rotation along the logitudinal axis
  7537. * @param beta Defines the camera rotation along the latitudinal axis
  7538. * @param radius Defines the camera distance from its target
  7539. * @param target Defines the camera target
  7540. * @param scene Defines the scene the camera belongs to
  7541. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  7542. */
  7543. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  7544. /** @hidden */
  7545. _initCache(): void;
  7546. /** @hidden */
  7547. _updateCache(ignoreParentClass?: boolean): void;
  7548. protected _getTargetPosition(): Vector3;
  7549. private _storedAlpha;
  7550. private _storedBeta;
  7551. private _storedRadius;
  7552. private _storedTarget;
  7553. /**
  7554. * Stores the current state of the camera (alpha, beta, radius and target)
  7555. * @returns the camera itself
  7556. */
  7557. storeState(): Camera;
  7558. /**
  7559. * @hidden
  7560. * Restored camera state. You must call storeState() first
  7561. */
  7562. _restoreStateValues(): boolean;
  7563. /** @hidden */
  7564. _isSynchronizedViewMatrix(): boolean;
  7565. /**
  7566. * Attached controls to the current camera.
  7567. * @param element Defines the element the controls should be listened from
  7568. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7569. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  7570. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  7571. */
  7572. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  7573. /**
  7574. * Detach the current controls from the camera.
  7575. * The camera will stop reacting to inputs.
  7576. * @param element Defines the element to stop listening the inputs from
  7577. */
  7578. detachControl(element: HTMLElement): void;
  7579. /** @hidden */
  7580. _checkInputs(): void;
  7581. protected _checkLimits(): void;
  7582. /**
  7583. * Rebuilds angles (alpha, beta) and radius from the give position and target.
  7584. */
  7585. rebuildAnglesAndRadius(): void;
  7586. /**
  7587. * Use a position to define the current camera related information like aplha, beta and radius
  7588. * @param position Defines the position to set the camera at
  7589. */
  7590. setPosition(position: Vector3): void;
  7591. /**
  7592. * Defines the target the camera should look at.
  7593. * This will automatically adapt alpha beta and radius to fit within the new target.
  7594. * @param target Defines the new target as a Vector or a mesh
  7595. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  7596. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  7597. */
  7598. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  7599. /** @hidden */
  7600. _getViewMatrix(): Matrix;
  7601. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  7602. /**
  7603. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  7604. * @param meshes Defines the mesh to zoom on
  7605. * @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)
  7606. */
  7607. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  7608. /**
  7609. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  7610. * The target will be changed but the radius
  7611. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  7612. * @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)
  7613. */
  7614. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  7615. min: Vector3;
  7616. max: Vector3;
  7617. distance: number;
  7618. }, doNotUpdateMaxZ?: boolean): void;
  7619. /**
  7620. * @override
  7621. * Override Camera.createRigCamera
  7622. */
  7623. createRigCamera(name: string, cameraIndex: number): Camera;
  7624. /**
  7625. * @hidden
  7626. * @override
  7627. * Override Camera._updateRigCameras
  7628. */
  7629. _updateRigCameras(): void;
  7630. /**
  7631. * Destroy the camera and release the current resources hold by it.
  7632. */
  7633. dispose(): void;
  7634. /**
  7635. * Gets the current object class name.
  7636. * @return the class name
  7637. */
  7638. getClassName(): string;
  7639. }
  7640. }
  7641. declare module BABYLON {
  7642. /**
  7643. * Default Inputs manager for the ArcRotateCamera.
  7644. * It groups all the default supported inputs for ease of use.
  7645. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  7646. */
  7647. class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  7648. /**
  7649. * Instantiates a new ArcRotateCameraInputsManager.
  7650. * @param camera Defines the camera the inputs belong to
  7651. */
  7652. constructor(camera: ArcRotateCamera);
  7653. /**
  7654. * Add mouse wheel input support to the input manager.
  7655. * @returns the current input manager
  7656. */
  7657. addMouseWheel(): ArcRotateCameraInputsManager;
  7658. /**
  7659. * Add pointers input support to the input manager.
  7660. * @returns the current input manager
  7661. */
  7662. addPointers(): ArcRotateCameraInputsManager;
  7663. /**
  7664. * Add keyboard input support to the input manager.
  7665. * @returns the current input manager
  7666. */
  7667. addKeyboard(): ArcRotateCameraInputsManager;
  7668. /**
  7669. * Add orientation input support to the input manager.
  7670. * @returns the current input manager
  7671. */
  7672. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  7673. }
  7674. }
  7675. declare module BABYLON {
  7676. /**
  7677. * This is the base class of all the camera used in the application.
  7678. * @see http://doc.babylonjs.com/features/cameras
  7679. */
  7680. class Camera extends Node {
  7681. /**
  7682. * This is the default projection mode used by the cameras.
  7683. * It helps recreating a feeling of perspective and better appreciate depth.
  7684. * This is the best way to simulate real life cameras.
  7685. */
  7686. static readonly PERSPECTIVE_CAMERA: number;
  7687. /**
  7688. * This helps creating camera with an orthographic mode.
  7689. * 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.
  7690. */
  7691. static readonly ORTHOGRAPHIC_CAMERA: number;
  7692. /**
  7693. * This is the default FOV mode for perspective cameras.
  7694. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  7695. */
  7696. static readonly FOVMODE_VERTICAL_FIXED: number;
  7697. /**
  7698. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  7699. */
  7700. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  7701. /**
  7702. * This specifies ther is no need for a camera rig.
  7703. * Basically only one eye is rendered corresponding to the camera.
  7704. */
  7705. static readonly RIG_MODE_NONE: number;
  7706. /**
  7707. * Simulates a camera Rig with one blue eye and one red eye.
  7708. * This can be use with 3d blue and red glasses.
  7709. */
  7710. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  7711. /**
  7712. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  7713. */
  7714. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  7715. /**
  7716. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  7717. */
  7718. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  7719. /**
  7720. * Defines that both eyes of the camera will be rendered over under each other.
  7721. */
  7722. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  7723. /**
  7724. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  7725. */
  7726. static readonly RIG_MODE_VR: number;
  7727. /**
  7728. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  7729. */
  7730. static readonly RIG_MODE_WEBVR: number;
  7731. /**
  7732. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  7733. */
  7734. static readonly RIG_MODE_CUSTOM: number;
  7735. /**
  7736. * Defines if by default attaching controls should prevent the default javascript event to continue.
  7737. */
  7738. static ForceAttachControlToAlwaysPreventDefault: boolean;
  7739. /**
  7740. * @hidden
  7741. * Might be removed once multiview will be a thing
  7742. */
  7743. static UseAlternateWebVRRendering: boolean;
  7744. /**
  7745. * Define the input manager associated with the camera.
  7746. */
  7747. inputs: CameraInputsManager<Camera>;
  7748. /**
  7749. * Define the current local position of the camera in the scene
  7750. */
  7751. position: Vector3;
  7752. /**
  7753. * The vector the camera should consider as up.
  7754. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  7755. */
  7756. upVector: Vector3;
  7757. /**
  7758. * Define the current limit on the left side for an orthographic camera
  7759. * In scene unit
  7760. */
  7761. orthoLeft: Nullable<number>;
  7762. /**
  7763. * Define the current limit on the right side for an orthographic camera
  7764. * In scene unit
  7765. */
  7766. orthoRight: Nullable<number>;
  7767. /**
  7768. * Define the current limit on the bottom side for an orthographic camera
  7769. * In scene unit
  7770. */
  7771. orthoBottom: Nullable<number>;
  7772. /**
  7773. * Define the current limit on the top side for an orthographic camera
  7774. * In scene unit
  7775. */
  7776. orthoTop: Nullable<number>;
  7777. /**
  7778. * Field Of View is set in Radians. (default is 0.8)
  7779. */
  7780. fov: number;
  7781. /**
  7782. * Define the minimum distance the camera can see from.
  7783. * This is important to note that the depth buffer are not infinite and the closer it starts
  7784. * the more your scene might encounter depth fighting issue.
  7785. */
  7786. minZ: number;
  7787. /**
  7788. * Define the maximum distance the camera can see to.
  7789. * This is important to note that the depth buffer are not infinite and the further it end
  7790. * the more your scene might encounter depth fighting issue.
  7791. */
  7792. maxZ: number;
  7793. /**
  7794. * Define the default inertia of the camera.
  7795. * This helps giving a smooth feeling to the camera movement.
  7796. */
  7797. inertia: number;
  7798. /**
  7799. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  7800. */
  7801. mode: number;
  7802. /**
  7803. * Define wether the camera is intermediate.
  7804. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  7805. */
  7806. isIntermediate: boolean;
  7807. /**
  7808. * Define the viewport of the camera.
  7809. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  7810. */
  7811. viewport: Viewport;
  7812. /**
  7813. * Restricts the camera to viewing objects with the same layerMask.
  7814. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  7815. */
  7816. layerMask: number;
  7817. /**
  7818. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  7819. */
  7820. fovMode: number;
  7821. /**
  7822. * Rig mode of the camera.
  7823. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  7824. * This is normally controlled byt the camera themselves as internal use.
  7825. */
  7826. cameraRigMode: number;
  7827. /**
  7828. * Defines the distance between both "eyes" in case of a RIG
  7829. */
  7830. interaxialDistance: number;
  7831. /**
  7832. * Defines if stereoscopic rendering is done side by side or over under.
  7833. */
  7834. isStereoscopicSideBySide: boolean;
  7835. /**
  7836. * 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
  7837. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  7838. * else in the scene.
  7839. */
  7840. customRenderTargets: RenderTargetTexture[];
  7841. /**
  7842. * When set, the camera will render to this render target instead of the default canvas
  7843. */
  7844. outputRenderTarget: Nullable<RenderTargetTexture>;
  7845. /**
  7846. * Observable triggered when the camera view matrix has changed.
  7847. */
  7848. onViewMatrixChangedObservable: Observable<Camera>;
  7849. /**
  7850. * Observable triggered when the camera Projection matrix has changed.
  7851. */
  7852. onProjectionMatrixChangedObservable: Observable<Camera>;
  7853. /**
  7854. * Observable triggered when the inputs have been processed.
  7855. */
  7856. onAfterCheckInputsObservable: Observable<Camera>;
  7857. /**
  7858. * Observable triggered when reset has been called and applied to the camera.
  7859. */
  7860. onRestoreStateObservable: Observable<Camera>;
  7861. /** @hidden */
  7862. _cameraRigParams: any;
  7863. /** @hidden */
  7864. _rigCameras: Camera[];
  7865. /** @hidden */
  7866. _rigPostProcess: Nullable<PostProcess>;
  7867. protected _webvrViewMatrix: Matrix;
  7868. /** @hidden */
  7869. _skipRendering: boolean;
  7870. /** @hidden */
  7871. _alternateCamera: Camera;
  7872. /** @hidden */
  7873. _projectionMatrix: Matrix;
  7874. /** @hidden */
  7875. _postProcesses: Nullable<PostProcess>[];
  7876. /** @hidden */
  7877. _activeMeshes: SmartArray<AbstractMesh>;
  7878. protected _globalPosition: Vector3;
  7879. /** hidden */
  7880. _computedViewMatrix: Matrix;
  7881. private _doNotComputeProjectionMatrix;
  7882. private _transformMatrix;
  7883. private _frustumPlanes;
  7884. private _refreshFrustumPlanes;
  7885. private _storedFov;
  7886. private _stateStored;
  7887. /**
  7888. * Instantiates a new camera object.
  7889. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  7890. * @see http://doc.babylonjs.com/features/cameras
  7891. * @param name Defines the name of the camera in the scene
  7892. * @param position Defines the position of the camera
  7893. * @param scene Defines the scene the camera belongs too
  7894. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  7895. */
  7896. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  7897. /**
  7898. * Store current camera state (fov, position, etc..)
  7899. * @returns the camera
  7900. */
  7901. storeState(): Camera;
  7902. /**
  7903. * Restores the camera state values if it has been stored. You must call storeState() first
  7904. */
  7905. protected _restoreStateValues(): boolean;
  7906. /**
  7907. * Restored camera state. You must call storeState() first.
  7908. * @returns true if restored and false otherwise
  7909. */
  7910. restoreState(): boolean;
  7911. /**
  7912. * Gets the class name of the camera.
  7913. * @returns the class name
  7914. */
  7915. getClassName(): string;
  7916. /**
  7917. * Gets a string representation of the camera useful for debug purpose.
  7918. * @param fullDetails Defines that a more verboe level of logging is required
  7919. * @returns the string representation
  7920. */
  7921. toString(fullDetails?: boolean): string;
  7922. /**
  7923. * Gets the current world space position of the camera.
  7924. */
  7925. readonly globalPosition: Vector3;
  7926. /**
  7927. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  7928. * @returns the active meshe list
  7929. */
  7930. getActiveMeshes(): SmartArray<AbstractMesh>;
  7931. /**
  7932. * Check wether a mesh is part of the current active mesh list of the camera
  7933. * @param mesh Defines the mesh to check
  7934. * @returns true if active, false otherwise
  7935. */
  7936. isActiveMesh(mesh: Mesh): boolean;
  7937. /**
  7938. * Is this camera ready to be used/rendered
  7939. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  7940. * @return true if the camera is ready
  7941. */
  7942. isReady(completeCheck?: boolean): boolean;
  7943. /** @hidden */
  7944. _initCache(): void;
  7945. /** @hidden */
  7946. _updateCache(ignoreParentClass?: boolean): void;
  7947. /** @hidden */
  7948. _isSynchronized(): boolean;
  7949. /** @hidden */
  7950. _isSynchronizedViewMatrix(): boolean;
  7951. /** @hidden */
  7952. _isSynchronizedProjectionMatrix(): boolean;
  7953. /**
  7954. * Attach the input controls to a specific dom element to get the input from.
  7955. * @param element Defines the element the controls should be listened from
  7956. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7957. */
  7958. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  7959. /**
  7960. * Detach the current controls from the specified dom element.
  7961. * @param element Defines the element to stop listening the inputs from
  7962. */
  7963. detachControl(element: HTMLElement): void;
  7964. /**
  7965. * Update the camera state according to the different inputs gathered during the frame.
  7966. */
  7967. update(): void;
  7968. /** @hidden */
  7969. _checkInputs(): void;
  7970. /** @hidden */
  7971. readonly rigCameras: Camera[];
  7972. /**
  7973. * Gets the post process used by the rig cameras
  7974. */
  7975. readonly rigPostProcess: Nullable<PostProcess>;
  7976. /**
  7977. * Internal, gets the first post proces.
  7978. * @returns the first post process to be run on this camera.
  7979. */
  7980. _getFirstPostProcess(): Nullable<PostProcess>;
  7981. private _cascadePostProcessesToRigCams;
  7982. /**
  7983. * Attach a post process to the camera.
  7984. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  7985. * @param postProcess The post process to attach to the camera
  7986. * @param insertAt The position of the post process in case several of them are in use in the scene
  7987. * @returns the position the post process has been inserted at
  7988. */
  7989. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  7990. /**
  7991. * Detach a post process to the camera.
  7992. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  7993. * @param postProcess The post process to detach from the camera
  7994. */
  7995. detachPostProcess(postProcess: PostProcess): void;
  7996. /**
  7997. * Gets the current world matrix of the camera
  7998. */
  7999. getWorldMatrix(): Matrix;
  8000. /** @hidden */
  8001. protected _getViewMatrix(): Matrix;
  8002. /**
  8003. * Gets the current view matrix of the camera.
  8004. * @param force forces the camera to recompute the matrix without looking at the cached state
  8005. * @returns the view matrix
  8006. */
  8007. getViewMatrix(force?: boolean): Matrix;
  8008. /**
  8009. * Freeze the projection matrix.
  8010. * It will prevent the cache check of the camera projection compute and can speed up perf
  8011. * if no parameter of the camera are meant to change
  8012. * @param projection Defines manually a projection if necessary
  8013. */
  8014. freezeProjectionMatrix(projection?: Matrix): void;
  8015. /**
  8016. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  8017. */
  8018. unfreezeProjectionMatrix(): void;
  8019. /**
  8020. * Gets the current projection matrix of the camera.
  8021. * @param force forces the camera to recompute the matrix without looking at the cached state
  8022. * @returns the projection matrix
  8023. */
  8024. getProjectionMatrix(force?: boolean): Matrix;
  8025. /**
  8026. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  8027. * @returns a Matrix
  8028. */
  8029. getTransformationMatrix(): Matrix;
  8030. private _updateFrustumPlanes;
  8031. /**
  8032. * Checks if a cullable object (mesh...) is in the camera frustum
  8033. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  8034. * @param target The object to check
  8035. * @returns true if the object is in frustum otherwise false
  8036. */
  8037. isInFrustum(target: ICullable): boolean;
  8038. /**
  8039. * Checks if a cullable object (mesh...) is in the camera frustum
  8040. * Unlike isInFrustum this cheks the full bounding box
  8041. * @param target The object to check
  8042. * @returns true if the object is in frustum otherwise false
  8043. */
  8044. isCompletelyInFrustum(target: ICullable): boolean;
  8045. /**
  8046. * Gets a ray in the forward direction from the camera.
  8047. * @param length Defines the length of the ray to create
  8048. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  8049. * @param origin Defines the start point of the ray which defaults to the camera position
  8050. * @returns the forward ray
  8051. */
  8052. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  8053. /**
  8054. * Releases resources associated with this node.
  8055. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  8056. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  8057. */
  8058. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  8059. /**
  8060. * Gets the left camera of a rig setup in case of Rigged Camera
  8061. */
  8062. readonly leftCamera: Nullable<FreeCamera>;
  8063. /**
  8064. * Gets the right camera of a rig setup in case of Rigged Camera
  8065. */
  8066. readonly rightCamera: Nullable<FreeCamera>;
  8067. /**
  8068. * Gets the left camera target of a rig setup in case of Rigged Camera
  8069. * @returns the target position
  8070. */
  8071. getLeftTarget(): Nullable<Vector3>;
  8072. /**
  8073. * Gets the right camera target of a rig setup in case of Rigged Camera
  8074. * @returns the target position
  8075. */
  8076. getRightTarget(): Nullable<Vector3>;
  8077. /**
  8078. * @hidden
  8079. */
  8080. setCameraRigMode(mode: number, rigParams: any): void;
  8081. private _getVRProjectionMatrix;
  8082. protected _updateCameraRotationMatrix(): void;
  8083. protected _updateWebVRCameraRotationMatrix(): void;
  8084. /**
  8085. * This function MUST be overwritten by the different WebVR cameras available.
  8086. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  8087. */
  8088. protected _getWebVRProjectionMatrix(): Matrix;
  8089. /**
  8090. * This function MUST be overwritten by the different WebVR cameras available.
  8091. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  8092. */
  8093. protected _getWebVRViewMatrix(): Matrix;
  8094. /** @hidden */
  8095. setCameraRigParameter(name: string, value: any): void;
  8096. /**
  8097. * needs to be overridden by children so sub has required properties to be copied
  8098. * @hidden
  8099. */
  8100. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8101. /**
  8102. * May need to be overridden by children
  8103. * @hidden
  8104. */
  8105. _updateRigCameras(): void;
  8106. /** @hidden */
  8107. _setupInputs(): void;
  8108. /**
  8109. * Serialiaze the camera setup to a json represention
  8110. * @returns the JSON representation
  8111. */
  8112. serialize(): any;
  8113. /**
  8114. * Clones the current camera.
  8115. * @param name The cloned camera name
  8116. * @returns the cloned camera
  8117. */
  8118. clone(name: string): Camera;
  8119. /**
  8120. * Gets the direction of the camera relative to a given local axis.
  8121. * @param localAxis Defines the reference axis to provide a relative direction.
  8122. * @return the direction
  8123. */
  8124. getDirection(localAxis: Vector3): Vector3;
  8125. /**
  8126. * Gets the direction of the camera relative to a given local axis into a passed vector.
  8127. * @param localAxis Defines the reference axis to provide a relative direction.
  8128. * @param result Defines the vector to store the result in
  8129. */
  8130. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  8131. /**
  8132. * Gets a camera constructor for a given camera type
  8133. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  8134. * @param name The name of the camera the result will be able to instantiate
  8135. * @param scene The scene the result will construct the camera in
  8136. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  8137. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  8138. * @returns a factory method to construc the camera
  8139. */
  8140. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  8141. /**
  8142. * Compute the world matrix of the camera.
  8143. * @returns the camera workd matrix
  8144. */
  8145. computeWorldMatrix(): Matrix;
  8146. /**
  8147. * Parse a JSON and creates the camera from the parsed information
  8148. * @param parsedCamera The JSON to parse
  8149. * @param scene The scene to instantiate the camera in
  8150. * @returns the newly constructed camera
  8151. */
  8152. static Parse(parsedCamera: any, scene: Scene): Camera;
  8153. }
  8154. }
  8155. declare module BABYLON {
  8156. /**
  8157. * @ignore
  8158. * This is a list of all the different input types that are available in the application.
  8159. * Fo instance: ArcRotateCameraGamepadInput...
  8160. */
  8161. var CameraInputTypes: {};
  8162. /**
  8163. * This is the contract to implement in order to create a new input class.
  8164. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8165. */
  8166. interface ICameraInput<TCamera extends Camera> {
  8167. /**
  8168. * Defines the camera the input is attached to.
  8169. */
  8170. camera: Nullable<TCamera>;
  8171. /**
  8172. * Gets the class name of the current intput.
  8173. * @returns the class name
  8174. */
  8175. getClassName(): string;
  8176. /**
  8177. * Get the friendly name associated with the input class.
  8178. * @returns the input friendly name
  8179. */
  8180. getSimpleName(): string;
  8181. /**
  8182. * Attach the input controls to a specific dom element to get the input from.
  8183. * @param element Defines the element the controls should be listened from
  8184. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8185. */
  8186. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8187. /**
  8188. * Detach the current controls from the specified dom element.
  8189. * @param element Defines the element to stop listening the inputs from
  8190. */
  8191. detachControl(element: Nullable<HTMLElement>): void;
  8192. /**
  8193. * Update the current camera state depending on the inputs that have been used this frame.
  8194. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8195. */
  8196. checkInputs?: () => void;
  8197. }
  8198. /**
  8199. * Represents a map of input types to input instance or input index to input instance.
  8200. */
  8201. interface CameraInputsMap<TCamera extends Camera> {
  8202. /**
  8203. * Accessor to the input by input type.
  8204. */
  8205. [name: string]: ICameraInput<TCamera>;
  8206. /**
  8207. * Accessor to the input by input index.
  8208. */
  8209. [idx: number]: ICameraInput<TCamera>;
  8210. }
  8211. /**
  8212. * This represents the input manager used within a camera.
  8213. * It helps dealing with all the different kind of input attached to a camera.
  8214. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8215. */
  8216. class CameraInputsManager<TCamera extends Camera> {
  8217. /**
  8218. * Defines the list of inputs attahed to the camera.
  8219. */
  8220. attached: CameraInputsMap<TCamera>;
  8221. /**
  8222. * Defines the dom element the camera is collecting inputs from.
  8223. * This is null if the controls have not been attached.
  8224. */
  8225. attachedElement: Nullable<HTMLElement>;
  8226. /**
  8227. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8228. */
  8229. noPreventDefault: boolean;
  8230. /**
  8231. * Defined the camera the input manager belongs to.
  8232. */
  8233. camera: TCamera;
  8234. /**
  8235. * Update the current camera state depending on the inputs that have been used this frame.
  8236. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8237. */
  8238. checkInputs: () => void;
  8239. /**
  8240. * Instantiate a new Camera Input Manager.
  8241. * @param camera Defines the camera the input manager blongs to
  8242. */
  8243. constructor(camera: TCamera);
  8244. /**
  8245. * Add an input method to a camera
  8246. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8247. * @param input camera input method
  8248. */
  8249. add(input: ICameraInput<TCamera>): void;
  8250. /**
  8251. * Remove a specific input method from a camera
  8252. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8253. * @param inputToRemove camera input method
  8254. */
  8255. remove(inputToRemove: ICameraInput<TCamera>): void;
  8256. /**
  8257. * Remove a specific input type from a camera
  8258. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8259. * @param inputType the type of the input to remove
  8260. */
  8261. removeByType(inputType: string): void;
  8262. private _addCheckInputs;
  8263. /**
  8264. * Attach the input controls to the currently attached dom element to listen the events from.
  8265. * @param input Defines the input to attach
  8266. */
  8267. attachInput(input: ICameraInput<TCamera>): void;
  8268. /**
  8269. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8270. * @param element Defines the dom element to collect the events from
  8271. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8272. */
  8273. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8274. /**
  8275. * Detach the current manager inputs controls from a specific dom element.
  8276. * @param element Defines the dom element to collect the events from
  8277. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8278. */
  8279. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8280. /**
  8281. * Rebuild the dynamic inputCheck function from the current list of
  8282. * defined inputs in the manager.
  8283. */
  8284. rebuildInputCheck(): void;
  8285. /**
  8286. * Remove all attached input methods from a camera
  8287. */
  8288. clear(): void;
  8289. /**
  8290. * Serialize the current input manager attached to a camera.
  8291. * This ensures than once parsed,
  8292. * the input associated to the camera will be identical to the current ones
  8293. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8294. */
  8295. serialize(serializedCamera: any): void;
  8296. /**
  8297. * Parses an input manager serialized JSON to restore the previous list of inputs
  8298. * and states associated to a camera.
  8299. * @param parsedCamera Defines the JSON to parse
  8300. */
  8301. parse(parsedCamera: any): void;
  8302. }
  8303. }
  8304. declare module BABYLON {
  8305. /**
  8306. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  8307. * being tilted forward or back and left or right.
  8308. */
  8309. class DeviceOrientationCamera extends FreeCamera {
  8310. private _initialQuaternion;
  8311. private _quaternionCache;
  8312. /**
  8313. * Creates a new device orientation camera
  8314. * @param name The name of the camera
  8315. * @param position The start position camera
  8316. * @param scene The scene the camera belongs to
  8317. */
  8318. constructor(name: string, position: Vector3, scene: Scene);
  8319. /**
  8320. * Gets the current instance class name ("DeviceOrientationCamera").
  8321. * This helps avoiding instanceof at run time.
  8322. * @returns the class name
  8323. */
  8324. getClassName(): string;
  8325. /**
  8326. * @hidden
  8327. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  8328. */
  8329. _checkInputs(): void;
  8330. /**
  8331. * Reset the camera to its default orientation on the specified axis only.
  8332. * @param axis The axis to reset
  8333. */
  8334. resetToCurrentRotation(axis?: Axis): void;
  8335. }
  8336. }
  8337. declare module BABYLON {
  8338. /**
  8339. * This is a flying camera, designed for 3D movement and rotation in all directions,
  8340. * such as in a 3D Space Shooter or a Flight Simulator.
  8341. */
  8342. class FlyCamera extends TargetCamera {
  8343. /**
  8344. * Define the collision ellipsoid of the camera.
  8345. * This is helpful for simulating a camera body, like a player's body.
  8346. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  8347. */
  8348. ellipsoid: Vector3;
  8349. /**
  8350. * Define an offset for the position of the ellipsoid around the camera.
  8351. * This can be helpful if the camera is attached away from the player's body center,
  8352. * such as at its head.
  8353. */
  8354. ellipsoidOffset: Vector3;
  8355. /**
  8356. * Enable or disable collisions of the camera with the rest of the scene objects.
  8357. */
  8358. checkCollisions: boolean;
  8359. /**
  8360. * Enable or disable gravity on the camera.
  8361. */
  8362. applyGravity: boolean;
  8363. /**
  8364. * Define the current direction the camera is moving to.
  8365. */
  8366. cameraDirection: Vector3;
  8367. /**
  8368. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  8369. * This overrides and empties cameraRotation.
  8370. */
  8371. rotationQuaternion: BABYLON.Quaternion;
  8372. /**
  8373. * Track Roll to maintain the wanted Rolling when looking around.
  8374. */
  8375. _trackRoll: number;
  8376. /**
  8377. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  8378. */
  8379. rollCorrect: number;
  8380. /**
  8381. * Mimic a banked turn, Rolling the camera when Yawing.
  8382. * It's recommended to use rollCorrect = 10 for faster banking correction.
  8383. */
  8384. bankedTurn: boolean;
  8385. /**
  8386. * Limit in radians for how much Roll banking will add. (Default: 90°)
  8387. */
  8388. bankedTurnLimit: number;
  8389. /**
  8390. * Value of 0 disables the banked Roll.
  8391. * Value of 1 is equal to the Yaw angle in radians.
  8392. */
  8393. bankedTurnMultiplier: number;
  8394. /**
  8395. * The inputs manager loads all the input sources, such as keyboard and mouse.
  8396. */
  8397. inputs: FlyCameraInputsManager;
  8398. /**
  8399. * Gets the input sensibility for mouse input.
  8400. * Higher values reduce sensitivity.
  8401. */
  8402. /**
  8403. * Sets the input sensibility for a mouse input.
  8404. * Higher values reduce sensitivity.
  8405. */
  8406. angularSensibility: number;
  8407. /**
  8408. * Get the keys for camera movement forward.
  8409. */
  8410. /**
  8411. * Set the keys for camera movement forward.
  8412. */
  8413. keysForward: number[];
  8414. /**
  8415. * Get the keys for camera movement backward.
  8416. */
  8417. keysBackward: number[];
  8418. /**
  8419. * Get the keys for camera movement up.
  8420. */
  8421. /**
  8422. * Set the keys for camera movement up.
  8423. */
  8424. keysUp: number[];
  8425. /**
  8426. * Get the keys for camera movement down.
  8427. */
  8428. /**
  8429. * Set the keys for camera movement down.
  8430. */
  8431. keysDown: number[];
  8432. /**
  8433. * Get the keys for camera movement left.
  8434. */
  8435. /**
  8436. * Set the keys for camera movement left.
  8437. */
  8438. keysLeft: number[];
  8439. /**
  8440. * Set the keys for camera movement right.
  8441. */
  8442. /**
  8443. * Set the keys for camera movement right.
  8444. */
  8445. keysRight: number[];
  8446. /**
  8447. * Event raised when the camera collides with a mesh in the scene.
  8448. */
  8449. onCollide: (collidedMesh: AbstractMesh) => void;
  8450. private _collider;
  8451. private _needMoveForGravity;
  8452. private _oldPosition;
  8453. private _diffPosition;
  8454. private _newPosition;
  8455. /** @hidden */
  8456. _localDirection: Vector3;
  8457. /** @hidden */
  8458. _transformedDirection: Vector3;
  8459. /**
  8460. * Instantiates a FlyCamera.
  8461. * This is a flying camera, designed for 3D movement and rotation in all directions,
  8462. * such as in a 3D Space Shooter or a Flight Simulator.
  8463. * @param name Define the name of the camera in the scene.
  8464. * @param position Define the starting position of the camera in the scene.
  8465. * @param scene Define the scene the camera belongs to.
  8466. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  8467. */
  8468. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8469. /**
  8470. * Attach a control to the HTML DOM element.
  8471. * @param element Defines the element that listens to the input events.
  8472. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  8473. */
  8474. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8475. /**
  8476. * Detach a control from the HTML DOM element.
  8477. * The camera will stop reacting to that input.
  8478. * @param element Defines the element that listens to the input events.
  8479. */
  8480. detachControl(element: HTMLElement): void;
  8481. private _collisionMask;
  8482. /**
  8483. * Get the mask that the camera ignores in collision events.
  8484. */
  8485. /**
  8486. * Set the mask that the camera ignores in collision events.
  8487. */
  8488. collisionMask: number;
  8489. /** @hidden */
  8490. _collideWithWorld(displacement: Vector3): void;
  8491. /** @hidden */
  8492. private _onCollisionPositionChange;
  8493. /** @hidden */
  8494. _checkInputs(): void;
  8495. /** @hidden */
  8496. _decideIfNeedsToMove(): boolean;
  8497. /** @hidden */
  8498. _updatePosition(): void;
  8499. /**
  8500. * Restore the Roll to its target value at the rate specified.
  8501. * @param rate - Higher means slower restoring.
  8502. * @hidden
  8503. */
  8504. restoreRoll(rate: number): void;
  8505. /**
  8506. * Destroy the camera and release the current resources held by it.
  8507. */
  8508. dispose(): void;
  8509. /**
  8510. * Get the current object class name.
  8511. * @returns the class name.
  8512. */
  8513. getClassName(): string;
  8514. }
  8515. }
  8516. declare module BABYLON {
  8517. /**
  8518. * Default Inputs manager for the FlyCamera.
  8519. * It groups all the default supported inputs for ease of use.
  8520. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8521. */
  8522. class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  8523. /**
  8524. * Instantiates a new FlyCameraInputsManager.
  8525. * @param camera Defines the camera the inputs belong to.
  8526. */
  8527. constructor(camera: FlyCamera);
  8528. /**
  8529. * Add keyboard input support to the input manager.
  8530. * @returns the new FlyCameraKeyboardMoveInput().
  8531. */
  8532. addKeyboard(): FlyCameraInputsManager;
  8533. /**
  8534. * Add mouse input support to the input manager.
  8535. * @param touchEnabled Enable touch screen support.
  8536. * @returns the new FlyCameraMouseInput().
  8537. */
  8538. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  8539. }
  8540. }
  8541. declare module BABYLON {
  8542. /**
  8543. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  8544. * an arc rotate version arcFollowCamera are available.
  8545. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  8546. */
  8547. class FollowCamera extends TargetCamera {
  8548. /**
  8549. * Distance the follow camera should follow an object at
  8550. */
  8551. radius: number;
  8552. /**
  8553. * Define a rotation offset between the camera and the object it follows
  8554. */
  8555. rotationOffset: number;
  8556. /**
  8557. * Define a height offset between the camera and the object it follows.
  8558. * It can help following an object from the top (like a car chaing a plane)
  8559. */
  8560. heightOffset: number;
  8561. /**
  8562. * Define how fast the camera can accelerate to follow it s target.
  8563. */
  8564. cameraAcceleration: number;
  8565. /**
  8566. * Define the speed limit of the camera following an object.
  8567. */
  8568. maxCameraSpeed: number;
  8569. /**
  8570. * Define the target of the camera.
  8571. */
  8572. lockedTarget: Nullable<AbstractMesh>;
  8573. /**
  8574. * Instantiates the follow camera.
  8575. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  8576. * @param name Define the name of the camera in the scene
  8577. * @param position Define the position of the camera
  8578. * @param scene Define the scene the camera belong to
  8579. * @param lockedTarget Define the target of the camera
  8580. */
  8581. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  8582. private _follow;
  8583. /** @hidden */
  8584. _checkInputs(): void;
  8585. /**
  8586. * Gets the camera class name.
  8587. * @returns the class name
  8588. */
  8589. getClassName(): string;
  8590. }
  8591. /**
  8592. * Arc Rotate version of the follow camera.
  8593. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  8594. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  8595. */
  8596. class ArcFollowCamera extends TargetCamera {
  8597. /** The longitudinal angle of the camera */
  8598. alpha: number;
  8599. /** The latitudinal angle of the camera */
  8600. beta: number;
  8601. /** The radius of the camera from its target */
  8602. radius: number;
  8603. /** Define the camera target (the messh it should follow) */
  8604. target: Nullable<AbstractMesh>;
  8605. private _cartesianCoordinates;
  8606. /**
  8607. * Instantiates a new ArcFollowCamera
  8608. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  8609. * @param name Define the name of the camera
  8610. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  8611. * @param beta Define the rotation angle of the camera around the elevation axis
  8612. * @param radius Define the radius of the camera from its target point
  8613. * @param target Define the target of the camera
  8614. * @param scene Define the scene the camera belongs to
  8615. */
  8616. constructor(name: string,
  8617. /** The longitudinal angle of the camera */
  8618. alpha: number,
  8619. /** The latitudinal angle of the camera */
  8620. beta: number,
  8621. /** The radius of the camera from its target */
  8622. radius: number,
  8623. /** Define the camera target (the messh it should follow) */
  8624. target: Nullable<AbstractMesh>, scene: Scene);
  8625. private _follow;
  8626. /** @hidden */
  8627. _checkInputs(): void;
  8628. /**
  8629. * Returns the class name of the object.
  8630. * It is mostly used internally for serialization purposes.
  8631. */
  8632. getClassName(): string;
  8633. }
  8634. }
  8635. declare module BABYLON {
  8636. /**
  8637. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  8638. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  8639. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8640. */
  8641. class FreeCamera extends TargetCamera {
  8642. /**
  8643. * Define the collision ellipsoid of the camera.
  8644. * This is helpful to simulate a camera body like the player body around the camera
  8645. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  8646. */
  8647. ellipsoid: Vector3;
  8648. /**
  8649. * Define an offset for the position of the ellipsoid around the camera.
  8650. * This can be helpful to determine the center of the body near the gravity center of the body
  8651. * instead of its head.
  8652. */
  8653. ellipsoidOffset: Vector3;
  8654. /**
  8655. * Enable or disable collisions of the camera with the rest of the scene objects.
  8656. */
  8657. checkCollisions: boolean;
  8658. /**
  8659. * Enable or disable gravity on the camera.
  8660. */
  8661. applyGravity: boolean;
  8662. /**
  8663. * Define the input manager associated to the camera.
  8664. */
  8665. inputs: FreeCameraInputsManager;
  8666. /**
  8667. * Gets the input sensibility for a mouse input. (default is 2000.0)
  8668. * Higher values reduce sensitivity.
  8669. */
  8670. /**
  8671. * Sets the input sensibility for a mouse input. (default is 2000.0)
  8672. * Higher values reduce sensitivity.
  8673. */
  8674. angularSensibility: number;
  8675. /**
  8676. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8677. */
  8678. keysUp: number[];
  8679. /**
  8680. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8681. */
  8682. keysDown: number[];
  8683. /**
  8684. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8685. */
  8686. keysLeft: number[];
  8687. /**
  8688. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8689. */
  8690. keysRight: number[];
  8691. /**
  8692. * Event raised when the camera collide with a mesh in the scene.
  8693. */
  8694. onCollide: (collidedMesh: AbstractMesh) => void;
  8695. private _collider;
  8696. private _needMoveForGravity;
  8697. private _oldPosition;
  8698. private _diffPosition;
  8699. private _newPosition;
  8700. /** @hidden */
  8701. _localDirection: Vector3;
  8702. /** @hidden */
  8703. _transformedDirection: Vector3;
  8704. /**
  8705. * Instantiates a Free Camera.
  8706. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  8707. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  8708. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8709. * @param name Define the name of the camera in the scene
  8710. * @param position Define the start position of the camera in the scene
  8711. * @param scene Define the scene the camera belongs to
  8712. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8713. */
  8714. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8715. /**
  8716. * Attached controls to the current camera.
  8717. * @param element Defines the element the controls should be listened from
  8718. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8719. */
  8720. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8721. /**
  8722. * Detach the current controls from the camera.
  8723. * The camera will stop reacting to inputs.
  8724. * @param element Defines the element to stop listening the inputs from
  8725. */
  8726. detachControl(element: HTMLElement): void;
  8727. private _collisionMask;
  8728. /**
  8729. * Define a collision mask to limit the list of object the camera can collide with
  8730. */
  8731. collisionMask: number;
  8732. /** @hidden */
  8733. _collideWithWorld(displacement: Vector3): void;
  8734. private _onCollisionPositionChange;
  8735. /** @hidden */
  8736. _checkInputs(): void;
  8737. /** @hidden */
  8738. _decideIfNeedsToMove(): boolean;
  8739. /** @hidden */
  8740. _updatePosition(): void;
  8741. /**
  8742. * Destroy the camera and release the current resources hold by it.
  8743. */
  8744. dispose(): void;
  8745. /**
  8746. * Gets the current object class name.
  8747. * @return the class name
  8748. */
  8749. getClassName(): string;
  8750. }
  8751. }
  8752. declare module BABYLON {
  8753. /**
  8754. * Default Inputs manager for the FreeCamera.
  8755. * It groups all the default supported inputs for ease of use.
  8756. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8757. */
  8758. class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  8759. /**
  8760. * Instantiates a new FreeCameraInputsManager.
  8761. * @param camera Defines the camera the inputs belong to
  8762. */
  8763. constructor(camera: FreeCamera);
  8764. /**
  8765. * Add keyboard input support to the input manager.
  8766. * @returns the current input manager
  8767. */
  8768. addKeyboard(): FreeCameraInputsManager;
  8769. /**
  8770. * Add mouse input support to the input manager.
  8771. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  8772. * @returns the current input manager
  8773. */
  8774. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  8775. /**
  8776. * Add orientation input support to the input manager.
  8777. * @returns the current input manager
  8778. */
  8779. addDeviceOrientation(): FreeCameraInputsManager;
  8780. /**
  8781. * Add touch input support to the input manager.
  8782. * @returns the current input manager
  8783. */
  8784. addTouch(): FreeCameraInputsManager;
  8785. /**
  8786. * Add virtual joystick input support to the input manager.
  8787. * @returns the current input manager
  8788. */
  8789. addVirtualJoystick(): FreeCameraInputsManager;
  8790. }
  8791. }
  8792. declare module BABYLON {
  8793. /**
  8794. * This represents a FPS type of camera. This is only here for back compat purpose.
  8795. * Please use the UniversalCamera instead as both are identical.
  8796. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8797. */
  8798. class GamepadCamera extends UniversalCamera {
  8799. /**
  8800. * Instantiates a new Gamepad Camera
  8801. * This represents a FPS type of camera. This is only here for back compat purpose.
  8802. * Please use the UniversalCamera instead as both are identical.
  8803. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8804. * @param name Define the name of the camera in the scene
  8805. * @param position Define the start position of the camera in the scene
  8806. * @param scene Define the scene the camera belongs to
  8807. */
  8808. constructor(name: string, position: Vector3, scene: Scene);
  8809. /**
  8810. * Gets the current object class name.
  8811. * @return the class name
  8812. */
  8813. getClassName(): string;
  8814. }
  8815. }
  8816. declare module BABYLON {
  8817. /**
  8818. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8819. * This is the base of the follow, arc rotate cameras and Free camera
  8820. * @see http://doc.babylonjs.com/features/cameras
  8821. */
  8822. class TargetCamera extends Camera {
  8823. private static _RigCamTransformMatrix;
  8824. private static _TargetTransformMatrix;
  8825. private static _TargetFocalPoint;
  8826. /**
  8827. * Define the current direction the camera is moving to
  8828. */
  8829. cameraDirection: Vector3;
  8830. /**
  8831. * Define the current rotation the camera is rotating to
  8832. */
  8833. cameraRotation: Vector2;
  8834. /**
  8835. * When set, the up vector of the camera will be updated by the rotation of the camera
  8836. */
  8837. updateUpVectorFromRotation: boolean;
  8838. private _tmpQuaternion;
  8839. /**
  8840. * Define the current rotation of the camera
  8841. */
  8842. rotation: Vector3;
  8843. /**
  8844. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8845. */
  8846. rotationQuaternion: Quaternion;
  8847. /**
  8848. * Define the current speed of the camera
  8849. */
  8850. speed: number;
  8851. /**
  8852. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8853. * around all axis.
  8854. */
  8855. noRotationConstraint: boolean;
  8856. /**
  8857. * Define the current target of the camera as an object or a position.
  8858. */
  8859. lockedTarget: any;
  8860. /** @hidden */
  8861. _currentTarget: Vector3;
  8862. /** @hidden */
  8863. _initialFocalDistance: number;
  8864. /** @hidden */
  8865. _viewMatrix: Matrix;
  8866. /** @hidden */
  8867. _camMatrix: Matrix;
  8868. /** @hidden */
  8869. _cameraTransformMatrix: Matrix;
  8870. /** @hidden */
  8871. _cameraRotationMatrix: Matrix;
  8872. /** @hidden */
  8873. _referencePoint: Vector3;
  8874. /** @hidden */
  8875. _transformedReferencePoint: Vector3;
  8876. protected _globalCurrentTarget: Vector3;
  8877. protected _globalCurrentUpVector: Vector3;
  8878. /** @hidden */
  8879. _reset: () => void;
  8880. private _defaultUp;
  8881. /**
  8882. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8883. * This is the base of the follow, arc rotate cameras and Free camera
  8884. * @see http://doc.babylonjs.com/features/cameras
  8885. * @param name Defines the name of the camera in the scene
  8886. * @param position Defines the start position of the camera in the scene
  8887. * @param scene Defines the scene the camera belongs to
  8888. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8889. */
  8890. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8891. /**
  8892. * Gets the position in front of the camera at a given distance.
  8893. * @param distance The distance from the camera we want the position to be
  8894. * @returns the position
  8895. */
  8896. getFrontPosition(distance: number): Vector3;
  8897. /** @hidden */
  8898. _getLockedTargetPosition(): Nullable<Vector3>;
  8899. private _storedPosition;
  8900. private _storedRotation;
  8901. private _storedRotationQuaternion;
  8902. /**
  8903. * Store current camera state of the camera (fov, position, rotation, etc..)
  8904. * @returns the camera
  8905. */
  8906. storeState(): Camera;
  8907. /**
  8908. * Restored camera state. You must call storeState() first
  8909. * @returns whether it was successful or not
  8910. * @hidden
  8911. */
  8912. _restoreStateValues(): boolean;
  8913. /** @hidden */
  8914. _initCache(): void;
  8915. /** @hidden */
  8916. _updateCache(ignoreParentClass?: boolean): void;
  8917. /** @hidden */
  8918. _isSynchronizedViewMatrix(): boolean;
  8919. /** @hidden */
  8920. _computeLocalCameraSpeed(): number;
  8921. /** @hidden */
  8922. setTarget(target: Vector3): void;
  8923. /**
  8924. * Return the current target position of the camera. This value is expressed in local space.
  8925. * @returns the target position
  8926. */
  8927. getTarget(): Vector3;
  8928. /** @hidden */
  8929. _decideIfNeedsToMove(): boolean;
  8930. /** @hidden */
  8931. _updatePosition(): void;
  8932. /** @hidden */
  8933. _checkInputs(): void;
  8934. protected _updateCameraRotationMatrix(): void;
  8935. /**
  8936. * 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)
  8937. * @returns the current camera
  8938. */
  8939. private _rotateUpVectorWithCameraRotationMatrix;
  8940. private _cachedRotationZ;
  8941. private _cachedQuaternionRotationZ;
  8942. /** @hidden */
  8943. _getViewMatrix(): Matrix;
  8944. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8945. /**
  8946. * @hidden
  8947. */
  8948. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8949. /**
  8950. * @hidden
  8951. */
  8952. _updateRigCameras(): void;
  8953. private _getRigCamPositionAndTarget;
  8954. /**
  8955. * Gets the current object class name.
  8956. * @return the class name
  8957. */
  8958. getClassName(): string;
  8959. }
  8960. }
  8961. declare module BABYLON {
  8962. /**
  8963. * This represents a FPS type of camera controlled by touch.
  8964. * This is like a universal camera minus the Gamepad controls.
  8965. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8966. */
  8967. class TouchCamera extends FreeCamera {
  8968. /**
  8969. * Defines the touch sensibility for rotation.
  8970. * The higher the faster.
  8971. */
  8972. touchAngularSensibility: number;
  8973. /**
  8974. * Defines the touch sensibility for move.
  8975. * The higher the faster.
  8976. */
  8977. touchMoveSensibility: number;
  8978. /**
  8979. * Instantiates a new touch camera.
  8980. * This represents a FPS type of camera controlled by touch.
  8981. * This is like a universal camera minus the Gamepad controls.
  8982. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8983. * @param name Define the name of the camera in the scene
  8984. * @param position Define the start position of the camera in the scene
  8985. * @param scene Define the scene the camera belongs to
  8986. */
  8987. constructor(name: string, position: Vector3, scene: Scene);
  8988. /**
  8989. * Gets the current object class name.
  8990. * @return the class name
  8991. */
  8992. getClassName(): string;
  8993. /** @hidden */
  8994. _setupInputs(): void;
  8995. }
  8996. }
  8997. declare module BABYLON {
  8998. /**
  8999. * 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,
  9000. * which still works and will still be found in many Playgrounds.
  9001. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  9002. */
  9003. class UniversalCamera extends TouchCamera {
  9004. /**
  9005. * Defines the gamepad rotation sensiblity.
  9006. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  9007. */
  9008. gamepadAngularSensibility: number;
  9009. /**
  9010. * Defines the gamepad move sensiblity.
  9011. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  9012. */
  9013. gamepadMoveSensibility: number;
  9014. /**
  9015. * 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,
  9016. * which still works and will still be found in many Playgrounds.
  9017. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  9018. * @param name Define the name of the camera in the scene
  9019. * @param position Define the start position of the camera in the scene
  9020. * @param scene Define the scene the camera belongs to
  9021. */
  9022. constructor(name: string, position: Vector3, scene: Scene);
  9023. /**
  9024. * Gets the current object class name.
  9025. * @return the class name
  9026. */
  9027. getClassName(): string;
  9028. }
  9029. }
  9030. declare module BABYLON {
  9031. /**
  9032. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  9033. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  9034. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  9035. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  9036. */
  9037. class VirtualJoysticksCamera extends FreeCamera {
  9038. /**
  9039. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  9040. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  9041. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  9042. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  9043. * @param name Define the name of the camera in the scene
  9044. * @param position Define the start position of the camera in the scene
  9045. * @param scene Define the scene the camera belongs to
  9046. */
  9047. constructor(name: string, position: Vector3, scene: Scene);
  9048. /**
  9049. * Gets the current object class name.
  9050. * @return the class name
  9051. */
  9052. getClassName(): string;
  9053. }
  9054. }
  9055. interface VRDisplay extends EventTarget {
  9056. /**
  9057. * Dictionary of capabilities describing the VRDisplay.
  9058. */
  9059. readonly capabilities: VRDisplayCapabilities;
  9060. /**
  9061. * z-depth defining the far plane of the eye view frustum
  9062. * enables mapping of values in the render target depth
  9063. * attachment to scene coordinates. Initially set to 10000.0.
  9064. */
  9065. depthFar: number;
  9066. /**
  9067. * z-depth defining the near plane of the eye view frustum
  9068. * enables mapping of values in the render target depth
  9069. * attachment to scene coordinates. Initially set to 0.01.
  9070. */
  9071. depthNear: number;
  9072. /**
  9073. * An identifier for this distinct VRDisplay. Used as an
  9074. * association point in the Gamepad API.
  9075. */
  9076. readonly displayId: number;
  9077. /**
  9078. * A display name, a user-readable name identifying it.
  9079. */
  9080. readonly displayName: string;
  9081. readonly isConnected: boolean;
  9082. readonly isPresenting: boolean;
  9083. /**
  9084. * If this VRDisplay supports room-scale experiences, the optional
  9085. * stage attribute contains details on the room-scale parameters.
  9086. */
  9087. readonly stageParameters: VRStageParameters | null;
  9088. /**
  9089. * Passing the value returned by `requestAnimationFrame` to
  9090. * `cancelAnimationFrame` will unregister the callback.
  9091. * @param handle Define the hanle of the request to cancel
  9092. */
  9093. cancelAnimationFrame(handle: number): void;
  9094. /**
  9095. * Stops presenting to the VRDisplay.
  9096. * @returns a promise to know when it stopped
  9097. */
  9098. exitPresent(): Promise<void>;
  9099. /**
  9100. * Return the current VREyeParameters for the given eye.
  9101. * @param whichEye Define the eye we want the parameter for
  9102. * @returns the eye parameters
  9103. */
  9104. getEyeParameters(whichEye: string): VREyeParameters;
  9105. /**
  9106. * Populates the passed VRFrameData with the information required to render
  9107. * the current frame.
  9108. * @param frameData Define the data structure to populate
  9109. * @returns true if ok otherwise false
  9110. */
  9111. getFrameData(frameData: VRFrameData): boolean;
  9112. /**
  9113. * Get the layers currently being presented.
  9114. * @returns the list of VR layers
  9115. */
  9116. getLayers(): VRLayer[];
  9117. /**
  9118. * Return a VRPose containing the future predicted pose of the VRDisplay
  9119. * when the current frame will be presented. The value returned will not
  9120. * change until JavaScript has returned control to the browser.
  9121. *
  9122. * The VRPose will contain the position, orientation, velocity,
  9123. * and acceleration of each of these properties.
  9124. * @returns the pose object
  9125. */
  9126. getPose(): VRPose;
  9127. /**
  9128. * Return the current instantaneous pose of the VRDisplay, with no
  9129. * prediction applied.
  9130. * @returns the current instantaneous pose
  9131. */
  9132. getImmediatePose(): VRPose;
  9133. /**
  9134. * The callback passed to `requestAnimationFrame` will be called
  9135. * any time a new frame should be rendered. When the VRDisplay is
  9136. * presenting the callback will be called at the native refresh
  9137. * rate of the HMD. When not presenting this function acts
  9138. * identically to how window.requestAnimationFrame acts. Content should
  9139. * make no assumptions of frame rate or vsync behavior as the HMD runs
  9140. * asynchronously from other displays and at differing refresh rates.
  9141. * @param callback Define the eaction to run next frame
  9142. * @returns the request handle it
  9143. */
  9144. requestAnimationFrame(callback: FrameRequestCallback): number;
  9145. /**
  9146. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  9147. * Repeat calls while already presenting will update the VRLayers being displayed.
  9148. * @param layers Define the list of layer to present
  9149. * @returns a promise to know when the request has been fulfilled
  9150. */
  9151. requestPresent(layers: VRLayer[]): Promise<void>;
  9152. /**
  9153. * Reset the pose for this display, treating its current position and
  9154. * orientation as the "origin/zero" values. VRPose.position,
  9155. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  9156. * updated when calling resetPose(). This should be called in only
  9157. * sitting-space experiences.
  9158. */
  9159. resetPose(): void;
  9160. /**
  9161. * The VRLayer provided to the VRDisplay will be captured and presented
  9162. * in the HMD. Calling this function has the same effect on the source
  9163. * canvas as any other operation that uses its source image, and canvases
  9164. * created without preserveDrawingBuffer set to true will be cleared.
  9165. * @param pose Define the pose to submit
  9166. */
  9167. submitFrame(pose?: VRPose): void;
  9168. }
  9169. declare var VRDisplay: {
  9170. prototype: VRDisplay;
  9171. new (): VRDisplay;
  9172. };
  9173. interface VRLayer {
  9174. leftBounds?: number[] | Float32Array | null;
  9175. rightBounds?: number[] | Float32Array | null;
  9176. source?: HTMLCanvasElement | null;
  9177. }
  9178. interface VRDisplayCapabilities {
  9179. readonly canPresent: boolean;
  9180. readonly hasExternalDisplay: boolean;
  9181. readonly hasOrientation: boolean;
  9182. readonly hasPosition: boolean;
  9183. readonly maxLayers: number;
  9184. }
  9185. interface VREyeParameters {
  9186. /** @deprecated */
  9187. readonly fieldOfView: VRFieldOfView;
  9188. readonly offset: Float32Array;
  9189. readonly renderHeight: number;
  9190. readonly renderWidth: number;
  9191. }
  9192. interface VRFieldOfView {
  9193. readonly downDegrees: number;
  9194. readonly leftDegrees: number;
  9195. readonly rightDegrees: number;
  9196. readonly upDegrees: number;
  9197. }
  9198. interface VRFrameData {
  9199. readonly leftProjectionMatrix: Float32Array;
  9200. readonly leftViewMatrix: Float32Array;
  9201. readonly pose: VRPose;
  9202. readonly rightProjectionMatrix: Float32Array;
  9203. readonly rightViewMatrix: Float32Array;
  9204. readonly timestamp: number;
  9205. }
  9206. interface VRPose {
  9207. readonly angularAcceleration: Float32Array | null;
  9208. readonly angularVelocity: Float32Array | null;
  9209. readonly linearAcceleration: Float32Array | null;
  9210. readonly linearVelocity: Float32Array | null;
  9211. readonly orientation: Float32Array | null;
  9212. readonly position: Float32Array | null;
  9213. readonly timestamp: number;
  9214. }
  9215. interface VRStageParameters {
  9216. sittingToStandingTransform?: Float32Array;
  9217. sizeX?: number;
  9218. sizeY?: number;
  9219. }
  9220. interface Navigator {
  9221. getVRDisplays(): Promise<VRDisplay[]>;
  9222. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  9223. }
  9224. interface Window {
  9225. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  9226. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  9227. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  9228. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  9229. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  9230. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  9231. }
  9232. interface Gamepad {
  9233. readonly displayId: number;
  9234. }
  9235. declare module BABYLON {
  9236. /** @hidden */
  9237. class Collider {
  9238. /** Define if a collision was found */
  9239. collisionFound: boolean;
  9240. /**
  9241. * Define last intersection point in local space
  9242. */
  9243. intersectionPoint: Vector3;
  9244. /**
  9245. * Define last collided mesh
  9246. */
  9247. collidedMesh: Nullable<AbstractMesh>;
  9248. private _collisionPoint;
  9249. private _planeIntersectionPoint;
  9250. private _tempVector;
  9251. private _tempVector2;
  9252. private _tempVector3;
  9253. private _tempVector4;
  9254. private _edge;
  9255. private _baseToVertex;
  9256. private _destinationPoint;
  9257. private _slidePlaneNormal;
  9258. private _displacementVector;
  9259. /** @hidden */
  9260. _radius: Vector3;
  9261. /** @hidden */
  9262. _retry: number;
  9263. private _velocity;
  9264. private _basePoint;
  9265. private _epsilon;
  9266. /** @hidden */
  9267. _velocityWorldLength: number;
  9268. /** @hidden */
  9269. _basePointWorld: Vector3;
  9270. private _velocityWorld;
  9271. private _normalizedVelocity;
  9272. /** @hidden */
  9273. _initialVelocity: Vector3;
  9274. /** @hidden */
  9275. _initialPosition: Vector3;
  9276. private _nearestDistance;
  9277. private _collisionMask;
  9278. collisionMask: number;
  9279. /**
  9280. * Gets the plane normal used to compute the sliding response (in local space)
  9281. */
  9282. readonly slidePlaneNormal: Vector3;
  9283. /** @hidden */
  9284. _initialize(source: Vector3, dir: Vector3, e: number): void;
  9285. /** @hidden */
  9286. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  9287. /** @hidden */
  9288. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  9289. /** @hidden */
  9290. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  9291. /** @hidden */
  9292. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  9293. /** @hidden */
  9294. _getResponse(pos: Vector3, vel: Vector3): void;
  9295. }
  9296. }
  9297. declare module BABYLON {
  9298. /** @hidden */
  9299. var CollisionWorker: string;
  9300. /** @hidden */
  9301. interface ICollisionCoordinator {
  9302. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  9303. init(scene: Scene): void;
  9304. destroy(): void;
  9305. onMeshAdded(mesh: AbstractMesh): void;
  9306. onMeshUpdated(mesh: AbstractMesh): void;
  9307. onMeshRemoved(mesh: AbstractMesh): void;
  9308. onGeometryAdded(geometry: Geometry): void;
  9309. onGeometryUpdated(geometry: Geometry): void;
  9310. onGeometryDeleted(geometry: Geometry): void;
  9311. }
  9312. /** @hidden */
  9313. interface SerializedMesh {
  9314. id: string;
  9315. name: string;
  9316. uniqueId: number;
  9317. geometryId: Nullable<string>;
  9318. sphereCenter: Array<number>;
  9319. sphereRadius: number;
  9320. boxMinimum: Array<number>;
  9321. boxMaximum: Array<number>;
  9322. worldMatrixFromCache: any;
  9323. subMeshes: Array<SerializedSubMesh>;
  9324. checkCollisions: boolean;
  9325. }
  9326. /** @hidden */
  9327. interface SerializedSubMesh {
  9328. position: number;
  9329. verticesStart: number;
  9330. verticesCount: number;
  9331. indexStart: number;
  9332. indexCount: number;
  9333. hasMaterial: boolean;
  9334. sphereCenter: Array<number>;
  9335. sphereRadius: number;
  9336. boxMinimum: Array<number>;
  9337. boxMaximum: Array<number>;
  9338. }
  9339. /**
  9340. * Interface describing the value associated with a geometry.
  9341. * @hidden
  9342. */
  9343. interface SerializedGeometry {
  9344. /**
  9345. * Defines the unique ID of the geometry
  9346. */
  9347. id: string;
  9348. /**
  9349. * Defines the array containing the positions
  9350. */
  9351. positions: Float32Array;
  9352. /**
  9353. * Defines the array containing the indices
  9354. */
  9355. indices: Uint32Array;
  9356. /**
  9357. * Defines the array containing the normals
  9358. */
  9359. normals: Float32Array;
  9360. }
  9361. /** @hidden */
  9362. interface BabylonMessage {
  9363. taskType: WorkerTaskType;
  9364. payload: InitPayload | CollidePayload | UpdatePayload;
  9365. }
  9366. /** @hidden */
  9367. interface SerializedColliderToWorker {
  9368. position: Array<number>;
  9369. velocity: Array<number>;
  9370. radius: Array<number>;
  9371. }
  9372. /** Defines supported task for worker process */
  9373. enum WorkerTaskType {
  9374. /** Initialization */
  9375. INIT = 0,
  9376. /** Update of geometry */
  9377. UPDATE = 1,
  9378. /** Evaluate collision */
  9379. COLLIDE = 2
  9380. }
  9381. /** @hidden */
  9382. interface WorkerReply {
  9383. error: WorkerReplyType;
  9384. taskType: WorkerTaskType;
  9385. payload?: any;
  9386. }
  9387. /** @hidden */
  9388. interface CollisionReplyPayload {
  9389. newPosition: Array<number>;
  9390. collisionId: number;
  9391. collidedMeshUniqueId: number;
  9392. }
  9393. /** @hidden */
  9394. interface InitPayload {
  9395. }
  9396. /** @hidden */
  9397. interface CollidePayload {
  9398. collisionId: number;
  9399. collider: SerializedColliderToWorker;
  9400. maximumRetry: number;
  9401. excludedMeshUniqueId: Nullable<number>;
  9402. }
  9403. /** @hidden */
  9404. interface UpdatePayload {
  9405. updatedMeshes: {
  9406. [n: number]: SerializedMesh;
  9407. };
  9408. updatedGeometries: {
  9409. [s: string]: SerializedGeometry;
  9410. };
  9411. removedMeshes: Array<number>;
  9412. removedGeometries: Array<string>;
  9413. }
  9414. /** Defines kind of replies returned by worker */
  9415. enum WorkerReplyType {
  9416. /** Success */
  9417. SUCCESS = 0,
  9418. /** Unkown error */
  9419. UNKNOWN_ERROR = 1
  9420. }
  9421. /** @hidden */
  9422. class CollisionCoordinatorWorker implements ICollisionCoordinator {
  9423. private _scene;
  9424. private _scaledPosition;
  9425. private _scaledVelocity;
  9426. private _collisionsCallbackArray;
  9427. private _init;
  9428. private _runningUpdated;
  9429. private _worker;
  9430. private _addUpdateMeshesList;
  9431. private _addUpdateGeometriesList;
  9432. private _toRemoveMeshesArray;
  9433. private _toRemoveGeometryArray;
  9434. constructor();
  9435. static SerializeMesh: (mesh: AbstractMesh) => SerializedMesh;
  9436. static SerializeGeometry: (geometry: Geometry) => SerializedGeometry;
  9437. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  9438. init(scene: Scene): void;
  9439. destroy(): void;
  9440. onMeshAdded(mesh: AbstractMesh): void;
  9441. onMeshUpdated: (transformNode: TransformNode) => void;
  9442. onMeshRemoved(mesh: AbstractMesh): void;
  9443. onGeometryAdded(geometry: Geometry): void;
  9444. onGeometryUpdated: (geometry: Geometry) => void;
  9445. onGeometryDeleted(geometry: Geometry): void;
  9446. private _afterRender;
  9447. private _onMessageFromWorker;
  9448. }
  9449. /** @hidden */
  9450. class CollisionCoordinatorLegacy implements ICollisionCoordinator {
  9451. private _scene;
  9452. private _scaledPosition;
  9453. private _scaledVelocity;
  9454. private _finalPosition;
  9455. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  9456. init(scene: Scene): void;
  9457. destroy(): void;
  9458. onMeshAdded(mesh: AbstractMesh): void;
  9459. onMeshUpdated(mesh: AbstractMesh): void;
  9460. onMeshRemoved(mesh: AbstractMesh): void;
  9461. onGeometryAdded(geometry: Geometry): void;
  9462. onGeometryUpdated(geometry: Geometry): void;
  9463. onGeometryDeleted(geometry: Geometry): void;
  9464. private _collideWithWorld;
  9465. }
  9466. }
  9467. declare function importScripts(...urls: string[]): void;
  9468. declare const safePostMessage: any;
  9469. declare module BABYLON {
  9470. /** @hidden */
  9471. var WorkerIncluded: boolean;
  9472. /** @hidden */
  9473. class CollisionCache {
  9474. private _meshes;
  9475. private _geometries;
  9476. getMeshes(): {
  9477. [n: number]: SerializedMesh;
  9478. };
  9479. getGeometries(): {
  9480. [s: number]: SerializedGeometry;
  9481. };
  9482. getMesh(id: any): SerializedMesh;
  9483. addMesh(mesh: SerializedMesh): void;
  9484. removeMesh(uniqueId: number): void;
  9485. getGeometry(id: string): SerializedGeometry;
  9486. addGeometry(geometry: SerializedGeometry): void;
  9487. removeGeometry(id: string): void;
  9488. }
  9489. /** @hidden */
  9490. class CollideWorker {
  9491. collider: Collider;
  9492. private _collisionCache;
  9493. private finalPosition;
  9494. private collisionsScalingMatrix;
  9495. private collisionTranformationMatrix;
  9496. constructor(collider: Collider, _collisionCache: CollisionCache, finalPosition: Vector3);
  9497. collideWithWorld(position: Vector3, velocity: Vector3, maximumRetry: number, excludedMeshUniqueId: Nullable<number>): void;
  9498. private checkCollision;
  9499. private processCollisionsForSubMeshes;
  9500. private collideForSubMesh;
  9501. private checkSubmeshCollision;
  9502. }
  9503. /** @hidden */
  9504. interface ICollisionDetector {
  9505. onInit(payload: InitPayload): void;
  9506. onUpdate(payload: UpdatePayload): void;
  9507. onCollision(payload: CollidePayload): void;
  9508. }
  9509. /** @hidden */
  9510. class CollisionDetectorTransferable implements ICollisionDetector {
  9511. private _collisionCache;
  9512. onInit(payload: InitPayload): void;
  9513. onUpdate(payload: UpdatePayload): void;
  9514. onCollision(payload: CollidePayload): void;
  9515. }
  9516. }
  9517. declare module BABYLON {
  9518. /**
  9519. * @hidden
  9520. */
  9521. class IntersectionInfo {
  9522. bu: Nullable<number>;
  9523. bv: Nullable<number>;
  9524. distance: number;
  9525. faceId: number;
  9526. subMeshId: number;
  9527. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  9528. }
  9529. /**
  9530. * Information about the result of picking within a scene
  9531. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  9532. */
  9533. class PickingInfo {
  9534. /**
  9535. * If the pick collided with an object
  9536. */
  9537. hit: boolean;
  9538. /**
  9539. * Distance away where the pick collided
  9540. */
  9541. distance: number;
  9542. /**
  9543. * The location of pick collision
  9544. */
  9545. pickedPoint: Nullable<Vector3>;
  9546. /**
  9547. * The mesh corresponding the the pick collision
  9548. */
  9549. pickedMesh: Nullable<AbstractMesh>;
  9550. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  9551. bu: number;
  9552. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  9553. bv: number;
  9554. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  9555. faceId: number;
  9556. /** Id of the the submesh that was picked */
  9557. subMeshId: number;
  9558. /** If a sprite was picked, this will be the sprite the pick collided with */
  9559. pickedSprite: Nullable<Sprite>;
  9560. /**
  9561. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  9562. */
  9563. originMesh: Nullable<AbstractMesh>;
  9564. /**
  9565. * The ray that was used to perform the picking.
  9566. */
  9567. ray: Nullable<Ray>;
  9568. /**
  9569. * Gets the normal correspodning to the face the pick collided with
  9570. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  9571. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  9572. * @returns The normal correspodning to the face the pick collided with
  9573. */
  9574. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  9575. /**
  9576. * Gets the texture coordinates of where the pick occured
  9577. * @returns the vector containing the coordnates of the texture
  9578. */
  9579. getTextureCoordinates(): Nullable<Vector2>;
  9580. }
  9581. }
  9582. /**
  9583. * Module Debug contains the (visual) components to debug a scene correctly
  9584. */
  9585. declare module BABYLON.Debug {
  9586. /**
  9587. * The Axes viewer will show 3 axes in a specific point in space
  9588. */
  9589. class AxesViewer {
  9590. private _xAxis;
  9591. private _yAxis;
  9592. private _zAxis;
  9593. private _scaleLinesFactor;
  9594. private _instanced;
  9595. /**
  9596. * Gets the hosting scene
  9597. */
  9598. scene: Scene;
  9599. /**
  9600. * Gets or sets a number used to scale line length
  9601. */
  9602. scaleLines: number;
  9603. /** Gets the node hierarchy used to render x-axis */
  9604. readonly xAxis: TransformNode;
  9605. /** Gets the node hierarchy used to render y-axis */
  9606. readonly yAxis: TransformNode;
  9607. /** Gets the node hierarchy used to render z-axis */
  9608. readonly zAxis: TransformNode;
  9609. /**
  9610. * Creates a new AxesViewer
  9611. * @param scene defines the hosting scene
  9612. * @param scaleLines defines a number used to scale line length (1 by default)
  9613. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  9614. * @param xAxis defines the node hierarchy used to render the x-axis
  9615. * @param yAxis defines the node hierarchy used to render the y-axis
  9616. * @param zAxis defines the node hierarchy used to render the z-axis
  9617. */
  9618. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  9619. /**
  9620. * Force the viewer to update
  9621. * @param position defines the position of the viewer
  9622. * @param xaxis defines the x axis of the viewer
  9623. * @param yaxis defines the y axis of the viewer
  9624. * @param zaxis defines the z axis of the viewer
  9625. */
  9626. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  9627. /**
  9628. * Creates an instance of this axes viewer.
  9629. * @returns a new axes viewer with instanced meshes
  9630. */
  9631. createInstance(): AxesViewer;
  9632. /** Releases resources */
  9633. dispose(): void;
  9634. private static _SetRenderingGroupId;
  9635. }
  9636. }
  9637. declare module BABYLON.Debug {
  9638. /**
  9639. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  9640. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  9641. */
  9642. class BoneAxesViewer extends AxesViewer {
  9643. /**
  9644. * Gets or sets the target mesh where to display the axes viewer
  9645. */
  9646. mesh: Nullable<Mesh>;
  9647. /**
  9648. * Gets or sets the target bone where to display the axes viewer
  9649. */
  9650. bone: Nullable<Bone>;
  9651. /** Gets current position */
  9652. pos: Vector3;
  9653. /** Gets direction of X axis */
  9654. xaxis: Vector3;
  9655. /** Gets direction of Y axis */
  9656. yaxis: Vector3;
  9657. /** Gets direction of Z axis */
  9658. zaxis: Vector3;
  9659. /**
  9660. * Creates a new BoneAxesViewer
  9661. * @param scene defines the hosting scene
  9662. * @param bone defines the target bone
  9663. * @param mesh defines the target mesh
  9664. * @param scaleLines defines a scaling factor for line length (1 by default)
  9665. */
  9666. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  9667. /**
  9668. * Force the viewer to update
  9669. */
  9670. update(): void;
  9671. /** Releases resources */
  9672. dispose(): void;
  9673. }
  9674. }
  9675. declare module BABYLON {
  9676. /**
  9677. * Interface used to define scene explorer extensibility option
  9678. */
  9679. interface IExplorerExtensibilityOption {
  9680. /**
  9681. * Define the option label
  9682. */
  9683. label: string;
  9684. /**
  9685. * Defines the action to execute on click
  9686. */
  9687. action: (entity: any) => void;
  9688. }
  9689. /**
  9690. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  9691. */
  9692. interface IExplorerExtensibilityGroup {
  9693. /**
  9694. * Defines a predicate to test if a given type mut be extended
  9695. */
  9696. predicate: (entity: any) => boolean;
  9697. /**
  9698. * Gets the list of options added to a type
  9699. */
  9700. entries: IExplorerExtensibilityOption[];
  9701. }
  9702. /**
  9703. * Interface used to define the options to use to create the Inspector
  9704. */
  9705. interface IInspectorOptions {
  9706. /**
  9707. * Display in overlay mode (default: false)
  9708. */
  9709. overlay?: boolean;
  9710. /**
  9711. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  9712. */
  9713. globalRoot?: HTMLElement;
  9714. /**
  9715. * Display the Scene explorer
  9716. */
  9717. showExplorer?: boolean;
  9718. /**
  9719. * Display the property inspector
  9720. */
  9721. showInspector?: boolean;
  9722. /**
  9723. * Display in embed mode (both panes on the right)
  9724. */
  9725. embedMode?: boolean;
  9726. /**
  9727. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  9728. */
  9729. handleResize?: boolean;
  9730. /**
  9731. * Allow the panes to popup (default: true)
  9732. */
  9733. enablePopup?: boolean;
  9734. /**
  9735. * Allow the panes to be closed by users (default: true)
  9736. */
  9737. enableClose?: boolean;
  9738. /**
  9739. * Optional list of extensibility entries
  9740. */
  9741. explorerExtensibility?: IExplorerExtensibilityGroup[];
  9742. }
  9743. interface Scene {
  9744. /**
  9745. * @hidden
  9746. * Backing field
  9747. */
  9748. _debugLayer: DebugLayer;
  9749. /**
  9750. * Gets the debug layer (aka Inspector) associated with the scene
  9751. * @see http://doc.babylonjs.com/features/playground_debuglayer
  9752. */
  9753. debugLayer: DebugLayer;
  9754. }
  9755. /**
  9756. * The debug layer (aka Inspector) is the go to tool in order to better understand
  9757. * what is happening in your scene
  9758. * @see http://doc.babylonjs.com/features/playground_debuglayer
  9759. */
  9760. class DebugLayer {
  9761. /**
  9762. * Define the url to get the inspector script from.
  9763. * By default it uses the babylonjs CDN.
  9764. * @ignoreNaming
  9765. */
  9766. static InspectorURL: string;
  9767. private _scene;
  9768. private BJSINSPECTOR;
  9769. /**
  9770. * Observable triggered when a property is changed through the inspector.
  9771. */
  9772. onPropertyChangedObservable: Observable<{
  9773. object: any;
  9774. property: string;
  9775. value: any;
  9776. initialValue: any;
  9777. }>;
  9778. /**
  9779. * Instantiates a new debug layer.
  9780. * The debug layer (aka Inspector) is the go to tool in order to better understand
  9781. * what is happening in your scene
  9782. * @see http://doc.babylonjs.com/features/playground_debuglayer
  9783. * @param scene Defines the scene to inspect
  9784. */
  9785. constructor(scene: Scene);
  9786. /** Creates the inspector window. */
  9787. private _createInspector;
  9788. /**
  9789. * Get if the inspector is visible or not.
  9790. * @returns true if visible otherwise, false
  9791. */
  9792. isVisible(): boolean;
  9793. /**
  9794. * Hide the inspector and close its window.
  9795. */
  9796. hide(): void;
  9797. /**
  9798. * Launch the debugLayer.
  9799. * @param config Define the configuration of the inspector
  9800. */
  9801. show(config?: IInspectorOptions): void;
  9802. }
  9803. }
  9804. declare module BABYLON.Debug {
  9805. /**
  9806. * Used to show the physics impostor around the specific mesh
  9807. */
  9808. class PhysicsViewer {
  9809. /** @hidden */
  9810. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  9811. /** @hidden */
  9812. protected _meshes: Array<Nullable<AbstractMesh>>;
  9813. /** @hidden */
  9814. protected _scene: Nullable<Scene>;
  9815. /** @hidden */
  9816. protected _numMeshes: number;
  9817. /** @hidden */
  9818. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  9819. private _renderFunction;
  9820. private _utilityLayer;
  9821. private _debugBoxMesh;
  9822. private _debugSphereMesh;
  9823. private _debugMaterial;
  9824. /**
  9825. * Creates a new PhysicsViewer
  9826. * @param scene defines the hosting scene
  9827. */
  9828. constructor(scene: Scene);
  9829. /** @hidden */
  9830. protected _updateDebugMeshes(): void;
  9831. /**
  9832. * Renders a specified physic impostor
  9833. * @param impostor defines the impostor to render
  9834. * @returns the new debug mesh used to render the impostor
  9835. */
  9836. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  9837. /**
  9838. * Hides a specified physic impostor
  9839. * @param impostor defines the impostor to hide
  9840. */
  9841. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  9842. private _getDebugMaterial;
  9843. private _getDebugBoxMesh;
  9844. private _getDebugSphereMesh;
  9845. private _getDebugMesh;
  9846. /** Releases all resources */
  9847. dispose(): void;
  9848. }
  9849. }
  9850. declare module BABYLON {
  9851. /**
  9852. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  9853. * in order to better appreciate the issue one might have.
  9854. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  9855. */
  9856. class RayHelper {
  9857. /**
  9858. * Defines the ray we are currently tryin to visualize.
  9859. */
  9860. ray: Nullable<Ray>;
  9861. private _renderPoints;
  9862. private _renderLine;
  9863. private _renderFunction;
  9864. private _scene;
  9865. private _updateToMeshFunction;
  9866. private _attachedToMesh;
  9867. private _meshSpaceDirection;
  9868. private _meshSpaceOrigin;
  9869. /**
  9870. * Helper function to create a colored helper in a scene in one line.
  9871. * @param ray Defines the ray we are currently tryin to visualize
  9872. * @param scene Defines the scene the ray is used in
  9873. * @param color Defines the color we want to see the ray in
  9874. * @returns The newly created ray helper.
  9875. */
  9876. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  9877. /**
  9878. * Instantiate a new ray helper.
  9879. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  9880. * in order to better appreciate the issue one might have.
  9881. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  9882. * @param ray Defines the ray we are currently tryin to visualize
  9883. */
  9884. constructor(ray: Ray);
  9885. /**
  9886. * Shows the ray we are willing to debug.
  9887. * @param scene Defines the scene the ray needs to be rendered in
  9888. * @param color Defines the color the ray needs to be rendered in
  9889. */
  9890. show(scene: Scene, color?: Color3): void;
  9891. /**
  9892. * Hides the ray we are debugging.
  9893. */
  9894. hide(): void;
  9895. private _render;
  9896. /**
  9897. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  9898. * @param mesh Defines the mesh we want the helper attached to
  9899. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  9900. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  9901. * @param length Defines the length of the ray
  9902. */
  9903. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  9904. /**
  9905. * Detach the ray helper from the mesh it has previously been attached to.
  9906. */
  9907. detachFromMesh(): void;
  9908. private _updateToMesh;
  9909. /**
  9910. * Dispose the helper and release its associated resources.
  9911. */
  9912. dispose(): void;
  9913. }
  9914. }
  9915. declare module BABYLON.Debug {
  9916. /**
  9917. * Class used to render a debug view of a given skeleton
  9918. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  9919. */
  9920. class SkeletonViewer {
  9921. /** defines the skeleton to render */
  9922. skeleton: Skeleton;
  9923. /** defines the mesh attached to the skeleton */
  9924. mesh: AbstractMesh;
  9925. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  9926. autoUpdateBonesMatrices: boolean;
  9927. /** defines the rendering group id to use with the viewer */
  9928. renderingGroupId: number;
  9929. /** Gets or sets the color used to render the skeleton */
  9930. color: Color3;
  9931. private _scene;
  9932. private _debugLines;
  9933. private _debugMesh;
  9934. private _isEnabled;
  9935. private _renderFunction;
  9936. private _utilityLayer;
  9937. /**
  9938. * Returns the mesh used to render the bones
  9939. */
  9940. readonly debugMesh: Nullable<LinesMesh>;
  9941. /**
  9942. * Creates a new SkeletonViewer
  9943. * @param skeleton defines the skeleton to render
  9944. * @param mesh defines the mesh attached to the skeleton
  9945. * @param scene defines the hosting scene
  9946. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  9947. * @param renderingGroupId defines the rendering group id to use with the viewer
  9948. */
  9949. constructor(
  9950. /** defines the skeleton to render */
  9951. skeleton: Skeleton,
  9952. /** defines the mesh attached to the skeleton */
  9953. mesh: AbstractMesh, scene: Scene,
  9954. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  9955. autoUpdateBonesMatrices?: boolean,
  9956. /** defines the rendering group id to use with the viewer */
  9957. renderingGroupId?: number);
  9958. /** Gets or sets a boolean indicating if the viewer is enabled */
  9959. isEnabled: boolean;
  9960. private _getBonePosition;
  9961. private _getLinesForBonesWithLength;
  9962. private _getLinesForBonesNoLength;
  9963. /** Update the viewer to sync with current skeleton state */
  9964. update(): void;
  9965. /** Release associated resources */
  9966. dispose(): void;
  9967. }
  9968. }
  9969. declare module BABYLON {
  9970. /**
  9971. * Interface for attribute information associated with buffer instanciation
  9972. */
  9973. class InstancingAttributeInfo {
  9974. /**
  9975. * Index/offset of the attribute in the vertex shader
  9976. */
  9977. index: number;
  9978. /**
  9979. * size of the attribute, 1, 2, 3 or 4
  9980. */
  9981. attributeSize: number;
  9982. /**
  9983. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  9984. * default is FLOAT
  9985. */
  9986. attribyteType: number;
  9987. /**
  9988. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  9989. */
  9990. normalized: boolean;
  9991. /**
  9992. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  9993. */
  9994. offset: number;
  9995. /**
  9996. * Name of the GLSL attribute, for debugging purpose only
  9997. */
  9998. attributeName: string;
  9999. }
  10000. /**
  10001. * Define options used to create a render target texture
  10002. */
  10003. class RenderTargetCreationOptions {
  10004. /**
  10005. * Specifies is mipmaps must be generated
  10006. */
  10007. generateMipMaps?: boolean;
  10008. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  10009. generateDepthBuffer?: boolean;
  10010. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  10011. generateStencilBuffer?: boolean;
  10012. /** Defines texture type (int by default) */
  10013. type?: number;
  10014. /** Defines sampling mode (trilinear by default) */
  10015. samplingMode?: number;
  10016. /** Defines format (RGBA by default) */
  10017. format?: number;
  10018. }
  10019. /**
  10020. * Define options used to create a depth texture
  10021. */
  10022. class DepthTextureCreationOptions {
  10023. /** Specifies whether or not a stencil should be allocated in the texture */
  10024. generateStencil?: boolean;
  10025. /** Specifies whether or not bilinear filtering is enable on the texture */
  10026. bilinearFiltering?: boolean;
  10027. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  10028. comparisonFunction?: number;
  10029. /** Specifies if the created texture is a cube texture */
  10030. isCube?: boolean;
  10031. }
  10032. /**
  10033. * Class used to describe the capabilities of the engine relatively to the current browser
  10034. */
  10035. class EngineCapabilities {
  10036. /** Maximum textures units per fragment shader */
  10037. maxTexturesImageUnits: number;
  10038. /** Maximum texture units per vertex shader */
  10039. maxVertexTextureImageUnits: number;
  10040. /** Maximum textures units in the entire pipeline */
  10041. maxCombinedTexturesImageUnits: number;
  10042. /** Maximum texture size */
  10043. maxTextureSize: number;
  10044. /** Maximum cube texture size */
  10045. maxCubemapTextureSize: number;
  10046. /** Maximum render texture size */
  10047. maxRenderTextureSize: number;
  10048. /** Maximum number of vertex attributes */
  10049. maxVertexAttribs: number;
  10050. /** Maximum number of varyings */
  10051. maxVaryingVectors: number;
  10052. /** Maximum number of uniforms per vertex shader */
  10053. maxVertexUniformVectors: number;
  10054. /** Maximum number of uniforms per fragment shader */
  10055. maxFragmentUniformVectors: number;
  10056. /** Defines if standard derivates (dx/dy) are supported */
  10057. standardDerivatives: boolean;
  10058. /** Defines if s3tc texture compression is supported */
  10059. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  10060. /** Defines if pvrtc texture compression is supported */
  10061. pvrtc: any;
  10062. /** Defines if etc1 texture compression is supported */
  10063. etc1: any;
  10064. /** Defines if etc2 texture compression is supported */
  10065. etc2: any;
  10066. /** Defines if astc texture compression is supported */
  10067. astc: any;
  10068. /** Defines if float textures are supported */
  10069. textureFloat: boolean;
  10070. /** Defines if vertex array objects are supported */
  10071. vertexArrayObject: boolean;
  10072. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  10073. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  10074. /** Gets the maximum level of anisotropy supported */
  10075. maxAnisotropy: number;
  10076. /** Defines if instancing is supported */
  10077. instancedArrays: boolean;
  10078. /** Defines if 32 bits indices are supported */
  10079. uintIndices: boolean;
  10080. /** Defines if high precision shaders are supported */
  10081. highPrecisionShaderSupported: boolean;
  10082. /** Defines if depth reading in the fragment shader is supported */
  10083. fragmentDepthSupported: boolean;
  10084. /** Defines if float texture linear filtering is supported*/
  10085. textureFloatLinearFiltering: boolean;
  10086. /** Defines if rendering to float textures is supported */
  10087. textureFloatRender: boolean;
  10088. /** Defines if half float textures are supported*/
  10089. textureHalfFloat: boolean;
  10090. /** Defines if half float texture linear filtering is supported*/
  10091. textureHalfFloatLinearFiltering: boolean;
  10092. /** Defines if rendering to half float textures is supported */
  10093. textureHalfFloatRender: boolean;
  10094. /** Defines if textureLOD shader command is supported */
  10095. textureLOD: boolean;
  10096. /** Defines if draw buffers extension is supported */
  10097. drawBuffersExtension: boolean;
  10098. /** Defines if depth textures are supported */
  10099. depthTextureExtension: boolean;
  10100. /** Defines if float color buffer are supported */
  10101. colorBufferFloat: boolean;
  10102. /** Gets disjoint timer query extension (null if not supported) */
  10103. timerQuery: EXT_disjoint_timer_query;
  10104. /** Defines if timestamp can be used with timer query */
  10105. canUseTimestampForTimerQuery: boolean;
  10106. /** Function used to let the system compiles shaders in background */
  10107. parallelShaderCompile: {
  10108. MAX_SHADER_COMPILER_THREADS_KHR: number;
  10109. maxShaderCompilerThreadsKHR: (thread: number) => void;
  10110. COMPLETION_STATUS_KHR: number;
  10111. };
  10112. }
  10113. /** Interface defining initialization parameters for Engine class */
  10114. interface EngineOptions extends WebGLContextAttributes {
  10115. /**
  10116. * Defines if the engine should no exceed a specified device ratio
  10117. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  10118. */
  10119. limitDeviceRatio?: number;
  10120. /**
  10121. * Defines if webvr should be enabled automatically
  10122. * @see http://doc.babylonjs.com/how_to/webvr_camera
  10123. */
  10124. autoEnableWebVR?: boolean;
  10125. /**
  10126. * Defines if webgl2 should be turned off even if supported
  10127. * @see http://doc.babylonjs.com/features/webgl2
  10128. */
  10129. disableWebGL2Support?: boolean;
  10130. /**
  10131. * Defines if webaudio should be initialized as well
  10132. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  10133. */
  10134. audioEngine?: boolean;
  10135. /**
  10136. * Defines if animations should run using a deterministic lock step
  10137. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  10138. */
  10139. deterministicLockstep?: boolean;
  10140. /** Defines the maximum steps to use with deterministic lock step mode */
  10141. lockstepMaxSteps?: number;
  10142. /**
  10143. * Defines that engine should ignore context lost events
  10144. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  10145. */
  10146. doNotHandleContextLost?: boolean;
  10147. }
  10148. /**
  10149. * Defines the interface used by display changed events
  10150. */
  10151. interface IDisplayChangedEventArgs {
  10152. /** Gets the vrDisplay object (if any) */
  10153. vrDisplay: Nullable<any>;
  10154. /** Gets a boolean indicating if webVR is supported */
  10155. vrSupported: boolean;
  10156. }
  10157. /**
  10158. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  10159. */
  10160. class Engine {
  10161. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  10162. static ExceptionList: ({
  10163. key: string;
  10164. capture: string;
  10165. captureConstraint: number;
  10166. targets: string[];
  10167. } | {
  10168. key: string;
  10169. capture: null;
  10170. captureConstraint: null;
  10171. targets: string[];
  10172. })[];
  10173. /** Gets the list of created engines */
  10174. static Instances: Engine[];
  10175. /**
  10176. * Gets the latest created engine
  10177. */
  10178. static readonly LastCreatedEngine: Nullable<Engine>;
  10179. /**
  10180. * Gets the latest created scene
  10181. */
  10182. static readonly LastCreatedScene: Nullable<Scene>;
  10183. /**
  10184. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  10185. * @param flag defines which part of the materials must be marked as dirty
  10186. * @param predicate defines a predicate used to filter which materials should be affected
  10187. */
  10188. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  10189. /**
  10190. * Hidden
  10191. */
  10192. static _TextureLoaders: IInternalTextureLoader[];
  10193. /** Defines that alpha blending is disabled */
  10194. static readonly ALPHA_DISABLE: number;
  10195. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  10196. static readonly ALPHA_ADD: number;
  10197. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  10198. static readonly ALPHA_COMBINE: number;
  10199. /** Defines that alpha blending to DEST - SRC * DEST */
  10200. static readonly ALPHA_SUBTRACT: number;
  10201. /** Defines that alpha blending to SRC * DEST */
  10202. static readonly ALPHA_MULTIPLY: number;
  10203. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  10204. static readonly ALPHA_MAXIMIZED: number;
  10205. /** Defines that alpha blending to SRC + DEST */
  10206. static readonly ALPHA_ONEONE: number;
  10207. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  10208. static readonly ALPHA_PREMULTIPLIED: number;
  10209. /**
  10210. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  10211. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  10212. */
  10213. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  10214. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  10215. static readonly ALPHA_INTERPOLATE: number;
  10216. /**
  10217. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  10218. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  10219. */
  10220. static readonly ALPHA_SCREENMODE: number;
  10221. /** Defines that the ressource is not delayed*/
  10222. static readonly DELAYLOADSTATE_NONE: number;
  10223. /** Defines that the ressource was successfully delay loaded */
  10224. static readonly DELAYLOADSTATE_LOADED: number;
  10225. /** Defines that the ressource is currently delay loading */
  10226. static readonly DELAYLOADSTATE_LOADING: number;
  10227. /** Defines that the ressource is delayed and has not started loading */
  10228. static readonly DELAYLOADSTATE_NOTLOADED: number;
  10229. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  10230. static readonly NEVER: number;
  10231. /** 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 */
  10232. static readonly ALWAYS: number;
  10233. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  10234. static readonly LESS: number;
  10235. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  10236. static readonly EQUAL: number;
  10237. /** 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 */
  10238. static readonly LEQUAL: number;
  10239. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  10240. static readonly GREATER: number;
  10241. /** 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 */
  10242. static readonly GEQUAL: number;
  10243. /** 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 */
  10244. static readonly NOTEQUAL: number;
  10245. /** Passed to stencilOperation to specify that stencil value must be kept */
  10246. static readonly KEEP: number;
  10247. /** Passed to stencilOperation to specify that stencil value must be replaced */
  10248. static readonly REPLACE: number;
  10249. /** Passed to stencilOperation to specify that stencil value must be incremented */
  10250. static readonly INCR: number;
  10251. /** Passed to stencilOperation to specify that stencil value must be decremented */
  10252. static readonly DECR: number;
  10253. /** Passed to stencilOperation to specify that stencil value must be inverted */
  10254. static readonly INVERT: number;
  10255. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  10256. static readonly INCR_WRAP: number;
  10257. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  10258. static readonly DECR_WRAP: number;
  10259. /** Texture is not repeating outside of 0..1 UVs */
  10260. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  10261. /** Texture is repeating outside of 0..1 UVs */
  10262. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  10263. /** Texture is repeating and mirrored */
  10264. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  10265. /** ALPHA */
  10266. static readonly TEXTUREFORMAT_ALPHA: number;
  10267. /** LUMINANCE */
  10268. static readonly TEXTUREFORMAT_LUMINANCE: number;
  10269. /** LUMINANCE_ALPHA */
  10270. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  10271. /** RGB */
  10272. static readonly TEXTUREFORMAT_RGB: number;
  10273. /** RGBA */
  10274. static readonly TEXTUREFORMAT_RGBA: number;
  10275. /** RED */
  10276. static readonly TEXTUREFORMAT_RED: number;
  10277. /** RED (2nd reference) */
  10278. static readonly TEXTUREFORMAT_R: number;
  10279. /** RG */
  10280. static readonly TEXTUREFORMAT_RG: number;
  10281. /** RED_INTEGER */
  10282. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  10283. /** RED_INTEGER (2nd reference) */
  10284. static readonly TEXTUREFORMAT_R_INTEGER: number;
  10285. /** RG_INTEGER */
  10286. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  10287. /** RGB_INTEGER */
  10288. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  10289. /** RGBA_INTEGER */
  10290. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  10291. /** UNSIGNED_BYTE */
  10292. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  10293. /** UNSIGNED_BYTE (2nd reference) */
  10294. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  10295. /** FLOAT */
  10296. static readonly TEXTURETYPE_FLOAT: number;
  10297. /** HALF_FLOAT */
  10298. static readonly TEXTURETYPE_HALF_FLOAT: number;
  10299. /** BYTE */
  10300. static readonly TEXTURETYPE_BYTE: number;
  10301. /** SHORT */
  10302. static readonly TEXTURETYPE_SHORT: number;
  10303. /** UNSIGNED_SHORT */
  10304. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  10305. /** INT */
  10306. static readonly TEXTURETYPE_INT: number;
  10307. /** UNSIGNED_INT */
  10308. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  10309. /** UNSIGNED_SHORT_4_4_4_4 */
  10310. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  10311. /** UNSIGNED_SHORT_5_5_5_1 */
  10312. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  10313. /** UNSIGNED_SHORT_5_6_5 */
  10314. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  10315. /** UNSIGNED_INT_2_10_10_10_REV */
  10316. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  10317. /** UNSIGNED_INT_24_8 */
  10318. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  10319. /** UNSIGNED_INT_10F_11F_11F_REV */
  10320. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  10321. /** UNSIGNED_INT_5_9_9_9_REV */
  10322. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  10323. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  10324. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  10325. /** nearest is mag = nearest and min = nearest and mip = linear */
  10326. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  10327. /** Bilinear is mag = linear and min = linear and mip = nearest */
  10328. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  10329. /** Trilinear is mag = linear and min = linear and mip = linear */
  10330. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  10331. /** nearest is mag = nearest and min = nearest and mip = linear */
  10332. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  10333. /** Bilinear is mag = linear and min = linear and mip = nearest */
  10334. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  10335. /** Trilinear is mag = linear and min = linear and mip = linear */
  10336. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  10337. /** mag = nearest and min = nearest and mip = nearest */
  10338. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  10339. /** mag = nearest and min = linear and mip = nearest */
  10340. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  10341. /** mag = nearest and min = linear and mip = linear */
  10342. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  10343. /** mag = nearest and min = linear and mip = none */
  10344. static readonly TEXTURE_NEAREST_LINEAR: number;
  10345. /** mag = nearest and min = nearest and mip = none */
  10346. static readonly TEXTURE_NEAREST_NEAREST: number;
  10347. /** mag = linear and min = nearest and mip = nearest */
  10348. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  10349. /** mag = linear and min = nearest and mip = linear */
  10350. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  10351. /** mag = linear and min = linear and mip = none */
  10352. static readonly TEXTURE_LINEAR_LINEAR: number;
  10353. /** mag = linear and min = nearest and mip = none */
  10354. static readonly TEXTURE_LINEAR_NEAREST: number;
  10355. /** Explicit coordinates mode */
  10356. static readonly TEXTURE_EXPLICIT_MODE: number;
  10357. /** Spherical coordinates mode */
  10358. static readonly TEXTURE_SPHERICAL_MODE: number;
  10359. /** Planar coordinates mode */
  10360. static readonly TEXTURE_PLANAR_MODE: number;
  10361. /** Cubic coordinates mode */
  10362. static readonly TEXTURE_CUBIC_MODE: number;
  10363. /** Projection coordinates mode */
  10364. static readonly TEXTURE_PROJECTION_MODE: number;
  10365. /** Skybox coordinates mode */
  10366. static readonly TEXTURE_SKYBOX_MODE: number;
  10367. /** Inverse Cubic coordinates mode */
  10368. static readonly TEXTURE_INVCUBIC_MODE: number;
  10369. /** Equirectangular coordinates mode */
  10370. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  10371. /** Equirectangular Fixed coordinates mode */
  10372. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  10373. /** Equirectangular Fixed Mirrored coordinates mode */
  10374. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  10375. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  10376. static readonly SCALEMODE_FLOOR: number;
  10377. /** Defines that texture rescaling will look for the nearest power of 2 size */
  10378. static readonly SCALEMODE_NEAREST: number;
  10379. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  10380. static readonly SCALEMODE_CEILING: number;
  10381. /**
  10382. * Returns the current version of the framework
  10383. */
  10384. static readonly Version: string;
  10385. /**
  10386. * Returns a string describing the current engine
  10387. */
  10388. readonly description: string;
  10389. /**
  10390. * Gets or sets the epsilon value used by collision engine
  10391. */
  10392. static CollisionsEpsilon: number;
  10393. /**
  10394. * Gets or sets the relative url used to load code if using the engine in non-minified mode
  10395. */
  10396. static CodeRepository: string;
  10397. /**
  10398. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  10399. */
  10400. static ShadersRepository: string;
  10401. /**
  10402. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  10403. */
  10404. forcePOTTextures: boolean;
  10405. /**
  10406. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  10407. */
  10408. isFullscreen: boolean;
  10409. /**
  10410. * Gets a boolean indicating if the pointer is currently locked
  10411. */
  10412. isPointerLock: boolean;
  10413. /**
  10414. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  10415. */
  10416. cullBackFaces: boolean;
  10417. /**
  10418. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  10419. */
  10420. renderEvenInBackground: boolean;
  10421. /**
  10422. * Gets or sets a boolean indicating that cache can be kept between frames
  10423. */
  10424. preventCacheWipeBetweenFrames: boolean;
  10425. /**
  10426. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  10427. **/
  10428. enableOfflineSupport: boolean;
  10429. /**
  10430. * 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)
  10431. **/
  10432. disableManifestCheck: boolean;
  10433. /**
  10434. * Gets the list of created scenes
  10435. */
  10436. scenes: Scene[];
  10437. /**
  10438. * Event raised when a new scene is created
  10439. */
  10440. onNewSceneAddedObservable: Observable<Scene>;
  10441. /**
  10442. * Gets the list of created postprocesses
  10443. */
  10444. postProcesses: PostProcess[];
  10445. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  10446. validateShaderPrograms: boolean;
  10447. /**
  10448. * Observable event triggered each time the rendering canvas is resized
  10449. */
  10450. onResizeObservable: Observable<Engine>;
  10451. /**
  10452. * Observable event triggered each time the canvas loses focus
  10453. */
  10454. onCanvasBlurObservable: Observable<Engine>;
  10455. /**
  10456. * Observable event triggered each time the canvas gains focus
  10457. */
  10458. onCanvasFocusObservable: Observable<Engine>;
  10459. /**
  10460. * Observable event triggered each time the canvas receives pointerout event
  10461. */
  10462. onCanvasPointerOutObservable: Observable<PointerEvent>;
  10463. /**
  10464. * Observable event triggered before each texture is initialized
  10465. */
  10466. onBeforeTextureInitObservable: Observable<Texture>;
  10467. private _vrDisplay;
  10468. private _vrSupported;
  10469. private _oldSize;
  10470. private _oldHardwareScaleFactor;
  10471. private _vrExclusivePointerMode;
  10472. private _webVRInitPromise;
  10473. /**
  10474. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  10475. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  10476. */
  10477. readonly isInVRExclusivePointerMode: boolean;
  10478. /**
  10479. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  10480. */
  10481. disableUniformBuffers: boolean;
  10482. /** @hidden */
  10483. _uniformBuffers: UniformBuffer[];
  10484. /**
  10485. * Gets a boolean indicating that the engine supports uniform buffers
  10486. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  10487. */
  10488. readonly supportsUniformBuffers: boolean;
  10489. /**
  10490. * Observable raised when the engine begins a new frame
  10491. */
  10492. onBeginFrameObservable: Observable<Engine>;
  10493. /**
  10494. * If set, will be used to request the next animation frame for the render loop
  10495. */
  10496. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  10497. /**
  10498. * Observable raised when the engine ends the current frame
  10499. */
  10500. onEndFrameObservable: Observable<Engine>;
  10501. /**
  10502. * Observable raised when the engine is about to compile a shader
  10503. */
  10504. onBeforeShaderCompilationObservable: Observable<Engine>;
  10505. /**
  10506. * Observable raised when the engine has jsut compiled a shader
  10507. */
  10508. onAfterShaderCompilationObservable: Observable<Engine>;
  10509. /** @hidden */
  10510. _gl: WebGLRenderingContext;
  10511. private _renderingCanvas;
  10512. private _windowIsBackground;
  10513. private _webGLVersion;
  10514. /**
  10515. * Gets a boolean indicating that only power of 2 textures are supported
  10516. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  10517. */
  10518. readonly needPOTTextures: boolean;
  10519. /** @hidden */
  10520. _badOS: boolean;
  10521. /** @hidden */
  10522. _badDesktopOS: boolean;
  10523. /**
  10524. * Gets or sets a value indicating if we want to disable texture binding optimization.
  10525. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  10526. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  10527. */
  10528. disableTextureBindingOptimization: boolean;
  10529. /**
  10530. * Gets the audio engine
  10531. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  10532. * @ignorenaming
  10533. */
  10534. static audioEngine: IAudioEngine;
  10535. /**
  10536. * Default AudioEngine factory responsible of creating the Audio Engine.
  10537. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  10538. */
  10539. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  10540. /**
  10541. * Default offline support factory responsible of creating a tool used to store data locally.
  10542. * By default, this will create a Database object if the workload has been embedded.
  10543. */
  10544. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  10545. private _onFocus;
  10546. private _onBlur;
  10547. private _onCanvasPointerOut;
  10548. private _onCanvasBlur;
  10549. private _onCanvasFocus;
  10550. private _onFullscreenChange;
  10551. private _onPointerLockChange;
  10552. private _onVRDisplayPointerRestricted;
  10553. private _onVRDisplayPointerUnrestricted;
  10554. private _onVrDisplayConnect;
  10555. private _onVrDisplayDisconnect;
  10556. private _onVrDisplayPresentChange;
  10557. /**
  10558. * Observable signaled when VR display mode changes
  10559. */
  10560. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  10561. /**
  10562. * Observable signaled when VR request present is complete
  10563. */
  10564. onVRRequestPresentComplete: Observable<boolean>;
  10565. /**
  10566. * Observable signaled when VR request present starts
  10567. */
  10568. onVRRequestPresentStart: Observable<Engine>;
  10569. private _hardwareScalingLevel;
  10570. /** @hidden */
  10571. protected _caps: EngineCapabilities;
  10572. private _pointerLockRequested;
  10573. private _isStencilEnable;
  10574. private _colorWrite;
  10575. private _loadingScreen;
  10576. /** @hidden */
  10577. _drawCalls: PerfCounter;
  10578. /** @hidden */
  10579. _textureCollisions: PerfCounter;
  10580. private _glVersion;
  10581. private _glRenderer;
  10582. private _glVendor;
  10583. private _videoTextureSupported;
  10584. private _renderingQueueLaunched;
  10585. private _activeRenderLoops;
  10586. private _deterministicLockstep;
  10587. private _lockstepMaxSteps;
  10588. /**
  10589. * Observable signaled when a context lost event is raised
  10590. */
  10591. onContextLostObservable: Observable<Engine>;
  10592. /**
  10593. * Observable signaled when a context restored event is raised
  10594. */
  10595. onContextRestoredObservable: Observable<Engine>;
  10596. private _onContextLost;
  10597. private _onContextRestored;
  10598. private _contextWasLost;
  10599. private _doNotHandleContextLost;
  10600. /**
  10601. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  10602. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  10603. */
  10604. doNotHandleContextLost: boolean;
  10605. private _performanceMonitor;
  10606. private _fps;
  10607. private _deltaTime;
  10608. /**
  10609. * Turn this value on if you want to pause FPS computation when in background
  10610. */
  10611. disablePerformanceMonitorInBackground: boolean;
  10612. /**
  10613. * Gets the performance monitor attached to this engine
  10614. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  10615. */
  10616. readonly performanceMonitor: PerformanceMonitor;
  10617. /** @hidden */
  10618. protected _depthCullingState: _DepthCullingState;
  10619. /** @hidden */
  10620. protected _stencilState: _StencilState;
  10621. /** @hidden */
  10622. protected _alphaState: _AlphaState;
  10623. /** @hidden */
  10624. protected _alphaMode: number;
  10625. protected _internalTexturesCache: InternalTexture[];
  10626. /** @hidden */
  10627. protected _activeChannel: number;
  10628. private _currentTextureChannel;
  10629. /** @hidden */
  10630. protected _boundTexturesCache: {
  10631. [key: string]: Nullable<InternalTexture>;
  10632. };
  10633. /** @hidden */
  10634. protected _currentEffect: Nullable<Effect>;
  10635. /** @hidden */
  10636. protected _currentProgram: Nullable<WebGLProgram>;
  10637. private _compiledEffects;
  10638. private _vertexAttribArraysEnabled;
  10639. /** @hidden */
  10640. protected _cachedViewport: Nullable<Viewport>;
  10641. private _cachedVertexArrayObject;
  10642. /** @hidden */
  10643. protected _cachedVertexBuffers: any;
  10644. /** @hidden */
  10645. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  10646. /** @hidden */
  10647. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  10648. /** @hidden */
  10649. protected _currentRenderTarget: Nullable<InternalTexture>;
  10650. private _uintIndicesCurrentlySet;
  10651. private _currentBoundBuffer;
  10652. /** @hidden */
  10653. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  10654. private _currentBufferPointers;
  10655. private _currentInstanceLocations;
  10656. private _currentInstanceBuffers;
  10657. private _textureUnits;
  10658. private _firstBoundInternalTextureTracker;
  10659. private _lastBoundInternalTextureTracker;
  10660. private _workingCanvas;
  10661. private _workingContext;
  10662. private _rescalePostProcess;
  10663. private _dummyFramebuffer;
  10664. private _externalData;
  10665. private _bindedRenderFunction;
  10666. private _vaoRecordInProgress;
  10667. private _mustWipeVertexAttributes;
  10668. private _emptyTexture;
  10669. private _emptyCubeTexture;
  10670. private _emptyTexture3D;
  10671. /** @hidden */
  10672. _frameHandler: number;
  10673. private _nextFreeTextureSlots;
  10674. private _maxSimultaneousTextures;
  10675. private _activeRequests;
  10676. private _texturesSupported;
  10677. private _textureFormatInUse;
  10678. /**
  10679. * Gets the list of texture formats supported
  10680. */
  10681. readonly texturesSupported: Array<string>;
  10682. /**
  10683. * Gets the list of texture formats in use
  10684. */
  10685. readonly textureFormatInUse: Nullable<string>;
  10686. /**
  10687. * Gets the current viewport
  10688. */
  10689. readonly currentViewport: Nullable<Viewport>;
  10690. /**
  10691. * Gets the default empty texture
  10692. */
  10693. readonly emptyTexture: InternalTexture;
  10694. /**
  10695. * Gets the default empty 3D texture
  10696. */
  10697. readonly emptyTexture3D: InternalTexture;
  10698. /**
  10699. * Gets the default empty cube texture
  10700. */
  10701. readonly emptyCubeTexture: InternalTexture;
  10702. /**
  10703. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  10704. */
  10705. readonly premultipliedAlpha: boolean;
  10706. /**
  10707. * Creates a new engine
  10708. * @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
  10709. * @param antialias defines enable antialiasing (default: false)
  10710. * @param options defines further options to be sent to the getContext() function
  10711. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  10712. */
  10713. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  10714. private _rebuildInternalTextures;
  10715. private _rebuildEffects;
  10716. /**
  10717. * Gets a boolean indicating if all created effects are ready
  10718. * @returns true if all effects are ready
  10719. */
  10720. areAllEffectsReady(): boolean;
  10721. private _rebuildBuffers;
  10722. private _initGLContext;
  10723. /**
  10724. * Gets version of the current webGL context
  10725. */
  10726. readonly webGLVersion: number;
  10727. /**
  10728. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  10729. */
  10730. readonly isStencilEnable: boolean;
  10731. private _prepareWorkingCanvas;
  10732. /**
  10733. * Reset the texture cache to empty state
  10734. */
  10735. resetTextureCache(): void;
  10736. /**
  10737. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  10738. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  10739. * @returns true if engine is in deterministic lock step mode
  10740. */
  10741. isDeterministicLockStep(): boolean;
  10742. /**
  10743. * Gets the max steps when engine is running in deterministic lock step
  10744. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  10745. * @returns the max steps
  10746. */
  10747. getLockstepMaxSteps(): number;
  10748. /**
  10749. * Gets an object containing information about the current webGL context
  10750. * @returns an object containing the vender, the renderer and the version of the current webGL context
  10751. */
  10752. getGlInfo(): {
  10753. vendor: string;
  10754. renderer: string;
  10755. version: string;
  10756. };
  10757. /**
  10758. * Gets current aspect ratio
  10759. * @param camera defines the camera to use to get the aspect ratio
  10760. * @param useScreen defines if screen size must be used (or the current render target if any)
  10761. * @returns a number defining the aspect ratio
  10762. */
  10763. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  10764. /**
  10765. * Gets current screen aspect ratio
  10766. * @returns a number defining the aspect ratio
  10767. */
  10768. getScreenAspectRatio(): number;
  10769. /**
  10770. * Gets the current render width
  10771. * @param useScreen defines if screen size must be used (or the current render target if any)
  10772. * @returns a number defining the current render width
  10773. */
  10774. getRenderWidth(useScreen?: boolean): number;
  10775. /**
  10776. * Gets the current render height
  10777. * @param useScreen defines if screen size must be used (or the current render target if any)
  10778. * @returns a number defining the current render height
  10779. */
  10780. getRenderHeight(useScreen?: boolean): number;
  10781. /**
  10782. * Gets the HTML canvas attached with the current webGL context
  10783. * @returns a HTML canvas
  10784. */
  10785. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  10786. /**
  10787. * Gets the client rect of the HTML canvas attached with the current webGL context
  10788. * @returns a client rectanglee
  10789. */
  10790. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  10791. /**
  10792. * Defines the hardware scaling level.
  10793. * By default the hardware scaling level is computed from the window device ratio.
  10794. * 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.
  10795. * @param level defines the level to use
  10796. */
  10797. setHardwareScalingLevel(level: number): void;
  10798. /**
  10799. * Gets the current hardware scaling level.
  10800. * By default the hardware scaling level is computed from the window device ratio.
  10801. * 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.
  10802. * @returns a number indicating the current hardware scaling level
  10803. */
  10804. getHardwareScalingLevel(): number;
  10805. /**
  10806. * Gets the list of loaded textures
  10807. * @returns an array containing all loaded textures
  10808. */
  10809. getLoadedTexturesCache(): InternalTexture[];
  10810. /**
  10811. * Gets the object containing all engine capabilities
  10812. * @returns the EngineCapabilities object
  10813. */
  10814. getCaps(): EngineCapabilities;
  10815. /**
  10816. * Gets the current depth function
  10817. * @returns a number defining the depth function
  10818. */
  10819. getDepthFunction(): Nullable<number>;
  10820. /**
  10821. * Sets the current depth function
  10822. * @param depthFunc defines the function to use
  10823. */
  10824. setDepthFunction(depthFunc: number): void;
  10825. /**
  10826. * Sets the current depth function to GREATER
  10827. */
  10828. setDepthFunctionToGreater(): void;
  10829. /**
  10830. * Sets the current depth function to GEQUAL
  10831. */
  10832. setDepthFunctionToGreaterOrEqual(): void;
  10833. /**
  10834. * Sets the current depth function to LESS
  10835. */
  10836. setDepthFunctionToLess(): void;
  10837. /**
  10838. * Sets the current depth function to LEQUAL
  10839. */
  10840. setDepthFunctionToLessOrEqual(): void;
  10841. /**
  10842. * Gets a boolean indicating if stencil buffer is enabled
  10843. * @returns the current stencil buffer state
  10844. */
  10845. getStencilBuffer(): boolean;
  10846. /**
  10847. * Enable or disable the stencil buffer
  10848. * @param enable defines if the stencil buffer must be enabled or disabled
  10849. */
  10850. setStencilBuffer(enable: boolean): void;
  10851. /**
  10852. * Gets the current stencil mask
  10853. * @returns a number defining the new stencil mask to use
  10854. */
  10855. getStencilMask(): number;
  10856. /**
  10857. * Sets the current stencil mask
  10858. * @param mask defines the new stencil mask to use
  10859. */
  10860. setStencilMask(mask: number): void;
  10861. /**
  10862. * Gets the current stencil function
  10863. * @returns a number defining the stencil function to use
  10864. */
  10865. getStencilFunction(): number;
  10866. /**
  10867. * Gets the current stencil reference value
  10868. * @returns a number defining the stencil reference value to use
  10869. */
  10870. getStencilFunctionReference(): number;
  10871. /**
  10872. * Gets the current stencil mask
  10873. * @returns a number defining the stencil mask to use
  10874. */
  10875. getStencilFunctionMask(): number;
  10876. /**
  10877. * Sets the current stencil function
  10878. * @param stencilFunc defines the new stencil function to use
  10879. */
  10880. setStencilFunction(stencilFunc: number): void;
  10881. /**
  10882. * Sets the current stencil reference
  10883. * @param reference defines the new stencil reference to use
  10884. */
  10885. setStencilFunctionReference(reference: number): void;
  10886. /**
  10887. * Sets the current stencil mask
  10888. * @param mask defines the new stencil mask to use
  10889. */
  10890. setStencilFunctionMask(mask: number): void;
  10891. /**
  10892. * Gets the current stencil operation when stencil fails
  10893. * @returns a number defining stencil operation to use when stencil fails
  10894. */
  10895. getStencilOperationFail(): number;
  10896. /**
  10897. * Gets the current stencil operation when depth fails
  10898. * @returns a number defining stencil operation to use when depth fails
  10899. */
  10900. getStencilOperationDepthFail(): number;
  10901. /**
  10902. * Gets the current stencil operation when stencil passes
  10903. * @returns a number defining stencil operation to use when stencil passes
  10904. */
  10905. getStencilOperationPass(): number;
  10906. /**
  10907. * Sets the stencil operation to use when stencil fails
  10908. * @param operation defines the stencil operation to use when stencil fails
  10909. */
  10910. setStencilOperationFail(operation: number): void;
  10911. /**
  10912. * Sets the stencil operation to use when depth fails
  10913. * @param operation defines the stencil operation to use when depth fails
  10914. */
  10915. setStencilOperationDepthFail(operation: number): void;
  10916. /**
  10917. * Sets the stencil operation to use when stencil passes
  10918. * @param operation defines the stencil operation to use when stencil passes
  10919. */
  10920. setStencilOperationPass(operation: number): void;
  10921. /**
  10922. * Sets a boolean indicating if the dithering state is enabled or disabled
  10923. * @param value defines the dithering state
  10924. */
  10925. setDitheringState(value: boolean): void;
  10926. /**
  10927. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  10928. * @param value defines the rasterizer state
  10929. */
  10930. setRasterizerState(value: boolean): void;
  10931. /**
  10932. * stop executing a render loop function and remove it from the execution array
  10933. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  10934. */
  10935. stopRenderLoop(renderFunction?: () => void): void;
  10936. /** @hidden */
  10937. _renderLoop(): void;
  10938. /**
  10939. * Register and execute a render loop. The engine can have more than one render function
  10940. * @param renderFunction defines the function to continuously execute
  10941. */
  10942. runRenderLoop(renderFunction: () => void): void;
  10943. /**
  10944. * Toggle full screen mode
  10945. * @param requestPointerLock defines if a pointer lock should be requested from the user
  10946. */
  10947. switchFullscreen(requestPointerLock: boolean): void;
  10948. /**
  10949. * Clear the current render buffer or the current render target (if any is set up)
  10950. * @param color defines the color to use
  10951. * @param backBuffer defines if the back buffer must be cleared
  10952. * @param depth defines if the depth buffer must be cleared
  10953. * @param stencil defines if the stencil buffer must be cleared
  10954. */
  10955. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  10956. /**
  10957. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  10958. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  10959. * @param y defines the y-coordinate of the corner of the clear rectangle
  10960. * @param width defines the width of the clear rectangle
  10961. * @param height defines the height of the clear rectangle
  10962. * @param clearColor defines the clear color
  10963. */
  10964. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  10965. /**
  10966. * Enable scissor test on a specific rectangle (ie. render will only be executed 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. */
  10972. enableScissor(x: number, y: number, width: number, height: number): void;
  10973. /**
  10974. * Disable previously set scissor test rectangle
  10975. */
  10976. disableScissor(): void;
  10977. private _viewportCached;
  10978. /** @hidden */
  10979. _viewport(x: number, y: number, width: number, height: number): void;
  10980. /**
  10981. * Set the WebGL's viewport
  10982. * @param viewport defines the viewport element to be used
  10983. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  10984. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  10985. */
  10986. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  10987. /**
  10988. * Directly set the WebGL Viewport
  10989. * @param x defines the x coordinate of the viewport (in screen space)
  10990. * @param y defines the y coordinate of the viewport (in screen space)
  10991. * @param width defines the width of the viewport (in screen space)
  10992. * @param height defines the height of the viewport (in screen space)
  10993. * @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
  10994. */
  10995. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  10996. /**
  10997. * Begin a new frame
  10998. */
  10999. beginFrame(): void;
  11000. /**
  11001. * Enf the current frame
  11002. */
  11003. endFrame(): void;
  11004. /**
  11005. * Resize the view according to the canvas' size
  11006. */
  11007. resize(): void;
  11008. /**
  11009. * Force a specific size of the canvas
  11010. * @param width defines the new canvas' width
  11011. * @param height defines the new canvas' height
  11012. */
  11013. setSize(width: number, height: number): void;
  11014. /**
  11015. * Gets a boolean indicating if a webVR device was detected
  11016. * @returns true if a webVR device was detected
  11017. */
  11018. isVRDevicePresent(): boolean;
  11019. /**
  11020. * Gets the current webVR device
  11021. * @returns the current webVR device (or null)
  11022. */
  11023. getVRDevice(): any;
  11024. /**
  11025. * Initializes a webVR display and starts listening to display change events
  11026. * The onVRDisplayChangedObservable will be notified upon these changes
  11027. * @returns The onVRDisplayChangedObservable
  11028. */
  11029. initWebVR(): Observable<IDisplayChangedEventArgs>;
  11030. /**
  11031. * Initializes a webVR display and starts listening to display change events
  11032. * The onVRDisplayChangedObservable will be notified upon these changes
  11033. * @returns A promise containing a VRDisplay and if vr is supported
  11034. */
  11035. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  11036. /**
  11037. * Call this function to switch to webVR mode
  11038. * Will do nothing if webVR is not supported or if there is no webVR device
  11039. * @see http://doc.babylonjs.com/how_to/webvr_camera
  11040. */
  11041. enableVR(): void;
  11042. /**
  11043. * Call this function to leave webVR mode
  11044. * Will do nothing if webVR is not supported or if there is no webVR device
  11045. * @see http://doc.babylonjs.com/how_to/webvr_camera
  11046. */
  11047. disableVR(): void;
  11048. private _onVRFullScreenTriggered;
  11049. private _getVRDisplaysAsync;
  11050. /**
  11051. * Binds the frame buffer to the specified texture.
  11052. * @param texture The texture to render to or null for the default canvas
  11053. * @param faceIndex The face of the texture to render to in case of cube texture
  11054. * @param requiredWidth The width of the target to render to
  11055. * @param requiredHeight The height of the target to render to
  11056. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  11057. * @param depthStencilTexture The depth stencil texture to use to render
  11058. * @param lodLevel defines le lod level to bind to the frame buffer
  11059. */
  11060. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  11061. private bindUnboundFramebuffer;
  11062. /**
  11063. * Unbind the current render target texture from the webGL context
  11064. * @param texture defines the render target texture to unbind
  11065. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  11066. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  11067. */
  11068. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  11069. /**
  11070. * Unbind a list of render target textures from the webGL context
  11071. * This is used only when drawBuffer extension or webGL2 are active
  11072. * @param textures defines the render target textures to unbind
  11073. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  11074. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  11075. */
  11076. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  11077. /**
  11078. * Force the mipmap generation for the given render target texture
  11079. * @param texture defines the render target texture to use
  11080. */
  11081. generateMipMapsForCubemap(texture: InternalTexture): void;
  11082. /**
  11083. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  11084. */
  11085. flushFramebuffer(): void;
  11086. /**
  11087. * Unbind the current render target and bind the default framebuffer
  11088. */
  11089. restoreDefaultFramebuffer(): void;
  11090. /**
  11091. * Create an uniform buffer
  11092. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  11093. * @param elements defines the content of the uniform buffer
  11094. * @returns the webGL uniform buffer
  11095. */
  11096. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  11097. /**
  11098. * Create a dynamic uniform buffer
  11099. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  11100. * @param elements defines the content of the uniform buffer
  11101. * @returns the webGL uniform buffer
  11102. */
  11103. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  11104. /**
  11105. * Update an existing uniform buffer
  11106. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  11107. * @param uniformBuffer defines the target uniform buffer
  11108. * @param elements defines the content to update
  11109. * @param offset defines the offset in the uniform buffer where update should start
  11110. * @param count defines the size of the data to update
  11111. */
  11112. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  11113. private _resetVertexBufferBinding;
  11114. /**
  11115. * Creates a vertex buffer
  11116. * @param data the data for the vertex buffer
  11117. * @returns the new WebGL static buffer
  11118. */
  11119. createVertexBuffer(data: DataArray): WebGLBuffer;
  11120. /**
  11121. * Creates a dynamic vertex buffer
  11122. * @param data the data for the dynamic vertex buffer
  11123. * @returns the new WebGL dynamic buffer
  11124. */
  11125. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  11126. /**
  11127. * Update a dynamic index buffer
  11128. * @param indexBuffer defines the target index buffer
  11129. * @param indices defines the data to update
  11130. * @param offset defines the offset in the target index buffer where update should start
  11131. */
  11132. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  11133. /**
  11134. * Updates a dynamic vertex buffer.
  11135. * @param vertexBuffer the vertex buffer to update
  11136. * @param data the data used to update the vertex buffer
  11137. * @param byteOffset the byte offset of the data
  11138. * @param byteLength the byte length of the data
  11139. */
  11140. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  11141. private _resetIndexBufferBinding;
  11142. /**
  11143. * Creates a new index buffer
  11144. * @param indices defines the content of the index buffer
  11145. * @param updatable defines if the index buffer must be updatable
  11146. * @returns a new webGL buffer
  11147. */
  11148. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  11149. /**
  11150. * Bind a webGL buffer to the webGL context
  11151. * @param buffer defines the buffer to bind
  11152. */
  11153. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  11154. /**
  11155. * Bind an uniform buffer to the current webGL context
  11156. * @param buffer defines the buffer to bind
  11157. */
  11158. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  11159. /**
  11160. * Bind a buffer to the current webGL context at a given location
  11161. * @param buffer defines the buffer to bind
  11162. * @param location defines the index where to bind the buffer
  11163. */
  11164. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  11165. /**
  11166. * Bind a specific block at a given index in a specific shader program
  11167. * @param shaderProgram defines the shader program
  11168. * @param blockName defines the block name
  11169. * @param index defines the index where to bind the block
  11170. */
  11171. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  11172. private bindIndexBuffer;
  11173. private bindBuffer;
  11174. /**
  11175. * update the bound buffer with the given data
  11176. * @param data defines the data to update
  11177. */
  11178. updateArrayBuffer(data: Float32Array): void;
  11179. private _vertexAttribPointer;
  11180. private _bindIndexBufferWithCache;
  11181. private _bindVertexBuffersAttributes;
  11182. /**
  11183. * Records a vertex array object
  11184. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  11185. * @param vertexBuffers defines the list of vertex buffers to store
  11186. * @param indexBuffer defines the index buffer to store
  11187. * @param effect defines the effect to store
  11188. * @returns the new vertex array object
  11189. */
  11190. recordVertexArrayObject(vertexBuffers: {
  11191. [key: string]: VertexBuffer;
  11192. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  11193. /**
  11194. * Bind a specific vertex array object
  11195. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  11196. * @param vertexArrayObject defines the vertex array object to bind
  11197. * @param indexBuffer defines the index buffer to bind
  11198. */
  11199. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  11200. /**
  11201. * Bind webGl buffers directly to the webGL context
  11202. * @param vertexBuffer defines the vertex buffer to bind
  11203. * @param indexBuffer defines the index buffer to bind
  11204. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  11205. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  11206. * @param effect defines the effect associated with the vertex buffer
  11207. */
  11208. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  11209. private _unbindVertexArrayObject;
  11210. /**
  11211. * Bind a list of vertex buffers to the webGL context
  11212. * @param vertexBuffers defines the list of vertex buffers to bind
  11213. * @param indexBuffer defines the index buffer to bind
  11214. * @param effect defines the effect associated with the vertex buffers
  11215. */
  11216. bindBuffers(vertexBuffers: {
  11217. [key: string]: Nullable<VertexBuffer>;
  11218. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  11219. /**
  11220. * Unbind all instance attributes
  11221. */
  11222. unbindInstanceAttributes(): void;
  11223. /**
  11224. * Release and free the memory of a vertex array object
  11225. * @param vao defines the vertex array object to delete
  11226. */
  11227. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  11228. /** @hidden */
  11229. _releaseBuffer(buffer: WebGLBuffer): boolean;
  11230. /**
  11231. * Creates a webGL buffer to use with instanciation
  11232. * @param capacity defines the size of the buffer
  11233. * @returns the webGL buffer
  11234. */
  11235. createInstancesBuffer(capacity: number): WebGLBuffer;
  11236. /**
  11237. * Delete a webGL buffer used with instanciation
  11238. * @param buffer defines the webGL buffer to delete
  11239. */
  11240. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  11241. /**
  11242. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  11243. * @param instancesBuffer defines the webGL buffer to update and bind
  11244. * @param data defines the data to store in the buffer
  11245. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  11246. */
  11247. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  11248. /**
  11249. * Apply all cached states (depth, culling, stencil and alpha)
  11250. */
  11251. applyStates(): void;
  11252. /**
  11253. * Send a draw order
  11254. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  11255. * @param indexStart defines the starting index
  11256. * @param indexCount defines the number of index to draw
  11257. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11258. */
  11259. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  11260. /**
  11261. * Draw a list of points
  11262. * @param verticesStart defines the index of first vertex to draw
  11263. * @param verticesCount defines the count of vertices to draw
  11264. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11265. */
  11266. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  11267. /**
  11268. * Draw a list of unindexed primitives
  11269. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  11270. * @param verticesStart defines the index of first vertex to draw
  11271. * @param verticesCount defines the count of vertices to draw
  11272. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11273. */
  11274. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  11275. /**
  11276. * Draw a list of indexed primitives
  11277. * @param fillMode defines the primitive to use
  11278. * @param indexStart defines the starting index
  11279. * @param indexCount defines the number of index to draw
  11280. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11281. */
  11282. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  11283. /**
  11284. * Draw a list of unindexed primitives
  11285. * @param fillMode defines the primitive to use
  11286. * @param verticesStart defines the index of first vertex to draw
  11287. * @param verticesCount defines the count of vertices to draw
  11288. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11289. */
  11290. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  11291. private _drawMode;
  11292. /** @hidden */
  11293. _releaseEffect(effect: Effect): void;
  11294. /** @hidden */
  11295. _deleteProgram(program: WebGLProgram): void;
  11296. /**
  11297. * Create a new effect (used to store vertex/fragment shaders)
  11298. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  11299. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  11300. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  11301. * @param samplers defines an array of string used to represent textures
  11302. * @param defines defines the string containing the defines to use to compile the shaders
  11303. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  11304. * @param onCompiled defines a function to call when the effect creation is successful
  11305. * @param onError defines a function to call when the effect creation has failed
  11306. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  11307. * @returns the new Effect
  11308. */
  11309. 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;
  11310. private _compileShader;
  11311. private _compileRawShader;
  11312. /**
  11313. * Directly creates a webGL program
  11314. * @param vertexCode defines the vertex shader code to use
  11315. * @param fragmentCode defines the fragment shader code to use
  11316. * @param context defines the webGL context to use (if not set, the current one will be used)
  11317. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  11318. * @returns the new webGL program
  11319. */
  11320. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  11321. /**
  11322. * 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 defines defines the string containing the defines to use to compile the shaders
  11326. * @param context defines the webGL context to use (if not set, the current one will be used)
  11327. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  11328. * @returns the new webGL program
  11329. */
  11330. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  11331. private _createShaderProgram;
  11332. private _finalizeProgram;
  11333. /** @hidden */
  11334. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  11335. /** @hidden */
  11336. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  11337. /**
  11338. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  11339. * @param shaderProgram defines the webGL program to use
  11340. * @param uniformsNames defines the list of uniform names
  11341. * @returns an array of webGL uniform locations
  11342. */
  11343. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  11344. /**
  11345. * Gets the lsit of active attributes for a given webGL program
  11346. * @param shaderProgram defines the webGL program to use
  11347. * @param attributesNames defines the list of attribute names to get
  11348. * @returns an array of indices indicating the offset of each attribute
  11349. */
  11350. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  11351. /**
  11352. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  11353. * @param effect defines the effect to activate
  11354. */
  11355. enableEffect(effect: Nullable<Effect>): void;
  11356. /**
  11357. * Set the value of an uniform to an array of int32
  11358. * @param uniform defines the webGL uniform location where to store the value
  11359. * @param array defines the array of int32 to store
  11360. */
  11361. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  11362. /**
  11363. * Set the value of an uniform to an array of int32 (stored as vec2)
  11364. * @param uniform defines the webGL uniform location where to store the value
  11365. * @param array defines the array of int32 to store
  11366. */
  11367. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  11368. /**
  11369. * Set the value of an uniform to an array of int32 (stored as vec3)
  11370. * @param uniform defines the webGL uniform location where to store the value
  11371. * @param array defines the array of int32 to store
  11372. */
  11373. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  11374. /**
  11375. * Set the value of an uniform to an array of int32 (stored as vec4)
  11376. * @param uniform defines the webGL uniform location where to store the value
  11377. * @param array defines the array of int32 to store
  11378. */
  11379. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  11380. /**
  11381. * Set the value of an uniform to an array of float32
  11382. * @param uniform defines the webGL uniform location where to store the value
  11383. * @param array defines the array of float32 to store
  11384. */
  11385. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  11386. /**
  11387. * Set the value of an uniform to an array of float32 (stored as vec2)
  11388. * @param uniform defines the webGL uniform location where to store the value
  11389. * @param array defines the array of float32 to store
  11390. */
  11391. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  11392. /**
  11393. * Set the value of an uniform to an array of float32 (stored as vec3)
  11394. * @param uniform defines the webGL uniform location where to store the value
  11395. * @param array defines the array of float32 to store
  11396. */
  11397. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  11398. /**
  11399. * Set the value of an uniform to an array of float32 (stored as vec4)
  11400. * @param uniform defines the webGL uniform location where to store the value
  11401. * @param array defines the array of float32 to store
  11402. */
  11403. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  11404. /**
  11405. * Set the value of an uniform to an array of number
  11406. * @param uniform defines the webGL uniform location where to store the value
  11407. * @param array defines the array of number to store
  11408. */
  11409. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  11410. /**
  11411. * Set the value of an uniform to an array of number (stored as vec2)
  11412. * @param uniform defines the webGL uniform location where to store the value
  11413. * @param array defines the array of number to store
  11414. */
  11415. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  11416. /**
  11417. * Set the value of an uniform to an array of number (stored as vec3)
  11418. * @param uniform defines the webGL uniform location where to store the value
  11419. * @param array defines the array of number to store
  11420. */
  11421. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  11422. /**
  11423. * Set the value of an uniform to an array of number (stored as vec4)
  11424. * @param uniform defines the webGL uniform location where to store the value
  11425. * @param array defines the array of number to store
  11426. */
  11427. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  11428. /**
  11429. * Set the value of an uniform to an array of float32 (stored as matrices)
  11430. * @param uniform defines the webGL uniform location where to store the value
  11431. * @param matrices defines the array of float32 to store
  11432. */
  11433. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  11434. /**
  11435. * Set the value of an uniform to a matrix
  11436. * @param uniform defines the webGL uniform location where to store the value
  11437. * @param matrix defines the matrix to store
  11438. */
  11439. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  11440. /**
  11441. * Set the value of an uniform to a matrix (3x3)
  11442. * @param uniform defines the webGL uniform location where to store the value
  11443. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  11444. */
  11445. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  11446. /**
  11447. * Set the value of an uniform to a matrix (2x2)
  11448. * @param uniform defines the webGL uniform location where to store the value
  11449. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  11450. */
  11451. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  11452. /**
  11453. * Set the value of an uniform to a number (int)
  11454. * @param uniform defines the webGL uniform location where to store the value
  11455. * @param value defines the int number to store
  11456. */
  11457. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  11458. /**
  11459. * Set the value of an uniform to a number (float)
  11460. * @param uniform defines the webGL uniform location where to store the value
  11461. * @param value defines the float number to store
  11462. */
  11463. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  11464. /**
  11465. * Set the value of an uniform to a vec2
  11466. * @param uniform defines the webGL uniform location where to store the value
  11467. * @param x defines the 1st component of the value
  11468. * @param y defines the 2nd component of the value
  11469. */
  11470. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  11471. /**
  11472. * Set the value of an uniform to a vec3
  11473. * @param uniform defines the webGL uniform location where to store the value
  11474. * @param x defines the 1st component of the value
  11475. * @param y defines the 2nd component of the value
  11476. * @param z defines the 3rd component of the value
  11477. */
  11478. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  11479. /**
  11480. * Set the value of an uniform to a boolean
  11481. * @param uniform defines the webGL uniform location where to store the value
  11482. * @param bool defines the boolean to store
  11483. */
  11484. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  11485. /**
  11486. * Set the value of an uniform to a vec4
  11487. * @param uniform defines the webGL uniform location where to store the value
  11488. * @param x defines the 1st component of the value
  11489. * @param y defines the 2nd component of the value
  11490. * @param z defines the 3rd component of the value
  11491. * @param w defines the 4th component of the value
  11492. */
  11493. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  11494. /**
  11495. * Set the value of an uniform to a Color3
  11496. * @param uniform defines the webGL uniform location where to store the value
  11497. * @param color3 defines the color to store
  11498. */
  11499. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  11500. /**
  11501. * Set the value of an uniform to a Color3 and an alpha value
  11502. * @param uniform defines the webGL uniform location where to store the value
  11503. * @param color3 defines the color to store
  11504. * @param alpha defines the alpha component to store
  11505. */
  11506. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  11507. /**
  11508. * Sets a Color4 on a uniform variable
  11509. * @param uniform defines the uniform location
  11510. * @param color4 defines the value to be set
  11511. */
  11512. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  11513. /**
  11514. * Set various states to the webGL context
  11515. * @param culling defines backface culling state
  11516. * @param zOffset defines the value to apply to zOffset (0 by default)
  11517. * @param force defines if states must be applied even if cache is up to date
  11518. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  11519. */
  11520. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  11521. /**
  11522. * Set the z offset to apply to current rendering
  11523. * @param value defines the offset to apply
  11524. */
  11525. setZOffset(value: number): void;
  11526. /**
  11527. * Gets the current value of the zOffset
  11528. * @returns the current zOffset state
  11529. */
  11530. getZOffset(): number;
  11531. /**
  11532. * Enable or disable depth buffering
  11533. * @param enable defines the state to set
  11534. */
  11535. setDepthBuffer(enable: boolean): void;
  11536. /**
  11537. * Gets a boolean indicating if depth writing is enabled
  11538. * @returns the current depth writing state
  11539. */
  11540. getDepthWrite(): boolean;
  11541. /**
  11542. * Enable or disable depth writing
  11543. * @param enable defines the state to set
  11544. */
  11545. setDepthWrite(enable: boolean): void;
  11546. /**
  11547. * Enable or disable color writing
  11548. * @param enable defines the state to set
  11549. */
  11550. setColorWrite(enable: boolean): void;
  11551. /**
  11552. * Gets a boolean indicating if color writing is enabled
  11553. * @returns the current color writing state
  11554. */
  11555. getColorWrite(): boolean;
  11556. /**
  11557. * Sets alpha constants used by some alpha blending modes
  11558. * @param r defines the red component
  11559. * @param g defines the green component
  11560. * @param b defines the blue component
  11561. * @param a defines the alpha component
  11562. */
  11563. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  11564. /**
  11565. * Sets the current alpha mode
  11566. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  11567. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  11568. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  11569. */
  11570. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  11571. /**
  11572. * Gets the current alpha mode
  11573. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  11574. * @returns the current alpha mode
  11575. */
  11576. getAlphaMode(): number;
  11577. /**
  11578. * Clears the list of texture accessible through engine.
  11579. * This can help preventing texture load conflict due to name collision.
  11580. */
  11581. clearInternalTexturesCache(): void;
  11582. /**
  11583. * Force the entire cache to be cleared
  11584. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  11585. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  11586. */
  11587. wipeCaches(bruteForce?: boolean): void;
  11588. /**
  11589. * Set the compressed texture format to use, based on the formats you have, and the formats
  11590. * supported by the hardware / browser.
  11591. *
  11592. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  11593. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  11594. * to API arguments needed to compressed textures. This puts the burden on the container
  11595. * generator to house the arcane code for determining these for current & future formats.
  11596. *
  11597. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  11598. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  11599. *
  11600. * Note: The result of this call is not taken into account when a texture is base64.
  11601. *
  11602. * @param formatsAvailable defines the list of those format families you have created
  11603. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  11604. *
  11605. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  11606. * @returns The extension selected.
  11607. */
  11608. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  11609. private _getSamplingParameters;
  11610. private _partialLoadImg;
  11611. private _cascadeLoadImgs;
  11612. /** @hidden */
  11613. _createTexture(): WebGLTexture;
  11614. /**
  11615. * Usually called from BABYLON.Texture.ts.
  11616. * Passed information to create a WebGLTexture
  11617. * @param urlArg defines a value which contains one of the following:
  11618. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  11619. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  11620. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  11621. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  11622. * @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)
  11623. * @param scene needed for loading to the correct scene
  11624. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  11625. * @param onLoad optional callback to be called upon successful completion
  11626. * @param onError optional callback to be called upon failure
  11627. * @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
  11628. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  11629. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  11630. * @param forcedExtension defines the extension to use to pick the right loader
  11631. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  11632. * @returns a InternalTexture for assignment back into BABYLON.Texture
  11633. */
  11634. 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;
  11635. private _rescaleTexture;
  11636. /**
  11637. * Update a raw texture
  11638. * @param texture defines the texture to update
  11639. * @param data defines the data to store in the texture
  11640. * @param format defines the format of the data
  11641. * @param invertY defines if data must be stored with Y axis inverted
  11642. * @param compression defines the compression used (null by default)
  11643. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11644. */
  11645. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  11646. /**
  11647. * Creates a raw texture
  11648. * @param data defines the data to store in the texture
  11649. * @param width defines the width of the texture
  11650. * @param height defines the height of the texture
  11651. * @param format defines the format of the data
  11652. * @param generateMipMaps defines if the engine should generate the mip levels
  11653. * @param invertY defines if data must be stored with Y axis inverted
  11654. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  11655. * @param compression defines the compression used (null by default)
  11656. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11657. * @returns the raw texture inside an InternalTexture
  11658. */
  11659. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  11660. private _unpackFlipYCached;
  11661. /**
  11662. * In case you are sharing the context with other applications, it might
  11663. * be interested to not cache the unpack flip y state to ensure a consistent
  11664. * value would be set.
  11665. */
  11666. enableUnpackFlipYCached: boolean;
  11667. /** @hidden */
  11668. _unpackFlipY(value: boolean): void;
  11669. /** @hidden */
  11670. _getUnpackAlignement(): number;
  11671. /**
  11672. * Creates a dynamic texture
  11673. * @param width defines the width of the texture
  11674. * @param height defines the height of the texture
  11675. * @param generateMipMaps defines if the engine should generate the mip levels
  11676. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  11677. * @returns the dynamic texture inside an InternalTexture
  11678. */
  11679. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  11680. /**
  11681. * Update the sampling mode of a given texture
  11682. * @param samplingMode defines the required sampling mode
  11683. * @param texture defines the texture to update
  11684. */
  11685. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  11686. /**
  11687. * Update the content of a dynamic texture
  11688. * @param texture defines the texture to update
  11689. * @param canvas defines the canvas containing the source
  11690. * @param invertY defines if data must be stored with Y axis inverted
  11691. * @param premulAlpha defines if alpha is stored as premultiplied
  11692. * @param format defines the format of the data
  11693. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  11694. */
  11695. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  11696. /**
  11697. * Update a video texture
  11698. * @param texture defines the texture to update
  11699. * @param video defines the video element to use
  11700. * @param invertY defines if data must be stored with Y axis inverted
  11701. */
  11702. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  11703. /**
  11704. * Updates a depth texture Comparison Mode and Function.
  11705. * If the comparison Function is equal to 0, the mode will be set to none.
  11706. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  11707. * @param texture The texture to set the comparison function for
  11708. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  11709. */
  11710. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  11711. private _setupDepthStencilTexture;
  11712. /**
  11713. * Creates a depth stencil texture.
  11714. * This is only available in WebGL 2 or with the depth texture extension available.
  11715. * @param size The size of face edge in the texture.
  11716. * @param options The options defining the texture.
  11717. * @returns The texture
  11718. */
  11719. createDepthStencilTexture(size: number | {
  11720. width: number;
  11721. height: number;
  11722. }, options: DepthTextureCreationOptions): InternalTexture;
  11723. /**
  11724. * Creates a depth stencil texture.
  11725. * This is only available in WebGL 2 or with the depth texture extension available.
  11726. * @param size The size of face edge in the texture.
  11727. * @param options The options defining the texture.
  11728. * @returns The texture
  11729. */
  11730. private _createDepthStencilTexture;
  11731. /**
  11732. * Creates a depth stencil cube texture.
  11733. * This is only available in WebGL 2.
  11734. * @param size The size of face edge in the cube texture.
  11735. * @param options The options defining the cube texture.
  11736. * @returns The cube texture
  11737. */
  11738. private _createDepthStencilCubeTexture;
  11739. /**
  11740. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  11741. * @param renderTarget The render target to set the frame buffer for
  11742. */
  11743. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  11744. /**
  11745. * Creates a new render target texture
  11746. * @param size defines the size of the texture
  11747. * @param options defines the options used to create the texture
  11748. * @returns a new render target texture stored in an InternalTexture
  11749. */
  11750. createRenderTargetTexture(size: number | {
  11751. width: number;
  11752. height: number;
  11753. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  11754. /**
  11755. * Create a multi render target texture
  11756. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  11757. * @param size defines the size of the texture
  11758. * @param options defines the creation options
  11759. * @returns the cube texture as an InternalTexture
  11760. */
  11761. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  11762. private _setupFramebufferDepthAttachments;
  11763. /**
  11764. * Updates the sample count of a render target texture
  11765. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  11766. * @param texture defines the texture to update
  11767. * @param samples defines the sample count to set
  11768. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  11769. */
  11770. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  11771. /**
  11772. * Update the sample count for a given multiple render target texture
  11773. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  11774. * @param textures defines the textures to update
  11775. * @param samples defines the sample count to set
  11776. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  11777. */
  11778. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  11779. /** @hidden */
  11780. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  11781. /** @hidden */
  11782. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  11783. /** @hidden */
  11784. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  11785. /** @hidden */
  11786. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  11787. /**
  11788. * Creates a new render target cube texture
  11789. * @param size defines the size of the texture
  11790. * @param options defines the options used to create the texture
  11791. * @returns a new render target cube texture stored in an InternalTexture
  11792. */
  11793. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11794. /**
  11795. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  11796. * @param rootUrl defines the url where the file to load is located
  11797. * @param scene defines the current scene
  11798. * @param lodScale defines scale to apply to the mip map selection
  11799. * @param lodOffset defines offset to apply to the mip map selection
  11800. * @param onLoad defines an optional callback raised when the texture is loaded
  11801. * @param onError defines an optional callback raised if there is an issue to load the texture
  11802. * @param format defines the format of the data
  11803. * @param forcedExtension defines the extension to use to pick the right loader
  11804. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  11805. * @returns the cube texture as an InternalTexture
  11806. */
  11807. 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;
  11808. /**
  11809. * Creates a cube texture
  11810. * @param rootUrl defines the url where the files to load is located
  11811. * @param scene defines the current scene
  11812. * @param files defines the list of files to load (1 per face)
  11813. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  11814. * @param onLoad defines an optional callback raised when the texture is loaded
  11815. * @param onError defines an optional callback raised if there is an issue to load the texture
  11816. * @param format defines the format of the data
  11817. * @param forcedExtension defines the extension to use to pick the right loader
  11818. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  11819. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11820. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11821. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  11822. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  11823. * @returns the cube texture as an InternalTexture
  11824. */
  11825. 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;
  11826. /**
  11827. * @hidden
  11828. */
  11829. _setCubeMapTextureParams(loadMipmap: boolean): void;
  11830. /**
  11831. * Update a raw cube texture
  11832. * @param texture defines the texture to udpdate
  11833. * @param data defines the data to store
  11834. * @param format defines the data format
  11835. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11836. * @param invertY defines if data must be stored with Y axis inverted
  11837. * @param compression defines the compression used (null by default)
  11838. * @param level defines which level of the texture to update
  11839. */
  11840. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  11841. /**
  11842. * Creates a new raw cube texture
  11843. * @param data defines the array of data to use to create each face
  11844. * @param size defines the size of the textures
  11845. * @param format defines the format of the data
  11846. * @param type defines the type of the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  11847. * @param generateMipMaps defines if the engine should generate the mip levels
  11848. * @param invertY defines if data must be stored with Y axis inverted
  11849. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  11850. * @param compression defines the compression used (null by default)
  11851. * @returns the cube texture as an InternalTexture
  11852. */
  11853. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  11854. /**
  11855. * Creates a new raw cube texture from a specified url
  11856. * @param url defines the url where the data is located
  11857. * @param scene defines the current scene
  11858. * @param size defines the size of the textures
  11859. * @param format defines the format of the data
  11860. * @param type defines the type fo the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  11861. * @param noMipmap defines if the engine should avoid generating the mip levels
  11862. * @param callback defines a callback used to extract texture data from loaded data
  11863. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11864. * @param onLoad defines a callback called when texture is loaded
  11865. * @param onError defines a callback called if there is an error
  11866. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  11867. * @param invertY defines if data must be stored with Y axis inverted
  11868. * @returns the cube texture as an InternalTexture
  11869. */
  11870. 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;
  11871. /**
  11872. * Update a raw 3D texture
  11873. * @param texture defines the texture to update
  11874. * @param data defines the data to store
  11875. * @param format defines the data format
  11876. * @param invertY defines if data must be stored with Y axis inverted
  11877. * @param compression defines the used compression (can be null)
  11878. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11879. */
  11880. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  11881. /**
  11882. * Creates a new raw 3D texture
  11883. * @param data defines the data used to create the texture
  11884. * @param width defines the width of the texture
  11885. * @param height defines the height of the texture
  11886. * @param depth defines the depth of the texture
  11887. * @param format defines the format of the texture
  11888. * @param generateMipMaps defines if the engine must generate mip levels
  11889. * @param invertY defines if data must be stored with Y axis inverted
  11890. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  11891. * @param compression defines the compressed used (can be null)
  11892. * @param textureType defines the compressed used (can be null)
  11893. * @returns a new raw 3D texture (stored in an InternalTexture)
  11894. */
  11895. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  11896. private _prepareWebGLTextureContinuation;
  11897. private _prepareWebGLTexture;
  11898. private _convertRGBtoRGBATextureData;
  11899. /** @hidden */
  11900. _releaseFramebufferObjects(texture: InternalTexture): void;
  11901. /** @hidden */
  11902. _releaseTexture(texture: InternalTexture): void;
  11903. private setProgram;
  11904. private _boundUniforms;
  11905. /**
  11906. * Binds an effect to the webGL context
  11907. * @param effect defines the effect to bind
  11908. */
  11909. bindSamplers(effect: Effect): void;
  11910. private _moveBoundTextureOnTop;
  11911. private _getCorrectTextureChannel;
  11912. private _linkTrackers;
  11913. private _removeDesignatedSlot;
  11914. private _activateCurrentTexture;
  11915. /** @hidden */
  11916. protected _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  11917. /** @hidden */
  11918. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  11919. /**
  11920. * Sets a texture to the webGL context from a postprocess
  11921. * @param channel defines the channel to use
  11922. * @param postProcess defines the source postprocess
  11923. */
  11924. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  11925. /**
  11926. * Binds the output of the passed in post process to the texture channel specified
  11927. * @param channel The channel the texture should be bound to
  11928. * @param postProcess The post process which's output should be bound
  11929. */
  11930. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  11931. /**
  11932. * Unbind all textures from the webGL context
  11933. */
  11934. unbindAllTextures(): void;
  11935. /**
  11936. * Sets a texture to the according uniform.
  11937. * @param channel The texture channel
  11938. * @param uniform The uniform to set
  11939. * @param texture The texture to apply
  11940. */
  11941. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  11942. /**
  11943. * Sets a depth stencil texture from a render target to the according uniform.
  11944. * @param channel The texture channel
  11945. * @param uniform The uniform to set
  11946. * @param texture The render target texture containing the depth stencil texture to apply
  11947. */
  11948. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  11949. private _bindSamplerUniformToChannel;
  11950. private _getTextureWrapMode;
  11951. private _setTexture;
  11952. /**
  11953. * Sets an array of texture to the webGL context
  11954. * @param channel defines the channel where the texture array must be set
  11955. * @param uniform defines the associated uniform location
  11956. * @param textures defines the array of textures to bind
  11957. */
  11958. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  11959. /** @hidden */
  11960. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  11961. private _setTextureParameterFloat;
  11962. private _setTextureParameterInteger;
  11963. /**
  11964. * Reads pixels from the current frame buffer. Please note that this function can be slow
  11965. * @param x defines the x coordinate of the rectangle where pixels must be read
  11966. * @param y defines the y coordinate of the rectangle where pixels must be read
  11967. * @param width defines the width of the rectangle where pixels must be read
  11968. * @param height defines the height of the rectangle where pixels must be read
  11969. * @returns a Uint8Array containing RGBA colors
  11970. */
  11971. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  11972. /**
  11973. * Add an externaly attached data from its key.
  11974. * This method call will fail and return false, if such key already exists.
  11975. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  11976. * @param key the unique key that identifies the data
  11977. * @param data the data object to associate to the key for this Engine instance
  11978. * @return true if no such key were already present and the data was added successfully, false otherwise
  11979. */
  11980. addExternalData<T>(key: string, data: T): boolean;
  11981. /**
  11982. * Get an externaly attached data from its key
  11983. * @param key the unique key that identifies the data
  11984. * @return the associated data, if present (can be null), or undefined if not present
  11985. */
  11986. getExternalData<T>(key: string): T;
  11987. /**
  11988. * Get an externaly attached data from its key, create it using a factory if it's not already present
  11989. * @param key the unique key that identifies the data
  11990. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  11991. * @return the associated data, can be null if the factory returned null.
  11992. */
  11993. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  11994. /**
  11995. * Remove an externaly attached data from the Engine instance
  11996. * @param key the unique key that identifies the data
  11997. * @return true if the data was successfully removed, false if it doesn't exist
  11998. */
  11999. removeExternalData(key: string): boolean;
  12000. /**
  12001. * Unbind all vertex attributes from the webGL context
  12002. */
  12003. unbindAllAttributes(): void;
  12004. /**
  12005. * 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
  12006. */
  12007. releaseEffects(): void;
  12008. /**
  12009. * Dispose and release all associated resources
  12010. */
  12011. dispose(): void;
  12012. /**
  12013. * Display the loading screen
  12014. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  12015. */
  12016. displayLoadingUI(): void;
  12017. /**
  12018. * Hide the loading screen
  12019. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  12020. */
  12021. hideLoadingUI(): void;
  12022. /**
  12023. * Gets the current loading screen object
  12024. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  12025. */
  12026. /**
  12027. * Sets the current loading screen object
  12028. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  12029. */
  12030. loadingScreen: ILoadingScreen;
  12031. /**
  12032. * Sets the current loading screen text
  12033. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  12034. */
  12035. loadingUIText: string;
  12036. /**
  12037. * Sets the current loading screen background color
  12038. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  12039. */
  12040. loadingUIBackgroundColor: string;
  12041. /**
  12042. * Attach a new callback raised when context lost event is fired
  12043. * @param callback defines the callback to call
  12044. */
  12045. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  12046. /**
  12047. * Attach a new callback raised when context restored event is fired
  12048. * @param callback defines the callback to call
  12049. */
  12050. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  12051. /**
  12052. * Gets the source code of the vertex shader associated with a specific webGL program
  12053. * @param program defines the program to use
  12054. * @returns a string containing the source code of the vertex shader associated with the program
  12055. */
  12056. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  12057. /**
  12058. * Gets the source code of the fragment shader associated with a specific webGL program
  12059. * @param program defines the program to use
  12060. * @returns a string containing the source code of the fragment shader associated with the program
  12061. */
  12062. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  12063. /**
  12064. * Get the current error code of the webGL context
  12065. * @returns the error code
  12066. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  12067. */
  12068. getError(): number;
  12069. /**
  12070. * Gets the current framerate
  12071. * @returns a number representing the framerate
  12072. */
  12073. getFps(): number;
  12074. /**
  12075. * Gets the time spent between current and previous frame
  12076. * @returns a number representing the delta time in ms
  12077. */
  12078. getDeltaTime(): number;
  12079. private _measureFps;
  12080. /** @hidden */
  12081. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  12082. private _canRenderToFloatFramebuffer;
  12083. private _canRenderToHalfFloatFramebuffer;
  12084. private _canRenderToFramebuffer;
  12085. /** @hidden */
  12086. _getWebGLTextureType(type: number): number;
  12087. private _getInternalFormat;
  12088. /** @hidden */
  12089. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  12090. /** @hidden */
  12091. _getRGBAMultiSampleBufferFormat(type: number): number;
  12092. /** @hidden */
  12093. _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;
  12094. /** @hidden */
  12095. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  12096. private _partialLoadFile;
  12097. private _cascadeLoadFiles;
  12098. /**
  12099. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  12100. * @returns true if the engine can be created
  12101. * @ignorenaming
  12102. */
  12103. static isSupported(): boolean;
  12104. }
  12105. }
  12106. declare module BABYLON {
  12107. /**
  12108. * Options to create the null engine
  12109. */
  12110. class NullEngineOptions {
  12111. /**
  12112. * Render width (Default: 512)
  12113. */
  12114. renderWidth: number;
  12115. /**
  12116. * Render height (Default: 256)
  12117. */
  12118. renderHeight: number;
  12119. /**
  12120. * Texture size (Default: 512)
  12121. */
  12122. textureSize: number;
  12123. /**
  12124. * If delta time between frames should be constant
  12125. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  12126. */
  12127. deterministicLockstep: boolean;
  12128. /**
  12129. * Maximum about of steps between frames (Default: 4)
  12130. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  12131. */
  12132. lockstepMaxSteps: number;
  12133. }
  12134. /**
  12135. * The null engine class provides support for headless version of babylon.js.
  12136. * This can be used in server side scenario or for testing purposes
  12137. */
  12138. class NullEngine extends Engine {
  12139. private _options;
  12140. /**
  12141. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  12142. */
  12143. isDeterministicLockStep(): boolean;
  12144. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  12145. getLockstepMaxSteps(): number;
  12146. /**
  12147. * Sets hardware scaling, used to save performance if needed
  12148. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  12149. */
  12150. getHardwareScalingLevel(): number;
  12151. constructor(options?: NullEngineOptions);
  12152. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  12153. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  12154. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  12155. getRenderWidth(useScreen?: boolean): number;
  12156. getRenderHeight(useScreen?: boolean): number;
  12157. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  12158. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  12159. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  12160. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  12161. bindSamplers(effect: Effect): void;
  12162. enableEffect(effect: Effect): void;
  12163. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  12164. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  12165. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  12166. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  12167. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  12168. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  12169. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  12170. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  12171. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  12172. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  12173. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  12174. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  12175. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  12176. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  12177. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  12178. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  12179. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  12180. setFloat(uniform: WebGLUniformLocation, value: number): void;
  12181. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  12182. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  12183. setBool(uniform: WebGLUniformLocation, bool: number): void;
  12184. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  12185. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  12186. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  12187. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  12188. bindBuffers(vertexBuffers: {
  12189. [key: string]: VertexBuffer;
  12190. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  12191. wipeCaches(bruteForce?: boolean): void;
  12192. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  12193. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  12194. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  12195. /** @hidden */
  12196. _createTexture(): WebGLTexture;
  12197. /** @hidden */
  12198. _releaseTexture(texture: InternalTexture): void;
  12199. 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;
  12200. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  12201. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  12202. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  12203. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  12204. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  12205. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  12206. areAllEffectsReady(): boolean;
  12207. /**
  12208. * @hidden
  12209. * Get the current error code of the webGL context
  12210. * @returns the error code
  12211. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  12212. */
  12213. getError(): number;
  12214. /** @hidden */
  12215. _getUnpackAlignement(): number;
  12216. /** @hidden */
  12217. _unpackFlipY(value: boolean): void;
  12218. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  12219. /**
  12220. * Updates a dynamic vertex buffer.
  12221. * @param vertexBuffer the vertex buffer to update
  12222. * @param data the data used to update the vertex buffer
  12223. * @param byteOffset the byte offset of the data (optional)
  12224. * @param byteLength the byte length of the data (optional)
  12225. */
  12226. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  12227. protected _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  12228. /** @hidden */
  12229. _bindTexture(channel: number, texture: InternalTexture): void;
  12230. /** @hidden */
  12231. _releaseBuffer(buffer: WebGLBuffer): boolean;
  12232. releaseEffects(): void;
  12233. displayLoadingUI(): void;
  12234. hideLoadingUI(): void;
  12235. /** @hidden */
  12236. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  12237. /** @hidden */
  12238. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  12239. /** @hidden */
  12240. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  12241. /** @hidden */
  12242. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  12243. }
  12244. }
  12245. interface WebGLRenderingContext {
  12246. readonly RASTERIZER_DISCARD: number;
  12247. readonly DEPTH_COMPONENT24: number;
  12248. readonly TEXTURE_3D: number;
  12249. readonly TEXTURE_2D_ARRAY: number;
  12250. readonly TEXTURE_COMPARE_FUNC: number;
  12251. readonly TEXTURE_COMPARE_MODE: number;
  12252. readonly COMPARE_REF_TO_TEXTURE: number;
  12253. readonly TEXTURE_WRAP_R: number;
  12254. readonly HALF_FLOAT: number;
  12255. readonly RGB8: number;
  12256. readonly RED_INTEGER: number;
  12257. readonly RG_INTEGER: number;
  12258. readonly RGB_INTEGER: number;
  12259. readonly RGBA_INTEGER: number;
  12260. readonly R8_SNORM: number;
  12261. readonly RG8_SNORM: number;
  12262. readonly RGB8_SNORM: number;
  12263. readonly RGBA8_SNORM: number;
  12264. readonly R8I: number;
  12265. readonly RG8I: number;
  12266. readonly RGB8I: number;
  12267. readonly RGBA8I: number;
  12268. readonly R8UI: number;
  12269. readonly RG8UI: number;
  12270. readonly RGB8UI: number;
  12271. readonly RGBA8UI: number;
  12272. readonly R16I: number;
  12273. readonly RG16I: number;
  12274. readonly RGB16I: number;
  12275. readonly RGBA16I: number;
  12276. readonly R16UI: number;
  12277. readonly RG16UI: number;
  12278. readonly RGB16UI: number;
  12279. readonly RGBA16UI: number;
  12280. readonly R32I: number;
  12281. readonly RG32I: number;
  12282. readonly RGB32I: number;
  12283. readonly RGBA32I: number;
  12284. readonly R32UI: number;
  12285. readonly RG32UI: number;
  12286. readonly RGB32UI: number;
  12287. readonly RGBA32UI: number;
  12288. readonly RGB10_A2UI: number;
  12289. readonly R11F_G11F_B10F: number;
  12290. readonly RGB9_E5: number;
  12291. readonly RGB10_A2: number;
  12292. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  12293. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  12294. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  12295. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  12296. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  12297. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  12298. 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;
  12299. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  12300. readonly TRANSFORM_FEEDBACK: number;
  12301. readonly INTERLEAVED_ATTRIBS: number;
  12302. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  12303. createTransformFeedback(): WebGLTransformFeedback;
  12304. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  12305. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  12306. beginTransformFeedback(primitiveMode: number): void;
  12307. endTransformFeedback(): void;
  12308. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  12309. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  12310. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  12311. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  12312. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  12313. }
  12314. interface ImageBitmap {
  12315. readonly width: number;
  12316. readonly height: number;
  12317. close(): void;
  12318. }
  12319. interface WebGLQuery extends WebGLObject {
  12320. }
  12321. declare var WebGLQuery: {
  12322. prototype: WebGLQuery;
  12323. new (): WebGLQuery;
  12324. };
  12325. interface WebGLSampler extends WebGLObject {
  12326. }
  12327. declare var WebGLSampler: {
  12328. prototype: WebGLSampler;
  12329. new (): WebGLSampler;
  12330. };
  12331. interface WebGLSync extends WebGLObject {
  12332. }
  12333. declare var WebGLSync: {
  12334. prototype: WebGLSync;
  12335. new (): WebGLSync;
  12336. };
  12337. interface WebGLTransformFeedback extends WebGLObject {
  12338. }
  12339. declare var WebGLTransformFeedback: {
  12340. prototype: WebGLTransformFeedback;
  12341. new (): WebGLTransformFeedback;
  12342. };
  12343. interface WebGLVertexArrayObject extends WebGLObject {
  12344. }
  12345. declare var WebGLVertexArrayObject: {
  12346. prototype: WebGLVertexArrayObject;
  12347. new (): WebGLVertexArrayObject;
  12348. };
  12349. declare module BABYLON {
  12350. /**
  12351. * Gather the list of clipboard event types as constants.
  12352. */
  12353. class ClipboardEventTypes {
  12354. /**
  12355. * The clipboard event is fired when a copy command is active (pressed).
  12356. */
  12357. static readonly COPY: number;
  12358. /**
  12359. * The clipboard event is fired when a cut command is active (pressed).
  12360. */
  12361. static readonly CUT: number;
  12362. /**
  12363. * The clipboard event is fired when a paste command is active (pressed).
  12364. */
  12365. static readonly PASTE: number;
  12366. }
  12367. /**
  12368. * This class is used to store clipboard related info for the onClipboardObservable event.
  12369. */
  12370. class ClipboardInfo {
  12371. /**
  12372. * Defines the type of event (BABYLON.ClipboardEventTypes)
  12373. */
  12374. type: number;
  12375. /**
  12376. * Defines the related dom event
  12377. */
  12378. event: ClipboardEvent;
  12379. /**
  12380. *Creates an instance of ClipboardInfo.
  12381. * @param {number} type
  12382. * @param {ClipboardEvent} event
  12383. */
  12384. constructor(
  12385. /**
  12386. * Defines the type of event (BABYLON.ClipboardEventTypes)
  12387. */
  12388. type: number,
  12389. /**
  12390. * Defines the related dom event
  12391. */
  12392. event: ClipboardEvent);
  12393. /**
  12394. * Get the clipboard event's type from the keycode.
  12395. * @param keyCode Defines the keyCode for the current keyboard event.
  12396. * @return {number}
  12397. */
  12398. static GetTypeFromCharacter(keyCode: number): number;
  12399. }
  12400. }
  12401. declare module BABYLON {
  12402. /**
  12403. * Gather the list of keyboard event types as constants.
  12404. */
  12405. class KeyboardEventTypes {
  12406. /**
  12407. * The keydown event is fired when a key becomes active (pressed).
  12408. */
  12409. static readonly KEYDOWN: number;
  12410. /**
  12411. * The keyup event is fired when a key has been released.
  12412. */
  12413. static readonly KEYUP: number;
  12414. }
  12415. /**
  12416. * This class is used to store keyboard related info for the onKeyboardObservable event.
  12417. */
  12418. class KeyboardInfo {
  12419. /**
  12420. * Defines the type of event (BABYLON.KeyboardEventTypes)
  12421. */
  12422. type: number;
  12423. /**
  12424. * Defines the related dom event
  12425. */
  12426. event: KeyboardEvent;
  12427. /**
  12428. * Instantiates a new keyboard info.
  12429. * This class is used to store keyboard related info for the onKeyboardObservable event.
  12430. * @param type Defines the type of event (BABYLON.KeyboardEventTypes)
  12431. * @param event Defines the related dom event
  12432. */
  12433. constructor(
  12434. /**
  12435. * Defines the type of event (BABYLON.KeyboardEventTypes)
  12436. */
  12437. type: number,
  12438. /**
  12439. * Defines the related dom event
  12440. */
  12441. event: KeyboardEvent);
  12442. }
  12443. /**
  12444. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  12445. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  12446. */
  12447. class KeyboardInfoPre extends KeyboardInfo {
  12448. /**
  12449. * Defines the type of event (BABYLON.KeyboardEventTypes)
  12450. */
  12451. type: number;
  12452. /**
  12453. * Defines the related dom event
  12454. */
  12455. event: KeyboardEvent;
  12456. /**
  12457. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  12458. */
  12459. skipOnPointerObservable: boolean;
  12460. /**
  12461. * Instantiates a new keyboard pre info.
  12462. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  12463. * @param type Defines the type of event (BABYLON.KeyboardEventTypes)
  12464. * @param event Defines the related dom event
  12465. */
  12466. constructor(
  12467. /**
  12468. * Defines the type of event (BABYLON.KeyboardEventTypes)
  12469. */
  12470. type: number,
  12471. /**
  12472. * Defines the related dom event
  12473. */
  12474. event: KeyboardEvent);
  12475. }
  12476. }
  12477. declare module BABYLON {
  12478. /**
  12479. * Gather the list of pointer event types as constants.
  12480. */
  12481. class PointerEventTypes {
  12482. /**
  12483. * 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.
  12484. */
  12485. static readonly POINTERDOWN: number;
  12486. /**
  12487. * The pointerup event is fired when a pointer is no longer active.
  12488. */
  12489. static readonly POINTERUP: number;
  12490. /**
  12491. * The pointermove event is fired when a pointer changes coordinates.
  12492. */
  12493. static readonly POINTERMOVE: number;
  12494. /**
  12495. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12496. */
  12497. static readonly POINTERWHEEL: number;
  12498. /**
  12499. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12500. */
  12501. static readonly POINTERPICK: number;
  12502. /**
  12503. * The pointertap event is fired when a the object has been touched and released without drag.
  12504. */
  12505. static readonly POINTERTAP: number;
  12506. /**
  12507. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12508. */
  12509. static readonly POINTERDOUBLETAP: number;
  12510. }
  12511. /**
  12512. * Base class of pointer info types.
  12513. */
  12514. class PointerInfoBase {
  12515. /**
  12516. * Defines the type of event (BABYLON.PointerEventTypes)
  12517. */
  12518. type: number;
  12519. /**
  12520. * Defines the related dom event
  12521. */
  12522. event: PointerEvent | MouseWheelEvent;
  12523. /**
  12524. * Instantiates the base class of pointers info.
  12525. * @param type Defines the type of event (BABYLON.PointerEventTypes)
  12526. * @param event Defines the related dom event
  12527. */
  12528. constructor(
  12529. /**
  12530. * Defines the type of event (BABYLON.PointerEventTypes)
  12531. */
  12532. type: number,
  12533. /**
  12534. * Defines the related dom event
  12535. */
  12536. event: PointerEvent | MouseWheelEvent);
  12537. }
  12538. /**
  12539. * This class is used to store pointer related info for the onPrePointerObservable event.
  12540. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12541. */
  12542. class PointerInfoPre extends PointerInfoBase {
  12543. /**
  12544. * Ray from a pointer if availible (eg. 6dof controller)
  12545. */
  12546. ray: Nullable<Ray>;
  12547. /**
  12548. * Defines the local position of the pointer on the canvas.
  12549. */
  12550. localPosition: Vector2;
  12551. /**
  12552. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12553. */
  12554. skipOnPointerObservable: boolean;
  12555. /**
  12556. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12557. * @param type Defines the type of event (BABYLON.PointerEventTypes)
  12558. * @param event Defines the related dom event
  12559. * @param localX Defines the local x coordinates of the pointer when the event occured
  12560. * @param localY Defines the local y coordinates of the pointer when the event occured
  12561. */
  12562. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12563. }
  12564. /**
  12565. * This type contains all the data related to a pointer event in Babylon.js.
  12566. * 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.
  12567. */
  12568. class PointerInfo extends PointerInfoBase {
  12569. /**
  12570. * Defines the picking info associated to the info (if any)\
  12571. */
  12572. pickInfo: Nullable<PickingInfo>;
  12573. /**
  12574. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12575. * @param type Defines the type of event (BABYLON.PointerEventTypes)
  12576. * @param event Defines the related dom event
  12577. * @param pickInfo Defines the picking info associated to the info (if any)\
  12578. */
  12579. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12580. /**
  12581. * Defines the picking info associated to the info (if any)\
  12582. */
  12583. pickInfo: Nullable<PickingInfo>);
  12584. }
  12585. }
  12586. declare module BABYLON {
  12587. /**
  12588. * Represents a gamepad control stick position
  12589. */
  12590. class StickValues {
  12591. /**
  12592. * The x component of the control stick
  12593. */
  12594. x: number;
  12595. /**
  12596. * The y component of the control stick
  12597. */
  12598. y: number;
  12599. /**
  12600. * Initializes the gamepad x and y control stick values
  12601. * @param x The x component of the gamepad control stick value
  12602. * @param y The y component of the gamepad control stick value
  12603. */
  12604. constructor(
  12605. /**
  12606. * The x component of the control stick
  12607. */
  12608. x: number,
  12609. /**
  12610. * The y component of the control stick
  12611. */
  12612. y: number);
  12613. }
  12614. /**
  12615. * An interface which manages callbacks for gamepad button changes
  12616. */
  12617. interface GamepadButtonChanges {
  12618. /**
  12619. * Called when a gamepad has been changed
  12620. */
  12621. changed: boolean;
  12622. /**
  12623. * Called when a gamepad press event has been triggered
  12624. */
  12625. pressChanged: boolean;
  12626. /**
  12627. * Called when a touch event has been triggered
  12628. */
  12629. touchChanged: boolean;
  12630. /**
  12631. * Called when a value has changed
  12632. */
  12633. valueChanged: boolean;
  12634. }
  12635. /**
  12636. * Represents a gamepad
  12637. */
  12638. class Gamepad {
  12639. /**
  12640. * The id of the gamepad
  12641. */
  12642. id: string;
  12643. /**
  12644. * The index of the gamepad
  12645. */
  12646. index: number;
  12647. /**
  12648. * The browser gamepad
  12649. */
  12650. browserGamepad: any;
  12651. /**
  12652. * Specifies what type of gamepad this represents
  12653. */
  12654. type: number;
  12655. private _leftStick;
  12656. private _rightStick;
  12657. /** @hidden */
  12658. _isConnected: boolean;
  12659. private _leftStickAxisX;
  12660. private _leftStickAxisY;
  12661. private _rightStickAxisX;
  12662. private _rightStickAxisY;
  12663. /**
  12664. * Triggered when the left control stick has been changed
  12665. */
  12666. private _onleftstickchanged;
  12667. /**
  12668. * Triggered when the right control stick has been changed
  12669. */
  12670. private _onrightstickchanged;
  12671. /**
  12672. * Represents a gamepad controller
  12673. */
  12674. static GAMEPAD: number;
  12675. /**
  12676. * Represents a generic controller
  12677. */
  12678. static GENERIC: number;
  12679. /**
  12680. * Represents an XBox controller
  12681. */
  12682. static XBOX: number;
  12683. /**
  12684. * Represents a pose-enabled controller
  12685. */
  12686. static POSE_ENABLED: number;
  12687. /**
  12688. * Specifies whether the left control stick should be Y-inverted
  12689. */
  12690. protected _invertLeftStickY: boolean;
  12691. /**
  12692. * Specifies if the gamepad has been connected
  12693. */
  12694. readonly isConnected: boolean;
  12695. /**
  12696. * Initializes the gamepad
  12697. * @param id The id of the gamepad
  12698. * @param index The index of the gamepad
  12699. * @param browserGamepad The browser gamepad
  12700. * @param leftStickX The x component of the left joystick
  12701. * @param leftStickY The y component of the left joystick
  12702. * @param rightStickX The x component of the right joystick
  12703. * @param rightStickY The y component of the right joystick
  12704. */
  12705. constructor(
  12706. /**
  12707. * The id of the gamepad
  12708. */
  12709. id: string,
  12710. /**
  12711. * The index of the gamepad
  12712. */
  12713. index: number,
  12714. /**
  12715. * The browser gamepad
  12716. */
  12717. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12718. /**
  12719. * Callback triggered when the left joystick has changed
  12720. * @param callback
  12721. */
  12722. onleftstickchanged(callback: (values: StickValues) => void): void;
  12723. /**
  12724. * Callback triggered when the right joystick has changed
  12725. * @param callback
  12726. */
  12727. onrightstickchanged(callback: (values: StickValues) => void): void;
  12728. /**
  12729. * Gets the left joystick
  12730. */
  12731. /**
  12732. * Sets the left joystick values
  12733. */
  12734. leftStick: StickValues;
  12735. /**
  12736. * Gets the right joystick
  12737. */
  12738. /**
  12739. * Sets the right joystick value
  12740. */
  12741. rightStick: StickValues;
  12742. /**
  12743. * Updates the gamepad joystick positions
  12744. */
  12745. update(): void;
  12746. /**
  12747. * Disposes the gamepad
  12748. */
  12749. dispose(): void;
  12750. }
  12751. /**
  12752. * Represents a generic gamepad
  12753. */
  12754. class GenericPad extends Gamepad {
  12755. private _buttons;
  12756. private _onbuttondown;
  12757. private _onbuttonup;
  12758. /**
  12759. * Observable triggered when a button has been pressed
  12760. */
  12761. onButtonDownObservable: Observable<number>;
  12762. /**
  12763. * Observable triggered when a button has been released
  12764. */
  12765. onButtonUpObservable: Observable<number>;
  12766. /**
  12767. * Callback triggered when a button has been pressed
  12768. * @param callback Called when a button has been pressed
  12769. */
  12770. onbuttondown(callback: (buttonPressed: number) => void): void;
  12771. /**
  12772. * Callback triggered when a button has been released
  12773. * @param callback Called when a button has been released
  12774. */
  12775. onbuttonup(callback: (buttonReleased: number) => void): void;
  12776. /**
  12777. * Initializes the generic gamepad
  12778. * @param id The id of the generic gamepad
  12779. * @param index The index of the generic gamepad
  12780. * @param browserGamepad The browser gamepad
  12781. */
  12782. constructor(id: string, index: number, browserGamepad: any);
  12783. private _setButtonValue;
  12784. /**
  12785. * Updates the generic gamepad
  12786. */
  12787. update(): void;
  12788. /**
  12789. * Disposes the generic gamepad
  12790. */
  12791. dispose(): void;
  12792. }
  12793. }
  12794. declare module BABYLON {
  12795. /**
  12796. * Manager for handling gamepads
  12797. */
  12798. class GamepadManager {
  12799. private _scene?;
  12800. private _babylonGamepads;
  12801. private _oneGamepadConnected;
  12802. /** @hidden */
  12803. _isMonitoring: boolean;
  12804. private _gamepadEventSupported;
  12805. private _gamepadSupport;
  12806. /**
  12807. * observable to be triggered when the gamepad controller has been connected
  12808. */
  12809. onGamepadConnectedObservable: Observable<Gamepad>;
  12810. /**
  12811. * observable to be triggered when the gamepad controller has been disconnected
  12812. */
  12813. onGamepadDisconnectedObservable: Observable<Gamepad>;
  12814. private _onGamepadConnectedEvent;
  12815. private _onGamepadDisconnectedEvent;
  12816. /**
  12817. * Initializes the gamepad manager
  12818. * @param _scene BabylonJS scene
  12819. */
  12820. constructor(_scene?: Scene | undefined);
  12821. /**
  12822. * The gamepads in the game pad manager
  12823. */
  12824. readonly gamepads: Gamepad[];
  12825. /**
  12826. * Get the gamepad controllers based on type
  12827. * @param type The type of gamepad controller
  12828. * @returns Nullable gamepad
  12829. */
  12830. getGamepadByType(type?: number): Nullable<Gamepad>;
  12831. /**
  12832. * Disposes the gamepad manager
  12833. */
  12834. dispose(): void;
  12835. private _addNewGamepad;
  12836. private _startMonitoringGamepads;
  12837. private _stopMonitoringGamepads;
  12838. /** @hidden */
  12839. _checkGamepadsStatus(): void;
  12840. private _updateGamepadObjects;
  12841. }
  12842. }
  12843. declare module BABYLON {
  12844. interface Scene {
  12845. /** @hidden */
  12846. _gamepadManager: Nullable<GamepadManager>;
  12847. /**
  12848. * Gets the gamepad manager associated with the scene
  12849. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  12850. */
  12851. gamepadManager: GamepadManager;
  12852. }
  12853. /**
  12854. * Interface representing a free camera inputs manager
  12855. */
  12856. interface FreeCameraInputsManager {
  12857. /**
  12858. * Adds gamepad input support to the FreeCameraInputsManager.
  12859. * @returns the FreeCameraInputsManager
  12860. */
  12861. addGamepad(): FreeCameraInputsManager;
  12862. }
  12863. /**
  12864. * Interface representing an arc rotate camera inputs manager
  12865. */
  12866. interface ArcRotateCameraInputsManager {
  12867. /**
  12868. * Adds gamepad input support to the ArcRotateCamera InputManager.
  12869. * @returns the camera inputs manager
  12870. */
  12871. addGamepad(): ArcRotateCameraInputsManager;
  12872. }
  12873. /**
  12874. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  12875. */
  12876. class GamepadSystemSceneComponent implements ISceneComponent {
  12877. /**
  12878. * The component name helpfull to identify the component in the list of scene components.
  12879. */
  12880. readonly name: string;
  12881. /**
  12882. * The scene the component belongs to.
  12883. */
  12884. scene: Scene;
  12885. /**
  12886. * Creates a new instance of the component for the given scene
  12887. * @param scene Defines the scene to register the component in
  12888. */
  12889. constructor(scene: Scene);
  12890. /**
  12891. * Registers the component in a given scene
  12892. */
  12893. register(): void;
  12894. /**
  12895. * Rebuilds the elements related to this component in case of
  12896. * context lost for instance.
  12897. */
  12898. rebuild(): void;
  12899. /**
  12900. * Disposes the component and the associated ressources
  12901. */
  12902. dispose(): void;
  12903. private _beforeCameraUpdate;
  12904. }
  12905. }
  12906. declare module BABYLON {
  12907. /**
  12908. * Defines supported buttons for XBox360 compatible gamepads
  12909. */
  12910. enum Xbox360Button {
  12911. /** A */
  12912. A = 0,
  12913. /** B */
  12914. B = 1,
  12915. /** X */
  12916. X = 2,
  12917. /** Y */
  12918. Y = 3,
  12919. /** Start */
  12920. Start = 4,
  12921. /** Back */
  12922. Back = 5,
  12923. /** Left button */
  12924. LB = 6,
  12925. /** Right button */
  12926. RB = 7,
  12927. /** Left stick */
  12928. LeftStick = 8,
  12929. /** Right stick */
  12930. RightStick = 9
  12931. }
  12932. /** Defines values for XBox360 DPad */
  12933. enum Xbox360Dpad {
  12934. /** Up */
  12935. Up = 0,
  12936. /** Down */
  12937. Down = 1,
  12938. /** Left */
  12939. Left = 2,
  12940. /** Right */
  12941. Right = 3
  12942. }
  12943. /**
  12944. * Defines a XBox360 gamepad
  12945. */
  12946. class Xbox360Pad extends Gamepad {
  12947. private _leftTrigger;
  12948. private _rightTrigger;
  12949. private _onlefttriggerchanged;
  12950. private _onrighttriggerchanged;
  12951. private _onbuttondown;
  12952. private _onbuttonup;
  12953. private _ondpaddown;
  12954. private _ondpadup;
  12955. /** Observable raised when a button is pressed */
  12956. onButtonDownObservable: Observable<Xbox360Button>;
  12957. /** Observable raised when a button is released */
  12958. onButtonUpObservable: Observable<Xbox360Button>;
  12959. /** Observable raised when a pad is pressed */
  12960. onPadDownObservable: Observable<Xbox360Dpad>;
  12961. /** Observable raised when a pad is released */
  12962. onPadUpObservable: Observable<Xbox360Dpad>;
  12963. private _buttonA;
  12964. private _buttonB;
  12965. private _buttonX;
  12966. private _buttonY;
  12967. private _buttonBack;
  12968. private _buttonStart;
  12969. private _buttonLB;
  12970. private _buttonRB;
  12971. private _buttonLeftStick;
  12972. private _buttonRightStick;
  12973. private _dPadUp;
  12974. private _dPadDown;
  12975. private _dPadLeft;
  12976. private _dPadRight;
  12977. private _isXboxOnePad;
  12978. /**
  12979. * Creates a new XBox360 gamepad object
  12980. * @param id defines the id of this gamepad
  12981. * @param index defines its index
  12982. * @param gamepad defines the internal HTML gamepad object
  12983. * @param xboxOne defines if it is a XBox One gamepad
  12984. */
  12985. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  12986. /**
  12987. * Defines the callback to call when left trigger is pressed
  12988. * @param callback defines the callback to use
  12989. */
  12990. onlefttriggerchanged(callback: (value: number) => void): void;
  12991. /**
  12992. * Defines the callback to call when right trigger is pressed
  12993. * @param callback defines the callback to use
  12994. */
  12995. onrighttriggerchanged(callback: (value: number) => void): void;
  12996. /**
  12997. * Gets the left trigger value
  12998. */
  12999. /**
  13000. * Sets the left trigger value
  13001. */
  13002. leftTrigger: number;
  13003. /**
  13004. * Gets the right trigger value
  13005. */
  13006. /**
  13007. * Sets the right trigger value
  13008. */
  13009. rightTrigger: number;
  13010. /**
  13011. * Defines the callback to call when a button is pressed
  13012. * @param callback defines the callback to use
  13013. */
  13014. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  13015. /**
  13016. * Defines the callback to call when a button is released
  13017. * @param callback defines the callback to use
  13018. */
  13019. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  13020. /**
  13021. * Defines the callback to call when a pad is pressed
  13022. * @param callback defines the callback to use
  13023. */
  13024. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  13025. /**
  13026. * Defines the callback to call when a pad is released
  13027. * @param callback defines the callback to use
  13028. */
  13029. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  13030. private _setButtonValue;
  13031. private _setDPadValue;
  13032. /**
  13033. * Gets the value of the `A` button
  13034. */
  13035. /**
  13036. * Sets the value of the `A` button
  13037. */
  13038. buttonA: number;
  13039. /**
  13040. * Gets the value of the `B` button
  13041. */
  13042. /**
  13043. * Sets the value of the `B` button
  13044. */
  13045. buttonB: number;
  13046. /**
  13047. * Gets the value of the `X` button
  13048. */
  13049. /**
  13050. * Sets the value of the `X` button
  13051. */
  13052. buttonX: number;
  13053. /**
  13054. * Gets the value of the `Y` button
  13055. */
  13056. /**
  13057. * Sets the value of the `Y` button
  13058. */
  13059. buttonY: number;
  13060. /**
  13061. * Gets the value of the `Start` button
  13062. */
  13063. /**
  13064. * Sets the value of the `Start` button
  13065. */
  13066. buttonStart: number;
  13067. /**
  13068. * Gets the value of the `Back` button
  13069. */
  13070. /**
  13071. * Sets the value of the `Back` button
  13072. */
  13073. buttonBack: number;
  13074. /**
  13075. * Gets the value of the `Left` button
  13076. */
  13077. /**
  13078. * Sets the value of the `Left` button
  13079. */
  13080. buttonLB: number;
  13081. /**
  13082. * Gets the value of the `Right` button
  13083. */
  13084. /**
  13085. * Sets the value of the `Right` button
  13086. */
  13087. buttonRB: number;
  13088. /**
  13089. * Gets the value of the Left joystick
  13090. */
  13091. /**
  13092. * Sets the value of the Left joystick
  13093. */
  13094. buttonLeftStick: number;
  13095. /**
  13096. * Gets the value of the Right joystick
  13097. */
  13098. /**
  13099. * Sets the value of the Right joystick
  13100. */
  13101. buttonRightStick: number;
  13102. /**
  13103. * Gets the value of D-pad up
  13104. */
  13105. /**
  13106. * Sets the value of D-pad up
  13107. */
  13108. dPadUp: number;
  13109. /**
  13110. * Gets the value of D-pad down
  13111. */
  13112. /**
  13113. * Sets the value of D-pad down
  13114. */
  13115. dPadDown: number;
  13116. /**
  13117. * Gets the value of D-pad left
  13118. */
  13119. /**
  13120. * Sets the value of D-pad left
  13121. */
  13122. dPadLeft: number;
  13123. /**
  13124. * Gets the value of D-pad right
  13125. */
  13126. /**
  13127. * Sets the value of D-pad right
  13128. */
  13129. dPadRight: number;
  13130. /**
  13131. * Force the gamepad to synchronize with device values
  13132. */
  13133. update(): void;
  13134. /**
  13135. * Disposes the gamepad
  13136. */
  13137. dispose(): void;
  13138. }
  13139. }
  13140. declare module BABYLON {
  13141. /**
  13142. * Single axis drag gizmo
  13143. */
  13144. class AxisDragGizmo extends Gizmo {
  13145. /**
  13146. * Drag behavior responsible for the gizmos dragging interactions
  13147. */
  13148. dragBehavior: PointerDragBehavior;
  13149. private _pointerObserver;
  13150. /**
  13151. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13152. */
  13153. snapDistance: number;
  13154. /**
  13155. * Event that fires each time the gizmo snaps to a new location.
  13156. * * snapDistance is the the change in distance
  13157. */
  13158. onSnapObservable: Observable<{
  13159. snapDistance: number;
  13160. }>;
  13161. /** @hidden */
  13162. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  13163. /** @hidden */
  13164. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  13165. /**
  13166. * Creates an AxisDragGizmo
  13167. * @param gizmoLayer The utility layer the gizmo will be added to
  13168. * @param dragAxis The axis which the gizmo will be able to drag on
  13169. * @param color The color of the gizmo
  13170. */
  13171. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  13172. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13173. /**
  13174. * Disposes of the gizmo
  13175. */
  13176. dispose(): void;
  13177. }
  13178. }
  13179. declare module BABYLON {
  13180. /**
  13181. * Single axis scale gizmo
  13182. */
  13183. class AxisScaleGizmo extends Gizmo {
  13184. private _coloredMaterial;
  13185. /**
  13186. * Drag behavior responsible for the gizmos dragging interactions
  13187. */
  13188. dragBehavior: PointerDragBehavior;
  13189. private _pointerObserver;
  13190. /**
  13191. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13192. */
  13193. snapDistance: number;
  13194. /**
  13195. * Event that fires each time the gizmo snaps to a new location.
  13196. * * snapDistance is the the change in distance
  13197. */
  13198. onSnapObservable: Observable<{
  13199. snapDistance: number;
  13200. }>;
  13201. /**
  13202. * If the scaling operation should be done on all axis (default: false)
  13203. */
  13204. uniformScaling: boolean;
  13205. /**
  13206. * Creates an AxisScaleGizmo
  13207. * @param gizmoLayer The utility layer the gizmo will be added to
  13208. * @param dragAxis The axis which the gizmo will be able to scale on
  13209. * @param color The color of the gizmo
  13210. */
  13211. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  13212. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13213. /**
  13214. * Disposes of the gizmo
  13215. */
  13216. dispose(): void;
  13217. /**
  13218. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  13219. * @param mesh The mesh to replace the default mesh of the gizmo
  13220. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  13221. */
  13222. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  13223. }
  13224. }
  13225. declare module BABYLON {
  13226. /**
  13227. * Bounding box gizmo
  13228. */
  13229. class BoundingBoxGizmo extends Gizmo {
  13230. private _lineBoundingBox;
  13231. private _rotateSpheresParent;
  13232. private _scaleBoxesParent;
  13233. private _boundingDimensions;
  13234. private _renderObserver;
  13235. private _pointerObserver;
  13236. private _scaleDragSpeed;
  13237. private _tmpQuaternion;
  13238. private _tmpVector;
  13239. private _tmpRotationMatrix;
  13240. /**
  13241. * 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)
  13242. */
  13243. ignoreChildren: boolean;
  13244. /**
  13245. * 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)
  13246. */
  13247. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  13248. /**
  13249. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  13250. */
  13251. rotationSphereSize: number;
  13252. /**
  13253. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  13254. */
  13255. scaleBoxSize: number;
  13256. /**
  13257. * 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)
  13258. */
  13259. fixedDragMeshScreenSize: boolean;
  13260. /**
  13261. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  13262. */
  13263. fixedDragMeshScreenSizeDistanceFactor: number;
  13264. /**
  13265. * Fired when a rotation sphere or scale box is dragged
  13266. */
  13267. onDragStartObservable: Observable<{}>;
  13268. /**
  13269. * Fired when a scale box is dragged
  13270. */
  13271. onScaleBoxDragObservable: Observable<{}>;
  13272. /**
  13273. * Fired when a scale box drag is ended
  13274. */
  13275. onScaleBoxDragEndObservable: Observable<{}>;
  13276. /**
  13277. * Fired when a rotation sphere is dragged
  13278. */
  13279. onRotationSphereDragObservable: Observable<{}>;
  13280. /**
  13281. * Fired when a rotation sphere drag is ended
  13282. */
  13283. onRotationSphereDragEndObservable: Observable<{}>;
  13284. /**
  13285. * 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)
  13286. */
  13287. scalePivot: Nullable<Vector3>;
  13288. private _anchorMesh;
  13289. private _existingMeshScale;
  13290. private _dragMesh;
  13291. private pointerDragBehavior;
  13292. private static _PivotCached;
  13293. private static _OldPivotPoint;
  13294. private static _PivotTranslation;
  13295. private static _PivotTmpVector;
  13296. /** @hidden */
  13297. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  13298. /** @hidden */
  13299. static _RestorePivotPoint(mesh: AbstractMesh): void;
  13300. /**
  13301. * Creates an BoundingBoxGizmo
  13302. * @param gizmoLayer The utility layer the gizmo will be added to
  13303. * @param color The color of the gizmo
  13304. */
  13305. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  13306. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13307. private _selectNode;
  13308. /**
  13309. * Updates the bounding box information for the Gizmo
  13310. */
  13311. updateBoundingBox(): void;
  13312. private _updateRotationSpheres;
  13313. private _updateScaleBoxes;
  13314. /**
  13315. * Enables rotation on the specified axis and disables rotation on the others
  13316. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  13317. */
  13318. setEnabledRotationAxis(axis: string): void;
  13319. private _updateDummy;
  13320. /**
  13321. * Enables a pointer drag behavior on the bounding box of the gizmo
  13322. */
  13323. enableDragBehavior(): void;
  13324. /**
  13325. * Disposes of the gizmo
  13326. */
  13327. dispose(): void;
  13328. /**
  13329. * 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)
  13330. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  13331. * @returns the bounding box mesh with the passed in mesh as a child
  13332. */
  13333. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  13334. /**
  13335. * CustomMeshes are not supported by this gizmo
  13336. * @param mesh The mesh to replace the default mesh of the gizmo
  13337. */
  13338. setCustomMesh(mesh: Mesh): void;
  13339. }
  13340. }
  13341. declare module BABYLON {
  13342. /**
  13343. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  13344. */
  13345. class Gizmo implements IDisposable {
  13346. /** The utility layer the gizmo will be added to */
  13347. gizmoLayer: UtilityLayerRenderer;
  13348. /**
  13349. * The root mesh of the gizmo
  13350. */
  13351. protected _rootMesh: Mesh;
  13352. private _attachedMesh;
  13353. /**
  13354. * Ratio for the scale of the gizmo (Default: 1)
  13355. */
  13356. scaleRatio: number;
  13357. private _tmpMatrix;
  13358. /**
  13359. * If a custom mesh has been set (Default: false)
  13360. */
  13361. protected _customMeshSet: boolean;
  13362. /**
  13363. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  13364. * * When set, interactions will be enabled
  13365. */
  13366. attachedMesh: Nullable<AbstractMesh>;
  13367. /**
  13368. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  13369. * @param mesh The mesh to replace the default mesh of the gizmo
  13370. */
  13371. setCustomMesh(mesh: Mesh): void;
  13372. /**
  13373. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  13374. */
  13375. updateGizmoRotationToMatchAttachedMesh: boolean;
  13376. /**
  13377. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  13378. */
  13379. updateGizmoPositionToMatchAttachedMesh: boolean;
  13380. /**
  13381. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  13382. */
  13383. protected _updateScale: boolean;
  13384. protected _interactionsEnabled: boolean;
  13385. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13386. private _beforeRenderObserver;
  13387. /**
  13388. * Creates a gizmo
  13389. * @param gizmoLayer The utility layer the gizmo will be added to
  13390. */
  13391. constructor(
  13392. /** The utility layer the gizmo will be added to */
  13393. gizmoLayer?: UtilityLayerRenderer);
  13394. private _tempVector;
  13395. /**
  13396. * @hidden
  13397. * Updates the gizmo to match the attached mesh's position/rotation
  13398. */
  13399. protected _update(): void;
  13400. /**
  13401. * Disposes of the gizmo
  13402. */
  13403. dispose(): void;
  13404. }
  13405. }
  13406. declare module BABYLON {
  13407. /**
  13408. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  13409. */
  13410. class GizmoManager implements IDisposable {
  13411. private scene;
  13412. /**
  13413. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  13414. */
  13415. gizmos: {
  13416. positionGizmo: Nullable<PositionGizmo>;
  13417. rotationGizmo: Nullable<RotationGizmo>;
  13418. scaleGizmo: Nullable<ScaleGizmo>;
  13419. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  13420. };
  13421. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  13422. clearGizmoOnEmptyPointerEvent: boolean;
  13423. /** Fires an event when the manager is attached to a mesh */
  13424. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  13425. private _gizmosEnabled;
  13426. private _pointerObserver;
  13427. private _attachedMesh;
  13428. private _boundingBoxColor;
  13429. private _defaultUtilityLayer;
  13430. private _defaultKeepDepthUtilityLayer;
  13431. /**
  13432. * When bounding box gizmo is enabled, this can be used to track drag/end events
  13433. */
  13434. boundingBoxDragBehavior: SixDofDragBehavior;
  13435. /**
  13436. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  13437. */
  13438. attachableMeshes: Nullable<Array<AbstractMesh>>;
  13439. /**
  13440. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  13441. */
  13442. usePointerToAttachGizmos: boolean;
  13443. /**
  13444. * Instatiates a gizmo manager
  13445. * @param scene the scene to overlay the gizmos on top of
  13446. */
  13447. constructor(scene: Scene);
  13448. /**
  13449. * Attaches a set of gizmos to the specified mesh
  13450. * @param mesh The mesh the gizmo's should be attached to
  13451. */
  13452. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  13453. /**
  13454. * If the position gizmo is enabled
  13455. */
  13456. positionGizmoEnabled: boolean;
  13457. /**
  13458. * If the rotation gizmo is enabled
  13459. */
  13460. rotationGizmoEnabled: boolean;
  13461. /**
  13462. * If the scale gizmo is enabled
  13463. */
  13464. scaleGizmoEnabled: boolean;
  13465. /**
  13466. * If the boundingBox gizmo is enabled
  13467. */
  13468. boundingBoxGizmoEnabled: boolean;
  13469. /**
  13470. * Disposes of the gizmo manager
  13471. */
  13472. dispose(): void;
  13473. }
  13474. }
  13475. declare module BABYLON {
  13476. /**
  13477. * Single plane rotation gizmo
  13478. */
  13479. class PlaneRotationGizmo extends Gizmo {
  13480. /**
  13481. * Drag behavior responsible for the gizmos dragging interactions
  13482. */
  13483. dragBehavior: PointerDragBehavior;
  13484. private _pointerObserver;
  13485. /**
  13486. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  13487. */
  13488. snapDistance: number;
  13489. /**
  13490. * Event that fires each time the gizmo snaps to a new location.
  13491. * * snapDistance is the the change in distance
  13492. */
  13493. onSnapObservable: Observable<{
  13494. snapDistance: number;
  13495. }>;
  13496. /**
  13497. * Creates a PlaneRotationGizmo
  13498. * @param gizmoLayer The utility layer the gizmo will be added to
  13499. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  13500. * @param color The color of the gizmo
  13501. * @param tessellation Amount of tessellation to be used when creating rotation circles
  13502. */
  13503. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  13504. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13505. /**
  13506. * Disposes of the gizmo
  13507. */
  13508. dispose(): void;
  13509. }
  13510. }
  13511. declare module BABYLON {
  13512. /**
  13513. * Gizmo that enables dragging a mesh along 3 axis
  13514. */
  13515. class PositionGizmo extends Gizmo {
  13516. /**
  13517. * Internal gizmo used for interactions on the x axis
  13518. */
  13519. xGizmo: AxisDragGizmo;
  13520. /**
  13521. * Internal gizmo used for interactions on the y axis
  13522. */
  13523. yGizmo: AxisDragGizmo;
  13524. /**
  13525. * Internal gizmo used for interactions on the z axis
  13526. */
  13527. zGizmo: AxisDragGizmo;
  13528. /** Fires an event when any of it's sub gizmos are dragged */
  13529. onDragStartObservable: Observable<{}>;
  13530. /** Fires an event when any of it's sub gizmos are released from dragging */
  13531. onDragEndObservable: Observable<{}>;
  13532. attachedMesh: Nullable<AbstractMesh>;
  13533. /**
  13534. * Creates a PositionGizmo
  13535. * @param gizmoLayer The utility layer the gizmo will be added to
  13536. */
  13537. constructor(gizmoLayer?: UtilityLayerRenderer);
  13538. updateGizmoRotationToMatchAttachedMesh: boolean;
  13539. /**
  13540. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13541. */
  13542. snapDistance: number;
  13543. /**
  13544. * Ratio for the scale of the gizmo (Default: 1)
  13545. */
  13546. scaleRatio: number;
  13547. /**
  13548. * Disposes of the gizmo
  13549. */
  13550. dispose(): void;
  13551. /**
  13552. * CustomMeshes are not supported by this gizmo
  13553. * @param mesh The mesh to replace the default mesh of the gizmo
  13554. */
  13555. setCustomMesh(mesh: Mesh): void;
  13556. }
  13557. }
  13558. declare module BABYLON {
  13559. /**
  13560. * Gizmo that enables rotating a mesh along 3 axis
  13561. */
  13562. class RotationGizmo extends Gizmo {
  13563. /**
  13564. * Internal gizmo used for interactions on the x axis
  13565. */
  13566. xGizmo: PlaneRotationGizmo;
  13567. /**
  13568. * Internal gizmo used for interactions on the y axis
  13569. */
  13570. yGizmo: PlaneRotationGizmo;
  13571. /**
  13572. * Internal gizmo used for interactions on the z axis
  13573. */
  13574. zGizmo: PlaneRotationGizmo;
  13575. /** Fires an event when any of it's sub gizmos are dragged */
  13576. onDragStartObservable: Observable<{}>;
  13577. /** Fires an event when any of it's sub gizmos are released from dragging */
  13578. onDragEndObservable: Observable<{}>;
  13579. attachedMesh: Nullable<AbstractMesh>;
  13580. /**
  13581. * Creates a RotationGizmo
  13582. * @param gizmoLayer The utility layer the gizmo will be added to
  13583. * @param tessellation Amount of tessellation to be used when creating rotation circles
  13584. */
  13585. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  13586. updateGizmoRotationToMatchAttachedMesh: boolean;
  13587. /**
  13588. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13589. */
  13590. snapDistance: number;
  13591. /**
  13592. * Ratio for the scale of the gizmo (Default: 1)
  13593. */
  13594. scaleRatio: number;
  13595. /**
  13596. * Disposes of the gizmo
  13597. */
  13598. dispose(): void;
  13599. /**
  13600. * CustomMeshes are not supported by this gizmo
  13601. * @param mesh The mesh to replace the default mesh of the gizmo
  13602. */
  13603. setCustomMesh(mesh: Mesh): void;
  13604. }
  13605. }
  13606. declare module BABYLON {
  13607. /**
  13608. * Gizmo that enables scaling a mesh along 3 axis
  13609. */
  13610. class ScaleGizmo extends Gizmo {
  13611. /**
  13612. * Internal gizmo used for interactions on the x axis
  13613. */
  13614. xGizmo: AxisScaleGizmo;
  13615. /**
  13616. * Internal gizmo used for interactions on the y axis
  13617. */
  13618. yGizmo: AxisScaleGizmo;
  13619. /**
  13620. * Internal gizmo used for interactions on the z axis
  13621. */
  13622. zGizmo: AxisScaleGizmo;
  13623. /**
  13624. * Internal gizmo used to scale all axis equally
  13625. */
  13626. uniformScaleGizmo: AxisScaleGizmo;
  13627. /** Fires an event when any of it's sub gizmos are dragged */
  13628. onDragStartObservable: Observable<{}>;
  13629. /** Fires an event when any of it's sub gizmos are released from dragging */
  13630. onDragEndObservable: Observable<{}>;
  13631. attachedMesh: Nullable<AbstractMesh>;
  13632. /**
  13633. * Creates a ScaleGizmo
  13634. * @param gizmoLayer The utility layer the gizmo will be added to
  13635. */
  13636. constructor(gizmoLayer?: UtilityLayerRenderer);
  13637. updateGizmoRotationToMatchAttachedMesh: boolean;
  13638. /**
  13639. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13640. */
  13641. snapDistance: number;
  13642. /**
  13643. * Ratio for the scale of the gizmo (Default: 1)
  13644. */
  13645. scaleRatio: number;
  13646. /**
  13647. * Disposes of the gizmo
  13648. */
  13649. dispose(): void;
  13650. }
  13651. }
  13652. declare module BABYLON {
  13653. /**
  13654. * Represents the different options available during the creation of
  13655. * a Environment helper.
  13656. *
  13657. * This can control the default ground, skybox and image processing setup of your scene.
  13658. */
  13659. interface IEnvironmentHelperOptions {
  13660. /**
  13661. * Specifies wether or not to create a ground.
  13662. * True by default.
  13663. */
  13664. createGround: boolean;
  13665. /**
  13666. * Specifies the ground size.
  13667. * 15 by default.
  13668. */
  13669. groundSize: number;
  13670. /**
  13671. * The texture used on the ground for the main color.
  13672. * Comes from the BabylonJS CDN by default.
  13673. *
  13674. * Remarks: Can be either a texture or a url.
  13675. */
  13676. groundTexture: string | BaseTexture;
  13677. /**
  13678. * The color mixed in the ground texture by default.
  13679. * BabylonJS clearColor by default.
  13680. */
  13681. groundColor: Color3;
  13682. /**
  13683. * Specifies the ground opacity.
  13684. * 1 by default.
  13685. */
  13686. groundOpacity: number;
  13687. /**
  13688. * Enables the ground to receive shadows.
  13689. * True by default.
  13690. */
  13691. enableGroundShadow: boolean;
  13692. /**
  13693. * Helps preventing the shadow to be fully black on the ground.
  13694. * 0.5 by default.
  13695. */
  13696. groundShadowLevel: number;
  13697. /**
  13698. * Creates a mirror texture attach to the ground.
  13699. * false by default.
  13700. */
  13701. enableGroundMirror: boolean;
  13702. /**
  13703. * Specifies the ground mirror size ratio.
  13704. * 0.3 by default as the default kernel is 64.
  13705. */
  13706. groundMirrorSizeRatio: number;
  13707. /**
  13708. * Specifies the ground mirror blur kernel size.
  13709. * 64 by default.
  13710. */
  13711. groundMirrorBlurKernel: number;
  13712. /**
  13713. * Specifies the ground mirror visibility amount.
  13714. * 1 by default
  13715. */
  13716. groundMirrorAmount: number;
  13717. /**
  13718. * Specifies the ground mirror reflectance weight.
  13719. * This uses the standard weight of the background material to setup the fresnel effect
  13720. * of the mirror.
  13721. * 1 by default.
  13722. */
  13723. groundMirrorFresnelWeight: number;
  13724. /**
  13725. * Specifies the ground mirror Falloff distance.
  13726. * This can helps reducing the size of the reflection.
  13727. * 0 by Default.
  13728. */
  13729. groundMirrorFallOffDistance: number;
  13730. /**
  13731. * Specifies the ground mirror texture type.
  13732. * Unsigned Int by Default.
  13733. */
  13734. groundMirrorTextureType: number;
  13735. /**
  13736. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  13737. * the shown objects.
  13738. */
  13739. groundYBias: number;
  13740. /**
  13741. * Specifies wether or not to create a skybox.
  13742. * True by default.
  13743. */
  13744. createSkybox: boolean;
  13745. /**
  13746. * Specifies the skybox size.
  13747. * 20 by default.
  13748. */
  13749. skyboxSize: number;
  13750. /**
  13751. * The texture used on the skybox for the main color.
  13752. * Comes from the BabylonJS CDN by default.
  13753. *
  13754. * Remarks: Can be either a texture or a url.
  13755. */
  13756. skyboxTexture: string | BaseTexture;
  13757. /**
  13758. * The color mixed in the skybox texture by default.
  13759. * BabylonJS clearColor by default.
  13760. */
  13761. skyboxColor: Color3;
  13762. /**
  13763. * The background rotation around the Y axis of the scene.
  13764. * This helps aligning the key lights of your scene with the background.
  13765. * 0 by default.
  13766. */
  13767. backgroundYRotation: number;
  13768. /**
  13769. * Compute automatically the size of the elements to best fit with the scene.
  13770. */
  13771. sizeAuto: boolean;
  13772. /**
  13773. * Default position of the rootMesh if autoSize is not true.
  13774. */
  13775. rootPosition: Vector3;
  13776. /**
  13777. * Sets up the image processing in the scene.
  13778. * true by default.
  13779. */
  13780. setupImageProcessing: boolean;
  13781. /**
  13782. * The texture used as your environment texture in the scene.
  13783. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  13784. *
  13785. * Remarks: Can be either a texture or a url.
  13786. */
  13787. environmentTexture: string | BaseTexture;
  13788. /**
  13789. * The value of the exposure to apply to the scene.
  13790. * 0.6 by default if setupImageProcessing is true.
  13791. */
  13792. cameraExposure: number;
  13793. /**
  13794. * The value of the contrast to apply to the scene.
  13795. * 1.6 by default if setupImageProcessing is true.
  13796. */
  13797. cameraContrast: number;
  13798. /**
  13799. * Specifies wether or not tonemapping should be enabled in the scene.
  13800. * true by default if setupImageProcessing is true.
  13801. */
  13802. toneMappingEnabled: boolean;
  13803. }
  13804. /**
  13805. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  13806. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  13807. * It also helps with the default setup of your imageProcessing configuration.
  13808. */
  13809. class EnvironmentHelper {
  13810. /**
  13811. * Default ground texture URL.
  13812. */
  13813. private static _groundTextureCDNUrl;
  13814. /**
  13815. * Default skybox texture URL.
  13816. */
  13817. private static _skyboxTextureCDNUrl;
  13818. /**
  13819. * Default environment texture URL.
  13820. */
  13821. private static _environmentTextureCDNUrl;
  13822. /**
  13823. * Creates the default options for the helper.
  13824. */
  13825. private static _getDefaultOptions;
  13826. private _rootMesh;
  13827. /**
  13828. * Gets the root mesh created by the helper.
  13829. */
  13830. readonly rootMesh: Mesh;
  13831. private _skybox;
  13832. /**
  13833. * Gets the skybox created by the helper.
  13834. */
  13835. readonly skybox: Nullable<Mesh>;
  13836. private _skyboxTexture;
  13837. /**
  13838. * Gets the skybox texture created by the helper.
  13839. */
  13840. readonly skyboxTexture: Nullable<BaseTexture>;
  13841. private _skyboxMaterial;
  13842. /**
  13843. * Gets the skybox material created by the helper.
  13844. */
  13845. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  13846. private _ground;
  13847. /**
  13848. * Gets the ground mesh created by the helper.
  13849. */
  13850. readonly ground: Nullable<Mesh>;
  13851. private _groundTexture;
  13852. /**
  13853. * Gets the ground texture created by the helper.
  13854. */
  13855. readonly groundTexture: Nullable<BaseTexture>;
  13856. private _groundMirror;
  13857. /**
  13858. * Gets the ground mirror created by the helper.
  13859. */
  13860. readonly groundMirror: Nullable<MirrorTexture>;
  13861. /**
  13862. * Gets the ground mirror render list to helps pushing the meshes
  13863. * you wish in the ground reflection.
  13864. */
  13865. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  13866. private _groundMaterial;
  13867. /**
  13868. * Gets the ground material created by the helper.
  13869. */
  13870. readonly groundMaterial: Nullable<BackgroundMaterial>;
  13871. /**
  13872. * Stores the creation options.
  13873. */
  13874. private readonly _scene;
  13875. private _options;
  13876. /**
  13877. * This observable will be notified with any error during the creation of the environment,
  13878. * mainly texture creation errors.
  13879. */
  13880. onErrorObservable: Observable<{
  13881. message?: string;
  13882. exception?: any;
  13883. }>;
  13884. /**
  13885. * constructor
  13886. * @param options
  13887. * @param scene The scene to add the material to
  13888. */
  13889. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  13890. /**
  13891. * Updates the background according to the new options
  13892. * @param options
  13893. */
  13894. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  13895. /**
  13896. * Sets the primary color of all the available elements.
  13897. * @param color the main color to affect to the ground and the background
  13898. */
  13899. setMainColor(color: Color3): void;
  13900. /**
  13901. * Setup the image processing according to the specified options.
  13902. */
  13903. private _setupImageProcessing;
  13904. /**
  13905. * Setup the environment texture according to the specified options.
  13906. */
  13907. private _setupEnvironmentTexture;
  13908. /**
  13909. * Setup the background according to the specified options.
  13910. */
  13911. private _setupBackground;
  13912. /**
  13913. * Get the scene sizes according to the setup.
  13914. */
  13915. private _getSceneSize;
  13916. /**
  13917. * Setup the ground according to the specified options.
  13918. */
  13919. private _setupGround;
  13920. /**
  13921. * Setup the ground material according to the specified options.
  13922. */
  13923. private _setupGroundMaterial;
  13924. /**
  13925. * Setup the ground diffuse texture according to the specified options.
  13926. */
  13927. private _setupGroundDiffuseTexture;
  13928. /**
  13929. * Setup the ground mirror texture according to the specified options.
  13930. */
  13931. private _setupGroundMirrorTexture;
  13932. /**
  13933. * Setup the ground to receive the mirror texture.
  13934. */
  13935. private _setupMirrorInGroundMaterial;
  13936. /**
  13937. * Setup the skybox according to the specified options.
  13938. */
  13939. private _setupSkybox;
  13940. /**
  13941. * Setup the skybox material according to the specified options.
  13942. */
  13943. private _setupSkyboxMaterial;
  13944. /**
  13945. * Setup the skybox reflection texture according to the specified options.
  13946. */
  13947. private _setupSkyboxReflectionTexture;
  13948. private _errorHandler;
  13949. /**
  13950. * Dispose all the elements created by the Helper.
  13951. */
  13952. dispose(): void;
  13953. }
  13954. }
  13955. declare module BABYLON {
  13956. /**
  13957. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  13958. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  13959. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  13960. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  13961. */
  13962. class PhotoDome extends TransformNode {
  13963. private _useDirectMapping;
  13964. /**
  13965. * The texture being displayed on the sphere
  13966. */
  13967. protected _photoTexture: Texture;
  13968. /**
  13969. * Gets or sets the texture being displayed on the sphere
  13970. */
  13971. photoTexture: Texture;
  13972. /**
  13973. * Observable raised when an error occured while loading the 360 image
  13974. */
  13975. onLoadErrorObservable: Observable<string>;
  13976. /**
  13977. * The skybox material
  13978. */
  13979. protected _material: BackgroundMaterial;
  13980. /**
  13981. * The surface used for the skybox
  13982. */
  13983. protected _mesh: Mesh;
  13984. /**
  13985. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  13986. * Also see the options.resolution property.
  13987. */
  13988. fovMultiplier: number;
  13989. /**
  13990. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  13991. * @param name Element's name, child elements will append suffixes for their own names.
  13992. * @param urlsOfPhoto defines the url of the photo to display
  13993. * @param options defines an object containing optional or exposed sub element properties
  13994. * @param onError defines a callback called when an error occured while loading the texture
  13995. */
  13996. constructor(name: string, urlOfPhoto: string, options: {
  13997. resolution?: number;
  13998. size?: number;
  13999. useDirectMapping?: boolean;
  14000. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  14001. /**
  14002. * Releases resources associated with this node.
  14003. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14004. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14005. */
  14006. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14007. }
  14008. }
  14009. declare module BABYLON {
  14010. interface Scene {
  14011. /**
  14012. * Creates a default light for the scene.
  14013. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  14014. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  14015. */
  14016. createDefaultLight(replace?: boolean): void;
  14017. /**
  14018. * Creates a default camera for the scene.
  14019. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  14020. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  14021. * @param replace has default false, when true replaces the active camera in the scene
  14022. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  14023. */
  14024. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  14025. /**
  14026. * Creates a default camera and a default light.
  14027. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  14028. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  14029. * @param replace has the default false, when true replaces the active camera/light in the scene
  14030. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  14031. */
  14032. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  14033. /**
  14034. * Creates a new sky box
  14035. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  14036. * @param environmentTexture defines the texture to use as environment texture
  14037. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  14038. * @param scale defines the overall scale of the skybox
  14039. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  14040. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  14041. * @returns a new mesh holding the sky box
  14042. */
  14043. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  14044. /**
  14045. * Creates a new environment
  14046. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  14047. * @param options defines the options you can use to configure the environment
  14048. * @returns the new EnvironmentHelper
  14049. */
  14050. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  14051. /**
  14052. * Creates a new VREXperienceHelper
  14053. * @see http://doc.babylonjs.com/how_to/webvr_helper
  14054. * @param webVROptions defines the options used to create the new VREXperienceHelper
  14055. * @returns a new VREXperienceHelper
  14056. */
  14057. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  14058. /**
  14059. * Creates a new XREXperienceHelper
  14060. * @see http://doc.babylonjs.com/how_to/webxr
  14061. * @returns a promise for a new XREXperienceHelper
  14062. */
  14063. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  14064. }
  14065. }
  14066. declare module BABYLON {
  14067. /**
  14068. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  14069. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  14070. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  14071. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  14072. */
  14073. class VideoDome extends TransformNode {
  14074. private _useDirectMapping;
  14075. /**
  14076. * The video texture being displayed on the sphere
  14077. */
  14078. protected _videoTexture: VideoTexture;
  14079. /**
  14080. * Gets the video texture being displayed on the sphere
  14081. */
  14082. readonly videoTexture: VideoTexture;
  14083. /**
  14084. * The skybox material
  14085. */
  14086. protected _material: BackgroundMaterial;
  14087. /**
  14088. * The surface used for the skybox
  14089. */
  14090. protected _mesh: Mesh;
  14091. /**
  14092. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  14093. * Also see the options.resolution property.
  14094. */
  14095. fovMultiplier: number;
  14096. /**
  14097. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  14098. * @param name Element's name, child elements will append suffixes for their own names.
  14099. * @param urlsOrVideo defines the url(s) or the video element to use
  14100. * @param options An object containing optional or exposed sub element properties
  14101. */
  14102. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  14103. resolution?: number;
  14104. clickToPlay?: boolean;
  14105. autoPlay?: boolean;
  14106. loop?: boolean;
  14107. size?: number;
  14108. poster?: string;
  14109. useDirectMapping?: boolean;
  14110. }, scene: Scene);
  14111. /**
  14112. * Releases resources associated with this node.
  14113. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14114. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14115. */
  14116. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14117. }
  14118. }
  14119. declare module BABYLON {
  14120. /**
  14121. * This class can be used to get instrumentation data from a Babylon engine
  14122. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  14123. */
  14124. class EngineInstrumentation implements IDisposable {
  14125. /**
  14126. * Define the instrumented engine.
  14127. */
  14128. engine: Engine;
  14129. private _captureGPUFrameTime;
  14130. private _gpuFrameTimeToken;
  14131. private _gpuFrameTime;
  14132. private _captureShaderCompilationTime;
  14133. private _shaderCompilationTime;
  14134. private _onBeginFrameObserver;
  14135. private _onEndFrameObserver;
  14136. private _onBeforeShaderCompilationObserver;
  14137. private _onAfterShaderCompilationObserver;
  14138. /**
  14139. * Gets the perf counter used for GPU frame time
  14140. */
  14141. readonly gpuFrameTimeCounter: PerfCounter;
  14142. /**
  14143. * Gets the GPU frame time capture status
  14144. */
  14145. /**
  14146. * Enable or disable the GPU frame time capture
  14147. */
  14148. captureGPUFrameTime: boolean;
  14149. /**
  14150. * Gets the perf counter used for shader compilation time
  14151. */
  14152. readonly shaderCompilationTimeCounter: PerfCounter;
  14153. /**
  14154. * Gets the shader compilation time capture status
  14155. */
  14156. /**
  14157. * Enable or disable the shader compilation time capture
  14158. */
  14159. captureShaderCompilationTime: boolean;
  14160. /**
  14161. * Instantiates a new engine instrumentation.
  14162. * This class can be used to get instrumentation data from a Babylon engine
  14163. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  14164. * @param engine Defines the engine to instrument
  14165. */
  14166. constructor(
  14167. /**
  14168. * Define the instrumented engine.
  14169. */
  14170. engine: Engine);
  14171. /**
  14172. * Dispose and release associated resources.
  14173. */
  14174. dispose(): void;
  14175. }
  14176. }
  14177. declare module BABYLON {
  14178. /**
  14179. * This class can be used to get instrumentation data from a Babylon engine
  14180. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  14181. */
  14182. class SceneInstrumentation implements IDisposable {
  14183. /**
  14184. * Defines the scene to instrument
  14185. */
  14186. scene: Scene;
  14187. private _captureActiveMeshesEvaluationTime;
  14188. private _activeMeshesEvaluationTime;
  14189. private _captureRenderTargetsRenderTime;
  14190. private _renderTargetsRenderTime;
  14191. private _captureFrameTime;
  14192. private _frameTime;
  14193. private _captureRenderTime;
  14194. private _renderTime;
  14195. private _captureInterFrameTime;
  14196. private _interFrameTime;
  14197. private _captureParticlesRenderTime;
  14198. private _particlesRenderTime;
  14199. private _captureSpritesRenderTime;
  14200. private _spritesRenderTime;
  14201. private _capturePhysicsTime;
  14202. private _physicsTime;
  14203. private _captureAnimationsTime;
  14204. private _animationsTime;
  14205. private _captureCameraRenderTime;
  14206. private _cameraRenderTime;
  14207. private _onBeforeActiveMeshesEvaluationObserver;
  14208. private _onAfterActiveMeshesEvaluationObserver;
  14209. private _onBeforeRenderTargetsRenderObserver;
  14210. private _onAfterRenderTargetsRenderObserver;
  14211. private _onAfterRenderObserver;
  14212. private _onBeforeDrawPhaseObserver;
  14213. private _onAfterDrawPhaseObserver;
  14214. private _onBeforeAnimationsObserver;
  14215. private _onBeforeParticlesRenderingObserver;
  14216. private _onAfterParticlesRenderingObserver;
  14217. private _onBeforeSpritesRenderingObserver;
  14218. private _onAfterSpritesRenderingObserver;
  14219. private _onBeforePhysicsObserver;
  14220. private _onAfterPhysicsObserver;
  14221. private _onAfterAnimationsObserver;
  14222. private _onBeforeCameraRenderObserver;
  14223. private _onAfterCameraRenderObserver;
  14224. /**
  14225. * Gets the perf counter used for active meshes evaluation time
  14226. */
  14227. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  14228. /**
  14229. * Gets the active meshes evaluation time capture status
  14230. */
  14231. /**
  14232. * Enable or disable the active meshes evaluation time capture
  14233. */
  14234. captureActiveMeshesEvaluationTime: boolean;
  14235. /**
  14236. * Gets the perf counter used for render targets render time
  14237. */
  14238. readonly renderTargetsRenderTimeCounter: PerfCounter;
  14239. /**
  14240. * Gets the render targets render time capture status
  14241. */
  14242. /**
  14243. * Enable or disable the render targets render time capture
  14244. */
  14245. captureRenderTargetsRenderTime: boolean;
  14246. /**
  14247. * Gets the perf counter used for particles render time
  14248. */
  14249. readonly particlesRenderTimeCounter: PerfCounter;
  14250. /**
  14251. * Gets the particles render time capture status
  14252. */
  14253. /**
  14254. * Enable or disable the particles render time capture
  14255. */
  14256. captureParticlesRenderTime: boolean;
  14257. /**
  14258. * Gets the perf counter used for sprites render time
  14259. */
  14260. readonly spritesRenderTimeCounter: PerfCounter;
  14261. /**
  14262. * Gets the sprites render time capture status
  14263. */
  14264. /**
  14265. * Enable or disable the sprites render time capture
  14266. */
  14267. captureSpritesRenderTime: boolean;
  14268. /**
  14269. * Gets the perf counter used for physics time
  14270. */
  14271. readonly physicsTimeCounter: PerfCounter;
  14272. /**
  14273. * Gets the physics time capture status
  14274. */
  14275. /**
  14276. * Enable or disable the physics time capture
  14277. */
  14278. capturePhysicsTime: boolean;
  14279. /**
  14280. * Gets the perf counter used for animations time
  14281. */
  14282. readonly animationsTimeCounter: PerfCounter;
  14283. /**
  14284. * Gets the animations time capture status
  14285. */
  14286. /**
  14287. * Enable or disable the animations time capture
  14288. */
  14289. captureAnimationsTime: boolean;
  14290. /**
  14291. * Gets the perf counter used for frame time capture
  14292. */
  14293. readonly frameTimeCounter: PerfCounter;
  14294. /**
  14295. * Gets the frame time capture status
  14296. */
  14297. /**
  14298. * Enable or disable the frame time capture
  14299. */
  14300. captureFrameTime: boolean;
  14301. /**
  14302. * Gets the perf counter used for inter-frames time capture
  14303. */
  14304. readonly interFrameTimeCounter: PerfCounter;
  14305. /**
  14306. * Gets the inter-frames time capture status
  14307. */
  14308. /**
  14309. * Enable or disable the inter-frames time capture
  14310. */
  14311. captureInterFrameTime: boolean;
  14312. /**
  14313. * Gets the perf counter used for render time capture
  14314. */
  14315. readonly renderTimeCounter: PerfCounter;
  14316. /**
  14317. * Gets the render time capture status
  14318. */
  14319. /**
  14320. * Enable or disable the render time capture
  14321. */
  14322. captureRenderTime: boolean;
  14323. /**
  14324. * Gets the perf counter used for camera render time capture
  14325. */
  14326. readonly cameraRenderTimeCounter: PerfCounter;
  14327. /**
  14328. * Gets the camera render time capture status
  14329. */
  14330. /**
  14331. * Enable or disable the camera render time capture
  14332. */
  14333. captureCameraRenderTime: boolean;
  14334. /**
  14335. * Gets the perf counter used for draw calls
  14336. */
  14337. readonly drawCallsCounter: PerfCounter;
  14338. /**
  14339. * Gets the perf counter used for texture collisions
  14340. */
  14341. readonly textureCollisionsCounter: PerfCounter;
  14342. /**
  14343. * Instantiates a new scene instrumentation.
  14344. * This class can be used to get instrumentation data from a Babylon engine
  14345. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  14346. * @param scene Defines the scene to instrument
  14347. */
  14348. constructor(
  14349. /**
  14350. * Defines the scene to instrument
  14351. */
  14352. scene: Scene);
  14353. /**
  14354. * Dispose and release associated resources.
  14355. */
  14356. dispose(): void;
  14357. }
  14358. }
  14359. declare module BABYLON {
  14360. /**
  14361. * @hidden
  14362. **/
  14363. class _TimeToken {
  14364. _startTimeQuery: Nullable<WebGLQuery>;
  14365. _endTimeQuery: Nullable<WebGLQuery>;
  14366. _timeElapsedQuery: Nullable<WebGLQuery>;
  14367. _timeElapsedQueryEnded: boolean;
  14368. }
  14369. }
  14370. declare module BABYLON {
  14371. /**
  14372. * Effect layer options. This helps customizing the behaviour
  14373. * of the effect layer.
  14374. */
  14375. interface IEffectLayerOptions {
  14376. /**
  14377. * Multiplication factor apply to the canvas size to compute the render target size
  14378. * used to generated the objects (the smaller the faster).
  14379. */
  14380. mainTextureRatio: number;
  14381. /**
  14382. * Enforces a fixed size texture to ensure effect stability across devices.
  14383. */
  14384. mainTextureFixedSize?: number;
  14385. /**
  14386. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  14387. */
  14388. alphaBlendingMode: number;
  14389. /**
  14390. * The camera attached to the layer.
  14391. */
  14392. camera: Nullable<Camera>;
  14393. /**
  14394. * The rendering group to draw the layer in.
  14395. */
  14396. renderingGroupId: number;
  14397. }
  14398. /**
  14399. * The effect layer Helps adding post process effect blended with the main pass.
  14400. *
  14401. * This can be for instance use to generate glow or higlight effects on the scene.
  14402. *
  14403. * The effect layer class can not be used directly and is intented to inherited from to be
  14404. * customized per effects.
  14405. */
  14406. abstract class EffectLayer {
  14407. private _vertexBuffers;
  14408. private _indexBuffer;
  14409. private _cachedDefines;
  14410. private _effectLayerMapGenerationEffect;
  14411. private _effectLayerOptions;
  14412. private _mergeEffect;
  14413. protected _scene: Scene;
  14414. protected _engine: Engine;
  14415. protected _maxSize: number;
  14416. protected _mainTextureDesiredSize: ISize;
  14417. protected _mainTexture: RenderTargetTexture;
  14418. protected _shouldRender: boolean;
  14419. protected _postProcesses: PostProcess[];
  14420. protected _textures: BaseTexture[];
  14421. protected _emissiveTextureAndColor: {
  14422. texture: Nullable<BaseTexture>;
  14423. color: Color4;
  14424. };
  14425. /**
  14426. * The name of the layer
  14427. */
  14428. name: string;
  14429. /**
  14430. * The clear color of the texture used to generate the glow map.
  14431. */
  14432. neutralColor: Color4;
  14433. /**
  14434. * Specifies wether the highlight layer is enabled or not.
  14435. */
  14436. isEnabled: boolean;
  14437. /**
  14438. * Gets the camera attached to the layer.
  14439. */
  14440. readonly camera: Nullable<Camera>;
  14441. /**
  14442. * Gets the rendering group id the layer should render in.
  14443. */
  14444. readonly renderingGroupId: number;
  14445. /**
  14446. * An event triggered when the effect layer has been disposed.
  14447. */
  14448. onDisposeObservable: Observable<EffectLayer>;
  14449. /**
  14450. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  14451. */
  14452. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  14453. /**
  14454. * An event triggered when the generated texture is being merged in the scene.
  14455. */
  14456. onBeforeComposeObservable: Observable<EffectLayer>;
  14457. /**
  14458. * An event triggered when the generated texture has been merged in the scene.
  14459. */
  14460. onAfterComposeObservable: Observable<EffectLayer>;
  14461. /**
  14462. * An event triggered when the efffect layer changes its size.
  14463. */
  14464. onSizeChangedObservable: Observable<EffectLayer>;
  14465. /**
  14466. * Instantiates a new effect Layer and references it in the scene.
  14467. * @param name The name of the layer
  14468. * @param scene The scene to use the layer in
  14469. */
  14470. constructor(
  14471. /** The Friendly of the effect in the scene */
  14472. name: string, scene: Scene);
  14473. /**
  14474. * Get the effect name of the layer.
  14475. * @return The effect name
  14476. */
  14477. abstract getEffectName(): string;
  14478. /**
  14479. * Checks for the readiness of the element composing the layer.
  14480. * @param subMesh the mesh to check for
  14481. * @param useInstances specify wether or not to use instances to render the mesh
  14482. * @return true if ready otherwise, false
  14483. */
  14484. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  14485. /**
  14486. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  14487. * @returns true if the effect requires stencil during the main canvas render pass.
  14488. */
  14489. abstract needStencil(): boolean;
  14490. /**
  14491. * Create the merge effect. This is the shader use to blit the information back
  14492. * to the main canvas at the end of the scene rendering.
  14493. * @returns The effect containing the shader used to merge the effect on the main canvas
  14494. */
  14495. protected abstract _createMergeEffect(): Effect;
  14496. /**
  14497. * Creates the render target textures and post processes used in the effect layer.
  14498. */
  14499. protected abstract _createTextureAndPostProcesses(): void;
  14500. /**
  14501. * Implementation specific of rendering the generating effect on the main canvas.
  14502. * @param effect The effect used to render through
  14503. */
  14504. protected abstract _internalRender(effect: Effect): void;
  14505. /**
  14506. * Sets the required values for both the emissive texture and and the main color.
  14507. */
  14508. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  14509. /**
  14510. * Free any resources and references associated to a mesh.
  14511. * Internal use
  14512. * @param mesh The mesh to free.
  14513. */
  14514. abstract _disposeMesh(mesh: Mesh): void;
  14515. /**
  14516. * Serializes this layer (Glow or Highlight for example)
  14517. * @returns a serialized layer object
  14518. */
  14519. abstract serialize?(): any;
  14520. /**
  14521. * Initializes the effect layer with the required options.
  14522. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  14523. */
  14524. protected _init(options: Partial<IEffectLayerOptions>): void;
  14525. /**
  14526. * Generates the index buffer of the full screen quad blending to the main canvas.
  14527. */
  14528. private _generateIndexBuffer;
  14529. /**
  14530. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  14531. */
  14532. private _genrateVertexBuffer;
  14533. /**
  14534. * Sets the main texture desired size which is the closest power of two
  14535. * of the engine canvas size.
  14536. */
  14537. private _setMainTextureSize;
  14538. /**
  14539. * Creates the main texture for the effect layer.
  14540. */
  14541. protected _createMainTexture(): void;
  14542. /**
  14543. * Checks for the readiness of the element composing the layer.
  14544. * @param subMesh the mesh to check for
  14545. * @param useInstances specify wether or not to use instances to render the mesh
  14546. * @param emissiveTexture the associated emissive texture used to generate the glow
  14547. * @return true if ready otherwise, false
  14548. */
  14549. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  14550. /**
  14551. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  14552. */
  14553. render(): void;
  14554. /**
  14555. * Determine if a given mesh will be used in the current effect.
  14556. * @param mesh mesh to test
  14557. * @returns true if the mesh will be used
  14558. */
  14559. hasMesh(mesh: AbstractMesh): boolean;
  14560. /**
  14561. * Returns true if the layer contains information to display, otherwise false.
  14562. * @returns true if the glow layer should be rendered
  14563. */
  14564. shouldRender(): boolean;
  14565. /**
  14566. * Returns true if the mesh should render, otherwise false.
  14567. * @param mesh The mesh to render
  14568. * @returns true if it should render otherwise false
  14569. */
  14570. protected _shouldRenderMesh(mesh: Mesh): boolean;
  14571. /**
  14572. * Returns true if the mesh should render, otherwise false.
  14573. * @param mesh The mesh to render
  14574. * @returns true if it should render otherwise false
  14575. */
  14576. protected _shouldRenderEmissiveTextureForMesh(mesh: Mesh): boolean;
  14577. /**
  14578. * Renders the submesh passed in parameter to the generation map.
  14579. */
  14580. protected _renderSubMesh(subMesh: SubMesh): void;
  14581. /**
  14582. * Rebuild the required buffers.
  14583. * @hidden Internal use only.
  14584. */
  14585. _rebuild(): void;
  14586. /**
  14587. * Dispose only the render target textures and post process.
  14588. */
  14589. private _disposeTextureAndPostProcesses;
  14590. /**
  14591. * Dispose the highlight layer and free resources.
  14592. */
  14593. dispose(): void;
  14594. /**
  14595. * Gets the class name of the effect layer
  14596. * @returns the string with the class name of the effect layer
  14597. */
  14598. getClassName(): string;
  14599. /**
  14600. * Creates an effect layer from parsed effect layer data
  14601. * @param parsedEffectLayer defines effect layer data
  14602. * @param scene defines the current scene
  14603. * @param rootUrl defines the root URL containing the effect layer information
  14604. * @returns a parsed effect Layer
  14605. */
  14606. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  14607. }
  14608. }
  14609. declare module BABYLON {
  14610. interface AbstractScene {
  14611. /**
  14612. * The list of effect layers (highlights/glow) added to the scene
  14613. * @see http://doc.babylonjs.com/how_to/highlight_layer
  14614. * @see http://doc.babylonjs.com/how_to/glow_layer
  14615. */
  14616. effectLayers: Array<EffectLayer>;
  14617. /**
  14618. * Removes the given effect layer from this scene.
  14619. * @param toRemove defines the effect layer to remove
  14620. * @returns the index of the removed effect layer
  14621. */
  14622. removeEffectLayer(toRemove: EffectLayer): number;
  14623. /**
  14624. * Adds the given effect layer to this scene
  14625. * @param newEffectLayer defines the effect layer to add
  14626. */
  14627. addEffectLayer(newEffectLayer: EffectLayer): void;
  14628. }
  14629. /**
  14630. * Defines the layer scene component responsible to manage any effect layers
  14631. * in a given scene.
  14632. */
  14633. class EffectLayerSceneComponent implements ISceneSerializableComponent {
  14634. /**
  14635. * The component name helpfull to identify the component in the list of scene components.
  14636. */
  14637. readonly name: string;
  14638. /**
  14639. * The scene the component belongs to.
  14640. */
  14641. scene: Scene;
  14642. private _engine;
  14643. private _renderEffects;
  14644. private _needStencil;
  14645. private _previousStencilState;
  14646. /**
  14647. * Creates a new instance of the component for the given scene
  14648. * @param scene Defines the scene to register the component in
  14649. */
  14650. constructor(scene: Scene);
  14651. /**
  14652. * Registers the component in a given scene
  14653. */
  14654. register(): void;
  14655. /**
  14656. * Rebuilds the elements related to this component in case of
  14657. * context lost for instance.
  14658. */
  14659. rebuild(): void;
  14660. /**
  14661. * Serializes the component data to the specified json object
  14662. * @param serializationObject The object to serialize to
  14663. */
  14664. serialize(serializationObject: any): void;
  14665. /**
  14666. * Adds all the element from the container to the scene
  14667. * @param container the container holding the elements
  14668. */
  14669. addFromContainer(container: AbstractScene): void;
  14670. /**
  14671. * Removes all the elements in the container from the scene
  14672. * @param container contains the elements to remove
  14673. */
  14674. removeFromContainer(container: AbstractScene): void;
  14675. /**
  14676. * Disposes the component and the associated ressources.
  14677. */
  14678. dispose(): void;
  14679. private _isReadyForMesh;
  14680. private _renderMainTexture;
  14681. private _setStencil;
  14682. private _setStencilBack;
  14683. private _draw;
  14684. private _drawCamera;
  14685. private _drawRenderingGroup;
  14686. }
  14687. }
  14688. declare module BABYLON {
  14689. interface AbstractScene {
  14690. /**
  14691. * Return a the first highlight layer of the scene with a given name.
  14692. * @param name The name of the highlight layer to look for.
  14693. * @return The highlight layer if found otherwise null.
  14694. */
  14695. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  14696. }
  14697. /**
  14698. * Glow layer options. This helps customizing the behaviour
  14699. * of the glow layer.
  14700. */
  14701. interface IGlowLayerOptions {
  14702. /**
  14703. * Multiplication factor apply to the canvas size to compute the render target size
  14704. * used to generated the glowing objects (the smaller the faster).
  14705. */
  14706. mainTextureRatio: number;
  14707. /**
  14708. * Enforces a fixed size texture to ensure resize independant blur.
  14709. */
  14710. mainTextureFixedSize?: number;
  14711. /**
  14712. * How big is the kernel of the blur texture.
  14713. */
  14714. blurKernelSize: number;
  14715. /**
  14716. * The camera attached to the layer.
  14717. */
  14718. camera: Nullable<Camera>;
  14719. /**
  14720. * Enable MSAA by chosing the number of samples.
  14721. */
  14722. mainTextureSamples?: number;
  14723. /**
  14724. * The rendering group to draw the layer in.
  14725. */
  14726. renderingGroupId: number;
  14727. }
  14728. /**
  14729. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  14730. *
  14731. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  14732. * glowy meshes to your scene.
  14733. *
  14734. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  14735. */
  14736. class GlowLayer extends EffectLayer {
  14737. /**
  14738. * Effect Name of the layer.
  14739. */
  14740. static readonly EffectName: string;
  14741. /**
  14742. * The default blur kernel size used for the glow.
  14743. */
  14744. static DefaultBlurKernelSize: number;
  14745. /**
  14746. * The default texture size ratio used for the glow.
  14747. */
  14748. static DefaultTextureRatio: number;
  14749. /**
  14750. * Sets the kernel size of the blur.
  14751. */
  14752. /**
  14753. * Gets the kernel size of the blur.
  14754. */
  14755. blurKernelSize: number;
  14756. /**
  14757. * Sets the glow intensity.
  14758. */
  14759. /**
  14760. * Gets the glow intensity.
  14761. */
  14762. intensity: number;
  14763. private _options;
  14764. private _intensity;
  14765. private _horizontalBlurPostprocess1;
  14766. private _verticalBlurPostprocess1;
  14767. private _horizontalBlurPostprocess2;
  14768. private _verticalBlurPostprocess2;
  14769. private _blurTexture1;
  14770. private _blurTexture2;
  14771. private _postProcesses1;
  14772. private _postProcesses2;
  14773. private _includedOnlyMeshes;
  14774. private _excludedMeshes;
  14775. /**
  14776. * Callback used to let the user override the color selection on a per mesh basis
  14777. */
  14778. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  14779. /**
  14780. * Callback used to let the user override the texture selection on a per mesh basis
  14781. */
  14782. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  14783. /**
  14784. * Instantiates a new glow Layer and references it to the scene.
  14785. * @param name The name of the layer
  14786. * @param scene The scene to use the layer in
  14787. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  14788. */
  14789. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  14790. /**
  14791. * Get the effect name of the layer.
  14792. * @return The effect name
  14793. */
  14794. getEffectName(): string;
  14795. /**
  14796. * Create the merge effect. This is the shader use to blit the information back
  14797. * to the main canvas at the end of the scene rendering.
  14798. */
  14799. protected _createMergeEffect(): Effect;
  14800. /**
  14801. * Creates the render target textures and post processes used in the glow layer.
  14802. */
  14803. protected _createTextureAndPostProcesses(): void;
  14804. /**
  14805. * Checks for the readiness of the element composing the layer.
  14806. * @param subMesh the mesh to check for
  14807. * @param useInstances specify wether or not to use instances to render the mesh
  14808. * @param emissiveTexture the associated emissive texture used to generate the glow
  14809. * @return true if ready otherwise, false
  14810. */
  14811. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  14812. /**
  14813. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  14814. */
  14815. needStencil(): boolean;
  14816. /**
  14817. * Implementation specific of rendering the generating effect on the main canvas.
  14818. * @param effect The effect used to render through
  14819. */
  14820. protected _internalRender(effect: Effect): void;
  14821. /**
  14822. * Sets the required values for both the emissive texture and and the main color.
  14823. */
  14824. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  14825. /**
  14826. * Returns true if the mesh should render, otherwise false.
  14827. * @param mesh The mesh to render
  14828. * @returns true if it should render otherwise false
  14829. */
  14830. protected _shouldRenderMesh(mesh: Mesh): boolean;
  14831. /**
  14832. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  14833. * @param mesh The mesh to exclude from the glow layer
  14834. */
  14835. addExcludedMesh(mesh: Mesh): void;
  14836. /**
  14837. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  14838. * @param mesh The mesh to remove
  14839. */
  14840. removeExcludedMesh(mesh: Mesh): void;
  14841. /**
  14842. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  14843. * @param mesh The mesh to include in the glow layer
  14844. */
  14845. addIncludedOnlyMesh(mesh: Mesh): void;
  14846. /**
  14847. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  14848. * @param mesh The mesh to remove
  14849. */
  14850. removeIncludedOnlyMesh(mesh: Mesh): void;
  14851. /**
  14852. * Determine if a given mesh will be used in the glow layer
  14853. * @param mesh The mesh to test
  14854. * @returns true if the mesh will be highlighted by the current glow layer
  14855. */
  14856. hasMesh(mesh: AbstractMesh): boolean;
  14857. /**
  14858. * Free any resources and references associated to a mesh.
  14859. * Internal use
  14860. * @param mesh The mesh to free.
  14861. * @hidden
  14862. */
  14863. _disposeMesh(mesh: Mesh): void;
  14864. /**
  14865. * Gets the class name of the effect layer
  14866. * @returns the string with the class name of the effect layer
  14867. */
  14868. getClassName(): string;
  14869. /**
  14870. * Serializes this glow layer
  14871. * @returns a serialized glow layer object
  14872. */
  14873. serialize(): any;
  14874. /**
  14875. * Creates a Glow Layer from parsed glow layer data
  14876. * @param parsedGlowLayer defines glow layer data
  14877. * @param scene defines the current scene
  14878. * @param rootUrl defines the root URL containing the glow layer information
  14879. * @returns a parsed Glow Layer
  14880. */
  14881. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  14882. }
  14883. }
  14884. declare module BABYLON {
  14885. interface AbstractScene {
  14886. /**
  14887. * Return a the first highlight layer of the scene with a given name.
  14888. * @param name The name of the highlight layer to look for.
  14889. * @return The highlight layer if found otherwise null.
  14890. */
  14891. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  14892. }
  14893. /**
  14894. * Highlight layer options. This helps customizing the behaviour
  14895. * of the highlight layer.
  14896. */
  14897. interface IHighlightLayerOptions {
  14898. /**
  14899. * Multiplication factor apply to the canvas size to compute the render target size
  14900. * used to generated the glowing objects (the smaller the faster).
  14901. */
  14902. mainTextureRatio: number;
  14903. /**
  14904. * Enforces a fixed size texture to ensure resize independant blur.
  14905. */
  14906. mainTextureFixedSize?: number;
  14907. /**
  14908. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  14909. * of the picture to blur (the smaller the faster).
  14910. */
  14911. blurTextureSizeRatio: number;
  14912. /**
  14913. * How big in texel of the blur texture is the vertical blur.
  14914. */
  14915. blurVerticalSize: number;
  14916. /**
  14917. * How big in texel of the blur texture is the horizontal blur.
  14918. */
  14919. blurHorizontalSize: number;
  14920. /**
  14921. * Alpha blending mode used to apply the blur. Default is combine.
  14922. */
  14923. alphaBlendingMode: number;
  14924. /**
  14925. * The camera attached to the layer.
  14926. */
  14927. camera: Nullable<Camera>;
  14928. /**
  14929. * Should we display highlight as a solid stroke?
  14930. */
  14931. isStroke?: boolean;
  14932. /**
  14933. * The rendering group to draw the layer in.
  14934. */
  14935. renderingGroupId: number;
  14936. }
  14937. /**
  14938. * The highlight layer Helps adding a glow effect around a mesh.
  14939. *
  14940. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  14941. * glowy meshes to your scene.
  14942. *
  14943. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  14944. */
  14945. class HighlightLayer extends EffectLayer {
  14946. name: string;
  14947. /**
  14948. * Effect Name of the highlight layer.
  14949. */
  14950. static readonly EffectName: string;
  14951. /**
  14952. * The neutral color used during the preparation of the glow effect.
  14953. * This is black by default as the blend operation is a blend operation.
  14954. */
  14955. static NeutralColor: Color4;
  14956. /**
  14957. * Stencil value used for glowing meshes.
  14958. */
  14959. static GlowingMeshStencilReference: number;
  14960. /**
  14961. * Stencil value used for the other meshes in the scene.
  14962. */
  14963. static NormalMeshStencilReference: number;
  14964. /**
  14965. * Specifies whether or not the inner glow is ACTIVE in the layer.
  14966. */
  14967. innerGlow: boolean;
  14968. /**
  14969. * Specifies whether or not the outer glow is ACTIVE in the layer.
  14970. */
  14971. outerGlow: boolean;
  14972. /**
  14973. * Specifies the horizontal size of the blur.
  14974. */
  14975. /**
  14976. * Gets the horizontal size of the blur.
  14977. */
  14978. blurHorizontalSize: number;
  14979. /**
  14980. * Specifies the vertical size of the blur.
  14981. */
  14982. /**
  14983. * Gets the vertical size of the blur.
  14984. */
  14985. blurVerticalSize: number;
  14986. /**
  14987. * An event triggered when the highlight layer is being blurred.
  14988. */
  14989. onBeforeBlurObservable: Observable<HighlightLayer>;
  14990. /**
  14991. * An event triggered when the highlight layer has been blurred.
  14992. */
  14993. onAfterBlurObservable: Observable<HighlightLayer>;
  14994. private _instanceGlowingMeshStencilReference;
  14995. private _options;
  14996. private _downSamplePostprocess;
  14997. private _horizontalBlurPostprocess;
  14998. private _verticalBlurPostprocess;
  14999. private _blurTexture;
  15000. private _meshes;
  15001. private _excludedMeshes;
  15002. /**
  15003. * Instantiates a new highlight Layer and references it to the scene..
  15004. * @param name The name of the layer
  15005. * @param scene The scene to use the layer in
  15006. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  15007. */
  15008. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  15009. /**
  15010. * Get the effect name of the layer.
  15011. * @return The effect name
  15012. */
  15013. getEffectName(): string;
  15014. /**
  15015. * Create the merge effect. This is the shader use to blit the information back
  15016. * to the main canvas at the end of the scene rendering.
  15017. */
  15018. protected _createMergeEffect(): Effect;
  15019. /**
  15020. * Creates the render target textures and post processes used in the highlight layer.
  15021. */
  15022. protected _createTextureAndPostProcesses(): void;
  15023. /**
  15024. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  15025. */
  15026. needStencil(): boolean;
  15027. /**
  15028. * Checks for the readiness of the element composing the layer.
  15029. * @param subMesh the mesh to check for
  15030. * @param useInstances specify wether or not to use instances to render the mesh
  15031. * @param emissiveTexture the associated emissive texture used to generate the glow
  15032. * @return true if ready otherwise, false
  15033. */
  15034. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  15035. /**
  15036. * Implementation specific of rendering the generating effect on the main canvas.
  15037. * @param effect The effect used to render through
  15038. */
  15039. protected _internalRender(effect: Effect): void;
  15040. /**
  15041. * Returns true if the layer contains information to display, otherwise false.
  15042. */
  15043. shouldRender(): boolean;
  15044. /**
  15045. * Returns true if the mesh should render, otherwise false.
  15046. * @param mesh The mesh to render
  15047. * @returns true if it should render otherwise false
  15048. */
  15049. protected _shouldRenderMesh(mesh: Mesh): boolean;
  15050. /**
  15051. * Sets the required values for both the emissive texture and and the main color.
  15052. */
  15053. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  15054. /**
  15055. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  15056. * @param mesh The mesh to exclude from the highlight layer
  15057. */
  15058. addExcludedMesh(mesh: Mesh): void;
  15059. /**
  15060. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  15061. * @param mesh The mesh to highlight
  15062. */
  15063. removeExcludedMesh(mesh: Mesh): void;
  15064. /**
  15065. * Determine if a given mesh will be highlighted by the current HighlightLayer
  15066. * @param mesh mesh to test
  15067. * @returns true if the mesh will be highlighted by the current HighlightLayer
  15068. */
  15069. hasMesh(mesh: AbstractMesh): boolean;
  15070. /**
  15071. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  15072. * @param mesh The mesh to highlight
  15073. * @param color The color of the highlight
  15074. * @param glowEmissiveOnly Extract the glow from the emissive texture
  15075. */
  15076. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  15077. /**
  15078. * Remove a mesh from the highlight layer in order to make it stop glowing.
  15079. * @param mesh The mesh to highlight
  15080. */
  15081. removeMesh(mesh: Mesh): void;
  15082. /**
  15083. * Force the stencil to the normal expected value for none glowing parts
  15084. */
  15085. private _defaultStencilReference;
  15086. /**
  15087. * Free any resources and references associated to a mesh.
  15088. * Internal use
  15089. * @param mesh The mesh to free.
  15090. * @hidden
  15091. */
  15092. _disposeMesh(mesh: Mesh): void;
  15093. /**
  15094. * Dispose the highlight layer and free resources.
  15095. */
  15096. dispose(): void;
  15097. /**
  15098. * Gets the class name of the effect layer
  15099. * @returns the string with the class name of the effect layer
  15100. */
  15101. getClassName(): string;
  15102. /**
  15103. * Serializes this Highlight layer
  15104. * @returns a serialized Highlight layer object
  15105. */
  15106. serialize(): any;
  15107. /**
  15108. * Creates a Highlight layer from parsed Highlight layer data
  15109. * @param parsedHightlightLayer defines the Highlight layer data
  15110. * @param scene defines the current scene
  15111. * @param rootUrl defines the root URL containing the Highlight layer information
  15112. * @returns a parsed Highlight layer
  15113. */
  15114. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  15115. }
  15116. }
  15117. declare module BABYLON {
  15118. /**
  15119. * This represents a full screen 2d layer.
  15120. * This can be useful to display a picture in the background of your scene for instance.
  15121. * @see https://www.babylonjs-playground.com/#08A2BS#1
  15122. */
  15123. class Layer {
  15124. /**
  15125. * Define the name of the layer.
  15126. */
  15127. name: string;
  15128. /**
  15129. * Define the texture the layer should display.
  15130. */
  15131. texture: Nullable<Texture>;
  15132. /**
  15133. * Is the layer in background or foreground.
  15134. */
  15135. isBackground: boolean;
  15136. /**
  15137. * Define the color of the layer (instead of texture).
  15138. */
  15139. color: Color4;
  15140. /**
  15141. * Define the scale of the layer in order to zoom in out of the texture.
  15142. */
  15143. scale: Vector2;
  15144. /**
  15145. * Define an offset for the layer in order to shift the texture.
  15146. */
  15147. offset: Vector2;
  15148. /**
  15149. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  15150. */
  15151. alphaBlendingMode: number;
  15152. /**
  15153. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  15154. * Alpha test will not mix with the background color in case of transparency.
  15155. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  15156. */
  15157. alphaTest: boolean;
  15158. /**
  15159. * Define a mask to restrict the layer to only some of the scene cameras.
  15160. */
  15161. layerMask: number;
  15162. /**
  15163. * Define the list of render target the layer is visible into.
  15164. */
  15165. renderTargetTextures: RenderTargetTexture[];
  15166. /**
  15167. * Define if the layer is only used in renderTarget or if it also
  15168. * renders in the main frame buffer of the canvas.
  15169. */
  15170. renderOnlyInRenderTargetTextures: boolean;
  15171. private _scene;
  15172. private _vertexBuffers;
  15173. private _indexBuffer;
  15174. private _effect;
  15175. private _alphaTestEffect;
  15176. /**
  15177. * An event triggered when the layer is disposed.
  15178. */
  15179. onDisposeObservable: Observable<Layer>;
  15180. private _onDisposeObserver;
  15181. /**
  15182. * Back compatibility with callback before the onDisposeObservable existed.
  15183. * The set callback will be triggered when the layer has been disposed.
  15184. */
  15185. onDispose: () => void;
  15186. /**
  15187. * An event triggered before rendering the scene
  15188. */
  15189. onBeforeRenderObservable: Observable<Layer>;
  15190. private _onBeforeRenderObserver;
  15191. /**
  15192. * Back compatibility with callback before the onBeforeRenderObservable existed.
  15193. * The set callback will be triggered just before rendering the layer.
  15194. */
  15195. onBeforeRender: () => void;
  15196. /**
  15197. * An event triggered after rendering the scene
  15198. */
  15199. onAfterRenderObservable: Observable<Layer>;
  15200. private _onAfterRenderObserver;
  15201. /**
  15202. * Back compatibility with callback before the onAfterRenderObservable existed.
  15203. * The set callback will be triggered just after rendering the layer.
  15204. */
  15205. onAfterRender: () => void;
  15206. /**
  15207. * Instantiates a new layer.
  15208. * This represents a full screen 2d layer.
  15209. * This can be useful to display a picture in the background of your scene for instance.
  15210. * @see https://www.babylonjs-playground.com/#08A2BS#1
  15211. * @param name Define the name of the layer in the scene
  15212. * @param imgUrl Define the url of the texture to display in the layer
  15213. * @param scene Define the scene the layer belongs to
  15214. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  15215. * @param color Defines a color for the layer
  15216. */
  15217. constructor(
  15218. /**
  15219. * Define the name of the layer.
  15220. */
  15221. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  15222. private _createIndexBuffer;
  15223. /** @hidden */
  15224. _rebuild(): void;
  15225. /**
  15226. * Renders the layer in the scene.
  15227. */
  15228. render(): void;
  15229. /**
  15230. * Disposes and releases the associated ressources.
  15231. */
  15232. dispose(): void;
  15233. }
  15234. }
  15235. declare module BABYLON {
  15236. interface AbstractScene {
  15237. /**
  15238. * The list of layers (background and foreground) of the scene
  15239. */
  15240. layers: Array<Layer>;
  15241. }
  15242. /**
  15243. * Defines the layer scene component responsible to manage any layers
  15244. * in a given scene.
  15245. */
  15246. class LayerSceneComponent implements ISceneComponent {
  15247. /**
  15248. * The component name helpfull to identify the component in the list of scene components.
  15249. */
  15250. readonly name: string;
  15251. /**
  15252. * The scene the component belongs to.
  15253. */
  15254. scene: Scene;
  15255. private _engine;
  15256. /**
  15257. * Creates a new instance of the component for the given scene
  15258. * @param scene Defines the scene to register the component in
  15259. */
  15260. constructor(scene: Scene);
  15261. /**
  15262. * Registers the component in a given scene
  15263. */
  15264. register(): void;
  15265. /**
  15266. * Rebuilds the elements related to this component in case of
  15267. * context lost for instance.
  15268. */
  15269. rebuild(): void;
  15270. /**
  15271. * Disposes the component and the associated ressources.
  15272. */
  15273. dispose(): void;
  15274. private _draw;
  15275. private _drawCameraPredicate;
  15276. private _drawCameraBackground;
  15277. private _drawCameraForeground;
  15278. private _drawRenderTargetPredicate;
  15279. private _drawRenderTargetBackground;
  15280. private _drawRenderTargetForeground;
  15281. }
  15282. }
  15283. declare module BABYLON {
  15284. /**
  15285. * This represents one of the lens effect in a `BABYLON.lensFlareSystem`.
  15286. * It controls one of the indiviual texture used in the effect.
  15287. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15288. */
  15289. class LensFlare {
  15290. /**
  15291. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  15292. */
  15293. size: number;
  15294. /**
  15295. * 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.
  15296. */
  15297. position: number;
  15298. /**
  15299. * Define the lens color.
  15300. */
  15301. color: Color3;
  15302. /**
  15303. * Define the lens texture.
  15304. */
  15305. texture: Nullable<Texture>;
  15306. /**
  15307. * Define the alpha mode to render this particular lens.
  15308. */
  15309. alphaMode: number;
  15310. private _system;
  15311. /**
  15312. * Creates a new Lens Flare.
  15313. * This represents one of the lens effect in a `BABYLON.lensFlareSystem`.
  15314. * It controls one of the indiviual texture used in the effect.
  15315. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15316. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  15317. * @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.
  15318. * @param color Define the lens color
  15319. * @param imgUrl Define the lens texture url
  15320. * @param system Define the `lensFlareSystem` this flare is part of
  15321. * @returns The newly created Lens Flare
  15322. */
  15323. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  15324. /**
  15325. * Instantiates a new Lens Flare.
  15326. * This represents one of the lens effect in a `BABYLON.lensFlareSystem`.
  15327. * It controls one of the indiviual texture used in the effect.
  15328. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15329. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  15330. * @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.
  15331. * @param color Define the lens color
  15332. * @param imgUrl Define the lens texture url
  15333. * @param system Define the `lensFlareSystem` this flare is part of
  15334. */
  15335. constructor(
  15336. /**
  15337. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  15338. */
  15339. size: number,
  15340. /**
  15341. * 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.
  15342. */
  15343. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  15344. /**
  15345. * Dispose and release the lens flare with its associated resources.
  15346. */
  15347. dispose(): void;
  15348. }
  15349. }
  15350. declare module BABYLON {
  15351. /**
  15352. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  15353. * It is usually composed of several `BABYLON.lensFlare`.
  15354. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15355. */
  15356. class LensFlareSystem {
  15357. /**
  15358. * Define the name of the lens flare system
  15359. */
  15360. name: string;
  15361. /**
  15362. * List of lens flares used in this system.
  15363. */
  15364. lensFlares: LensFlare[];
  15365. /**
  15366. * Define a limit from the border the lens flare can be visible.
  15367. */
  15368. borderLimit: number;
  15369. /**
  15370. * Define a viewport border we do not want to see the lens flare in.
  15371. */
  15372. viewportBorder: number;
  15373. /**
  15374. * Define a predicate which could limit the list of meshes able to occlude the effect.
  15375. */
  15376. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  15377. /**
  15378. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  15379. */
  15380. layerMask: number;
  15381. /**
  15382. * Define the id of the lens flare system in the scene.
  15383. * (equal to name by default)
  15384. */
  15385. id: string;
  15386. private _scene;
  15387. private _emitter;
  15388. private _vertexBuffers;
  15389. private _indexBuffer;
  15390. private _effect;
  15391. private _positionX;
  15392. private _positionY;
  15393. private _isEnabled;
  15394. /**
  15395. * Instantiates a lens flare system.
  15396. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  15397. * It is usually composed of several `BABYLON.lensFlare`.
  15398. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15399. * @param name Define the name of the lens flare system in the scene
  15400. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  15401. * @param scene Define the scene the lens flare system belongs to
  15402. */
  15403. constructor(
  15404. /**
  15405. * Define the name of the lens flare system
  15406. */
  15407. name: string, emitter: any, scene: Scene);
  15408. /**
  15409. * Define if the lens flare system is enabled.
  15410. */
  15411. isEnabled: boolean;
  15412. /**
  15413. * Get the scene the effects belongs to.
  15414. * @returns the scene holding the lens flare system
  15415. */
  15416. getScene(): Scene;
  15417. /**
  15418. * Get the emitter of the lens flare system.
  15419. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  15420. * @returns the emitter of the lens flare system
  15421. */
  15422. getEmitter(): any;
  15423. /**
  15424. * Set the emitter of the lens flare system.
  15425. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  15426. * @param newEmitter Define the new emitter of the system
  15427. */
  15428. setEmitter(newEmitter: any): void;
  15429. /**
  15430. * Get the lens flare system emitter position.
  15431. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  15432. * @returns the position
  15433. */
  15434. getEmitterPosition(): Vector3;
  15435. /**
  15436. * @hidden
  15437. */
  15438. computeEffectivePosition(globalViewport: Viewport): boolean;
  15439. /** @hidden */
  15440. _isVisible(): boolean;
  15441. /**
  15442. * @hidden
  15443. */
  15444. render(): boolean;
  15445. /**
  15446. * Dispose and release the lens flare with its associated resources.
  15447. */
  15448. dispose(): void;
  15449. /**
  15450. * Parse a lens flare system from a JSON repressentation
  15451. * @param parsedLensFlareSystem Define the JSON to parse
  15452. * @param scene Define the scene the parsed system should be instantiated in
  15453. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  15454. * @returns the parsed system
  15455. */
  15456. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  15457. /**
  15458. * Serialize the current Lens Flare System into a JSON representation.
  15459. * @returns the serialized JSON
  15460. */
  15461. serialize(): any;
  15462. }
  15463. }
  15464. declare module BABYLON {
  15465. interface AbstractScene {
  15466. /**
  15467. * The list of lens flare system added to the scene
  15468. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15469. */
  15470. lensFlareSystems: Array<LensFlareSystem>;
  15471. /**
  15472. * Removes the given lens flare system from this scene.
  15473. * @param toRemove The lens flare system to remove
  15474. * @returns The index of the removed lens flare system
  15475. */
  15476. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  15477. /**
  15478. * Adds the given lens flare system to this scene
  15479. * @param newLensFlareSystem The lens flare system to add
  15480. */
  15481. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  15482. /**
  15483. * Gets a lens flare system using its name
  15484. * @param name defines the name to look for
  15485. * @returns the lens flare system or null if not found
  15486. */
  15487. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  15488. /**
  15489. * Gets a lens flare system using its id
  15490. * @param id defines the id to look for
  15491. * @returns the lens flare system or null if not found
  15492. */
  15493. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  15494. }
  15495. /**
  15496. * Defines the lens flare scene component responsible to manage any lens flares
  15497. * in a given scene.
  15498. */
  15499. class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  15500. /**
  15501. * The component name helpfull to identify the component in the list of scene components.
  15502. */
  15503. readonly name: string;
  15504. /**
  15505. * The scene the component belongs to.
  15506. */
  15507. scene: Scene;
  15508. /**
  15509. * Creates a new instance of the component for the given scene
  15510. * @param scene Defines the scene to register the component in
  15511. */
  15512. constructor(scene: Scene);
  15513. /**
  15514. * Registers the component in a given scene
  15515. */
  15516. register(): void;
  15517. /**
  15518. * Rebuilds the elements related to this component in case of
  15519. * context lost for instance.
  15520. */
  15521. rebuild(): void;
  15522. /**
  15523. * Adds all the element from the container to the scene
  15524. * @param container the container holding the elements
  15525. */
  15526. addFromContainer(container: AbstractScene): void;
  15527. /**
  15528. * Removes all the elements in the container from the scene
  15529. * @param container contains the elements to remove
  15530. */
  15531. removeFromContainer(container: AbstractScene): void;
  15532. /**
  15533. * Serializes the component data to the specified json object
  15534. * @param serializationObject The object to serialize to
  15535. */
  15536. serialize(serializationObject: any): void;
  15537. /**
  15538. * Disposes the component and the associated ressources.
  15539. */
  15540. dispose(): void;
  15541. private _draw;
  15542. }
  15543. }
  15544. declare module BABYLON {
  15545. /**
  15546. * A directional light is defined by a direction (what a surprise!).
  15547. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  15548. * 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.
  15549. * Documentation: https://doc.babylonjs.com/babylon101/lights
  15550. */
  15551. class DirectionalLight extends ShadowLight {
  15552. private _shadowFrustumSize;
  15553. /**
  15554. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  15555. */
  15556. /**
  15557. * Specifies a fix frustum size for the shadow generation.
  15558. */
  15559. shadowFrustumSize: number;
  15560. private _shadowOrthoScale;
  15561. /**
  15562. * Gets the shadow projection scale against the optimal computed one.
  15563. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  15564. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  15565. */
  15566. /**
  15567. * Sets the shadow projection scale against the optimal computed one.
  15568. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  15569. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  15570. */
  15571. shadowOrthoScale: number;
  15572. /**
  15573. * Automatically compute the projection matrix to best fit (including all the casters)
  15574. * on each frame.
  15575. */
  15576. autoUpdateExtends: boolean;
  15577. private _orthoLeft;
  15578. private _orthoRight;
  15579. private _orthoTop;
  15580. private _orthoBottom;
  15581. /**
  15582. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  15583. * The directional light is emitted from everywhere in the given direction.
  15584. * It can cast shadows.
  15585. * Documentation : https://doc.babylonjs.com/babylon101/lights
  15586. * @param name The friendly name of the light
  15587. * @param direction The direction of the light
  15588. * @param scene The scene the light belongs to
  15589. */
  15590. constructor(name: string, direction: Vector3, scene: Scene);
  15591. /**
  15592. * Returns the string "DirectionalLight".
  15593. * @return The class name
  15594. */
  15595. getClassName(): string;
  15596. /**
  15597. * Returns the integer 1.
  15598. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15599. */
  15600. getTypeID(): number;
  15601. /**
  15602. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  15603. * Returns the DirectionalLight Shadow projection matrix.
  15604. */
  15605. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  15606. /**
  15607. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  15608. * Returns the DirectionalLight Shadow projection matrix.
  15609. */
  15610. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix): void;
  15611. /**
  15612. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  15613. * Returns the DirectionalLight Shadow projection matrix.
  15614. */
  15615. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  15616. protected _buildUniformLayout(): void;
  15617. /**
  15618. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  15619. * @param effect The effect to update
  15620. * @param lightIndex The index of the light in the effect to update
  15621. * @returns The directional light
  15622. */
  15623. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  15624. /**
  15625. * Gets the minZ used for shadow according to both the scene and the light.
  15626. *
  15627. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  15628. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  15629. * @param activeCamera The camera we are returning the min for
  15630. * @returns the depth min z
  15631. */
  15632. getDepthMinZ(activeCamera: Camera): number;
  15633. /**
  15634. * Gets the maxZ 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 max for
  15639. * @returns the depth max z
  15640. */
  15641. getDepthMaxZ(activeCamera: Camera): number;
  15642. /**
  15643. * Prepares the list of defines specific to the light type.
  15644. * @param defines the list of defines
  15645. * @param lightIndex defines the index of the light for the effect
  15646. */
  15647. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15648. }
  15649. }
  15650. declare module BABYLON {
  15651. /**
  15652. * The HemisphericLight simulates the ambient environment light,
  15653. * so the passed direction is the light reflection direction, not the incoming direction.
  15654. */
  15655. class HemisphericLight extends Light {
  15656. /**
  15657. * The groundColor is the light in the opposite direction to the one specified during creation.
  15658. * 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.
  15659. */
  15660. groundColor: Color3;
  15661. /**
  15662. * The light reflection direction, not the incoming direction.
  15663. */
  15664. direction: Vector3;
  15665. /**
  15666. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  15667. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  15668. * The HemisphericLight can't cast shadows.
  15669. * Documentation : https://doc.babylonjs.com/babylon101/lights
  15670. * @param name The friendly name of the light
  15671. * @param direction The direction of the light reflection
  15672. * @param scene The scene the light belongs to
  15673. */
  15674. constructor(name: string, direction: Vector3, scene: Scene);
  15675. protected _buildUniformLayout(): void;
  15676. /**
  15677. * Returns the string "HemisphericLight".
  15678. * @return The class name
  15679. */
  15680. getClassName(): string;
  15681. /**
  15682. * Sets the HemisphericLight direction towards the passed target (Vector3).
  15683. * Returns the updated direction.
  15684. * @param target The target the direction should point to
  15685. * @return The computed direction
  15686. */
  15687. setDirectionToTarget(target: Vector3): Vector3;
  15688. /**
  15689. * Returns the shadow generator associated to the light.
  15690. * @returns Always null for hemispheric lights because it does not support shadows.
  15691. */
  15692. getShadowGenerator(): Nullable<IShadowGenerator>;
  15693. /**
  15694. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  15695. * @param effect The effect to update
  15696. * @param lightIndex The index of the light in the effect to update
  15697. * @returns The hemispheric light
  15698. */
  15699. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  15700. /**
  15701. * Computes the world matrix of the node
  15702. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15703. * @param useWasUpdatedFlag defines a reserved property
  15704. * @returns the world matrix
  15705. */
  15706. computeWorldMatrix(force?: boolean, useWasUpdatedFlag?: boolean): Matrix;
  15707. /**
  15708. * Returns the integer 3.
  15709. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15710. */
  15711. getTypeID(): number;
  15712. /**
  15713. * Prepares the list of defines specific to the light type.
  15714. * @param defines the list of defines
  15715. * @param lightIndex defines the index of the light for the effect
  15716. */
  15717. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15718. }
  15719. }
  15720. declare module BABYLON {
  15721. /**
  15722. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  15723. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  15724. * 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.
  15725. */
  15726. abstract class Light extends Node {
  15727. /**
  15728. * Falloff Default: light is falling off following the material specification:
  15729. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  15730. */
  15731. static readonly FALLOFF_DEFAULT: number;
  15732. /**
  15733. * Falloff Physical: light is falling off following the inverse squared distance law.
  15734. */
  15735. static readonly FALLOFF_PHYSICAL: number;
  15736. /**
  15737. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  15738. * to enhance interoperability with other engines.
  15739. */
  15740. static readonly FALLOFF_GLTF: number;
  15741. /**
  15742. * Falloff Standard: light is falling off like in the standard material
  15743. * to enhance interoperability with other materials.
  15744. */
  15745. static readonly FALLOFF_STANDARD: number;
  15746. /**
  15747. * If every light affecting the material is in this lightmapMode,
  15748. * material.lightmapTexture adds or multiplies
  15749. * (depends on material.useLightmapAsShadowmap)
  15750. * after every other light calculations.
  15751. */
  15752. static readonly LIGHTMAP_DEFAULT: number;
  15753. /**
  15754. * material.lightmapTexture as only diffuse lighting from this light
  15755. * adds only specular lighting from this light
  15756. * adds dynamic shadows
  15757. */
  15758. static readonly LIGHTMAP_SPECULAR: number;
  15759. /**
  15760. * material.lightmapTexture as only lighting
  15761. * no light calculation from this light
  15762. * only adds dynamic shadows from this light
  15763. */
  15764. static readonly LIGHTMAP_SHADOWSONLY: number;
  15765. /**
  15766. * Each light type uses the default quantity according to its type:
  15767. * point/spot lights use luminous intensity
  15768. * directional lights use illuminance
  15769. */
  15770. static readonly INTENSITYMODE_AUTOMATIC: number;
  15771. /**
  15772. * lumen (lm)
  15773. */
  15774. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  15775. /**
  15776. * candela (lm/sr)
  15777. */
  15778. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  15779. /**
  15780. * lux (lm/m^2)
  15781. */
  15782. static readonly INTENSITYMODE_ILLUMINANCE: number;
  15783. /**
  15784. * nit (cd/m^2)
  15785. */
  15786. static readonly INTENSITYMODE_LUMINANCE: number;
  15787. /**
  15788. * Light type const id of the point light.
  15789. */
  15790. static readonly LIGHTTYPEID_POINTLIGHT: number;
  15791. /**
  15792. * Light type const id of the directional light.
  15793. */
  15794. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  15795. /**
  15796. * Light type const id of the spot light.
  15797. */
  15798. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  15799. /**
  15800. * Light type const id of the hemispheric light.
  15801. */
  15802. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  15803. /**
  15804. * Diffuse gives the basic color to an object.
  15805. */
  15806. diffuse: Color3;
  15807. /**
  15808. * Specular produces a highlight color on an object.
  15809. * Note: This is note affecting PBR materials.
  15810. */
  15811. specular: Color3;
  15812. /**
  15813. * Defines the falloff type for this light. This lets overrriding how punctual light are
  15814. * falling off base on range or angle.
  15815. * This can be set to any values in Light.FALLOFF_x.
  15816. *
  15817. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  15818. * other types of materials.
  15819. */
  15820. falloffType: number;
  15821. /**
  15822. * Strength of the light.
  15823. * Note: By default it is define in the framework own unit.
  15824. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  15825. */
  15826. intensity: number;
  15827. private _range;
  15828. protected _inverseSquaredRange: number;
  15829. /**
  15830. * Defines how far from the source the light is impacting in scene units.
  15831. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  15832. */
  15833. /**
  15834. * Defines how far from the source the light is impacting in scene units.
  15835. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  15836. */
  15837. range: number;
  15838. /**
  15839. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  15840. * of light.
  15841. */
  15842. private _photometricScale;
  15843. private _intensityMode;
  15844. /**
  15845. * Gets the photometric scale used to interpret the intensity.
  15846. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  15847. */
  15848. /**
  15849. * Sets the photometric scale used to interpret the intensity.
  15850. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  15851. */
  15852. intensityMode: number;
  15853. private _radius;
  15854. /**
  15855. * Gets the light radius used by PBR Materials to simulate soft area lights.
  15856. */
  15857. /**
  15858. * sets the light radius used by PBR Materials to simulate soft area lights.
  15859. */
  15860. radius: number;
  15861. private _renderPriority;
  15862. /**
  15863. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  15864. * exceeding the number allowed of the materials.
  15865. */
  15866. renderPriority: number;
  15867. private _shadowEnabled;
  15868. /**
  15869. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  15870. * the current shadow generator.
  15871. */
  15872. /**
  15873. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  15874. * the current shadow generator.
  15875. */
  15876. shadowEnabled: boolean;
  15877. private _includedOnlyMeshes;
  15878. /**
  15879. * Gets the only meshes impacted by this light.
  15880. */
  15881. /**
  15882. * Sets the only meshes impacted by this light.
  15883. */
  15884. includedOnlyMeshes: AbstractMesh[];
  15885. private _excludedMeshes;
  15886. /**
  15887. * Gets the meshes not impacted by this light.
  15888. */
  15889. /**
  15890. * Sets the meshes not impacted by this light.
  15891. */
  15892. excludedMeshes: AbstractMesh[];
  15893. private _excludeWithLayerMask;
  15894. /**
  15895. * Gets the layer id use to find what meshes are not impacted by the light.
  15896. * Inactive if 0
  15897. */
  15898. /**
  15899. * Sets the layer id use to find what meshes are not impacted by the light.
  15900. * Inactive if 0
  15901. */
  15902. excludeWithLayerMask: number;
  15903. private _includeOnlyWithLayerMask;
  15904. /**
  15905. * Gets the layer id use to find what meshes are impacted by the light.
  15906. * Inactive if 0
  15907. */
  15908. /**
  15909. * Sets the layer id use to find what meshes are impacted by the light.
  15910. * Inactive if 0
  15911. */
  15912. includeOnlyWithLayerMask: number;
  15913. private _lightmapMode;
  15914. /**
  15915. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  15916. */
  15917. /**
  15918. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  15919. */
  15920. lightmapMode: number;
  15921. /**
  15922. * Shadow generator associted to the light.
  15923. * @hidden Internal use only.
  15924. */
  15925. _shadowGenerator: Nullable<IShadowGenerator>;
  15926. /**
  15927. * @hidden Internal use only.
  15928. */
  15929. _excludedMeshesIds: string[];
  15930. /**
  15931. * @hidden Internal use only.
  15932. */
  15933. _includedOnlyMeshesIds: string[];
  15934. /**
  15935. * The current light unifom buffer.
  15936. * @hidden Internal use only.
  15937. */
  15938. _uniformBuffer: UniformBuffer;
  15939. /**
  15940. * Creates a Light object in the scene.
  15941. * Documentation : https://doc.babylonjs.com/babylon101/lights
  15942. * @param name The firendly name of the light
  15943. * @param scene The scene the light belongs too
  15944. */
  15945. constructor(name: string, scene: Scene);
  15946. protected abstract _buildUniformLayout(): void;
  15947. /**
  15948. * Sets the passed Effect "effect" with the Light information.
  15949. * @param effect The effect to update
  15950. * @param lightIndex The index of the light in the effect to update
  15951. * @returns The light
  15952. */
  15953. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  15954. /**
  15955. * Returns the string "Light".
  15956. * @returns the class name
  15957. */
  15958. getClassName(): string;
  15959. /**
  15960. * Converts the light information to a readable string for debug purpose.
  15961. * @param fullDetails Supports for multiple levels of logging within scene loading
  15962. * @returns the human readable light info
  15963. */
  15964. toString(fullDetails?: boolean): string;
  15965. /** @hidden */
  15966. protected _syncParentEnabledState(): void;
  15967. /**
  15968. * Set the enabled state of this node.
  15969. * @param value - the new enabled state
  15970. */
  15971. setEnabled(value: boolean): void;
  15972. /**
  15973. * Returns the Light associated shadow generator if any.
  15974. * @return the associated shadow generator.
  15975. */
  15976. getShadowGenerator(): Nullable<IShadowGenerator>;
  15977. /**
  15978. * Returns a Vector3, the absolute light position in the World.
  15979. * @returns the world space position of the light
  15980. */
  15981. getAbsolutePosition(): Vector3;
  15982. /**
  15983. * Specifies if the light will affect the passed mesh.
  15984. * @param mesh The mesh to test against the light
  15985. * @return true the mesh is affected otherwise, false.
  15986. */
  15987. canAffectMesh(mesh: AbstractMesh): boolean;
  15988. /**
  15989. * Sort function to order lights for rendering.
  15990. * @param a First Light object to compare to second.
  15991. * @param b Second Light object to compare first.
  15992. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  15993. */
  15994. static CompareLightsPriority(a: Light, b: Light): number;
  15995. /**
  15996. * Releases resources associated with this node.
  15997. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15998. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15999. */
  16000. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16001. /**
  16002. * Returns the light type ID (integer).
  16003. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  16004. */
  16005. getTypeID(): number;
  16006. /**
  16007. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  16008. * @returns the scaled intensity in intensity mode unit
  16009. */
  16010. getScaledIntensity(): number;
  16011. /**
  16012. * Returns a new Light object, named "name", from the current one.
  16013. * @param name The name of the cloned light
  16014. * @returns the new created light
  16015. */
  16016. clone(name: string): Nullable<Light>;
  16017. /**
  16018. * Serializes the current light into a Serialization object.
  16019. * @returns the serialized object.
  16020. */
  16021. serialize(): any;
  16022. /**
  16023. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  16024. * This new light is named "name" and added to the passed scene.
  16025. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  16026. * @param name The friendly name of the light
  16027. * @param scene The scene the new light will belong to
  16028. * @returns the constructor function
  16029. */
  16030. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  16031. /**
  16032. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  16033. * @param parsedLight The JSON representation of the light
  16034. * @param scene The scene to create the parsed light in
  16035. * @returns the created light after parsing
  16036. */
  16037. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  16038. private _hookArrayForExcluded;
  16039. private _hookArrayForIncludedOnly;
  16040. private _resyncMeshes;
  16041. /**
  16042. * Forces the meshes to update their light related information in their rendering used effects
  16043. * @hidden Internal Use Only
  16044. */
  16045. _markMeshesAsLightDirty(): void;
  16046. /**
  16047. * Recomputes the cached photometric scale if needed.
  16048. */
  16049. private _computePhotometricScale;
  16050. /**
  16051. * Returns the Photometric Scale according to the light type and intensity mode.
  16052. */
  16053. private _getPhotometricScale;
  16054. /**
  16055. * Reorder the light in the scene according to their defined priority.
  16056. * @hidden Internal Use Only
  16057. */
  16058. _reorderLightsInScene(): void;
  16059. /**
  16060. * Prepares the list of defines specific to the light type.
  16061. * @param defines the list of defines
  16062. * @param lightIndex defines the index of the light for the effect
  16063. */
  16064. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  16065. }
  16066. }
  16067. declare module BABYLON {
  16068. /**
  16069. * A point light is a light defined by an unique point in world space.
  16070. * The light is emitted in every direction from this point.
  16071. * A good example of a point light is a standard light bulb.
  16072. * Documentation: https://doc.babylonjs.com/babylon101/lights
  16073. */
  16074. class PointLight extends ShadowLight {
  16075. private _shadowAngle;
  16076. /**
  16077. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  16078. * This specifies what angle the shadow will use to be created.
  16079. *
  16080. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  16081. */
  16082. /**
  16083. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  16084. * This specifies what angle the shadow will use to be created.
  16085. *
  16086. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  16087. */
  16088. shadowAngle: number;
  16089. /**
  16090. * Gets the direction if it has been set.
  16091. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  16092. */
  16093. /**
  16094. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  16095. */
  16096. direction: Vector3;
  16097. /**
  16098. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  16099. * A PointLight emits the light in every direction.
  16100. * It can cast shadows.
  16101. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  16102. * ```javascript
  16103. * var pointLight = new BABYLON.PointLight("pl", camera.position, scene);
  16104. * ```
  16105. * Documentation : https://doc.babylonjs.com/babylon101/lights
  16106. * @param name The light friendly name
  16107. * @param position The position of the point light in the scene
  16108. * @param scene The scene the lights belongs to
  16109. */
  16110. constructor(name: string, position: Vector3, scene: Scene);
  16111. /**
  16112. * Returns the string "PointLight"
  16113. * @returns the class name
  16114. */
  16115. getClassName(): string;
  16116. /**
  16117. * Returns the integer 0.
  16118. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  16119. */
  16120. getTypeID(): number;
  16121. /**
  16122. * Specifies wether or not the shadowmap should be a cube texture.
  16123. * @returns true if the shadowmap needs to be a cube texture.
  16124. */
  16125. needCube(): boolean;
  16126. /**
  16127. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  16128. * @param faceIndex The index of the face we are computed the direction to generate shadow
  16129. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  16130. */
  16131. getShadowDirection(faceIndex?: number): Vector3;
  16132. /**
  16133. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  16134. * - fov = PI / 2
  16135. * - aspect ratio : 1.0
  16136. * - z-near and far equal to the active camera minZ and maxZ.
  16137. * Returns the PointLight.
  16138. */
  16139. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  16140. protected _buildUniformLayout(): void;
  16141. /**
  16142. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  16143. * @param effect The effect to update
  16144. * @param lightIndex The index of the light in the effect to update
  16145. * @returns The point light
  16146. */
  16147. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  16148. /**
  16149. * Prepares the list of defines specific to the light type.
  16150. * @param defines the list of defines
  16151. * @param lightIndex defines the index of the light for the effect
  16152. */
  16153. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  16154. }
  16155. }
  16156. declare module BABYLON {
  16157. /**
  16158. * Interface describing all the common properties and methods a shadow light needs to implement.
  16159. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  16160. * as well as binding the different shadow properties to the effects.
  16161. */
  16162. interface IShadowLight extends Light {
  16163. /**
  16164. * The light id in the scene (used in scene.findLighById for instance)
  16165. */
  16166. id: string;
  16167. /**
  16168. * The position the shdow will be casted from.
  16169. */
  16170. position: Vector3;
  16171. /**
  16172. * In 2d mode (needCube being false), the direction used to cast the shadow.
  16173. */
  16174. direction: Vector3;
  16175. /**
  16176. * The transformed position. Position of the light in world space taking parenting in account.
  16177. */
  16178. transformedPosition: Vector3;
  16179. /**
  16180. * The transformed direction. Direction of the light in world space taking parenting in account.
  16181. */
  16182. transformedDirection: Vector3;
  16183. /**
  16184. * The friendly name of the light in the scene.
  16185. */
  16186. name: string;
  16187. /**
  16188. * Defines the shadow projection clipping minimum z value.
  16189. */
  16190. shadowMinZ: number;
  16191. /**
  16192. * Defines the shadow projection clipping maximum z value.
  16193. */
  16194. shadowMaxZ: number;
  16195. /**
  16196. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  16197. * @returns true if the information has been computed, false if it does not need to (no parenting)
  16198. */
  16199. computeTransformedInformation(): boolean;
  16200. /**
  16201. * Gets the scene the light belongs to.
  16202. * @returns The scene
  16203. */
  16204. getScene(): Scene;
  16205. /**
  16206. * Callback defining a custom Projection Matrix Builder.
  16207. * This can be used to override the default projection matrix computation.
  16208. */
  16209. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  16210. /**
  16211. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  16212. * @param matrix The materix to updated with the projection information
  16213. * @param viewMatrix The transform matrix of the light
  16214. * @param renderList The list of mesh to render in the map
  16215. * @returns The current light
  16216. */
  16217. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  16218. /**
  16219. * Gets the current depth scale used in ESM.
  16220. * @returns The scale
  16221. */
  16222. getDepthScale(): number;
  16223. /**
  16224. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  16225. * @returns true if a cube texture needs to be use
  16226. */
  16227. needCube(): boolean;
  16228. /**
  16229. * Detects if the projection matrix requires to be recomputed this frame.
  16230. * @returns true if it requires to be recomputed otherwise, false.
  16231. */
  16232. needProjectionMatrixCompute(): boolean;
  16233. /**
  16234. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  16235. */
  16236. forceProjectionMatrixCompute(): void;
  16237. /**
  16238. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  16239. * @param faceIndex The index of the face we are computed the direction to generate shadow
  16240. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  16241. */
  16242. getShadowDirection(faceIndex?: number): Vector3;
  16243. /**
  16244. * Gets the minZ used for shadow according to both the scene and the light.
  16245. * @param activeCamera The camera we are returning the min for
  16246. * @returns the depth min z
  16247. */
  16248. getDepthMinZ(activeCamera: Camera): number;
  16249. /**
  16250. * Gets the maxZ used for shadow according to both the scene and the light.
  16251. * @param activeCamera The camera we are returning the max for
  16252. * @returns the depth max z
  16253. */
  16254. getDepthMaxZ(activeCamera: Camera): number;
  16255. }
  16256. /**
  16257. * Base implementation IShadowLight
  16258. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  16259. */
  16260. abstract class ShadowLight extends Light implements IShadowLight {
  16261. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  16262. protected _position: Vector3;
  16263. protected _setPosition(value: Vector3): void;
  16264. /**
  16265. * Sets the position the shadow will be casted from. Also use as the light position for both
  16266. * point and spot lights.
  16267. */
  16268. /**
  16269. * Sets the position the shadow will be casted from. Also use as the light position for both
  16270. * point and spot lights.
  16271. */
  16272. position: Vector3;
  16273. protected _direction: Vector3;
  16274. protected _setDirection(value: Vector3): void;
  16275. /**
  16276. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  16277. * Also use as the light direction on spot and directional lights.
  16278. */
  16279. /**
  16280. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  16281. * Also use as the light direction on spot and directional lights.
  16282. */
  16283. direction: Vector3;
  16284. private _shadowMinZ;
  16285. /**
  16286. * Gets the shadow projection clipping minimum z value.
  16287. */
  16288. /**
  16289. * Sets the shadow projection clipping minimum z value.
  16290. */
  16291. shadowMinZ: number;
  16292. private _shadowMaxZ;
  16293. /**
  16294. * Sets the shadow projection clipping maximum z value.
  16295. */
  16296. /**
  16297. * Gets the shadow projection clipping maximum z value.
  16298. */
  16299. shadowMaxZ: number;
  16300. /**
  16301. * Callback defining a custom Projection Matrix Builder.
  16302. * This can be used to override the default projection matrix computation.
  16303. */
  16304. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  16305. /**
  16306. * The transformed position. Position of the light in world space taking parenting in account.
  16307. */
  16308. transformedPosition: Vector3;
  16309. /**
  16310. * The transformed direction. Direction of the light in world space taking parenting in account.
  16311. */
  16312. transformedDirection: Vector3;
  16313. private _needProjectionMatrixCompute;
  16314. /**
  16315. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  16316. * @returns true if the information has been computed, false if it does not need to (no parenting)
  16317. */
  16318. computeTransformedInformation(): boolean;
  16319. /**
  16320. * Return the depth scale used for the shadow map.
  16321. * @returns the depth scale.
  16322. */
  16323. getDepthScale(): number;
  16324. /**
  16325. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  16326. * @param faceIndex The index of the face we are computed the direction to generate shadow
  16327. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  16328. */
  16329. getShadowDirection(faceIndex?: number): Vector3;
  16330. /**
  16331. * Returns the ShadowLight absolute position in the World.
  16332. * @returns the position vector in world space
  16333. */
  16334. getAbsolutePosition(): Vector3;
  16335. /**
  16336. * Sets the ShadowLight direction toward the passed target.
  16337. * @param target The point tot target in local space
  16338. * @returns the updated ShadowLight direction
  16339. */
  16340. setDirectionToTarget(target: Vector3): Vector3;
  16341. /**
  16342. * Returns the light rotation in euler definition.
  16343. * @returns the x y z rotation in local space.
  16344. */
  16345. getRotation(): Vector3;
  16346. /**
  16347. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  16348. * @returns true if a cube texture needs to be use
  16349. */
  16350. needCube(): boolean;
  16351. /**
  16352. * Detects if the projection matrix requires to be recomputed this frame.
  16353. * @returns true if it requires to be recomputed otherwise, false.
  16354. */
  16355. needProjectionMatrixCompute(): boolean;
  16356. /**
  16357. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  16358. */
  16359. forceProjectionMatrixCompute(): void;
  16360. /** @hidden */
  16361. _initCache(): void;
  16362. /** @hidden */
  16363. _isSynchronized(): boolean;
  16364. /**
  16365. * Computes the world matrix of the node
  16366. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  16367. * @returns the world matrix
  16368. */
  16369. computeWorldMatrix(force?: boolean): Matrix;
  16370. /**
  16371. * Gets the minZ used for shadow according to both the scene and the light.
  16372. * @param activeCamera The camera we are returning the min for
  16373. * @returns the depth min z
  16374. */
  16375. getDepthMinZ(activeCamera: Camera): number;
  16376. /**
  16377. * Gets the maxZ used for shadow according to both the scene and the light.
  16378. * @param activeCamera The camera we are returning the max for
  16379. * @returns the depth max z
  16380. */
  16381. getDepthMaxZ(activeCamera: Camera): number;
  16382. /**
  16383. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  16384. * @param matrix The materix to updated with the projection information
  16385. * @param viewMatrix The transform matrix of the light
  16386. * @param renderList The list of mesh to render in the map
  16387. * @returns The current light
  16388. */
  16389. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  16390. }
  16391. }
  16392. declare module BABYLON {
  16393. /**
  16394. * A spot light is defined by a position, a direction, an angle, and an exponent.
  16395. * These values define a cone of light starting from the position, emitting toward the direction.
  16396. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  16397. * and the exponent defines the speed of the decay of the light with distance (reach).
  16398. * Documentation: https://doc.babylonjs.com/babylon101/lights
  16399. */
  16400. class SpotLight extends ShadowLight {
  16401. private _angle;
  16402. private _innerAngle;
  16403. private _cosHalfAngle;
  16404. private _lightAngleScale;
  16405. private _lightAngleOffset;
  16406. /**
  16407. * Gets the cone angle of the spot light in Radians.
  16408. */
  16409. /**
  16410. * Sets the cone angle of the spot light in Radians.
  16411. */
  16412. angle: number;
  16413. /**
  16414. * Only used in gltf falloff mode, this defines the angle where
  16415. * the directional falloff will start before cutting at angle which could be seen
  16416. * as outer angle.
  16417. */
  16418. /**
  16419. * Only used in gltf falloff mode, this defines the angle where
  16420. * the directional falloff will start before cutting at angle which could be seen
  16421. * as outer angle.
  16422. */
  16423. innerAngle: number;
  16424. private _shadowAngleScale;
  16425. /**
  16426. * Allows scaling the angle of the light for shadow generation only.
  16427. */
  16428. /**
  16429. * Allows scaling the angle of the light for shadow generation only.
  16430. */
  16431. shadowAngleScale: number;
  16432. /**
  16433. * The light decay speed with the distance from the emission spot.
  16434. */
  16435. exponent: number;
  16436. private _projectionTextureMatrix;
  16437. /**
  16438. * Allows reading the projecton texture
  16439. */
  16440. readonly projectionTextureMatrix: Matrix;
  16441. protected _projectionTextureLightNear: number;
  16442. /**
  16443. * Gets the near clip of the Spotlight for texture projection.
  16444. */
  16445. /**
  16446. * Sets the near clip of the Spotlight for texture projection.
  16447. */
  16448. projectionTextureLightNear: number;
  16449. protected _projectionTextureLightFar: number;
  16450. /**
  16451. * Gets the far clip of the Spotlight for texture projection.
  16452. */
  16453. /**
  16454. * Sets the far clip of the Spotlight for texture projection.
  16455. */
  16456. projectionTextureLightFar: number;
  16457. protected _projectionTextureUpDirection: Vector3;
  16458. /**
  16459. * Gets the Up vector of the Spotlight for texture projection.
  16460. */
  16461. /**
  16462. * Sets the Up vector of the Spotlight for texture projection.
  16463. */
  16464. projectionTextureUpDirection: Vector3;
  16465. private _projectionTexture;
  16466. /**
  16467. * Gets the projection texture of the light.
  16468. */
  16469. /**
  16470. * Sets the projection texture of the light.
  16471. */
  16472. projectionTexture: Nullable<BaseTexture>;
  16473. private _projectionTextureViewLightDirty;
  16474. private _projectionTextureProjectionLightDirty;
  16475. private _projectionTextureDirty;
  16476. private _projectionTextureViewTargetVector;
  16477. private _projectionTextureViewLightMatrix;
  16478. private _projectionTextureProjectionLightMatrix;
  16479. private _projectionTextureScalingMatrix;
  16480. /**
  16481. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  16482. * It can cast shadows.
  16483. * Documentation : https://doc.babylonjs.com/babylon101/lights
  16484. * @param name The light friendly name
  16485. * @param position The position of the spot light in the scene
  16486. * @param direction The direction of the light in the scene
  16487. * @param angle The cone angle of the light in Radians
  16488. * @param exponent The light decay speed with the distance from the emission spot
  16489. * @param scene The scene the lights belongs to
  16490. */
  16491. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  16492. /**
  16493. * Returns the string "SpotLight".
  16494. * @returns the class name
  16495. */
  16496. getClassName(): string;
  16497. /**
  16498. * Returns the integer 2.
  16499. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  16500. */
  16501. getTypeID(): number;
  16502. /**
  16503. * Overrides the direction setter to recompute the projection texture view light Matrix.
  16504. */
  16505. protected _setDirection(value: Vector3): void;
  16506. /**
  16507. * Overrides the position setter to recompute the projection texture view light Matrix.
  16508. */
  16509. protected _setPosition(value: Vector3): void;
  16510. /**
  16511. * 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.
  16512. * Returns the SpotLight.
  16513. */
  16514. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  16515. protected _computeProjectionTextureViewLightMatrix(): void;
  16516. protected _computeProjectionTextureProjectionLightMatrix(): void;
  16517. /**
  16518. * Main function for light texture projection matrix computing.
  16519. */
  16520. protected _computeProjectionTextureMatrix(): void;
  16521. protected _buildUniformLayout(): void;
  16522. private _computeAngleValues;
  16523. /**
  16524. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  16525. * @param effect The effect to update
  16526. * @param lightIndex The index of the light in the effect to update
  16527. * @returns The spot light
  16528. */
  16529. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  16530. /**
  16531. * Disposes the light and the associated resources.
  16532. */
  16533. dispose(): void;
  16534. /**
  16535. * Prepares the list of defines specific to the light type.
  16536. * @param defines the list of defines
  16537. * @param lightIndex defines the index of the light for the effect
  16538. */
  16539. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  16540. }
  16541. }
  16542. declare module BABYLON {
  16543. /**
  16544. * Interface used to present a loading screen while loading a scene
  16545. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  16546. */
  16547. interface ILoadingScreen {
  16548. /**
  16549. * Function called to display the loading screen
  16550. */
  16551. displayLoadingUI: () => void;
  16552. /**
  16553. * Function called to hide the loading screen
  16554. */
  16555. hideLoadingUI: () => void;
  16556. /**
  16557. * Gets or sets the color to use for the background
  16558. */
  16559. loadingUIBackgroundColor: string;
  16560. /**
  16561. * Gets or sets the text to display while loading
  16562. */
  16563. loadingUIText: string;
  16564. }
  16565. /**
  16566. * Class used for the default loading screen
  16567. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  16568. */
  16569. class DefaultLoadingScreen implements ILoadingScreen {
  16570. private _renderingCanvas;
  16571. private _loadingText;
  16572. private _loadingDivBackgroundColor;
  16573. private _loadingDiv;
  16574. private _loadingTextDiv;
  16575. /**
  16576. * Creates a new default loading screen
  16577. * @param _renderingCanvas defines the canvas used to render the scene
  16578. * @param _loadingText defines the default text to display
  16579. * @param _loadingDivBackgroundColor defines the default background color
  16580. */
  16581. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  16582. /**
  16583. * Function called to display the loading screen
  16584. */
  16585. displayLoadingUI(): void;
  16586. /**
  16587. * Function called to hide the loading screen
  16588. */
  16589. hideLoadingUI(): void;
  16590. /**
  16591. * Gets or sets the text to display while loading
  16592. */
  16593. loadingUIText: string;
  16594. /**
  16595. * Gets or sets the color to use for the background
  16596. */
  16597. loadingUIBackgroundColor: string;
  16598. private _resizeLoadingUI;
  16599. }
  16600. }
  16601. declare module BABYLON {
  16602. /**
  16603. * Class used to represent data loading progression
  16604. */
  16605. class SceneLoaderProgressEvent {
  16606. /** defines if data length to load can be evaluated */
  16607. readonly lengthComputable: boolean;
  16608. /** defines the loaded data length */
  16609. readonly loaded: number;
  16610. /** defines the data length to load */
  16611. readonly total: number;
  16612. /**
  16613. * Create a new progress event
  16614. * @param lengthComputable defines if data length to load can be evaluated
  16615. * @param loaded defines the loaded data length
  16616. * @param total defines the data length to load
  16617. */
  16618. constructor(
  16619. /** defines if data length to load can be evaluated */
  16620. lengthComputable: boolean,
  16621. /** defines the loaded data length */
  16622. loaded: number,
  16623. /** defines the data length to load */
  16624. total: number);
  16625. /**
  16626. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  16627. * @param event defines the source event
  16628. * @returns a new SceneLoaderProgressEvent
  16629. */
  16630. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  16631. }
  16632. /**
  16633. * Interface used by SceneLoader plugins to define supported file extensions
  16634. */
  16635. interface ISceneLoaderPluginExtensions {
  16636. /**
  16637. * Defines the list of supported extensions
  16638. */
  16639. [extension: string]: {
  16640. isBinary: boolean;
  16641. };
  16642. }
  16643. /**
  16644. * Interface used by SceneLoader plugin factory
  16645. */
  16646. interface ISceneLoaderPluginFactory {
  16647. /**
  16648. * Defines the name of the factory
  16649. */
  16650. name: string;
  16651. /**
  16652. * Function called to create a new plugin
  16653. * @return the new plugin
  16654. */
  16655. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  16656. /**
  16657. * Boolean indicating if the plugin can direct load specific data
  16658. */
  16659. canDirectLoad?: (data: string) => boolean;
  16660. }
  16661. /**
  16662. * Interface used to define a SceneLoader plugin
  16663. */
  16664. interface ISceneLoaderPlugin {
  16665. /**
  16666. * The friendly name of this plugin.
  16667. */
  16668. name: string;
  16669. /**
  16670. * The file extensions supported by this plugin.
  16671. */
  16672. extensions: string | ISceneLoaderPluginExtensions;
  16673. /**
  16674. * Import meshes into a scene.
  16675. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  16676. * @param scene The scene to import into
  16677. * @param data The data to import
  16678. * @param rootUrl The root url for scene and resources
  16679. * @param meshes The meshes array to import into
  16680. * @param particleSystems The particle systems array to import into
  16681. * @param skeletons The skeletons array to import into
  16682. * @param onError The callback when import fails
  16683. * @returns True if successful or false otherwise
  16684. */
  16685. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  16686. /**
  16687. * Load into a scene.
  16688. * @param scene The scene to load into
  16689. * @param data The data to import
  16690. * @param rootUrl The root url for scene and resources
  16691. * @param onError The callback when import fails
  16692. * @returns true if successful or false otherwise
  16693. */
  16694. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  16695. /**
  16696. * The callback that returns true if the data can be directly loaded.
  16697. */
  16698. canDirectLoad?: (data: string) => boolean;
  16699. /**
  16700. * The callback that allows custom handling of the root url based on the response url.
  16701. */
  16702. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  16703. /**
  16704. * Load into an asset container.
  16705. * @param scene The scene to load into
  16706. * @param data The data to import
  16707. * @param rootUrl The root url for scene and resources
  16708. * @param onError The callback when import fails
  16709. * @returns The loaded asset container
  16710. */
  16711. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  16712. }
  16713. /**
  16714. * Interface used to define an async SceneLoader plugin
  16715. */
  16716. interface ISceneLoaderPluginAsync {
  16717. /**
  16718. * The friendly name of this plugin.
  16719. */
  16720. name: string;
  16721. /**
  16722. * The file extensions supported by this plugin.
  16723. */
  16724. extensions: string | ISceneLoaderPluginExtensions;
  16725. /**
  16726. * Import meshes into a scene.
  16727. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  16728. * @param scene The scene to import into
  16729. * @param data The data to import
  16730. * @param rootUrl The root url for scene and resources
  16731. * @param onProgress The callback when the load progresses
  16732. * @param fileName Defines the name of the file to load
  16733. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  16734. */
  16735. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  16736. meshes: AbstractMesh[];
  16737. particleSystems: IParticleSystem[];
  16738. skeletons: Skeleton[];
  16739. animationGroups: AnimationGroup[];
  16740. }>;
  16741. /**
  16742. * Load into a scene.
  16743. * @param scene The scene to load into
  16744. * @param data The data to import
  16745. * @param rootUrl The root url for scene and resources
  16746. * @param onProgress The callback when the load progresses
  16747. * @param fileName Defines the name of the file to load
  16748. * @returns Nothing
  16749. */
  16750. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  16751. /**
  16752. * The callback that returns true if the data can be directly loaded.
  16753. */
  16754. canDirectLoad?: (data: string) => boolean;
  16755. /**
  16756. * The callback that allows custom handling of the root url based on the response url.
  16757. */
  16758. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  16759. /**
  16760. * Load into an asset container.
  16761. * @param scene The scene to load into
  16762. * @param data The data to import
  16763. * @param rootUrl The root url for scene and resources
  16764. * @param onProgress The callback when the load progresses
  16765. * @param fileName Defines the name of the file to load
  16766. * @returns The loaded asset container
  16767. */
  16768. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  16769. }
  16770. /**
  16771. * Class used to load scene from various file formats using registered plugins
  16772. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  16773. */
  16774. class SceneLoader {
  16775. private static _ForceFullSceneLoadingForIncremental;
  16776. private static _ShowLoadingScreen;
  16777. private static _CleanBoneMatrixWeights;
  16778. /**
  16779. * No logging while loading
  16780. */
  16781. static readonly NO_LOGGING: number;
  16782. /**
  16783. * Minimal logging while loading
  16784. */
  16785. static readonly MINIMAL_LOGGING: number;
  16786. /**
  16787. * Summary logging while loading
  16788. */
  16789. static readonly SUMMARY_LOGGING: number;
  16790. /**
  16791. * Detailled logging while loading
  16792. */
  16793. static readonly DETAILED_LOGGING: number;
  16794. private static _loggingLevel;
  16795. /**
  16796. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  16797. */
  16798. static ForceFullSceneLoadingForIncremental: boolean;
  16799. /**
  16800. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  16801. */
  16802. static ShowLoadingScreen: boolean;
  16803. /**
  16804. * Defines the current logging level (while loading the scene)
  16805. * @ignorenaming
  16806. */
  16807. static loggingLevel: number;
  16808. /**
  16809. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  16810. */
  16811. static CleanBoneMatrixWeights: boolean;
  16812. /**
  16813. * Event raised when a plugin is used to load a scene
  16814. */
  16815. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  16816. private static _registeredPlugins;
  16817. private static _getDefaultPlugin;
  16818. private static _getPluginForExtension;
  16819. private static _getPluginForDirectLoad;
  16820. private static _getPluginForFilename;
  16821. private static _getDirectLoad;
  16822. private static _loadData;
  16823. private static _getFileInfo;
  16824. /**
  16825. * Gets a plugin that can load the given extension
  16826. * @param extension defines the extension to load
  16827. * @returns a plugin or null if none works
  16828. */
  16829. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  16830. /**
  16831. * Gets a boolean indicating that the given extension can be loaded
  16832. * @param extension defines the extension to load
  16833. * @returns true if the extension is supported
  16834. */
  16835. static IsPluginForExtensionAvailable(extension: string): boolean;
  16836. /**
  16837. * Adds a new plugin to the list of registered plugins
  16838. * @param plugin defines the plugin to add
  16839. */
  16840. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  16841. /**
  16842. * Import meshes into a scene
  16843. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  16844. * @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)
  16845. * @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)
  16846. * @param scene the instance of BABYLON.Scene to append to
  16847. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  16848. * @param onProgress a callback with a progress event for each file being loaded
  16849. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  16850. * @param pluginExtension the extension used to determine the plugin
  16851. * @returns The loaded plugin
  16852. */
  16853. 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>;
  16854. /**
  16855. * Import meshes into a scene
  16856. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  16857. * @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)
  16858. * @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)
  16859. * @param scene the instance of BABYLON.Scene to append to
  16860. * @param onProgress a callback with a progress event for each file being loaded
  16861. * @param pluginExtension the extension used to determine the plugin
  16862. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  16863. */
  16864. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  16865. meshes: AbstractMesh[];
  16866. particleSystems: IParticleSystem[];
  16867. skeletons: Skeleton[];
  16868. animationGroups: AnimationGroup[];
  16869. }>;
  16870. /**
  16871. * Load a scene
  16872. * @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)
  16873. * @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)
  16874. * @param engine is the instance of BABYLON.Engine to use to create the scene
  16875. * @param onSuccess a callback with the scene when import succeeds
  16876. * @param onProgress a callback with a progress event for each file being loaded
  16877. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  16878. * @param pluginExtension the extension used to determine the plugin
  16879. * @returns The loaded plugin
  16880. */
  16881. 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>;
  16882. /**
  16883. * Load a scene
  16884. * @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)
  16885. * @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)
  16886. * @param engine is the instance of BABYLON.Engine to use to create the scene
  16887. * @param onProgress a callback with a progress event for each file being loaded
  16888. * @param pluginExtension the extension used to determine the plugin
  16889. * @returns The loaded scene
  16890. */
  16891. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  16892. /**
  16893. * Append a scene
  16894. * @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)
  16895. * @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)
  16896. * @param scene is the instance of BABYLON.Scene to append to
  16897. * @param onSuccess a callback with the scene when import succeeds
  16898. * @param onProgress a callback with a progress event for each file being loaded
  16899. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  16900. * @param pluginExtension the extension used to determine the plugin
  16901. * @returns The loaded plugin
  16902. */
  16903. 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>;
  16904. /**
  16905. * Append a scene
  16906. * @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)
  16907. * @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)
  16908. * @param scene is the instance of BABYLON.Scene to append to
  16909. * @param onProgress a callback with a progress event for each file being loaded
  16910. * @param pluginExtension the extension used to determine the plugin
  16911. * @returns The given scene
  16912. */
  16913. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  16914. /**
  16915. * Load a scene into an asset container
  16916. * @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)
  16917. * @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)
  16918. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  16919. * @param onSuccess a callback with the scene when import succeeds
  16920. * @param onProgress a callback with a progress event for each file being loaded
  16921. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  16922. * @param pluginExtension the extension used to determine the plugin
  16923. * @returns The loaded plugin
  16924. */
  16925. 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>;
  16926. /**
  16927. * Load a scene into an asset container
  16928. * @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)
  16929. * @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)
  16930. * @param scene is the instance of BABYLON.Scene to append to
  16931. * @param onProgress a callback with a progress event for each file being loaded
  16932. * @param pluginExtension the extension used to determine the plugin
  16933. * @returns The loaded asset container
  16934. */
  16935. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  16936. }
  16937. }
  16938. declare module BABYLON {
  16939. /**
  16940. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  16941. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  16942. * 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;
  16943. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  16944. */
  16945. class ColorCurves {
  16946. private _dirty;
  16947. private _tempColor;
  16948. private _globalCurve;
  16949. private _highlightsCurve;
  16950. private _midtonesCurve;
  16951. private _shadowsCurve;
  16952. private _positiveCurve;
  16953. private _negativeCurve;
  16954. private _globalHue;
  16955. private _globalDensity;
  16956. private _globalSaturation;
  16957. private _globalExposure;
  16958. /**
  16959. * Gets the global Hue value.
  16960. * 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).
  16961. */
  16962. /**
  16963. * Sets the global Hue value.
  16964. * 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).
  16965. */
  16966. globalHue: number;
  16967. /**
  16968. * Gets the global Density value.
  16969. * 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.
  16970. * Values less than zero provide a filter of opposite hue.
  16971. */
  16972. /**
  16973. * Sets the global Density value.
  16974. * 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.
  16975. * Values less than zero provide a filter of opposite hue.
  16976. */
  16977. globalDensity: number;
  16978. /**
  16979. * Gets the global Saturation value.
  16980. * 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.
  16981. */
  16982. /**
  16983. * Sets the global Saturation value.
  16984. * 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.
  16985. */
  16986. globalSaturation: number;
  16987. /**
  16988. * Gets the global Exposure value.
  16989. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  16990. */
  16991. /**
  16992. * Sets the global Exposure value.
  16993. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  16994. */
  16995. globalExposure: number;
  16996. private _highlightsHue;
  16997. private _highlightsDensity;
  16998. private _highlightsSaturation;
  16999. private _highlightsExposure;
  17000. /**
  17001. * Gets the highlights Hue value.
  17002. * 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).
  17003. */
  17004. /**
  17005. * Sets the highlights Hue value.
  17006. * 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).
  17007. */
  17008. highlightsHue: number;
  17009. /**
  17010. * Gets the highlights Density value.
  17011. * 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.
  17012. * Values less than zero provide a filter of opposite hue.
  17013. */
  17014. /**
  17015. * Sets the highlights Density value.
  17016. * 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.
  17017. * Values less than zero provide a filter of opposite hue.
  17018. */
  17019. highlightsDensity: number;
  17020. /**
  17021. * Gets the highlights Saturation value.
  17022. * 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.
  17023. */
  17024. /**
  17025. * Sets the highlights Saturation value.
  17026. * 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.
  17027. */
  17028. highlightsSaturation: number;
  17029. /**
  17030. * Gets the highlights Exposure value.
  17031. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  17032. */
  17033. /**
  17034. * Sets the highlights Exposure value.
  17035. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  17036. */
  17037. highlightsExposure: number;
  17038. private _midtonesHue;
  17039. private _midtonesDensity;
  17040. private _midtonesSaturation;
  17041. private _midtonesExposure;
  17042. /**
  17043. * Gets the midtones Hue value.
  17044. * 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).
  17045. */
  17046. /**
  17047. * Sets the midtones Hue value.
  17048. * 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).
  17049. */
  17050. midtonesHue: number;
  17051. /**
  17052. * Gets the midtones Density value.
  17053. * 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.
  17054. * Values less than zero provide a filter of opposite hue.
  17055. */
  17056. /**
  17057. * Sets the midtones Density value.
  17058. * 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.
  17059. * Values less than zero provide a filter of opposite hue.
  17060. */
  17061. midtonesDensity: number;
  17062. /**
  17063. * Gets the midtones Saturation value.
  17064. * 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.
  17065. */
  17066. /**
  17067. * Sets the midtones Saturation value.
  17068. * 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.
  17069. */
  17070. midtonesSaturation: number;
  17071. /**
  17072. * Gets the midtones Exposure value.
  17073. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  17074. */
  17075. /**
  17076. * Sets the midtones Exposure value.
  17077. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  17078. */
  17079. midtonesExposure: number;
  17080. private _shadowsHue;
  17081. private _shadowsDensity;
  17082. private _shadowsSaturation;
  17083. private _shadowsExposure;
  17084. /**
  17085. * Gets the shadows Hue value.
  17086. * 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).
  17087. */
  17088. /**
  17089. * Sets the shadows Hue value.
  17090. * 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).
  17091. */
  17092. shadowsHue: number;
  17093. /**
  17094. * Gets the shadows Density value.
  17095. * 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.
  17096. * Values less than zero provide a filter of opposite hue.
  17097. */
  17098. /**
  17099. * Sets the shadows Density value.
  17100. * 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.
  17101. * Values less than zero provide a filter of opposite hue.
  17102. */
  17103. shadowsDensity: number;
  17104. /**
  17105. * Gets the shadows Saturation value.
  17106. * 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.
  17107. */
  17108. /**
  17109. * Sets the shadows Saturation value.
  17110. * 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.
  17111. */
  17112. shadowsSaturation: number;
  17113. /**
  17114. * Gets the shadows Exposure value.
  17115. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  17116. */
  17117. /**
  17118. * Sets the shadows Exposure value.
  17119. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  17120. */
  17121. shadowsExposure: number;
  17122. /**
  17123. * Returns the class name
  17124. * @returns The class name
  17125. */
  17126. getClassName(): string;
  17127. /**
  17128. * Binds the color curves to the shader.
  17129. * @param colorCurves The color curve to bind
  17130. * @param effect The effect to bind to
  17131. * @param positiveUniform The positive uniform shader parameter
  17132. * @param neutralUniform The neutral uniform shader parameter
  17133. * @param negativeUniform The negative uniform shader parameter
  17134. */
  17135. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  17136. /**
  17137. * Prepare the list of uniforms associated with the ColorCurves effects.
  17138. * @param uniformsList The list of uniforms used in the effect
  17139. */
  17140. static PrepareUniforms(uniformsList: string[]): void;
  17141. /**
  17142. * Returns color grading data based on a hue, density, saturation and exposure value.
  17143. * @param filterHue The hue of the color filter.
  17144. * @param filterDensity The density of the color filter.
  17145. * @param saturation The saturation.
  17146. * @param exposure The exposure.
  17147. * @param result The result data container.
  17148. */
  17149. private getColorGradingDataToRef;
  17150. /**
  17151. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  17152. * @param value The input slider value in range [-100,100].
  17153. * @returns Adjusted value.
  17154. */
  17155. private static applyColorGradingSliderNonlinear;
  17156. /**
  17157. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  17158. * @param hue The hue (H) input.
  17159. * @param saturation The saturation (S) input.
  17160. * @param brightness The brightness (B) input.
  17161. * @result An RGBA color represented as Vector4.
  17162. */
  17163. private static fromHSBToRef;
  17164. /**
  17165. * Returns a value clamped between min and max
  17166. * @param value The value to clamp
  17167. * @param min The minimum of value
  17168. * @param max The maximum of value
  17169. * @returns The clamped value.
  17170. */
  17171. private static clamp;
  17172. /**
  17173. * Clones the current color curve instance.
  17174. * @return The cloned curves
  17175. */
  17176. clone(): ColorCurves;
  17177. /**
  17178. * Serializes the current color curve instance to a json representation.
  17179. * @return a JSON representation
  17180. */
  17181. serialize(): any;
  17182. /**
  17183. * Parses the color curve from a json representation.
  17184. * @param source the JSON source to parse
  17185. * @return The parsed curves
  17186. */
  17187. static Parse(source: any): ColorCurves;
  17188. }
  17189. }
  17190. declare module BABYLON {
  17191. /**
  17192. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  17193. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  17194. */
  17195. class EffectFallbacks {
  17196. private _defines;
  17197. private _currentRank;
  17198. private _maxRank;
  17199. private _mesh;
  17200. /**
  17201. * Removes the fallback from the bound mesh.
  17202. */
  17203. unBindMesh(): void;
  17204. /**
  17205. * Adds a fallback on the specified property.
  17206. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  17207. * @param define The name of the define in the shader
  17208. */
  17209. addFallback(rank: number, define: string): void;
  17210. /**
  17211. * Sets the mesh to use CPU skinning when needing to fallback.
  17212. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  17213. * @param mesh The mesh to use the fallbacks.
  17214. */
  17215. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  17216. /**
  17217. * Checks to see if more fallbacks are still availible.
  17218. */
  17219. readonly isMoreFallbacks: boolean;
  17220. /**
  17221. * Removes the defines that shoould be removed when falling back.
  17222. * @param currentDefines defines the current define statements for the shader.
  17223. * @param effect defines the current effect we try to compile
  17224. * @returns The resulting defines with defines of the current rank removed.
  17225. */
  17226. reduce(currentDefines: string, effect: Effect): string;
  17227. }
  17228. /**
  17229. * Options to be used when creating an effect.
  17230. */
  17231. class EffectCreationOptions {
  17232. /**
  17233. * Atrributes that will be used in the shader.
  17234. */
  17235. attributes: string[];
  17236. /**
  17237. * Uniform varible names that will be set in the shader.
  17238. */
  17239. uniformsNames: string[];
  17240. /**
  17241. * Uniform buffer varible names that will be set in the shader.
  17242. */
  17243. uniformBuffersNames: string[];
  17244. /**
  17245. * Sampler texture variable names that will be set in the shader.
  17246. */
  17247. samplers: string[];
  17248. /**
  17249. * Define statements that will be set in the shader.
  17250. */
  17251. defines: any;
  17252. /**
  17253. * Possible fallbacks for this effect to improve performance when needed.
  17254. */
  17255. fallbacks: Nullable<EffectFallbacks>;
  17256. /**
  17257. * Callback that will be called when the shader is compiled.
  17258. */
  17259. onCompiled: Nullable<(effect: Effect) => void>;
  17260. /**
  17261. * Callback that will be called if an error occurs during shader compilation.
  17262. */
  17263. onError: Nullable<(effect: Effect, errors: string) => void>;
  17264. /**
  17265. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  17266. */
  17267. indexParameters: any;
  17268. /**
  17269. * Max number of lights that can be used in the shader.
  17270. */
  17271. maxSimultaneousLights: number;
  17272. /**
  17273. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  17274. */
  17275. transformFeedbackVaryings: Nullable<string[]>;
  17276. }
  17277. /**
  17278. * Effect containing vertex and fragment shader that can be executed on an object.
  17279. */
  17280. class Effect {
  17281. /**
  17282. * Name of the effect.
  17283. */
  17284. name: any;
  17285. /**
  17286. * String container all the define statements that should be set on the shader.
  17287. */
  17288. defines: string;
  17289. /**
  17290. * Callback that will be called when the shader is compiled.
  17291. */
  17292. onCompiled: Nullable<(effect: Effect) => void>;
  17293. /**
  17294. * Callback that will be called if an error occurs during shader compilation.
  17295. */
  17296. onError: Nullable<(effect: Effect, errors: string) => void>;
  17297. /**
  17298. * Callback that will be called when effect is bound.
  17299. */
  17300. onBind: Nullable<(effect: Effect) => void>;
  17301. /**
  17302. * Unique ID of the effect.
  17303. */
  17304. uniqueId: number;
  17305. /**
  17306. * Observable that will be called when the shader is compiled.
  17307. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  17308. */
  17309. onCompileObservable: Observable<Effect>;
  17310. /**
  17311. * Observable that will be called if an error occurs during shader compilation.
  17312. */
  17313. onErrorObservable: Observable<Effect>;
  17314. /** @hidden */
  17315. _onBindObservable: Nullable<Observable<Effect>>;
  17316. /**
  17317. * Observable that will be called when effect is bound.
  17318. */
  17319. readonly onBindObservable: Observable<Effect>;
  17320. /** @hidden */
  17321. _bonesComputationForcedToCPU: boolean;
  17322. private static _uniqueIdSeed;
  17323. private _engine;
  17324. private _uniformBuffersNames;
  17325. private _uniformsNames;
  17326. private _samplers;
  17327. private _isReady;
  17328. private _compilationError;
  17329. private _attributesNames;
  17330. private _attributes;
  17331. private _uniforms;
  17332. /**
  17333. * Key for the effect.
  17334. * @hidden
  17335. */
  17336. _key: string;
  17337. private _indexParameters;
  17338. private _fallbacks;
  17339. private _vertexSourceCode;
  17340. private _fragmentSourceCode;
  17341. private _vertexSourceCodeOverride;
  17342. private _fragmentSourceCodeOverride;
  17343. private _transformFeedbackVaryings;
  17344. /**
  17345. * Compiled shader to webGL program.
  17346. * @hidden
  17347. */
  17348. _program: WebGLProgram;
  17349. private _valueCache;
  17350. private static _baseCache;
  17351. /**
  17352. * Instantiates an effect.
  17353. * An effect can be used to create/manage/execute vertex and fragment shaders.
  17354. * @param baseName Name of the effect.
  17355. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  17356. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  17357. * @param samplers List of sampler variables that will be passed to the shader.
  17358. * @param engine Engine to be used to render the effect
  17359. * @param defines Define statements to be added to the shader.
  17360. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  17361. * @param onCompiled Callback that will be called when the shader is compiled.
  17362. * @param onError Callback that will be called if an error occurs during shader compilation.
  17363. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  17364. */
  17365. 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);
  17366. /**
  17367. * Unique key for this effect
  17368. */
  17369. readonly key: string;
  17370. /**
  17371. * If the effect has been compiled and prepared.
  17372. * @returns if the effect is compiled and prepared.
  17373. */
  17374. isReady(): boolean;
  17375. /**
  17376. * The engine the effect was initialized with.
  17377. * @returns the engine.
  17378. */
  17379. getEngine(): Engine;
  17380. /**
  17381. * The compiled webGL program for the effect
  17382. * @returns the webGL program.
  17383. */
  17384. getProgram(): WebGLProgram;
  17385. /**
  17386. * The set of names of attribute variables for the shader.
  17387. * @returns An array of attribute names.
  17388. */
  17389. getAttributesNames(): string[];
  17390. /**
  17391. * Returns the attribute at the given index.
  17392. * @param index The index of the attribute.
  17393. * @returns The location of the attribute.
  17394. */
  17395. getAttributeLocation(index: number): number;
  17396. /**
  17397. * Returns the attribute based on the name of the variable.
  17398. * @param name of the attribute to look up.
  17399. * @returns the attribute location.
  17400. */
  17401. getAttributeLocationByName(name: string): number;
  17402. /**
  17403. * The number of attributes.
  17404. * @returns the numnber of attributes.
  17405. */
  17406. getAttributesCount(): number;
  17407. /**
  17408. * Gets the index of a uniform variable.
  17409. * @param uniformName of the uniform to look up.
  17410. * @returns the index.
  17411. */
  17412. getUniformIndex(uniformName: string): number;
  17413. /**
  17414. * Returns the attribute based on the name of the variable.
  17415. * @param uniformName of the uniform to look up.
  17416. * @returns the location of the uniform.
  17417. */
  17418. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  17419. /**
  17420. * Returns an array of sampler variable names
  17421. * @returns The array of sampler variable neames.
  17422. */
  17423. getSamplers(): string[];
  17424. /**
  17425. * The error from the last compilation.
  17426. * @returns the error string.
  17427. */
  17428. getCompilationError(): string;
  17429. /**
  17430. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  17431. * @param func The callback to be used.
  17432. */
  17433. executeWhenCompiled(func: (effect: Effect) => void): void;
  17434. private _checkIsReady;
  17435. /** @hidden */
  17436. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  17437. /** @hidden */
  17438. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  17439. /** @hidden */
  17440. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  17441. private _processShaderConversion;
  17442. private _processIncludes;
  17443. private _processPrecision;
  17444. /**
  17445. * Recompiles the webGL program
  17446. * @param vertexSourceCode The source code for the vertex shader.
  17447. * @param fragmentSourceCode The source code for the fragment shader.
  17448. * @param onCompiled Callback called when completed.
  17449. * @param onError Callback called on error.
  17450. * @hidden
  17451. */
  17452. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  17453. /**
  17454. * Gets the uniform locations of the the specified variable names
  17455. * @param names THe names of the variables to lookup.
  17456. * @returns Array of locations in the same order as variable names.
  17457. */
  17458. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  17459. /**
  17460. * Prepares the effect
  17461. * @hidden
  17462. */
  17463. _prepareEffect(): void;
  17464. /**
  17465. * Checks if the effect is supported. (Must be called after compilation)
  17466. */
  17467. readonly isSupported: boolean;
  17468. /**
  17469. * Binds a texture to the engine to be used as output of the shader.
  17470. * @param channel Name of the output variable.
  17471. * @param texture Texture to bind.
  17472. * @hidden
  17473. */
  17474. _bindTexture(channel: string, texture: InternalTexture): void;
  17475. /**
  17476. * Sets a texture on the engine to be used in the shader.
  17477. * @param channel Name of the sampler variable.
  17478. * @param texture Texture to set.
  17479. */
  17480. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  17481. /**
  17482. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  17483. * @param channel Name of the sampler variable.
  17484. * @param texture Texture to set.
  17485. */
  17486. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  17487. /**
  17488. * Sets an array of textures on the engine to be used in the shader.
  17489. * @param channel Name of the variable.
  17490. * @param textures Textures to set.
  17491. */
  17492. setTextureArray(channel: string, textures: BaseTexture[]): void;
  17493. /**
  17494. * 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)
  17495. * @param channel Name of the sampler variable.
  17496. * @param postProcess Post process to get the input texture from.
  17497. */
  17498. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  17499. /**
  17500. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  17501. * 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)
  17502. * @param channel Name of the sampler variable.
  17503. * @param postProcess Post process to get the output texture from.
  17504. */
  17505. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  17506. /** @hidden */
  17507. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  17508. /** @hidden */
  17509. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  17510. /** @hidden */
  17511. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  17512. /** @hidden */
  17513. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  17514. /**
  17515. * Binds a buffer to a uniform.
  17516. * @param buffer Buffer to bind.
  17517. * @param name Name of the uniform variable to bind to.
  17518. */
  17519. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  17520. /**
  17521. * Binds block to a uniform.
  17522. * @param blockName Name of the block to bind.
  17523. * @param index Index to bind.
  17524. */
  17525. bindUniformBlock(blockName: string, index: number): void;
  17526. /**
  17527. * Sets an interger value on a uniform variable.
  17528. * @param uniformName Name of the variable.
  17529. * @param value Value to be set.
  17530. * @returns this effect.
  17531. */
  17532. setInt(uniformName: string, value: number): Effect;
  17533. /**
  17534. * Sets an int array on a uniform variable.
  17535. * @param uniformName Name of the variable.
  17536. * @param array array to be set.
  17537. * @returns this effect.
  17538. */
  17539. setIntArray(uniformName: string, array: Int32Array): Effect;
  17540. /**
  17541. * 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)
  17542. * @param uniformName Name of the variable.
  17543. * @param array array to be set.
  17544. * @returns this effect.
  17545. */
  17546. setIntArray2(uniformName: string, array: Int32Array): Effect;
  17547. /**
  17548. * 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)
  17549. * @param uniformName Name of the variable.
  17550. * @param array array to be set.
  17551. * @returns this effect.
  17552. */
  17553. setIntArray3(uniformName: string, array: Int32Array): Effect;
  17554. /**
  17555. * 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)
  17556. * @param uniformName Name of the variable.
  17557. * @param array array to be set.
  17558. * @returns this effect.
  17559. */
  17560. setIntArray4(uniformName: string, array: Int32Array): Effect;
  17561. /**
  17562. * Sets an float array on a uniform variable.
  17563. * @param uniformName Name of the variable.
  17564. * @param array array to be set.
  17565. * @returns this effect.
  17566. */
  17567. setFloatArray(uniformName: string, array: Float32Array): Effect;
  17568. /**
  17569. * 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)
  17570. * @param uniformName Name of the variable.
  17571. * @param array array to be set.
  17572. * @returns this effect.
  17573. */
  17574. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  17575. /**
  17576. * 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)
  17577. * @param uniformName Name of the variable.
  17578. * @param array array to be set.
  17579. * @returns this effect.
  17580. */
  17581. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  17582. /**
  17583. * 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)
  17584. * @param uniformName Name of the variable.
  17585. * @param array array to be set.
  17586. * @returns this effect.
  17587. */
  17588. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  17589. /**
  17590. * Sets an array on a uniform variable.
  17591. * @param uniformName Name of the variable.
  17592. * @param array array to be set.
  17593. * @returns this effect.
  17594. */
  17595. setArray(uniformName: string, array: number[]): Effect;
  17596. /**
  17597. * 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)
  17598. * @param uniformName Name of the variable.
  17599. * @param array array to be set.
  17600. * @returns this effect.
  17601. */
  17602. setArray2(uniformName: string, array: number[]): Effect;
  17603. /**
  17604. * 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)
  17605. * @param uniformName Name of the variable.
  17606. * @param array array to be set.
  17607. * @returns this effect.
  17608. */
  17609. setArray3(uniformName: string, array: number[]): Effect;
  17610. /**
  17611. * 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)
  17612. * @param uniformName Name of the variable.
  17613. * @param array array to be set.
  17614. * @returns this effect.
  17615. */
  17616. setArray4(uniformName: string, array: number[]): Effect;
  17617. /**
  17618. * Sets matrices on a uniform variable.
  17619. * @param uniformName Name of the variable.
  17620. * @param matrices matrices to be set.
  17621. * @returns this effect.
  17622. */
  17623. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  17624. /**
  17625. * Sets matrix on a uniform variable.
  17626. * @param uniformName Name of the variable.
  17627. * @param matrix matrix to be set.
  17628. * @returns this effect.
  17629. */
  17630. setMatrix(uniformName: string, matrix: Matrix): Effect;
  17631. /**
  17632. * 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)
  17633. * @param uniformName Name of the variable.
  17634. * @param matrix matrix to be set.
  17635. * @returns this effect.
  17636. */
  17637. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  17638. /**
  17639. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  17640. * @param uniformName Name of the variable.
  17641. * @param matrix matrix to be set.
  17642. * @returns this effect.
  17643. */
  17644. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  17645. /**
  17646. * Sets a float on a uniform variable.
  17647. * @param uniformName Name of the variable.
  17648. * @param value value to be set.
  17649. * @returns this effect.
  17650. */
  17651. setFloat(uniformName: string, value: number): Effect;
  17652. /**
  17653. * Sets a boolean on a uniform variable.
  17654. * @param uniformName Name of the variable.
  17655. * @param bool value to be set.
  17656. * @returns this effect.
  17657. */
  17658. setBool(uniformName: string, bool: boolean): Effect;
  17659. /**
  17660. * Sets a Vector2 on a uniform variable.
  17661. * @param uniformName Name of the variable.
  17662. * @param vector2 vector2 to be set.
  17663. * @returns this effect.
  17664. */
  17665. setVector2(uniformName: string, vector2: Vector2): Effect;
  17666. /**
  17667. * Sets a float2 on a uniform variable.
  17668. * @param uniformName Name of the variable.
  17669. * @param x First float in float2.
  17670. * @param y Second float in float2.
  17671. * @returns this effect.
  17672. */
  17673. setFloat2(uniformName: string, x: number, y: number): Effect;
  17674. /**
  17675. * Sets a Vector3 on a uniform variable.
  17676. * @param uniformName Name of the variable.
  17677. * @param vector3 Value to be set.
  17678. * @returns this effect.
  17679. */
  17680. setVector3(uniformName: string, vector3: Vector3): Effect;
  17681. /**
  17682. * Sets a float3 on a uniform variable.
  17683. * @param uniformName Name of the variable.
  17684. * @param x First float in float3.
  17685. * @param y Second float in float3.
  17686. * @param z Third float in float3.
  17687. * @returns this effect.
  17688. */
  17689. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  17690. /**
  17691. * Sets a Vector4 on a uniform variable.
  17692. * @param uniformName Name of the variable.
  17693. * @param vector4 Value to be set.
  17694. * @returns this effect.
  17695. */
  17696. setVector4(uniformName: string, vector4: Vector4): Effect;
  17697. /**
  17698. * Sets a float4 on a uniform variable.
  17699. * @param uniformName Name of the variable.
  17700. * @param x First float in float4.
  17701. * @param y Second float in float4.
  17702. * @param z Third float in float4.
  17703. * @param w Fourth float in float4.
  17704. * @returns this effect.
  17705. */
  17706. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  17707. /**
  17708. * Sets a Color3 on a uniform variable.
  17709. * @param uniformName Name of the variable.
  17710. * @param color3 Value to be set.
  17711. * @returns this effect.
  17712. */
  17713. setColor3(uniformName: string, color3: Color3): Effect;
  17714. /**
  17715. * Sets a Color4 on a uniform variable.
  17716. * @param uniformName Name of the variable.
  17717. * @param color3 Value to be set.
  17718. * @param alpha Alpha value to be set.
  17719. * @returns this effect.
  17720. */
  17721. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  17722. /**
  17723. * Sets a Color4 on a uniform variable
  17724. * @param uniformName defines the name of the variable
  17725. * @param color4 defines the value to be set
  17726. * @returns this effect.
  17727. */
  17728. setDirectColor4(uniformName: string, color4: Color4): Effect;
  17729. /**
  17730. * This function will add a new shader to the shader store
  17731. * @param name the name of the shader
  17732. * @param pixelShader optional pixel shader content
  17733. * @param vertexShader optional vertex shader content
  17734. */
  17735. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  17736. /**
  17737. * Store of each shader (The can be looked up using effect.key)
  17738. */
  17739. static ShadersStore: {
  17740. [key: string]: string;
  17741. };
  17742. /**
  17743. * Store of each included file for a shader (The can be looked up using effect.key)
  17744. */
  17745. static IncludesShadersStore: {
  17746. [key: string]: string;
  17747. };
  17748. /**
  17749. * Resets the cache of effects.
  17750. */
  17751. static ResetCache(): void;
  17752. }
  17753. }
  17754. declare module BABYLON {
  17755. /**
  17756. * This represents all the required information to add a fresnel effect on a material:
  17757. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  17758. */
  17759. class FresnelParameters {
  17760. private _isEnabled;
  17761. /**
  17762. * Define if the fresnel effect is enable or not.
  17763. */
  17764. isEnabled: boolean;
  17765. /**
  17766. * Define the color used on edges (grazing angle)
  17767. */
  17768. leftColor: Color3;
  17769. /**
  17770. * Define the color used on center
  17771. */
  17772. rightColor: Color3;
  17773. /**
  17774. * Define bias applied to computed fresnel term
  17775. */
  17776. bias: number;
  17777. /**
  17778. * Defined the power exponent applied to fresnel term
  17779. */
  17780. power: number;
  17781. /**
  17782. * Clones the current fresnel and its valuues
  17783. * @returns a clone fresnel configuration
  17784. */
  17785. clone(): FresnelParameters;
  17786. /**
  17787. * Serializes the current fresnel parameters to a JSON representation.
  17788. * @return the JSON serialization
  17789. */
  17790. serialize(): any;
  17791. /**
  17792. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  17793. * @param parsedFresnelParameters Define the JSON representation
  17794. * @returns the parsed parameters
  17795. */
  17796. static Parse(parsedFresnelParameters: any): FresnelParameters;
  17797. }
  17798. }
  17799. declare module BABYLON {
  17800. /**
  17801. * Interface to follow in your material defines to integrate easily the
  17802. * Image proccessing functions.
  17803. * @hidden
  17804. */
  17805. interface IImageProcessingConfigurationDefines {
  17806. IMAGEPROCESSING: boolean;
  17807. VIGNETTE: boolean;
  17808. VIGNETTEBLENDMODEMULTIPLY: boolean;
  17809. VIGNETTEBLENDMODEOPAQUE: boolean;
  17810. TONEMAPPING: boolean;
  17811. TONEMAPPING_ACES: boolean;
  17812. CONTRAST: boolean;
  17813. EXPOSURE: boolean;
  17814. COLORCURVES: boolean;
  17815. COLORGRADING: boolean;
  17816. COLORGRADING3D: boolean;
  17817. SAMPLER3DGREENDEPTH: boolean;
  17818. SAMPLER3DBGRMAP: boolean;
  17819. IMAGEPROCESSINGPOSTPROCESS: boolean;
  17820. }
  17821. /**
  17822. * @hidden
  17823. */
  17824. class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  17825. IMAGEPROCESSING: boolean;
  17826. VIGNETTE: boolean;
  17827. VIGNETTEBLENDMODEMULTIPLY: boolean;
  17828. VIGNETTEBLENDMODEOPAQUE: boolean;
  17829. TONEMAPPING: boolean;
  17830. TONEMAPPING_ACES: boolean;
  17831. CONTRAST: boolean;
  17832. COLORCURVES: boolean;
  17833. COLORGRADING: boolean;
  17834. COLORGRADING3D: boolean;
  17835. SAMPLER3DGREENDEPTH: boolean;
  17836. SAMPLER3DBGRMAP: boolean;
  17837. IMAGEPROCESSINGPOSTPROCESS: boolean;
  17838. EXPOSURE: boolean;
  17839. constructor();
  17840. }
  17841. /**
  17842. * This groups together the common properties used for image processing either in direct forward pass
  17843. * or through post processing effect depending on the use of the image processing pipeline in your scene
  17844. * or not.
  17845. */
  17846. class ImageProcessingConfiguration {
  17847. /**
  17848. * Default tone mapping applied in BabylonJS.
  17849. */
  17850. static readonly TONEMAPPING_STANDARD: number;
  17851. /**
  17852. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  17853. * to other engines rendering to increase portability.
  17854. */
  17855. static readonly TONEMAPPING_ACES: number;
  17856. /**
  17857. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  17858. */
  17859. colorCurves: Nullable<ColorCurves>;
  17860. private _colorCurvesEnabled;
  17861. /**
  17862. * Gets wether the color curves effect is enabled.
  17863. */
  17864. /**
  17865. * Sets wether the color curves effect is enabled.
  17866. */
  17867. colorCurvesEnabled: boolean;
  17868. private _colorGradingTexture;
  17869. /**
  17870. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  17871. */
  17872. /**
  17873. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  17874. */
  17875. colorGradingTexture: Nullable<BaseTexture>;
  17876. private _colorGradingEnabled;
  17877. /**
  17878. * Gets wether the color grading effect is enabled.
  17879. */
  17880. /**
  17881. * Sets wether the color grading effect is enabled.
  17882. */
  17883. colorGradingEnabled: boolean;
  17884. private _colorGradingWithGreenDepth;
  17885. /**
  17886. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  17887. */
  17888. /**
  17889. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  17890. */
  17891. colorGradingWithGreenDepth: boolean;
  17892. private _colorGradingBGR;
  17893. /**
  17894. * Gets wether the color grading texture contains BGR values.
  17895. */
  17896. /**
  17897. * Sets wether the color grading texture contains BGR values.
  17898. */
  17899. colorGradingBGR: boolean;
  17900. /** @hidden */
  17901. _exposure: number;
  17902. /**
  17903. * Gets the Exposure used in the effect.
  17904. */
  17905. /**
  17906. * Sets the Exposure used in the effect.
  17907. */
  17908. exposure: number;
  17909. private _toneMappingEnabled;
  17910. /**
  17911. * Gets wether the tone mapping effect is enabled.
  17912. */
  17913. /**
  17914. * Sets wether the tone mapping effect is enabled.
  17915. */
  17916. toneMappingEnabled: boolean;
  17917. private _toneMappingType;
  17918. /**
  17919. * Gets the type of tone mapping effect.
  17920. */
  17921. /**
  17922. * Sets the type of tone mapping effect used in BabylonJS.
  17923. */
  17924. toneMappingType: number;
  17925. protected _contrast: number;
  17926. /**
  17927. * Gets the contrast used in the effect.
  17928. */
  17929. /**
  17930. * Sets the contrast used in the effect.
  17931. */
  17932. contrast: number;
  17933. /**
  17934. * Vignette stretch size.
  17935. */
  17936. vignetteStretch: number;
  17937. /**
  17938. * Vignette centre X Offset.
  17939. */
  17940. vignetteCentreX: number;
  17941. /**
  17942. * Vignette centre Y Offset.
  17943. */
  17944. vignetteCentreY: number;
  17945. /**
  17946. * Vignette weight or intensity of the vignette effect.
  17947. */
  17948. vignetteWeight: number;
  17949. /**
  17950. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  17951. * if vignetteEnabled is set to true.
  17952. */
  17953. vignetteColor: Color4;
  17954. /**
  17955. * Camera field of view used by the Vignette effect.
  17956. */
  17957. vignetteCameraFov: number;
  17958. private _vignetteBlendMode;
  17959. /**
  17960. * Gets the vignette blend mode allowing different kind of effect.
  17961. */
  17962. /**
  17963. * Sets the vignette blend mode allowing different kind of effect.
  17964. */
  17965. vignetteBlendMode: number;
  17966. private _vignetteEnabled;
  17967. /**
  17968. * Gets wether the vignette effect is enabled.
  17969. */
  17970. /**
  17971. * Sets wether the vignette effect is enabled.
  17972. */
  17973. vignetteEnabled: boolean;
  17974. private _applyByPostProcess;
  17975. /**
  17976. * Gets wether the image processing is applied through a post process or not.
  17977. */
  17978. /**
  17979. * Sets wether the image processing is applied through a post process or not.
  17980. */
  17981. applyByPostProcess: boolean;
  17982. private _isEnabled;
  17983. /**
  17984. * Gets wether the image processing is enabled or not.
  17985. */
  17986. /**
  17987. * Sets wether the image processing is enabled or not.
  17988. */
  17989. isEnabled: boolean;
  17990. /**
  17991. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  17992. */
  17993. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  17994. /**
  17995. * Method called each time the image processing information changes requires to recompile the effect.
  17996. */
  17997. protected _updateParameters(): void;
  17998. /**
  17999. * Gets the current class name.
  18000. * @return "ImageProcessingConfiguration"
  18001. */
  18002. getClassName(): string;
  18003. /**
  18004. * Prepare the list of uniforms associated with the Image Processing effects.
  18005. * @param uniforms The list of uniforms used in the effect
  18006. * @param defines the list of defines currently in use
  18007. */
  18008. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  18009. /**
  18010. * Prepare the list of samplers associated with the Image Processing effects.
  18011. * @param samplersList The list of uniforms used in the effect
  18012. * @param defines the list of defines currently in use
  18013. */
  18014. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  18015. /**
  18016. * Prepare the list of defines associated to the shader.
  18017. * @param defines the list of defines to complete
  18018. * @param forPostProcess Define if we are currently in post process mode or not
  18019. */
  18020. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  18021. /**
  18022. * Returns true if all the image processing information are ready.
  18023. * @returns True if ready, otherwise, false
  18024. */
  18025. isReady(): boolean;
  18026. /**
  18027. * Binds the image processing to the shader.
  18028. * @param effect The effect to bind to
  18029. * @param aspectRatio Define the current aspect ratio of the effect
  18030. */
  18031. bind(effect: Effect, aspectRatio?: number): void;
  18032. /**
  18033. * Clones the current image processing instance.
  18034. * @return The cloned image processing
  18035. */
  18036. clone(): ImageProcessingConfiguration;
  18037. /**
  18038. * Serializes the current image processing instance to a json representation.
  18039. * @return a JSON representation
  18040. */
  18041. serialize(): any;
  18042. /**
  18043. * Parses the image processing from a json representation.
  18044. * @param source the JSON source to parse
  18045. * @return The parsed image processing
  18046. */
  18047. static Parse(source: any): ImageProcessingConfiguration;
  18048. private static _VIGNETTEMODE_MULTIPLY;
  18049. private static _VIGNETTEMODE_OPAQUE;
  18050. /**
  18051. * Used to apply the vignette as a mix with the pixel color.
  18052. */
  18053. static readonly VIGNETTEMODE_MULTIPLY: number;
  18054. /**
  18055. * Used to apply the vignette as a replacement of the pixel color.
  18056. */
  18057. static readonly VIGNETTEMODE_OPAQUE: number;
  18058. }
  18059. }
  18060. declare module BABYLON {
  18061. /**
  18062. * Manages the defines for the Material
  18063. */
  18064. class MaterialDefines {
  18065. private _keys;
  18066. private _isDirty;
  18067. /** @hidden */
  18068. _renderId: number;
  18069. /** @hidden */
  18070. _areLightsDirty: boolean;
  18071. /** @hidden */
  18072. _areAttributesDirty: boolean;
  18073. /** @hidden */
  18074. _areTexturesDirty: boolean;
  18075. /** @hidden */
  18076. _areFresnelDirty: boolean;
  18077. /** @hidden */
  18078. _areMiscDirty: boolean;
  18079. /** @hidden */
  18080. _areImageProcessingDirty: boolean;
  18081. /** @hidden */
  18082. _normals: boolean;
  18083. /** @hidden */
  18084. _uvs: boolean;
  18085. /** @hidden */
  18086. _needNormals: boolean;
  18087. /** @hidden */
  18088. _needUVs: boolean;
  18089. /**
  18090. * Specifies if the material needs to be re-calculated
  18091. */
  18092. readonly isDirty: boolean;
  18093. /**
  18094. * Marks the material to indicate that it has been re-calculated
  18095. */
  18096. markAsProcessed(): void;
  18097. /**
  18098. * Marks the material to indicate that it needs to be re-calculated
  18099. */
  18100. markAsUnprocessed(): void;
  18101. /**
  18102. * Marks the material to indicate all of its defines need to be re-calculated
  18103. */
  18104. markAllAsDirty(): void;
  18105. /**
  18106. * Marks the material to indicate that image processing needs to be re-calculated
  18107. */
  18108. markAsImageProcessingDirty(): void;
  18109. /**
  18110. * Marks the material to indicate the lights need to be re-calculated
  18111. */
  18112. markAsLightDirty(): void;
  18113. /**
  18114. * Marks the attribute state as changed
  18115. */
  18116. markAsAttributesDirty(): void;
  18117. /**
  18118. * Marks the texture state as changed
  18119. */
  18120. markAsTexturesDirty(): void;
  18121. /**
  18122. * Marks the fresnel state as changed
  18123. */
  18124. markAsFresnelDirty(): void;
  18125. /**
  18126. * Marks the misc state as changed
  18127. */
  18128. markAsMiscDirty(): void;
  18129. /**
  18130. * Rebuilds the material defines
  18131. */
  18132. rebuild(): void;
  18133. /**
  18134. * Specifies if two material defines are equal
  18135. * @param other - A material define instance to compare to
  18136. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  18137. */
  18138. isEqual(other: MaterialDefines): boolean;
  18139. /**
  18140. * Clones this instance's defines to another instance
  18141. * @param other - material defines to clone values to
  18142. */
  18143. cloneTo(other: MaterialDefines): void;
  18144. /**
  18145. * Resets the material define values
  18146. */
  18147. reset(): void;
  18148. /**
  18149. * Converts the material define values to a string
  18150. * @returns - String of material define information
  18151. */
  18152. toString(): string;
  18153. }
  18154. /**
  18155. * Base class for the main features of a material in Babylon.js
  18156. */
  18157. class Material implements IAnimatable {
  18158. private static _TriangleFillMode;
  18159. private static _WireFrameFillMode;
  18160. private static _PointFillMode;
  18161. private static _PointListDrawMode;
  18162. private static _LineListDrawMode;
  18163. private static _LineLoopDrawMode;
  18164. private static _LineStripDrawMode;
  18165. private static _TriangleStripDrawMode;
  18166. private static _TriangleFanDrawMode;
  18167. /**
  18168. * Returns the triangle fill mode
  18169. */
  18170. static readonly TriangleFillMode: number;
  18171. /**
  18172. * Returns the wireframe mode
  18173. */
  18174. static readonly WireFrameFillMode: number;
  18175. /**
  18176. * Returns the point fill mode
  18177. */
  18178. static readonly PointFillMode: number;
  18179. /**
  18180. * Returns the point list draw mode
  18181. */
  18182. static readonly PointListDrawMode: number;
  18183. /**
  18184. * Returns the line list draw mode
  18185. */
  18186. static readonly LineListDrawMode: number;
  18187. /**
  18188. * Returns the line loop draw mode
  18189. */
  18190. static readonly LineLoopDrawMode: number;
  18191. /**
  18192. * Returns the line strip draw mode
  18193. */
  18194. static readonly LineStripDrawMode: number;
  18195. /**
  18196. * Returns the triangle strip draw mode
  18197. */
  18198. static readonly TriangleStripDrawMode: number;
  18199. /**
  18200. * Returns the triangle fan draw mode
  18201. */
  18202. static readonly TriangleFanDrawMode: number;
  18203. /**
  18204. * Stores the clock-wise side orientation
  18205. */
  18206. private static _ClockWiseSideOrientation;
  18207. /**
  18208. * Stores the counter clock-wise side orientation
  18209. */
  18210. private static _CounterClockWiseSideOrientation;
  18211. /**
  18212. * Returns the clock-wise side orientation
  18213. */
  18214. static readonly ClockWiseSideOrientation: number;
  18215. /**
  18216. * Returns the counter clock-wise side orientation
  18217. */
  18218. static readonly CounterClockWiseSideOrientation: number;
  18219. /**
  18220. * The dirty texture flag value
  18221. */
  18222. static readonly TextureDirtyFlag: number;
  18223. /**
  18224. * The dirty light flag value
  18225. */
  18226. static readonly LightDirtyFlag: number;
  18227. /**
  18228. * The dirty fresnel flag value
  18229. */
  18230. static readonly FresnelDirtyFlag: number;
  18231. /**
  18232. * The dirty attribute flag value
  18233. */
  18234. static readonly AttributesDirtyFlag: number;
  18235. /**
  18236. * The dirty misc flag value
  18237. */
  18238. static readonly MiscDirtyFlag: number;
  18239. /**
  18240. * The all dirty flag value
  18241. */
  18242. static readonly AllDirtyFlag: number;
  18243. /**
  18244. * The ID of the material
  18245. */
  18246. id: string;
  18247. /**
  18248. * Gets or sets the unique id of the material
  18249. */
  18250. uniqueId: number;
  18251. /**
  18252. * The name of the material
  18253. */
  18254. name: string;
  18255. /**
  18256. * Gets or sets user defined metadata
  18257. */
  18258. metadata: any;
  18259. /**
  18260. * For internal use only. Please do not use.
  18261. */
  18262. reservedDataStore: any;
  18263. /**
  18264. * Specifies if the ready state should be checked on each call
  18265. */
  18266. checkReadyOnEveryCall: boolean;
  18267. /**
  18268. * Specifies if the ready state should be checked once
  18269. */
  18270. checkReadyOnlyOnce: boolean;
  18271. /**
  18272. * The state of the material
  18273. */
  18274. state: string;
  18275. /**
  18276. * The alpha value of the material
  18277. */
  18278. protected _alpha: number;
  18279. /**
  18280. * Sets the alpha value of the material
  18281. */
  18282. /**
  18283. * Gets the alpha value of the material
  18284. */
  18285. alpha: number;
  18286. /**
  18287. * Specifies if back face culling is enabled
  18288. */
  18289. protected _backFaceCulling: boolean;
  18290. /**
  18291. * Sets the back-face culling state
  18292. */
  18293. /**
  18294. * Gets the back-face culling state
  18295. */
  18296. backFaceCulling: boolean;
  18297. /**
  18298. * Stores the value for side orientation
  18299. */
  18300. sideOrientation: number;
  18301. /**
  18302. * Callback triggered when the material is compiled
  18303. */
  18304. onCompiled: (effect: Effect) => void;
  18305. /**
  18306. * Callback triggered when an error occurs
  18307. */
  18308. onError: (effect: Effect, errors: string) => void;
  18309. /**
  18310. * Callback triggered to get the render target textures
  18311. */
  18312. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  18313. /**
  18314. * Gets a boolean indicating that current material needs to register RTT
  18315. */
  18316. readonly hasRenderTargetTextures: boolean;
  18317. /**
  18318. * Specifies if the material should be serialized
  18319. */
  18320. doNotSerialize: boolean;
  18321. /**
  18322. * @hidden
  18323. */
  18324. _storeEffectOnSubMeshes: boolean;
  18325. /**
  18326. * Stores the animations for the material
  18327. */
  18328. animations: Array<Animation>;
  18329. /**
  18330. * An event triggered when the material is disposed
  18331. */
  18332. onDisposeObservable: Observable<Material>;
  18333. /**
  18334. * An observer which watches for dispose events
  18335. */
  18336. private _onDisposeObserver;
  18337. private _onUnBindObservable;
  18338. /**
  18339. * Called during a dispose event
  18340. */
  18341. onDispose: () => void;
  18342. private _onBindObservable;
  18343. /**
  18344. * An event triggered when the material is bound
  18345. */
  18346. readonly onBindObservable: Observable<AbstractMesh>;
  18347. /**
  18348. * An observer which watches for bind events
  18349. */
  18350. private _onBindObserver;
  18351. /**
  18352. * Called during a bind event
  18353. */
  18354. onBind: (Mesh: AbstractMesh) => void;
  18355. /**
  18356. * An event triggered when the material is unbound
  18357. */
  18358. readonly onUnBindObservable: Observable<Material>;
  18359. /**
  18360. * Stores the value of the alpha mode
  18361. */
  18362. private _alphaMode;
  18363. /**
  18364. * Sets the value of the alpha mode.
  18365. *
  18366. * | Value | Type | Description |
  18367. * | --- | --- | --- |
  18368. * | 0 | ALPHA_DISABLE | |
  18369. * | 1 | ALPHA_ADD | |
  18370. * | 2 | ALPHA_COMBINE | |
  18371. * | 3 | ALPHA_SUBTRACT | |
  18372. * | 4 | ALPHA_MULTIPLY | |
  18373. * | 5 | ALPHA_MAXIMIZED | |
  18374. * | 6 | ALPHA_ONEONE | |
  18375. * | 7 | ALPHA_PREMULTIPLIED | |
  18376. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  18377. * | 9 | ALPHA_INTERPOLATE | |
  18378. * | 10 | ALPHA_SCREENMODE | |
  18379. *
  18380. */
  18381. /**
  18382. * Gets the value of the alpha mode
  18383. */
  18384. alphaMode: number;
  18385. /**
  18386. * Stores the state of the need depth pre-pass value
  18387. */
  18388. private _needDepthPrePass;
  18389. /**
  18390. * Sets the need depth pre-pass value
  18391. */
  18392. /**
  18393. * Gets the depth pre-pass value
  18394. */
  18395. needDepthPrePass: boolean;
  18396. /**
  18397. * Specifies if depth writing should be disabled
  18398. */
  18399. disableDepthWrite: boolean;
  18400. /**
  18401. * Specifies if depth writing should be forced
  18402. */
  18403. forceDepthWrite: boolean;
  18404. /**
  18405. * Specifies if there should be a separate pass for culling
  18406. */
  18407. separateCullingPass: boolean;
  18408. /**
  18409. * Stores the state specifing if fog should be enabled
  18410. */
  18411. private _fogEnabled;
  18412. /**
  18413. * Sets the state for enabling fog
  18414. */
  18415. /**
  18416. * Gets the value of the fog enabled state
  18417. */
  18418. fogEnabled: boolean;
  18419. /**
  18420. * Stores the size of points
  18421. */
  18422. pointSize: number;
  18423. /**
  18424. * Stores the z offset value
  18425. */
  18426. zOffset: number;
  18427. /**
  18428. * Gets a value specifying if wireframe mode is enabled
  18429. */
  18430. /**
  18431. * Sets the state of wireframe mode
  18432. */
  18433. wireframe: boolean;
  18434. /**
  18435. * Gets the value specifying if point clouds are enabled
  18436. */
  18437. /**
  18438. * Sets the state of point cloud mode
  18439. */
  18440. pointsCloud: boolean;
  18441. /**
  18442. * Gets the material fill mode
  18443. */
  18444. /**
  18445. * Sets the material fill mode
  18446. */
  18447. fillMode: number;
  18448. /**
  18449. * @hidden
  18450. * Stores the effects for the material
  18451. */
  18452. _effect: Nullable<Effect>;
  18453. /**
  18454. * @hidden
  18455. * Specifies if the material was previously ready
  18456. */
  18457. _wasPreviouslyReady: boolean;
  18458. /**
  18459. * Specifies if uniform buffers should be used
  18460. */
  18461. private _useUBO;
  18462. /**
  18463. * Stores a reference to the scene
  18464. */
  18465. private _scene;
  18466. /**
  18467. * Stores the fill mode state
  18468. */
  18469. private _fillMode;
  18470. /**
  18471. * Specifies if the depth write state should be cached
  18472. */
  18473. private _cachedDepthWriteState;
  18474. /**
  18475. * Stores the uniform buffer
  18476. */
  18477. protected _uniformBuffer: UniformBuffer;
  18478. /** @hidden */
  18479. _indexInSceneMaterialArray: number;
  18480. /** @hidden */
  18481. meshMap: Nullable<{
  18482. [id: string]: AbstractMesh | undefined;
  18483. }>;
  18484. /**
  18485. * Creates a material instance
  18486. * @param name defines the name of the material
  18487. * @param scene defines the scene to reference
  18488. * @param doNotAdd specifies if the material should be added to the scene
  18489. */
  18490. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  18491. /**
  18492. * Returns a string representation of the current material
  18493. * @param fullDetails defines a boolean indicating which levels of logging is desired
  18494. * @returns a string with material information
  18495. */
  18496. toString(fullDetails?: boolean): string;
  18497. /**
  18498. * Gets the class name of the material
  18499. * @returns a string with the class name of the material
  18500. */
  18501. getClassName(): string;
  18502. /**
  18503. * Specifies if updates for the material been locked
  18504. */
  18505. readonly isFrozen: boolean;
  18506. /**
  18507. * Locks updates for the material
  18508. */
  18509. freeze(): void;
  18510. /**
  18511. * Unlocks updates for the material
  18512. */
  18513. unfreeze(): void;
  18514. /**
  18515. * Specifies if the material is ready to be used
  18516. * @param mesh defines the mesh to check
  18517. * @param useInstances specifies if instances should be used
  18518. * @returns a boolean indicating if the material is ready to be used
  18519. */
  18520. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  18521. /**
  18522. * Specifies that the submesh is ready to be used
  18523. * @param mesh defines the mesh to check
  18524. * @param subMesh defines which submesh to check
  18525. * @param useInstances specifies that instances should be used
  18526. * @returns a boolean indicating that the submesh is ready or not
  18527. */
  18528. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  18529. /**
  18530. * Returns the material effect
  18531. * @returns the effect associated with the material
  18532. */
  18533. getEffect(): Nullable<Effect>;
  18534. /**
  18535. * Returns the current scene
  18536. * @returns a Scene
  18537. */
  18538. getScene(): Scene;
  18539. /**
  18540. * Specifies if the material will require alpha blending
  18541. * @returns a boolean specifying if alpha blending is needed
  18542. */
  18543. needAlphaBlending(): boolean;
  18544. /**
  18545. * Specifies if the mesh will require alpha blending
  18546. * @param mesh defines the mesh to check
  18547. * @returns a boolean specifying if alpha blending is needed for the mesh
  18548. */
  18549. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  18550. /**
  18551. * Specifies if this material should be rendered in alpha test mode
  18552. * @returns a boolean specifying if an alpha test is needed.
  18553. */
  18554. needAlphaTesting(): boolean;
  18555. /**
  18556. * Gets the texture used for the alpha test
  18557. * @returns the texture to use for alpha testing
  18558. */
  18559. getAlphaTestTexture(): Nullable<BaseTexture>;
  18560. /**
  18561. * Marks the material to indicate that it needs to be re-calculated
  18562. */
  18563. markDirty(): void;
  18564. /** @hidden */
  18565. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  18566. /**
  18567. * Binds the material to the mesh
  18568. * @param world defines the world transformation matrix
  18569. * @param mesh defines the mesh to bind the material to
  18570. */
  18571. bind(world: Matrix, mesh?: Mesh): void;
  18572. /**
  18573. * Binds the submesh to the material
  18574. * @param world defines the world transformation matrix
  18575. * @param mesh defines the mesh containing the submesh
  18576. * @param subMesh defines the submesh to bind the material to
  18577. */
  18578. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  18579. /**
  18580. * Binds the world matrix to the material
  18581. * @param world defines the world transformation matrix
  18582. */
  18583. bindOnlyWorldMatrix(world: Matrix): void;
  18584. /**
  18585. * Binds the scene's uniform buffer to the effect.
  18586. * @param effect defines the effect to bind to the scene uniform buffer
  18587. * @param sceneUbo defines the uniform buffer storing scene data
  18588. */
  18589. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  18590. /**
  18591. * Binds the view matrix to the effect
  18592. * @param effect defines the effect to bind the view matrix to
  18593. */
  18594. bindView(effect: Effect): void;
  18595. /**
  18596. * Binds the view projection matrix to the effect
  18597. * @param effect defines the effect to bind the view projection matrix to
  18598. */
  18599. bindViewProjection(effect: Effect): void;
  18600. /**
  18601. * Specifies if material alpha testing should be turned on for the mesh
  18602. * @param mesh defines the mesh to check
  18603. */
  18604. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  18605. /**
  18606. * Processes to execute after binding the material to a mesh
  18607. * @param mesh defines the rendered mesh
  18608. */
  18609. protected _afterBind(mesh?: Mesh): void;
  18610. /**
  18611. * Unbinds the material from the mesh
  18612. */
  18613. unbind(): void;
  18614. /**
  18615. * Gets the active textures from the material
  18616. * @returns an array of textures
  18617. */
  18618. getActiveTextures(): BaseTexture[];
  18619. /**
  18620. * Specifies if the material uses a texture
  18621. * @param texture defines the texture to check against the material
  18622. * @returns a boolean specifying if the material uses the texture
  18623. */
  18624. hasTexture(texture: BaseTexture): boolean;
  18625. /**
  18626. * Makes a duplicate of the material, and gives it a new name
  18627. * @param name defines the new name for the duplicated material
  18628. * @returns the cloned material
  18629. */
  18630. clone(name: string): Nullable<Material>;
  18631. /**
  18632. * Gets the meshes bound to the material
  18633. * @returns an array of meshes bound to the material
  18634. */
  18635. getBindedMeshes(): AbstractMesh[];
  18636. /**
  18637. * Force shader compilation
  18638. * @param mesh defines the mesh associated with this material
  18639. * @param onCompiled defines a function to execute once the material is compiled
  18640. * @param options defines the options to configure the compilation
  18641. */
  18642. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  18643. clipPlane: boolean;
  18644. }>): void;
  18645. /**
  18646. * Force shader compilation
  18647. * @param mesh defines the mesh that will use this material
  18648. * @param options defines additional options for compiling the shaders
  18649. * @returns a promise that resolves when the compilation completes
  18650. */
  18651. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  18652. clipPlane: boolean;
  18653. }>): Promise<void>;
  18654. private static readonly _ImageProcessingDirtyCallBack;
  18655. private static readonly _TextureDirtyCallBack;
  18656. private static readonly _FresnelDirtyCallBack;
  18657. private static readonly _MiscDirtyCallBack;
  18658. private static readonly _LightsDirtyCallBack;
  18659. private static readonly _AttributeDirtyCallBack;
  18660. private static _FresnelAndMiscDirtyCallBack;
  18661. private static _TextureAndMiscDirtyCallBack;
  18662. private static readonly _DirtyCallbackArray;
  18663. private static readonly _RunDirtyCallBacks;
  18664. /**
  18665. * Marks a define in the material to indicate that it needs to be re-computed
  18666. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  18667. */
  18668. markAsDirty(flag: number): void;
  18669. /**
  18670. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  18671. * @param func defines a function which checks material defines against the submeshes
  18672. */
  18673. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  18674. /**
  18675. * Indicates that image processing needs to be re-calculated for all submeshes
  18676. */
  18677. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  18678. /**
  18679. * Indicates that textures need to be re-calculated for all submeshes
  18680. */
  18681. protected _markAllSubMeshesAsTexturesDirty(): void;
  18682. /**
  18683. * Indicates that fresnel needs to be re-calculated for all submeshes
  18684. */
  18685. protected _markAllSubMeshesAsFresnelDirty(): void;
  18686. /**
  18687. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  18688. */
  18689. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  18690. /**
  18691. * Indicates that lights need to be re-calculated for all submeshes
  18692. */
  18693. protected _markAllSubMeshesAsLightsDirty(): void;
  18694. /**
  18695. * Indicates that attributes need to be re-calculated for all submeshes
  18696. */
  18697. protected _markAllSubMeshesAsAttributesDirty(): void;
  18698. /**
  18699. * Indicates that misc needs to be re-calculated for all submeshes
  18700. */
  18701. protected _markAllSubMeshesAsMiscDirty(): void;
  18702. /**
  18703. * Indicates that textures and misc need to be re-calculated for all submeshes
  18704. */
  18705. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  18706. /**
  18707. * Disposes the material
  18708. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  18709. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  18710. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  18711. */
  18712. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  18713. /** @hidden */
  18714. private releaseVertexArrayObject;
  18715. /**
  18716. * Serializes this material
  18717. * @returns the serialized material object
  18718. */
  18719. serialize(): any;
  18720. /**
  18721. * Creates a MultiMaterial from parsed MultiMaterial data.
  18722. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  18723. * @param scene defines the hosting scene
  18724. * @returns a new MultiMaterial
  18725. */
  18726. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  18727. /**
  18728. * Creates a material from parsed material data
  18729. * @param parsedMaterial defines parsed material data
  18730. * @param scene defines the hosting scene
  18731. * @param rootUrl defines the root URL to use to load textures
  18732. * @returns a new material
  18733. */
  18734. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  18735. }
  18736. }
  18737. declare module BABYLON {
  18738. /**
  18739. * "Static Class" containing the most commonly used helper while dealing with material for
  18740. * rendering purpose.
  18741. *
  18742. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  18743. *
  18744. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  18745. */
  18746. class MaterialHelper {
  18747. /**
  18748. * Bind the current view position to an effect.
  18749. * @param effect The effect to be bound
  18750. * @param scene The scene the eyes position is used from
  18751. */
  18752. static BindEyePosition(effect: Effect, scene: Scene): void;
  18753. /**
  18754. * Helps preparing the defines values about the UVs in used in the effect.
  18755. * UVs are shared as much as we can accross channels in the shaders.
  18756. * @param texture The texture we are preparing the UVs for
  18757. * @param defines The defines to update
  18758. * @param key The channel key "diffuse", "specular"... used in the shader
  18759. */
  18760. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  18761. /**
  18762. * Binds a texture matrix value to its corrsponding uniform
  18763. * @param texture The texture to bind the matrix for
  18764. * @param uniformBuffer The uniform buffer receivin the data
  18765. * @param key The channel key "diffuse", "specular"... used in the shader
  18766. */
  18767. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  18768. /**
  18769. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  18770. * @param mesh defines the current mesh
  18771. * @param scene defines the current scene
  18772. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  18773. * @param pointsCloud defines if point cloud rendering has to be turned on
  18774. * @param fogEnabled defines if fog has to be turned on
  18775. * @param alphaTest defines if alpha testing has to be turned on
  18776. * @param defines defines the current list of defines
  18777. */
  18778. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  18779. /**
  18780. * Helper used to prepare the list of defines associated with frame values for shader compilation
  18781. * @param scene defines the current scene
  18782. * @param engine defines the current engine
  18783. * @param defines specifies the list of active defines
  18784. * @param useInstances defines if instances have to be turned on
  18785. * @param useClipPlane defines if clip plane have to be turned on
  18786. */
  18787. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  18788. /**
  18789. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  18790. * @param mesh The mesh containing the geometry data we will draw
  18791. * @param defines The defines to update
  18792. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  18793. * @param useBones Precise whether bones should be used or not (override mesh info)
  18794. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  18795. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  18796. * @returns false if defines are considered not dirty and have not been checked
  18797. */
  18798. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  18799. /**
  18800. * Prepares the defines related to the light information passed in parameter
  18801. * @param scene The scene we are intending to draw
  18802. * @param mesh The mesh the effect is compiling for
  18803. * @param defines The defines to update
  18804. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  18805. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  18806. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  18807. * @returns true if normals will be required for the rest of the effect
  18808. */
  18809. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  18810. /**
  18811. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  18812. * that won t be acctive due to defines being turned off.
  18813. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  18814. * @param samplersList The samplers list
  18815. * @param defines The defines helping in the list generation
  18816. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  18817. */
  18818. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  18819. /**
  18820. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  18821. * @param defines The defines to update while falling back
  18822. * @param fallbacks The authorized effect fallbacks
  18823. * @param maxSimultaneousLights The maximum number of lights allowed
  18824. * @param rank the current rank of the Effect
  18825. * @returns The newly affected rank
  18826. */
  18827. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  18828. /**
  18829. * Prepares the list of attributes required for morph targets according to the effect defines.
  18830. * @param attribs The current list of supported attribs
  18831. * @param mesh The mesh to prepare the morph targets attributes for
  18832. * @param defines The current Defines of the effect
  18833. */
  18834. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  18835. /**
  18836. * Prepares the list of attributes required for bones according to the effect defines.
  18837. * @param attribs The current list of supported attribs
  18838. * @param mesh The mesh to prepare the bones attributes for
  18839. * @param defines The current Defines of the effect
  18840. * @param fallbacks The current efffect fallback strategy
  18841. */
  18842. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  18843. /**
  18844. * Prepares the list of attributes required for instances according to the effect defines.
  18845. * @param attribs The current list of supported attribs
  18846. * @param defines The current Defines of the effect
  18847. */
  18848. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  18849. /**
  18850. * Binds the light shadow information to the effect for the given mesh.
  18851. * @param light The light containing the generator
  18852. * @param scene The scene the lights belongs to
  18853. * @param mesh The mesh we are binding the information to render
  18854. * @param lightIndex The light index in the effect used to render the mesh
  18855. * @param effect The effect we are binding the data to
  18856. */
  18857. static BindLightShadow(light: Light, scene: Scene, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  18858. /**
  18859. * Binds the light information to the effect.
  18860. * @param light The light containing the generator
  18861. * @param effect The effect we are binding the data to
  18862. * @param lightIndex The light index in the effect used to render
  18863. */
  18864. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  18865. /**
  18866. * Binds the lights information from the scene to the effect for the given mesh.
  18867. * @param scene The scene the lights belongs to
  18868. * @param mesh The mesh we are binding the information to render
  18869. * @param effect The effect we are binding the data to
  18870. * @param defines The generated defines for the effect
  18871. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  18872. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  18873. */
  18874. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  18875. private static _tempFogColor;
  18876. /**
  18877. * Binds the fog information from the scene to the effect for the given mesh.
  18878. * @param scene The scene the lights belongs to
  18879. * @param mesh The mesh we are binding the information to render
  18880. * @param effect The effect we are binding the data to
  18881. * @param linearSpace Defines if the fog effect is applied in linear space
  18882. */
  18883. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  18884. /**
  18885. * Binds the bones information from the mesh to the effect.
  18886. * @param mesh The mesh we are binding the information to render
  18887. * @param effect The effect we are binding the data to
  18888. */
  18889. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  18890. /**
  18891. * Binds the morph targets information from the mesh to the effect.
  18892. * @param abstractMesh The mesh we are binding the information to render
  18893. * @param effect The effect we are binding the data to
  18894. */
  18895. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  18896. /**
  18897. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  18898. * @param defines The generated defines used in the effect
  18899. * @param effect The effect we are binding the data to
  18900. * @param scene The scene we are willing to render with logarithmic scale for
  18901. */
  18902. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  18903. /**
  18904. * Binds the clip plane information from the scene to the effect.
  18905. * @param scene The scene the clip plane information are extracted from
  18906. * @param effect The effect we are binding the data to
  18907. */
  18908. static BindClipPlane(effect: Effect, scene: Scene): void;
  18909. }
  18910. }
  18911. declare module BABYLON {
  18912. /**
  18913. * A multi-material is used to apply different materials to different parts of the same object without the need of
  18914. * separate meshes. This can be use to improve performances.
  18915. * @see http://doc.babylonjs.com/how_to/multi_materials
  18916. */
  18917. class MultiMaterial extends Material {
  18918. private _subMaterials;
  18919. /**
  18920. * Gets or Sets the list of Materials used within the multi material.
  18921. * They need to be ordered according to the submeshes order in the associated mesh
  18922. */
  18923. subMaterials: Nullable<Material>[];
  18924. /**
  18925. * Function used to align with Node.getChildren()
  18926. * @returns the list of Materials used within the multi material
  18927. */
  18928. getChildren(): Nullable<Material>[];
  18929. /**
  18930. * Instantiates a new Multi Material
  18931. * A multi-material is used to apply different materials to different parts of the same object without the need of
  18932. * separate meshes. This can be use to improve performances.
  18933. * @see http://doc.babylonjs.com/how_to/multi_materials
  18934. * @param name Define the name in the scene
  18935. * @param scene Define the scene the material belongs to
  18936. */
  18937. constructor(name: string, scene: Scene);
  18938. private _hookArray;
  18939. /**
  18940. * Get one of the submaterial by its index in the submaterials array
  18941. * @param index The index to look the sub material at
  18942. * @returns The Material if the index has been defined
  18943. */
  18944. getSubMaterial(index: number): Nullable<Material>;
  18945. /**
  18946. * Get the list of active textures for the whole sub materials list.
  18947. * @returns All the textures that will be used during the rendering
  18948. */
  18949. getActiveTextures(): BaseTexture[];
  18950. /**
  18951. * Gets the current class name of the material e.g. "MultiMaterial"
  18952. * Mainly use in serialization.
  18953. * @returns the class name
  18954. */
  18955. getClassName(): string;
  18956. /**
  18957. * Checks if the material is ready to render the requested sub mesh
  18958. * @param mesh Define the mesh the submesh belongs to
  18959. * @param subMesh Define the sub mesh to look readyness for
  18960. * @param useInstances Define whether or not the material is used with instances
  18961. * @returns true if ready, otherwise false
  18962. */
  18963. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  18964. /**
  18965. * Clones the current material and its related sub materials
  18966. * @param name Define the name of the newly cloned material
  18967. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  18968. * @returns the cloned material
  18969. */
  18970. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  18971. /**
  18972. * Serializes the materials into a JSON representation.
  18973. * @returns the JSON representation
  18974. */
  18975. serialize(): any;
  18976. /**
  18977. * Dispose the material and release its associated resources
  18978. * @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)
  18979. * @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)
  18980. */
  18981. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  18982. }
  18983. }
  18984. declare module BABYLON {
  18985. /**
  18986. * Base class of materials working in push mode in babylon JS
  18987. * @hidden
  18988. */
  18989. class PushMaterial extends Material {
  18990. protected _activeEffect: Effect;
  18991. protected _normalMatrix: Matrix;
  18992. /**
  18993. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  18994. * This means that the material can keep using a previous shader while a new one is being compiled.
  18995. * This is mostly used when shader parallel compilation is supported (true by default)
  18996. */
  18997. allowShaderHotSwapping: boolean;
  18998. constructor(name: string, scene: Scene);
  18999. getEffect(): Effect;
  19000. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19001. /**
  19002. * Binds the given world matrix to the active effect
  19003. *
  19004. * @param world the matrix to bind
  19005. */
  19006. bindOnlyWorldMatrix(world: Matrix): void;
  19007. /**
  19008. * Binds the given normal matrix to the active effect
  19009. *
  19010. * @param normalMatrix the matrix to bind
  19011. */
  19012. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  19013. bind(world: Matrix, mesh?: Mesh): void;
  19014. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  19015. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  19016. }
  19017. }
  19018. declare module BABYLON {
  19019. /**
  19020. * Defines the options associated with the creation of a shader material.
  19021. */
  19022. interface IShaderMaterialOptions {
  19023. /**
  19024. * Does the material work in alpha blend mode
  19025. */
  19026. needAlphaBlending: boolean;
  19027. /**
  19028. * Does the material work in alpha test mode
  19029. */
  19030. needAlphaTesting: boolean;
  19031. /**
  19032. * The list of attribute names used in the shader
  19033. */
  19034. attributes: string[];
  19035. /**
  19036. * The list of unifrom names used in the shader
  19037. */
  19038. uniforms: string[];
  19039. /**
  19040. * The list of UBO names used in the shader
  19041. */
  19042. uniformBuffers: string[];
  19043. /**
  19044. * The list of sampler names used in the shader
  19045. */
  19046. samplers: string[];
  19047. /**
  19048. * The list of defines used in the shader
  19049. */
  19050. defines: string[];
  19051. }
  19052. /**
  19053. * 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.
  19054. *
  19055. * This returned material effects how the mesh will look based on the code in the shaders.
  19056. *
  19057. * @see http://doc.babylonjs.com/how_to/shader_material
  19058. */
  19059. class ShaderMaterial extends Material {
  19060. private _shaderPath;
  19061. private _options;
  19062. private _textures;
  19063. private _textureArrays;
  19064. private _floats;
  19065. private _ints;
  19066. private _floatsArrays;
  19067. private _colors3;
  19068. private _colors3Arrays;
  19069. private _colors4;
  19070. private _vectors2;
  19071. private _vectors3;
  19072. private _vectors4;
  19073. private _matrices;
  19074. private _matrices3x3;
  19075. private _matrices2x2;
  19076. private _vectors2Arrays;
  19077. private _vectors3Arrays;
  19078. private _cachedWorldViewMatrix;
  19079. private _renderId;
  19080. /**
  19081. * Instantiate a new shader material.
  19082. * 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.
  19083. * This returned material effects how the mesh will look based on the code in the shaders.
  19084. * @see http://doc.babylonjs.com/how_to/shader_material
  19085. * @param name Define the name of the material in the scene
  19086. * @param scene Define the scene the material belongs to
  19087. * @param shaderPath Defines the route to the shader code in one of three ways:
  19088. * - object - { vertex: "custom", fragment: "custom" }, used with BABYLON.Effect.ShadersStore["customVertexShader"] and BABYLON.Effect.ShadersStore["customFragmentShader"]
  19089. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  19090. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19091. * @param options Define the options used to create the shader
  19092. */
  19093. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19094. /**
  19095. * Gets the current class name of the material e.g. "ShaderMaterial"
  19096. * Mainly use in serialization.
  19097. * @returns the class name
  19098. */
  19099. getClassName(): string;
  19100. /**
  19101. * Specifies if the material will require alpha blending
  19102. * @returns a boolean specifying if alpha blending is needed
  19103. */
  19104. needAlphaBlending(): boolean;
  19105. /**
  19106. * Specifies if this material should be rendered in alpha test mode
  19107. * @returns a boolean specifying if an alpha test is needed.
  19108. */
  19109. needAlphaTesting(): boolean;
  19110. private _checkUniform;
  19111. /**
  19112. * Set a texture in the shader.
  19113. * @param name Define the name of the uniform samplers as defined in the shader
  19114. * @param texture Define the texture to bind to this sampler
  19115. * @return the material itself allowing "fluent" like uniform updates
  19116. */
  19117. setTexture(name: string, texture: Texture): ShaderMaterial;
  19118. /**
  19119. * Set a texture array in the shader.
  19120. * @param name Define the name of the uniform sampler array as defined in the shader
  19121. * @param textures Define the list of textures to bind to this sampler
  19122. * @return the material itself allowing "fluent" like uniform updates
  19123. */
  19124. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19125. /**
  19126. * Set a float in the shader.
  19127. * @param name Define the name of the uniform as defined in the shader
  19128. * @param value Define the value to give to the uniform
  19129. * @return the material itself allowing "fluent" like uniform updates
  19130. */
  19131. setFloat(name: string, value: number): ShaderMaterial;
  19132. /**
  19133. * Set a int in the shader.
  19134. * @param name Define the name of the uniform as defined in the shader
  19135. * @param value Define the value to give to the uniform
  19136. * @return the material itself allowing "fluent" like uniform updates
  19137. */
  19138. setInt(name: string, value: number): ShaderMaterial;
  19139. /**
  19140. * Set an array of floats in the shader.
  19141. * @param name Define the name of the uniform as defined in the shader
  19142. * @param value Define the value to give to the uniform
  19143. * @return the material itself allowing "fluent" like uniform updates
  19144. */
  19145. setFloats(name: string, value: number[]): ShaderMaterial;
  19146. /**
  19147. * Set a vec3 in the shader from a Color3.
  19148. * @param name Define the name of the uniform as defined in the shader
  19149. * @param value Define the value to give to the uniform
  19150. * @return the material itself allowing "fluent" like uniform updates
  19151. */
  19152. setColor3(name: string, value: Color3): ShaderMaterial;
  19153. /**
  19154. * Set a vec3 array in the shader from a Color3 array.
  19155. * @param name Define the name of the uniform as defined in the shader
  19156. * @param value Define the value to give to the uniform
  19157. * @return the material itself allowing "fluent" like uniform updates
  19158. */
  19159. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19160. /**
  19161. * Set a vec4 in the shader from a Color4.
  19162. * @param name Define the name of the uniform as defined in the shader
  19163. * @param value Define the value to give to the uniform
  19164. * @return the material itself allowing "fluent" like uniform updates
  19165. */
  19166. setColor4(name: string, value: Color4): ShaderMaterial;
  19167. /**
  19168. * Set a vec2 in the shader from a Vector2.
  19169. * @param name Define the name of the uniform as defined in the shader
  19170. * @param value Define the value to give to the uniform
  19171. * @return the material itself allowing "fluent" like uniform updates
  19172. */
  19173. setVector2(name: string, value: Vector2): ShaderMaterial;
  19174. /**
  19175. * Set a vec3 in the shader from a Vector3.
  19176. * @param name Define the name of the uniform as defined in the shader
  19177. * @param value Define the value to give to the uniform
  19178. * @return the material itself allowing "fluent" like uniform updates
  19179. */
  19180. setVector3(name: string, value: Vector3): ShaderMaterial;
  19181. /**
  19182. * Set a vec4 in the shader from a Vector4.
  19183. * @param name Define the name of the uniform as defined in the shader
  19184. * @param value Define the value to give to the uniform
  19185. * @return the material itself allowing "fluent" like uniform updates
  19186. */
  19187. setVector4(name: string, value: Vector4): ShaderMaterial;
  19188. /**
  19189. * Set a mat4 in the shader from a Matrix.
  19190. * @param name Define the name of the uniform as defined in the shader
  19191. * @param value Define the value to give to the uniform
  19192. * @return the material itself allowing "fluent" like uniform updates
  19193. */
  19194. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19195. /**
  19196. * Set a mat3 in the shader from a Float32Array.
  19197. * @param name Define the name of the uniform as defined in the shader
  19198. * @param value Define the value to give to the uniform
  19199. * @return the material itself allowing "fluent" like uniform updates
  19200. */
  19201. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19202. /**
  19203. * Set a mat2 in the shader from a Float32Array.
  19204. * @param name Define the name of the uniform as defined in the shader
  19205. * @param value Define the value to give to the uniform
  19206. * @return the material itself allowing "fluent" like uniform updates
  19207. */
  19208. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19209. /**
  19210. * Set a vec2 array in the shader from a number array.
  19211. * @param name Define the name of the uniform as defined in the shader
  19212. * @param value Define the value to give to the uniform
  19213. * @return the material itself allowing "fluent" like uniform updates
  19214. */
  19215. setArray2(name: string, value: number[]): ShaderMaterial;
  19216. /**
  19217. * Set a vec3 array in the shader from a number array.
  19218. * @param name Define the name of the uniform as defined in the shader
  19219. * @param value Define the value to give to the uniform
  19220. * @return the material itself allowing "fluent" like uniform updates
  19221. */
  19222. setArray3(name: string, value: number[]): ShaderMaterial;
  19223. private _checkCache;
  19224. /**
  19225. * Checks if the material is ready to render the requested mesh
  19226. * @param mesh Define the mesh to render
  19227. * @param useInstances Define whether or not the material is used with instances
  19228. * @returns true if ready, otherwise false
  19229. */
  19230. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19231. /**
  19232. * Binds the world matrix to the material
  19233. * @param world defines the world transformation matrix
  19234. */
  19235. bindOnlyWorldMatrix(world: Matrix): void;
  19236. /**
  19237. * Binds the material to the mesh
  19238. * @param world defines the world transformation matrix
  19239. * @param mesh defines the mesh to bind the material to
  19240. */
  19241. bind(world: Matrix, mesh?: Mesh): void;
  19242. /**
  19243. * Gets the active textures from the material
  19244. * @returns an array of textures
  19245. */
  19246. getActiveTextures(): BaseTexture[];
  19247. /**
  19248. * Specifies if the material uses a texture
  19249. * @param texture defines the texture to check against the material
  19250. * @returns a boolean specifying if the material uses the texture
  19251. */
  19252. hasTexture(texture: BaseTexture): boolean;
  19253. /**
  19254. * Makes a duplicate of the material, and gives it a new name
  19255. * @param name defines the new name for the duplicated material
  19256. * @returns the cloned material
  19257. */
  19258. clone(name: string): ShaderMaterial;
  19259. /**
  19260. * Disposes the material
  19261. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19262. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19263. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19264. */
  19265. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19266. /**
  19267. * Serializes this material in a JSON representation
  19268. * @returns the serialized material object
  19269. */
  19270. serialize(): any;
  19271. /**
  19272. * Creates a shader material from parsed shader material data
  19273. * @param source defines the JSON represnetation of the material
  19274. * @param scene defines the hosting scene
  19275. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19276. * @returns a new material
  19277. */
  19278. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19279. }
  19280. }
  19281. declare module BABYLON {
  19282. /** @hidden */
  19283. class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  19284. MAINUV1: boolean;
  19285. MAINUV2: boolean;
  19286. DIFFUSE: boolean;
  19287. DIFFUSEDIRECTUV: number;
  19288. AMBIENT: boolean;
  19289. AMBIENTDIRECTUV: number;
  19290. OPACITY: boolean;
  19291. OPACITYDIRECTUV: number;
  19292. OPACITYRGB: boolean;
  19293. REFLECTION: boolean;
  19294. EMISSIVE: boolean;
  19295. EMISSIVEDIRECTUV: number;
  19296. SPECULAR: boolean;
  19297. SPECULARDIRECTUV: number;
  19298. BUMP: boolean;
  19299. BUMPDIRECTUV: number;
  19300. PARALLAX: boolean;
  19301. PARALLAXOCCLUSION: boolean;
  19302. SPECULAROVERALPHA: boolean;
  19303. CLIPPLANE: boolean;
  19304. CLIPPLANE2: boolean;
  19305. CLIPPLANE3: boolean;
  19306. CLIPPLANE4: boolean;
  19307. ALPHATEST: boolean;
  19308. DEPTHPREPASS: boolean;
  19309. ALPHAFROMDIFFUSE: boolean;
  19310. POINTSIZE: boolean;
  19311. FOG: boolean;
  19312. SPECULARTERM: boolean;
  19313. DIFFUSEFRESNEL: boolean;
  19314. OPACITYFRESNEL: boolean;
  19315. REFLECTIONFRESNEL: boolean;
  19316. REFRACTIONFRESNEL: boolean;
  19317. EMISSIVEFRESNEL: boolean;
  19318. FRESNEL: boolean;
  19319. NORMAL: boolean;
  19320. UV1: boolean;
  19321. UV2: boolean;
  19322. VERTEXCOLOR: boolean;
  19323. VERTEXALPHA: boolean;
  19324. NUM_BONE_INFLUENCERS: number;
  19325. BonesPerMesh: number;
  19326. BONETEXTURE: boolean;
  19327. INSTANCES: boolean;
  19328. GLOSSINESS: boolean;
  19329. ROUGHNESS: boolean;
  19330. EMISSIVEASILLUMINATION: boolean;
  19331. LINKEMISSIVEWITHDIFFUSE: boolean;
  19332. REFLECTIONFRESNELFROMSPECULAR: boolean;
  19333. LIGHTMAP: boolean;
  19334. LIGHTMAPDIRECTUV: number;
  19335. OBJECTSPACE_NORMALMAP: boolean;
  19336. USELIGHTMAPASSHADOWMAP: boolean;
  19337. REFLECTIONMAP_3D: boolean;
  19338. REFLECTIONMAP_SPHERICAL: boolean;
  19339. REFLECTIONMAP_PLANAR: boolean;
  19340. REFLECTIONMAP_CUBIC: boolean;
  19341. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  19342. REFLECTIONMAP_PROJECTION: boolean;
  19343. REFLECTIONMAP_SKYBOX: boolean;
  19344. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  19345. REFLECTIONMAP_EXPLICIT: boolean;
  19346. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  19347. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  19348. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  19349. INVERTCUBICMAP: boolean;
  19350. LOGARITHMICDEPTH: boolean;
  19351. REFRACTION: boolean;
  19352. REFRACTIONMAP_3D: boolean;
  19353. REFLECTIONOVERALPHA: boolean;
  19354. TWOSIDEDLIGHTING: boolean;
  19355. SHADOWFLOAT: boolean;
  19356. MORPHTARGETS: boolean;
  19357. MORPHTARGETS_NORMAL: boolean;
  19358. MORPHTARGETS_TANGENT: boolean;
  19359. NUM_MORPH_INFLUENCERS: number;
  19360. NONUNIFORMSCALING: boolean;
  19361. PREMULTIPLYALPHA: boolean;
  19362. IMAGEPROCESSING: boolean;
  19363. VIGNETTE: boolean;
  19364. VIGNETTEBLENDMODEMULTIPLY: boolean;
  19365. VIGNETTEBLENDMODEOPAQUE: boolean;
  19366. TONEMAPPING: boolean;
  19367. TONEMAPPING_ACES: boolean;
  19368. CONTRAST: boolean;
  19369. COLORCURVES: boolean;
  19370. COLORGRADING: boolean;
  19371. COLORGRADING3D: boolean;
  19372. SAMPLER3DGREENDEPTH: boolean;
  19373. SAMPLER3DBGRMAP: boolean;
  19374. IMAGEPROCESSINGPOSTPROCESS: boolean;
  19375. /**
  19376. * If the reflection texture on this material is in linear color space
  19377. * @hidden
  19378. */
  19379. IS_REFLECTION_LINEAR: boolean;
  19380. /**
  19381. * If the refraction texture on this material is in linear color space
  19382. * @hidden
  19383. */
  19384. IS_REFRACTION_LINEAR: boolean;
  19385. EXPOSURE: boolean;
  19386. constructor();
  19387. setReflectionMode(modeToEnable: string): void;
  19388. }
  19389. /**
  19390. * This is the default material used in Babylon. It is the best trade off between quality
  19391. * and performances.
  19392. * @see http://doc.babylonjs.com/babylon101/materials
  19393. */
  19394. class StandardMaterial extends PushMaterial {
  19395. private _diffuseTexture;
  19396. /**
  19397. * The basic texture of the material as viewed under a light.
  19398. */
  19399. diffuseTexture: Nullable<BaseTexture>;
  19400. private _ambientTexture;
  19401. /**
  19402. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  19403. */
  19404. ambientTexture: Nullable<BaseTexture>;
  19405. private _opacityTexture;
  19406. /**
  19407. * Define the transparency of the material from a texture.
  19408. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  19409. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  19410. */
  19411. opacityTexture: Nullable<BaseTexture>;
  19412. private _reflectionTexture;
  19413. /**
  19414. * Define the texture used to display the reflection.
  19415. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19416. */
  19417. reflectionTexture: Nullable<BaseTexture>;
  19418. private _emissiveTexture;
  19419. /**
  19420. * Define texture of the material as if self lit.
  19421. * This will be mixed in the final result even in the absence of light.
  19422. */
  19423. emissiveTexture: Nullable<BaseTexture>;
  19424. private _specularTexture;
  19425. /**
  19426. * Define how the color and intensity of the highlight given by the light in the material.
  19427. */
  19428. specularTexture: Nullable<BaseTexture>;
  19429. private _bumpTexture;
  19430. /**
  19431. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  19432. * 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.
  19433. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  19434. */
  19435. bumpTexture: Nullable<BaseTexture>;
  19436. private _lightmapTexture;
  19437. /**
  19438. * Complex lighting can be computationally expensive to compute at runtime.
  19439. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  19440. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  19441. */
  19442. lightmapTexture: Nullable<BaseTexture>;
  19443. private _refractionTexture;
  19444. /**
  19445. * Define the texture used to display the refraction.
  19446. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19447. */
  19448. refractionTexture: Nullable<BaseTexture>;
  19449. /**
  19450. * The color of the material lit by the environmental background lighting.
  19451. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  19452. */
  19453. ambientColor: Color3;
  19454. /**
  19455. * The basic color of the material as viewed under a light.
  19456. */
  19457. diffuseColor: Color3;
  19458. /**
  19459. * Define how the color and intensity of the highlight given by the light in the material.
  19460. */
  19461. specularColor: Color3;
  19462. /**
  19463. * Define the color of the material as if self lit.
  19464. * This will be mixed in the final result even in the absence of light.
  19465. */
  19466. emissiveColor: Color3;
  19467. /**
  19468. * Defines how sharp are the highlights in the material.
  19469. * The bigger the value the sharper giving a more glossy feeling to the result.
  19470. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  19471. */
  19472. specularPower: number;
  19473. private _useAlphaFromDiffuseTexture;
  19474. /**
  19475. * Does the transparency come from the diffuse texture alpha channel.
  19476. */
  19477. useAlphaFromDiffuseTexture: boolean;
  19478. private _useEmissiveAsIllumination;
  19479. /**
  19480. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  19481. */
  19482. useEmissiveAsIllumination: boolean;
  19483. private _linkEmissiveWithDiffuse;
  19484. /**
  19485. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  19486. * the emissive level when the final color is close to one.
  19487. */
  19488. linkEmissiveWithDiffuse: boolean;
  19489. private _useSpecularOverAlpha;
  19490. /**
  19491. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  19492. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  19493. */
  19494. useSpecularOverAlpha: boolean;
  19495. private _useReflectionOverAlpha;
  19496. /**
  19497. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  19498. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  19499. */
  19500. useReflectionOverAlpha: boolean;
  19501. private _disableLighting;
  19502. /**
  19503. * Does lights from the scene impacts this material.
  19504. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  19505. */
  19506. disableLighting: boolean;
  19507. private _useObjectSpaceNormalMap;
  19508. /**
  19509. * Allows using an object space normal map (instead of tangent space).
  19510. */
  19511. useObjectSpaceNormalMap: boolean;
  19512. private _useParallax;
  19513. /**
  19514. * Is parallax enabled or not.
  19515. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  19516. */
  19517. useParallax: boolean;
  19518. private _useParallaxOcclusion;
  19519. /**
  19520. * Is parallax occlusion enabled or not.
  19521. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  19522. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  19523. */
  19524. useParallaxOcclusion: boolean;
  19525. /**
  19526. * 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.
  19527. */
  19528. parallaxScaleBias: number;
  19529. private _roughness;
  19530. /**
  19531. * Helps to define how blurry the reflections should appears in the material.
  19532. */
  19533. roughness: number;
  19534. /**
  19535. * In case of refraction, define the value of the indice of refraction.
  19536. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19537. */
  19538. indexOfRefraction: number;
  19539. /**
  19540. * Invert the refraction texture alongside the y axis.
  19541. * It can be useful with procedural textures or probe for instance.
  19542. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19543. */
  19544. invertRefractionY: boolean;
  19545. /**
  19546. * Defines the alpha limits in alpha test mode.
  19547. */
  19548. alphaCutOff: number;
  19549. private _useLightmapAsShadowmap;
  19550. /**
  19551. * In case of light mapping, define whether the map contains light or shadow informations.
  19552. */
  19553. useLightmapAsShadowmap: boolean;
  19554. private _diffuseFresnelParameters;
  19555. /**
  19556. * Define the diffuse fresnel parameters of the material.
  19557. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19558. */
  19559. diffuseFresnelParameters: FresnelParameters;
  19560. private _opacityFresnelParameters;
  19561. /**
  19562. * Define the opacity fresnel parameters of the material.
  19563. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19564. */
  19565. opacityFresnelParameters: FresnelParameters;
  19566. private _reflectionFresnelParameters;
  19567. /**
  19568. * Define the reflection fresnel parameters of the material.
  19569. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19570. */
  19571. reflectionFresnelParameters: FresnelParameters;
  19572. private _refractionFresnelParameters;
  19573. /**
  19574. * Define the refraction fresnel parameters of the material.
  19575. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19576. */
  19577. refractionFresnelParameters: FresnelParameters;
  19578. private _emissiveFresnelParameters;
  19579. /**
  19580. * Define the emissive fresnel parameters of the material.
  19581. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19582. */
  19583. emissiveFresnelParameters: FresnelParameters;
  19584. private _useReflectionFresnelFromSpecular;
  19585. /**
  19586. * If true automatically deducts the fresnels values from the material specularity.
  19587. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19588. */
  19589. useReflectionFresnelFromSpecular: boolean;
  19590. private _useGlossinessFromSpecularMapAlpha;
  19591. /**
  19592. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  19593. */
  19594. useGlossinessFromSpecularMapAlpha: boolean;
  19595. private _maxSimultaneousLights;
  19596. /**
  19597. * Defines the maximum number of lights that can be used in the material
  19598. */
  19599. maxSimultaneousLights: number;
  19600. private _invertNormalMapX;
  19601. /**
  19602. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  19603. */
  19604. invertNormalMapX: boolean;
  19605. private _invertNormalMapY;
  19606. /**
  19607. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  19608. */
  19609. invertNormalMapY: boolean;
  19610. private _twoSidedLighting;
  19611. /**
  19612. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  19613. */
  19614. twoSidedLighting: boolean;
  19615. /**
  19616. * Default configuration related to image processing available in the standard Material.
  19617. */
  19618. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  19619. /**
  19620. * Gets the image processing configuration used either in this material.
  19621. */
  19622. /**
  19623. * Sets the Default image processing configuration used either in the this material.
  19624. *
  19625. * If sets to null, the scene one is in use.
  19626. */
  19627. imageProcessingConfiguration: ImageProcessingConfiguration;
  19628. /**
  19629. * Keep track of the image processing observer to allow dispose and replace.
  19630. */
  19631. private _imageProcessingObserver;
  19632. /**
  19633. * Attaches a new image processing configuration to the Standard Material.
  19634. * @param configuration
  19635. */
  19636. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  19637. /**
  19638. * Gets wether the color curves effect is enabled.
  19639. */
  19640. /**
  19641. * Sets wether the color curves effect is enabled.
  19642. */
  19643. cameraColorCurvesEnabled: boolean;
  19644. /**
  19645. * Gets wether the color grading effect is enabled.
  19646. */
  19647. /**
  19648. * Gets wether the color grading effect is enabled.
  19649. */
  19650. cameraColorGradingEnabled: boolean;
  19651. /**
  19652. * Gets wether tonemapping is enabled or not.
  19653. */
  19654. /**
  19655. * Sets wether tonemapping is enabled or not
  19656. */
  19657. cameraToneMappingEnabled: boolean;
  19658. /**
  19659. * The camera exposure used on this material.
  19660. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  19661. * This corresponds to a photographic exposure.
  19662. */
  19663. /**
  19664. * The camera exposure used on this material.
  19665. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  19666. * This corresponds to a photographic exposure.
  19667. */
  19668. cameraExposure: number;
  19669. /**
  19670. * Gets The camera contrast used on this material.
  19671. */
  19672. /**
  19673. * Sets The camera contrast used on this material.
  19674. */
  19675. cameraContrast: number;
  19676. /**
  19677. * Gets the Color Grading 2D Lookup Texture.
  19678. */
  19679. /**
  19680. * Sets the Color Grading 2D Lookup Texture.
  19681. */
  19682. cameraColorGradingTexture: Nullable<BaseTexture>;
  19683. /**
  19684. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  19685. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19686. * 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;
  19687. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19688. */
  19689. /**
  19690. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  19691. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19692. * 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;
  19693. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19694. */
  19695. cameraColorCurves: Nullable<ColorCurves>;
  19696. /**
  19697. * Custom callback helping to override the default shader used in the material.
  19698. */
  19699. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  19700. protected _renderTargets: SmartArray<RenderTargetTexture>;
  19701. protected _worldViewProjectionMatrix: Matrix;
  19702. protected _globalAmbientColor: Color3;
  19703. protected _useLogarithmicDepth: boolean;
  19704. /**
  19705. * Instantiates a new standard material.
  19706. * This is the default material used in Babylon. It is the best trade off between quality
  19707. * and performances.
  19708. * @see http://doc.babylonjs.com/babylon101/materials
  19709. * @param name Define the name of the material in the scene
  19710. * @param scene Define the scene the material belong to
  19711. */
  19712. constructor(name: string, scene: Scene);
  19713. /**
  19714. * Gets a boolean indicating that current material needs to register RTT
  19715. */
  19716. readonly hasRenderTargetTextures: boolean;
  19717. /**
  19718. * Gets the current class name of the material e.g. "StandardMaterial"
  19719. * Mainly use in serialization.
  19720. * @returns the class name
  19721. */
  19722. getClassName(): string;
  19723. /**
  19724. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  19725. * You can try switching to logarithmic depth.
  19726. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  19727. */
  19728. useLogarithmicDepth: boolean;
  19729. /**
  19730. * Specifies if the material will require alpha blending
  19731. * @returns a boolean specifying if alpha blending is needed
  19732. */
  19733. needAlphaBlending(): boolean;
  19734. /**
  19735. * Specifies if this material should be rendered in alpha test mode
  19736. * @returns a boolean specifying if an alpha test is needed.
  19737. */
  19738. needAlphaTesting(): boolean;
  19739. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  19740. /**
  19741. * Get the texture used for alpha test purpose.
  19742. * @returns the diffuse texture in case of the standard material.
  19743. */
  19744. getAlphaTestTexture(): Nullable<BaseTexture>;
  19745. /**
  19746. * Get if the submesh is ready to be used and all its information available.
  19747. * Child classes can use it to update shaders
  19748. * @param mesh defines the mesh to check
  19749. * @param subMesh defines which submesh to check
  19750. * @param useInstances specifies that instances should be used
  19751. * @returns a boolean indicating that the submesh is ready or not
  19752. */
  19753. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  19754. /**
  19755. * Builds the material UBO layouts.
  19756. * Used internally during the effect preparation.
  19757. */
  19758. buildUniformLayout(): void;
  19759. /**
  19760. * Unbinds the material from the mesh
  19761. */
  19762. unbind(): void;
  19763. /**
  19764. * Binds the submesh to this material by preparing the effect and shader to draw
  19765. * @param world defines the world transformation matrix
  19766. * @param mesh defines the mesh containing the submesh
  19767. * @param subMesh defines the submesh to bind the material to
  19768. */
  19769. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  19770. /**
  19771. * Get the list of animatables in the material.
  19772. * @returns the list of animatables object used in the material
  19773. */
  19774. getAnimatables(): IAnimatable[];
  19775. /**
  19776. * Gets the active textures from the material
  19777. * @returns an array of textures
  19778. */
  19779. getActiveTextures(): BaseTexture[];
  19780. /**
  19781. * Specifies if the material uses a texture
  19782. * @param texture defines the texture to check against the material
  19783. * @returns a boolean specifying if the material uses the texture
  19784. */
  19785. hasTexture(texture: BaseTexture): boolean;
  19786. /**
  19787. * Disposes the material
  19788. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19789. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19790. */
  19791. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  19792. /**
  19793. * Makes a duplicate of the material, and gives it a new name
  19794. * @param name defines the new name for the duplicated material
  19795. * @returns the cloned material
  19796. */
  19797. clone(name: string): StandardMaterial;
  19798. /**
  19799. * Serializes this material in a JSON representation
  19800. * @returns the serialized material object
  19801. */
  19802. serialize(): any;
  19803. /**
  19804. * Creates a standard material from parsed material data
  19805. * @param source defines the JSON represnetation of the material
  19806. * @param scene defines the hosting scene
  19807. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19808. * @returns a new material
  19809. */
  19810. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  19811. private static _DiffuseTextureEnabled;
  19812. /**
  19813. * Are diffuse textures enabled in the application.
  19814. */
  19815. static DiffuseTextureEnabled: boolean;
  19816. private static _AmbientTextureEnabled;
  19817. /**
  19818. * Are ambient textures enabled in the application.
  19819. */
  19820. static AmbientTextureEnabled: boolean;
  19821. private static _OpacityTextureEnabled;
  19822. /**
  19823. * Are opacity textures enabled in the application.
  19824. */
  19825. static OpacityTextureEnabled: boolean;
  19826. private static _ReflectionTextureEnabled;
  19827. /**
  19828. * Are reflection textures enabled in the application.
  19829. */
  19830. static ReflectionTextureEnabled: boolean;
  19831. private static _EmissiveTextureEnabled;
  19832. /**
  19833. * Are emissive textures enabled in the application.
  19834. */
  19835. static EmissiveTextureEnabled: boolean;
  19836. private static _SpecularTextureEnabled;
  19837. /**
  19838. * Are specular textures enabled in the application.
  19839. */
  19840. static SpecularTextureEnabled: boolean;
  19841. private static _BumpTextureEnabled;
  19842. /**
  19843. * Are bump textures enabled in the application.
  19844. */
  19845. static BumpTextureEnabled: boolean;
  19846. private static _LightmapTextureEnabled;
  19847. /**
  19848. * Are lightmap textures enabled in the application.
  19849. */
  19850. static LightmapTextureEnabled: boolean;
  19851. private static _RefractionTextureEnabled;
  19852. /**
  19853. * Are refraction textures enabled in the application.
  19854. */
  19855. static RefractionTextureEnabled: boolean;
  19856. private static _ColorGradingTextureEnabled;
  19857. /**
  19858. * Are color grading textures enabled in the application.
  19859. */
  19860. static ColorGradingTextureEnabled: boolean;
  19861. private static _FresnelEnabled;
  19862. /**
  19863. * Are fresnels enabled in the application.
  19864. */
  19865. static FresnelEnabled: boolean;
  19866. }
  19867. }
  19868. declare module BABYLON {
  19869. /**
  19870. * Uniform buffer objects.
  19871. *
  19872. * Handles blocks of uniform on the GPU.
  19873. *
  19874. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  19875. *
  19876. * For more information, please refer to :
  19877. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  19878. */
  19879. class UniformBuffer {
  19880. private _engine;
  19881. private _buffer;
  19882. private _data;
  19883. private _bufferData;
  19884. private _dynamic?;
  19885. private _uniformLocations;
  19886. private _uniformSizes;
  19887. private _uniformLocationPointer;
  19888. private _needSync;
  19889. private _noUBO;
  19890. private _currentEffect;
  19891. private static _MAX_UNIFORM_SIZE;
  19892. private static _tempBuffer;
  19893. /**
  19894. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  19895. * This is dynamic to allow compat with webgl 1 and 2.
  19896. * You will need to pass the name of the uniform as well as the value.
  19897. */
  19898. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  19899. /**
  19900. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  19901. * This is dynamic to allow compat with webgl 1 and 2.
  19902. * You will need to pass the name of the uniform as well as the value.
  19903. */
  19904. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  19905. /**
  19906. * Lambda to Update a single float in a uniform buffer.
  19907. * This is dynamic to allow compat with webgl 1 and 2.
  19908. * You will need to pass the name of the uniform as well as the value.
  19909. */
  19910. updateFloat: (name: string, x: number) => void;
  19911. /**
  19912. * Lambda to Update a vec2 of float in a uniform buffer.
  19913. * This is dynamic to allow compat with webgl 1 and 2.
  19914. * You will need to pass the name of the uniform as well as the value.
  19915. */
  19916. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  19917. /**
  19918. * Lambda to Update a vec3 of float in a uniform buffer.
  19919. * This is dynamic to allow compat with webgl 1 and 2.
  19920. * You will need to pass the name of the uniform as well as the value.
  19921. */
  19922. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  19923. /**
  19924. * Lambda to Update a vec4 of float in a uniform buffer.
  19925. * This is dynamic to allow compat with webgl 1 and 2.
  19926. * You will need to pass the name of the uniform as well as the value.
  19927. */
  19928. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  19929. /**
  19930. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  19931. * This is dynamic to allow compat with webgl 1 and 2.
  19932. * You will need to pass the name of the uniform as well as the value.
  19933. */
  19934. updateMatrix: (name: string, mat: Matrix) => void;
  19935. /**
  19936. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  19937. * This is dynamic to allow compat with webgl 1 and 2.
  19938. * You will need to pass the name of the uniform as well as the value.
  19939. */
  19940. updateVector3: (name: string, vector: Vector3) => void;
  19941. /**
  19942. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  19943. * This is dynamic to allow compat with webgl 1 and 2.
  19944. * You will need to pass the name of the uniform as well as the value.
  19945. */
  19946. updateVector4: (name: string, vector: Vector4) => void;
  19947. /**
  19948. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  19949. * This is dynamic to allow compat with webgl 1 and 2.
  19950. * You will need to pass the name of the uniform as well as the value.
  19951. */
  19952. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  19953. /**
  19954. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  19955. * This is dynamic to allow compat with webgl 1 and 2.
  19956. * You will need to pass the name of the uniform as well as the value.
  19957. */
  19958. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  19959. /**
  19960. * Instantiates a new Uniform buffer objects.
  19961. *
  19962. * Handles blocks of uniform on the GPU.
  19963. *
  19964. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  19965. *
  19966. * For more information, please refer to :
  19967. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  19968. * @param engine Define the engine the buffer is associated with
  19969. * @param data Define the data contained in the buffer
  19970. * @param dynamic Define if the buffer is updatable
  19971. */
  19972. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  19973. /**
  19974. * Indicates if the buffer is using the WebGL2 UBO implementation,
  19975. * or just falling back on setUniformXXX calls.
  19976. */
  19977. readonly useUbo: boolean;
  19978. /**
  19979. * Indicates if the WebGL underlying uniform buffer is in sync
  19980. * with the javascript cache data.
  19981. */
  19982. readonly isSync: boolean;
  19983. /**
  19984. * Indicates if the WebGL underlying uniform buffer is dynamic.
  19985. * Also, a dynamic UniformBuffer will disable cache verification and always
  19986. * update the underlying WebGL uniform buffer to the GPU.
  19987. * @returns if Dynamic, otherwise false
  19988. */
  19989. isDynamic(): boolean;
  19990. /**
  19991. * The data cache on JS side.
  19992. * @returns the underlying data as a float array
  19993. */
  19994. getData(): Float32Array;
  19995. /**
  19996. * The underlying WebGL Uniform buffer.
  19997. * @returns the webgl buffer
  19998. */
  19999. getBuffer(): Nullable<WebGLBuffer>;
  20000. /**
  20001. * std140 layout specifies how to align data within an UBO structure.
  20002. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  20003. * for specs.
  20004. */
  20005. private _fillAlignment;
  20006. /**
  20007. * Adds an uniform in the buffer.
  20008. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  20009. * for the layout to be correct !
  20010. * @param name Name of the uniform, as used in the uniform block in the shader.
  20011. * @param size Data size, or data directly.
  20012. */
  20013. addUniform(name: string, size: number | number[]): void;
  20014. /**
  20015. * Adds a Matrix 4x4 to the uniform buffer.
  20016. * @param name Name of the uniform, as used in the uniform block in the shader.
  20017. * @param mat A 4x4 matrix.
  20018. */
  20019. addMatrix(name: string, mat: Matrix): void;
  20020. /**
  20021. * Adds a vec2 to the uniform buffer.
  20022. * @param name Name of the uniform, as used in the uniform block in the shader.
  20023. * @param x Define the x component value of the vec2
  20024. * @param y Define the y component value of the vec2
  20025. */
  20026. addFloat2(name: string, x: number, y: number): void;
  20027. /**
  20028. * Adds a vec3 to the uniform buffer.
  20029. * @param name Name of the uniform, as used in the uniform block in the shader.
  20030. * @param x Define the x component value of the vec3
  20031. * @param y Define the y component value of the vec3
  20032. * @param z Define the z component value of the vec3
  20033. */
  20034. addFloat3(name: string, x: number, y: number, z: number): void;
  20035. /**
  20036. * Adds a vec3 to the uniform buffer.
  20037. * @param name Name of the uniform, as used in the uniform block in the shader.
  20038. * @param color Define the vec3 from a Color
  20039. */
  20040. addColor3(name: string, color: Color3): void;
  20041. /**
  20042. * Adds a vec4 to the uniform buffer.
  20043. * @param name Name of the uniform, as used in the uniform block in the shader.
  20044. * @param color Define the rgb components from a Color
  20045. * @param alpha Define the a component of the vec4
  20046. */
  20047. addColor4(name: string, color: Color3, alpha: number): void;
  20048. /**
  20049. * Adds a vec3 to the uniform buffer.
  20050. * @param name Name of the uniform, as used in the uniform block in the shader.
  20051. * @param vector Define the vec3 components from a Vector
  20052. */
  20053. addVector3(name: string, vector: Vector3): void;
  20054. /**
  20055. * Adds a Matrix 3x3 to the uniform buffer.
  20056. * @param name Name of the uniform, as used in the uniform block in the shader.
  20057. */
  20058. addMatrix3x3(name: string): void;
  20059. /**
  20060. * Adds a Matrix 2x2 to the uniform buffer.
  20061. * @param name Name of the uniform, as used in the uniform block in the shader.
  20062. */
  20063. addMatrix2x2(name: string): void;
  20064. /**
  20065. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  20066. */
  20067. create(): void;
  20068. /** @hidden */
  20069. _rebuild(): void;
  20070. /**
  20071. * Updates the WebGL Uniform Buffer on the GPU.
  20072. * If the `dynamic` flag is set to true, no cache comparison is done.
  20073. * Otherwise, the buffer will be updated only if the cache differs.
  20074. */
  20075. update(): void;
  20076. /**
  20077. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  20078. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  20079. * @param data Define the flattened data
  20080. * @param size Define the size of the data.
  20081. */
  20082. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  20083. private _updateMatrix3x3ForUniform;
  20084. private _updateMatrix3x3ForEffect;
  20085. private _updateMatrix2x2ForEffect;
  20086. private _updateMatrix2x2ForUniform;
  20087. private _updateFloatForEffect;
  20088. private _updateFloatForUniform;
  20089. private _updateFloat2ForEffect;
  20090. private _updateFloat2ForUniform;
  20091. private _updateFloat3ForEffect;
  20092. private _updateFloat3ForUniform;
  20093. private _updateFloat4ForEffect;
  20094. private _updateFloat4ForUniform;
  20095. private _updateMatrixForEffect;
  20096. private _updateMatrixForUniform;
  20097. private _updateVector3ForEffect;
  20098. private _updateVector3ForUniform;
  20099. private _updateVector4ForEffect;
  20100. private _updateVector4ForUniform;
  20101. private _updateColor3ForEffect;
  20102. private _updateColor3ForUniform;
  20103. private _updateColor4ForEffect;
  20104. private _updateColor4ForUniform;
  20105. /**
  20106. * Sets a sampler uniform on the effect.
  20107. * @param name Define the name of the sampler.
  20108. * @param texture Define the texture to set in the sampler
  20109. */
  20110. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  20111. /**
  20112. * Directly updates the value of the uniform in the cache AND on the GPU.
  20113. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  20114. * @param data Define the flattened data
  20115. */
  20116. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  20117. /**
  20118. * Binds this uniform buffer to an effect.
  20119. * @param effect Define the effect to bind the buffer to
  20120. * @param name Name of the uniform block in the shader.
  20121. */
  20122. bindToEffect(effect: Effect, name: string): void;
  20123. /**
  20124. * Disposes the uniform buffer.
  20125. */
  20126. dispose(): void;
  20127. }
  20128. }
  20129. declare module BABYLON {
  20130. /**
  20131. * Scalar computation library
  20132. */
  20133. class Scalar {
  20134. /**
  20135. * Two pi constants convenient for computation.
  20136. */
  20137. static TwoPi: number;
  20138. /**
  20139. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  20140. * @param a number
  20141. * @param b number
  20142. * @param epsilon (default = 1.401298E-45)
  20143. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  20144. */
  20145. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  20146. /**
  20147. * Returns a string : the upper case translation of the number i to hexadecimal.
  20148. * @param i number
  20149. * @returns the upper case translation of the number i to hexadecimal.
  20150. */
  20151. static ToHex(i: number): string;
  20152. /**
  20153. * Returns -1 if value is negative and +1 is value is positive.
  20154. * @param value the value
  20155. * @returns the value itself if it's equal to zero.
  20156. */
  20157. static Sign(value: number): number;
  20158. /**
  20159. * Returns the value itself if it's between min and max.
  20160. * Returns min if the value is lower than min.
  20161. * Returns max if the value is greater than max.
  20162. * @param value the value to clmap
  20163. * @param min the min value to clamp to (default: 0)
  20164. * @param max the max value to clamp to (default: 1)
  20165. * @returns the clamped value
  20166. */
  20167. static Clamp(value: number, min?: number, max?: number): number;
  20168. /**
  20169. * the log2 of value.
  20170. * @param value the value to compute log2 of
  20171. * @returns the log2 of value.
  20172. */
  20173. static Log2(value: number): number;
  20174. /**
  20175. * Loops the value, so that it is never larger than length and never smaller than 0.
  20176. *
  20177. * This is similar to the modulo operator but it works with floating point numbers.
  20178. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  20179. * With t = 5 and length = 2.5, the result would be 0.0.
  20180. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  20181. * @param value the value
  20182. * @param length the length
  20183. * @returns the looped value
  20184. */
  20185. static Repeat(value: number, length: number): number;
  20186. /**
  20187. * Normalize the value between 0.0 and 1.0 using min and max values
  20188. * @param value value to normalize
  20189. * @param min max to normalize between
  20190. * @param max min to normalize between
  20191. * @returns the normalized value
  20192. */
  20193. static Normalize(value: number, min: number, max: number): number;
  20194. /**
  20195. * Denormalize the value from 0.0 and 1.0 using min and max values
  20196. * @param normalized value to denormalize
  20197. * @param min max to denormalize between
  20198. * @param max min to denormalize between
  20199. * @returns the denormalized value
  20200. */
  20201. static Denormalize(normalized: number, min: number, max: number): number;
  20202. /**
  20203. * Calculates the shortest difference between two given angles given in degrees.
  20204. * @param current current angle in degrees
  20205. * @param target target angle in degrees
  20206. * @returns the delta
  20207. */
  20208. static DeltaAngle(current: number, target: number): number;
  20209. /**
  20210. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  20211. * @param tx value
  20212. * @param length length
  20213. * @returns The returned value will move back and forth between 0 and length
  20214. */
  20215. static PingPong(tx: number, length: number): number;
  20216. /**
  20217. * Interpolates between min and max with smoothing at the limits.
  20218. *
  20219. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  20220. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  20221. * @param from from
  20222. * @param to to
  20223. * @param tx value
  20224. * @returns the smooth stepped value
  20225. */
  20226. static SmoothStep(from: number, to: number, tx: number): number;
  20227. /**
  20228. * Moves a value current towards target.
  20229. *
  20230. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  20231. * Negative values of maxDelta pushes the value away from target.
  20232. * @param current current value
  20233. * @param target target value
  20234. * @param maxDelta max distance to move
  20235. * @returns resulting value
  20236. */
  20237. static MoveTowards(current: number, target: number, maxDelta: number): number;
  20238. /**
  20239. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  20240. *
  20241. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  20242. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  20243. * @param current current value
  20244. * @param target target value
  20245. * @param maxDelta max distance to move
  20246. * @returns resulting angle
  20247. */
  20248. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  20249. /**
  20250. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  20251. * @param start start value
  20252. * @param end target value
  20253. * @param amount amount to lerp between
  20254. * @returns the lerped value
  20255. */
  20256. static Lerp(start: number, end: number, amount: number): number;
  20257. /**
  20258. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  20259. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  20260. * @param start start value
  20261. * @param end target value
  20262. * @param amount amount to lerp between
  20263. * @returns the lerped value
  20264. */
  20265. static LerpAngle(start: number, end: number, amount: number): number;
  20266. /**
  20267. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  20268. * @param a start value
  20269. * @param b target value
  20270. * @param value value between a and b
  20271. * @returns the inverseLerp value
  20272. */
  20273. static InverseLerp(a: number, b: number, value: number): number;
  20274. /**
  20275. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  20276. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  20277. * @param value1 spline value
  20278. * @param tangent1 spline value
  20279. * @param value2 spline value
  20280. * @param tangent2 spline value
  20281. * @param amount input value
  20282. * @returns hermite result
  20283. */
  20284. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  20285. /**
  20286. * Returns a random float number between and min and max values
  20287. * @param min min value of random
  20288. * @param max max value of random
  20289. * @returns random value
  20290. */
  20291. static RandomRange(min: number, max: number): number;
  20292. /**
  20293. * This function returns percentage of a number in a given range.
  20294. *
  20295. * RangeToPercent(40,20,60) will return 0.5 (50%)
  20296. * RangeToPercent(34,0,100) will return 0.34 (34%)
  20297. * @param number to convert to percentage
  20298. * @param min min range
  20299. * @param max max range
  20300. * @returns the percentage
  20301. */
  20302. static RangeToPercent(number: number, min: number, max: number): number;
  20303. /**
  20304. * This function returns number that corresponds to the percentage in a given range.
  20305. *
  20306. * PercentToRange(0.34,0,100) will return 34.
  20307. * @param percent to convert to number
  20308. * @param min min range
  20309. * @param max max range
  20310. * @returns the number
  20311. */
  20312. static PercentToRange(percent: number, min: number, max: number): number;
  20313. /**
  20314. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  20315. * @param angle The angle to normalize in radian.
  20316. * @return The converted angle.
  20317. */
  20318. static NormalizeRadians(angle: number): number;
  20319. }
  20320. }
  20321. declare module BABYLON {
  20322. /**
  20323. * Constant used to convert a value to gamma space
  20324. * @ignorenaming
  20325. */
  20326. const ToGammaSpace: number;
  20327. /**
  20328. * Constant used to convert a value to linear space
  20329. * @ignorenaming
  20330. */
  20331. const ToLinearSpace = 2.2;
  20332. /**
  20333. * Constant used to define the minimal number value in Babylon.js
  20334. * @ignorenaming
  20335. */
  20336. const Epsilon = 0.001;
  20337. /**
  20338. * Class used to hold a RBG color
  20339. */
  20340. class Color3 {
  20341. /**
  20342. * Defines the red component (between 0 and 1, default is 0)
  20343. */
  20344. r: number;
  20345. /**
  20346. * Defines the green component (between 0 and 1, default is 0)
  20347. */
  20348. g: number;
  20349. /**
  20350. * Defines the blue component (between 0 and 1, default is 0)
  20351. */
  20352. b: number;
  20353. /**
  20354. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  20355. * @param r defines the red component (between 0 and 1, default is 0)
  20356. * @param g defines the green component (between 0 and 1, default is 0)
  20357. * @param b defines the blue component (between 0 and 1, default is 0)
  20358. */
  20359. constructor(
  20360. /**
  20361. * Defines the red component (between 0 and 1, default is 0)
  20362. */
  20363. r?: number,
  20364. /**
  20365. * Defines the green component (between 0 and 1, default is 0)
  20366. */
  20367. g?: number,
  20368. /**
  20369. * Defines the blue component (between 0 and 1, default is 0)
  20370. */
  20371. b?: number);
  20372. /**
  20373. * Creates a string with the Color3 current values
  20374. * @returns the string representation of the Color3 object
  20375. */
  20376. toString(): string;
  20377. /**
  20378. * Returns the string "Color3"
  20379. * @returns "Color3"
  20380. */
  20381. getClassName(): string;
  20382. /**
  20383. * Compute the Color3 hash code
  20384. * @returns an unique number that can be used to hash Color3 objects
  20385. */
  20386. getHashCode(): number;
  20387. /**
  20388. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  20389. * @param array defines the array where to store the r,g,b components
  20390. * @param index defines an optional index in the target array to define where to start storing values
  20391. * @returns the current Color3 object
  20392. */
  20393. toArray(array: FloatArray, index?: number): Color3;
  20394. /**
  20395. * Returns a new Color4 object from the current Color3 and the given alpha
  20396. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  20397. * @returns a new Color4 object
  20398. */
  20399. toColor4(alpha?: number): Color4;
  20400. /**
  20401. * Returns a new array populated with 3 numeric elements : red, green and blue values
  20402. * @returns the new array
  20403. */
  20404. asArray(): number[];
  20405. /**
  20406. * Returns the luminance value
  20407. * @returns a float value
  20408. */
  20409. toLuminance(): number;
  20410. /**
  20411. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  20412. * @param otherColor defines the second operand
  20413. * @returns the new Color3 object
  20414. */
  20415. multiply(otherColor: DeepImmutable<Color3>): Color3;
  20416. /**
  20417. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  20418. * @param otherColor defines the second operand
  20419. * @param result defines the Color3 object where to store the result
  20420. * @returns the current Color3
  20421. */
  20422. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  20423. /**
  20424. * Determines equality between Color3 objects
  20425. * @param otherColor defines the second operand
  20426. * @returns true if the rgb values are equal to the given ones
  20427. */
  20428. equals(otherColor: DeepImmutable<Color3>): boolean;
  20429. /**
  20430. * Determines equality between the current Color3 object and a set of r,b,g values
  20431. * @param r defines the red component to check
  20432. * @param g defines the green component to check
  20433. * @param b defines the blue component to check
  20434. * @returns true if the rgb values are equal to the given ones
  20435. */
  20436. equalsFloats(r: number, g: number, b: number): boolean;
  20437. /**
  20438. * Multiplies in place each rgb value by scale
  20439. * @param scale defines the scaling factor
  20440. * @returns the updated Color3
  20441. */
  20442. scale(scale: number): Color3;
  20443. /**
  20444. * Multiplies the rgb values by scale and stores the result into "result"
  20445. * @param scale defines the scaling factor
  20446. * @param result defines the Color3 object where to store the result
  20447. * @returns the unmodified current Color3
  20448. */
  20449. scaleToRef(scale: number, result: Color3): Color3;
  20450. /**
  20451. * Scale the current Color3 values by a factor and add the result to a given Color3
  20452. * @param scale defines the scale factor
  20453. * @param result defines color to store the result into
  20454. * @returns the unmodified current Color3
  20455. */
  20456. scaleAndAddToRef(scale: number, result: Color3): Color3;
  20457. /**
  20458. * Clamps the rgb values by the min and max values and stores the result into "result"
  20459. * @param min defines minimum clamping value (default is 0)
  20460. * @param max defines maximum clamping value (default is 1)
  20461. * @param result defines color to store the result into
  20462. * @returns the original Color3
  20463. */
  20464. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  20465. /**
  20466. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  20467. * @param otherColor defines the second operand
  20468. * @returns the new Color3
  20469. */
  20470. add(otherColor: DeepImmutable<Color3>): Color3;
  20471. /**
  20472. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  20473. * @param otherColor defines the second operand
  20474. * @param result defines Color3 object to store the result into
  20475. * @returns the unmodified current Color3
  20476. */
  20477. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  20478. /**
  20479. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  20480. * @param otherColor defines the second operand
  20481. * @returns the new Color3
  20482. */
  20483. subtract(otherColor: DeepImmutable<Color3>): Color3;
  20484. /**
  20485. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  20486. * @param otherColor defines the second operand
  20487. * @param result defines Color3 object to store the result into
  20488. * @returns the unmodified current Color3
  20489. */
  20490. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  20491. /**
  20492. * Copy the current object
  20493. * @returns a new Color3 copied the current one
  20494. */
  20495. clone(): Color3;
  20496. /**
  20497. * Copies the rgb values from the source in the current Color3
  20498. * @param source defines the source Color3 object
  20499. * @returns the updated Color3 object
  20500. */
  20501. copyFrom(source: DeepImmutable<Color3>): Color3;
  20502. /**
  20503. * Updates the Color3 rgb values from the given floats
  20504. * @param r defines the red component to read from
  20505. * @param g defines the green component to read from
  20506. * @param b defines the blue component to read from
  20507. * @returns the current Color3 object
  20508. */
  20509. copyFromFloats(r: number, g: number, b: number): Color3;
  20510. /**
  20511. * Updates the Color3 rgb values from the given floats
  20512. * @param r defines the red component to read from
  20513. * @param g defines the green component to read from
  20514. * @param b defines the blue component to read from
  20515. * @returns the current Color3 object
  20516. */
  20517. set(r: number, g: number, b: number): Color3;
  20518. /**
  20519. * Compute the Color3 hexadecimal code as a string
  20520. * @returns a string containing the hexadecimal representation of the Color3 object
  20521. */
  20522. toHexString(): string;
  20523. /**
  20524. * Computes a new Color3 converted from the current one to linear space
  20525. * @returns a new Color3 object
  20526. */
  20527. toLinearSpace(): Color3;
  20528. /**
  20529. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  20530. * @param convertedColor defines the Color3 object where to store the linear space version
  20531. * @returns the unmodified Color3
  20532. */
  20533. toLinearSpaceToRef(convertedColor: Color3): Color3;
  20534. /**
  20535. * Computes a new Color3 converted from the current one to gamma space
  20536. * @returns a new Color3 object
  20537. */
  20538. toGammaSpace(): Color3;
  20539. /**
  20540. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  20541. * @param convertedColor defines the Color3 object where to store the gamma space version
  20542. * @returns the unmodified Color3
  20543. */
  20544. toGammaSpaceToRef(convertedColor: Color3): Color3;
  20545. /**
  20546. * Creates a new Color3 from the string containing valid hexadecimal values
  20547. * @param hex defines a string containing valid hexadecimal values
  20548. * @returns a new Color3 object
  20549. */
  20550. static FromHexString(hex: string): Color3;
  20551. /**
  20552. * Creates a new Vector3 from the starting index of the given array
  20553. * @param array defines the source array
  20554. * @param offset defines an offset in the source array
  20555. * @returns a new Color3 object
  20556. */
  20557. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  20558. /**
  20559. * Creates a new Color3 from integer values (< 256)
  20560. * @param r defines the red component to read from (value between 0 and 255)
  20561. * @param g defines the green component to read from (value between 0 and 255)
  20562. * @param b defines the blue component to read from (value between 0 and 255)
  20563. * @returns a new Color3 object
  20564. */
  20565. static FromInts(r: number, g: number, b: number): Color3;
  20566. /**
  20567. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  20568. * @param start defines the start Color3 value
  20569. * @param end defines the end Color3 value
  20570. * @param amount defines the gradient value between start and end
  20571. * @returns a new Color3 object
  20572. */
  20573. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  20574. /**
  20575. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  20576. * @param left defines the start value
  20577. * @param right defines the end value
  20578. * @param amount defines the gradient factor
  20579. * @param result defines the Color3 object where to store the result
  20580. */
  20581. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  20582. /**
  20583. * Returns a Color3 value containing a red color
  20584. * @returns a new Color3 object
  20585. */
  20586. static Red(): Color3;
  20587. /**
  20588. * Returns a Color3 value containing a green color
  20589. * @returns a new Color3 object
  20590. */
  20591. static Green(): Color3;
  20592. /**
  20593. * Returns a Color3 value containing a blue color
  20594. * @returns a new Color3 object
  20595. */
  20596. static Blue(): Color3;
  20597. /**
  20598. * Returns a Color3 value containing a black color
  20599. * @returns a new Color3 object
  20600. */
  20601. static Black(): Color3;
  20602. /**
  20603. * Returns a Color3 value containing a white color
  20604. * @returns a new Color3 object
  20605. */
  20606. static White(): Color3;
  20607. /**
  20608. * Returns a Color3 value containing a purple color
  20609. * @returns a new Color3 object
  20610. */
  20611. static Purple(): Color3;
  20612. /**
  20613. * Returns a Color3 value containing a magenta color
  20614. * @returns a new Color3 object
  20615. */
  20616. static Magenta(): Color3;
  20617. /**
  20618. * Returns a Color3 value containing a yellow color
  20619. * @returns a new Color3 object
  20620. */
  20621. static Yellow(): Color3;
  20622. /**
  20623. * Returns a Color3 value containing a gray color
  20624. * @returns a new Color3 object
  20625. */
  20626. static Gray(): Color3;
  20627. /**
  20628. * Returns a Color3 value containing a teal color
  20629. * @returns a new Color3 object
  20630. */
  20631. static Teal(): Color3;
  20632. /**
  20633. * Returns a Color3 value containing a random color
  20634. * @returns a new Color3 object
  20635. */
  20636. static Random(): Color3;
  20637. }
  20638. /**
  20639. * Class used to hold a RBGA color
  20640. */
  20641. class Color4 {
  20642. /**
  20643. * Defines the red component (between 0 and 1, default is 0)
  20644. */
  20645. r: number;
  20646. /**
  20647. * Defines the green component (between 0 and 1, default is 0)
  20648. */
  20649. g: number;
  20650. /**
  20651. * Defines the blue component (between 0 and 1, default is 0)
  20652. */
  20653. b: number;
  20654. /**
  20655. * Defines the alpha component (between 0 and 1, default is 1)
  20656. */
  20657. a: number;
  20658. /**
  20659. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  20660. * @param r defines the red component (between 0 and 1, default is 0)
  20661. * @param g defines the green component (between 0 and 1, default is 0)
  20662. * @param b defines the blue component (between 0 and 1, default is 0)
  20663. * @param a defines the alpha component (between 0 and 1, default is 1)
  20664. */
  20665. constructor(
  20666. /**
  20667. * Defines the red component (between 0 and 1, default is 0)
  20668. */
  20669. r?: number,
  20670. /**
  20671. * Defines the green component (between 0 and 1, default is 0)
  20672. */
  20673. g?: number,
  20674. /**
  20675. * Defines the blue component (between 0 and 1, default is 0)
  20676. */
  20677. b?: number,
  20678. /**
  20679. * Defines the alpha component (between 0 and 1, default is 1)
  20680. */
  20681. a?: number);
  20682. /**
  20683. * Adds in place the given Color4 values to the current Color4 object
  20684. * @param right defines the second operand
  20685. * @returns the current updated Color4 object
  20686. */
  20687. addInPlace(right: DeepImmutable<Color4>): Color4;
  20688. /**
  20689. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  20690. * @returns the new array
  20691. */
  20692. asArray(): number[];
  20693. /**
  20694. * Stores from the starting index in the given array the Color4 successive values
  20695. * @param array defines the array where to store the r,g,b components
  20696. * @param index defines an optional index in the target array to define where to start storing values
  20697. * @returns the current Color4 object
  20698. */
  20699. toArray(array: number[], index?: number): Color4;
  20700. /**
  20701. * Determines equality between Color4 objects
  20702. * @param otherColor defines the second operand
  20703. * @returns true if the rgba values are equal to the given ones
  20704. */
  20705. equals(otherColor: DeepImmutable<Color4>): boolean;
  20706. /**
  20707. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  20708. * @param right defines the second operand
  20709. * @returns a new Color4 object
  20710. */
  20711. add(right: DeepImmutable<Color4>): Color4;
  20712. /**
  20713. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  20714. * @param right defines the second operand
  20715. * @returns a new Color4 object
  20716. */
  20717. subtract(right: DeepImmutable<Color4>): Color4;
  20718. /**
  20719. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  20720. * @param right defines the second operand
  20721. * @param result defines the Color4 object where to store the result
  20722. * @returns the current Color4 object
  20723. */
  20724. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  20725. /**
  20726. * Creates a new Color4 with the current Color4 values multiplied by scale
  20727. * @param scale defines the scaling factor to apply
  20728. * @returns a new Color4 object
  20729. */
  20730. scale(scale: number): Color4;
  20731. /**
  20732. * Multiplies the current Color4 values by scale and stores the result in "result"
  20733. * @param scale defines the scaling factor to apply
  20734. * @param result defines the Color4 object where to store the result
  20735. * @returns the current unmodified Color4
  20736. */
  20737. scaleToRef(scale: number, result: Color4): Color4;
  20738. /**
  20739. * Scale the current Color4 values by a factor and add the result to a given Color4
  20740. * @param scale defines the scale factor
  20741. * @param result defines the Color4 object where to store the result
  20742. * @returns the unmodified current Color4
  20743. */
  20744. scaleAndAddToRef(scale: number, result: Color4): Color4;
  20745. /**
  20746. * Clamps the rgb values by the min and max values and stores the result into "result"
  20747. * @param min defines minimum clamping value (default is 0)
  20748. * @param max defines maximum clamping value (default is 1)
  20749. * @param result defines color to store the result into.
  20750. * @returns the cuurent Color4
  20751. */
  20752. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  20753. /**
  20754. * Multipy an Color4 value by another and return a new Color4 object
  20755. * @param color defines the Color4 value to multiply by
  20756. * @returns a new Color4 object
  20757. */
  20758. multiply(color: Color4): Color4;
  20759. /**
  20760. * Multipy a Color4 value by another and push the result in a reference value
  20761. * @param color defines the Color4 value to multiply by
  20762. * @param result defines the Color4 to fill the result in
  20763. * @returns the result Color4
  20764. */
  20765. multiplyToRef(color: Color4, result: Color4): Color4;
  20766. /**
  20767. * Creates a string with the Color4 current values
  20768. * @returns the string representation of the Color4 object
  20769. */
  20770. toString(): string;
  20771. /**
  20772. * Returns the string "Color4"
  20773. * @returns "Color4"
  20774. */
  20775. getClassName(): string;
  20776. /**
  20777. * Compute the Color4 hash code
  20778. * @returns an unique number that can be used to hash Color4 objects
  20779. */
  20780. getHashCode(): number;
  20781. /**
  20782. * Creates a new Color4 copied from the current one
  20783. * @returns a new Color4 object
  20784. */
  20785. clone(): Color4;
  20786. /**
  20787. * Copies the given Color4 values into the current one
  20788. * @param source defines the source Color4 object
  20789. * @returns the current updated Color4 object
  20790. */
  20791. copyFrom(source: Color4): Color4;
  20792. /**
  20793. * Copies the given float values into the current one
  20794. * @param r defines the red component to read from
  20795. * @param g defines the green component to read from
  20796. * @param b defines the blue component to read from
  20797. * @param a defines the alpha component to read from
  20798. * @returns the current updated Color4 object
  20799. */
  20800. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  20801. /**
  20802. * Copies the given float values into the current one
  20803. * @param r defines the red component to read from
  20804. * @param g defines the green component to read from
  20805. * @param b defines the blue component to read from
  20806. * @param a defines the alpha component to read from
  20807. * @returns the current updated Color4 object
  20808. */
  20809. set(r: number, g: number, b: number, a: number): Color4;
  20810. /**
  20811. * Compute the Color4 hexadecimal code as a string
  20812. * @returns a string containing the hexadecimal representation of the Color4 object
  20813. */
  20814. toHexString(): string;
  20815. /**
  20816. * Computes a new Color4 converted from the current one to linear space
  20817. * @returns a new Color4 object
  20818. */
  20819. toLinearSpace(): Color4;
  20820. /**
  20821. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  20822. * @param convertedColor defines the Color4 object where to store the linear space version
  20823. * @returns the unmodified Color4
  20824. */
  20825. toLinearSpaceToRef(convertedColor: Color4): Color4;
  20826. /**
  20827. * Computes a new Color4 converted from the current one to gamma space
  20828. * @returns a new Color4 object
  20829. */
  20830. toGammaSpace(): Color4;
  20831. /**
  20832. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  20833. * @param convertedColor defines the Color4 object where to store the gamma space version
  20834. * @returns the unmodified Color4
  20835. */
  20836. toGammaSpaceToRef(convertedColor: Color4): Color4;
  20837. /**
  20838. * Creates a new Color4 from the string containing valid hexadecimal values
  20839. * @param hex defines a string containing valid hexadecimal values
  20840. * @returns a new Color4 object
  20841. */
  20842. static FromHexString(hex: string): Color4;
  20843. /**
  20844. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  20845. * @param left defines the start value
  20846. * @param right defines the end value
  20847. * @param amount defines the gradient factor
  20848. * @returns a new Color4 object
  20849. */
  20850. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  20851. /**
  20852. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  20853. * @param left defines the start value
  20854. * @param right defines the end value
  20855. * @param amount defines the gradient factor
  20856. * @param result defines the Color4 object where to store data
  20857. */
  20858. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  20859. /**
  20860. * Creates a new Color4 from a Color3 and an alpha value
  20861. * @param color3 defines the source Color3 to read from
  20862. * @param alpha defines the alpha component (1.0 by default)
  20863. * @returns a new Color4 object
  20864. */
  20865. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  20866. /**
  20867. * Creates a new Color4 from the starting index element of the given array
  20868. * @param array defines the source array to read from
  20869. * @param offset defines the offset in the source array
  20870. * @returns a new Color4 object
  20871. */
  20872. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  20873. /**
  20874. * Creates a new Color3 from integer values (< 256)
  20875. * @param r defines the red component to read from (value between 0 and 255)
  20876. * @param g defines the green component to read from (value between 0 and 255)
  20877. * @param b defines the blue component to read from (value between 0 and 255)
  20878. * @param a defines the alpha component to read from (value between 0 and 255)
  20879. * @returns a new Color3 object
  20880. */
  20881. static FromInts(r: number, g: number, b: number, a: number): Color4;
  20882. /**
  20883. * Check the content of a given array and convert it to an array containing RGBA data
  20884. * If the original array was already containing count * 4 values then it is returned directly
  20885. * @param colors defines the array to check
  20886. * @param count defines the number of RGBA data to expect
  20887. * @returns an array containing count * 4 values (RGBA)
  20888. */
  20889. static CheckColors4(colors: number[], count: number): number[];
  20890. }
  20891. /**
  20892. * Class representing a vector containing 2 coordinates
  20893. */
  20894. class Vector2 {
  20895. /** defines the first coordinate */
  20896. x: number;
  20897. /** defines the second coordinate */
  20898. y: number;
  20899. /**
  20900. * Creates a new Vector2 from the given x and y coordinates
  20901. * @param x defines the first coordinate
  20902. * @param y defines the second coordinate
  20903. */
  20904. constructor(
  20905. /** defines the first coordinate */
  20906. x?: number,
  20907. /** defines the second coordinate */
  20908. y?: number);
  20909. /**
  20910. * Gets a string with the Vector2 coordinates
  20911. * @returns a string with the Vector2 coordinates
  20912. */
  20913. toString(): string;
  20914. /**
  20915. * Gets class name
  20916. * @returns the string "Vector2"
  20917. */
  20918. getClassName(): string;
  20919. /**
  20920. * Gets current vector hash code
  20921. * @returns the Vector2 hash code as a number
  20922. */
  20923. getHashCode(): number;
  20924. /**
  20925. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  20926. * @param array defines the source array
  20927. * @param index defines the offset in source array
  20928. * @returns the current Vector2
  20929. */
  20930. toArray(array: FloatArray, index?: number): Vector2;
  20931. /**
  20932. * Copy the current vector to an array
  20933. * @returns a new array with 2 elements: the Vector2 coordinates.
  20934. */
  20935. asArray(): number[];
  20936. /**
  20937. * Sets the Vector2 coordinates with the given Vector2 coordinates
  20938. * @param source defines the source Vector2
  20939. * @returns the current updated Vector2
  20940. */
  20941. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  20942. /**
  20943. * Sets the Vector2 coordinates with the given floats
  20944. * @param x defines the first coordinate
  20945. * @param y defines the second coordinate
  20946. * @returns the current updated Vector2
  20947. */
  20948. copyFromFloats(x: number, y: number): Vector2;
  20949. /**
  20950. * Sets the Vector2 coordinates with the given floats
  20951. * @param x defines the first coordinate
  20952. * @param y defines the second coordinate
  20953. * @returns the current updated Vector2
  20954. */
  20955. set(x: number, y: number): Vector2;
  20956. /**
  20957. * Add another vector with the current one
  20958. * @param otherVector defines the other vector
  20959. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  20960. */
  20961. add(otherVector: DeepImmutable<Vector2>): Vector2;
  20962. /**
  20963. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  20964. * @param otherVector defines the other vector
  20965. * @param result defines the target vector
  20966. * @returns the unmodified current Vector2
  20967. */
  20968. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  20969. /**
  20970. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  20971. * @param otherVector defines the other vector
  20972. * @returns the current updated Vector2
  20973. */
  20974. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  20975. /**
  20976. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  20977. * @param otherVector defines the other vector
  20978. * @returns a new Vector2
  20979. */
  20980. addVector3(otherVector: Vector3): Vector2;
  20981. /**
  20982. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  20983. * @param otherVector defines the other vector
  20984. * @returns a new Vector2
  20985. */
  20986. subtract(otherVector: Vector2): Vector2;
  20987. /**
  20988. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  20989. * @param otherVector defines the other vector
  20990. * @param result defines the target vector
  20991. * @returns the unmodified current Vector2
  20992. */
  20993. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  20994. /**
  20995. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  20996. * @param otherVector defines the other vector
  20997. * @returns the current updated Vector2
  20998. */
  20999. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  21000. /**
  21001. * Multiplies in place the current Vector2 coordinates by the given ones
  21002. * @param otherVector defines the other vector
  21003. * @returns the current updated Vector2
  21004. */
  21005. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  21006. /**
  21007. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  21008. * @param otherVector defines the other vector
  21009. * @returns a new Vector2
  21010. */
  21011. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  21012. /**
  21013. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  21014. * @param otherVector defines the other vector
  21015. * @param result defines the target vector
  21016. * @returns the unmodified current Vector2
  21017. */
  21018. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  21019. /**
  21020. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  21021. * @param x defines the first coordinate
  21022. * @param y defines the second coordinate
  21023. * @returns a new Vector2
  21024. */
  21025. multiplyByFloats(x: number, y: number): Vector2;
  21026. /**
  21027. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  21028. * @param otherVector defines the other vector
  21029. * @returns a new Vector2
  21030. */
  21031. divide(otherVector: Vector2): Vector2;
  21032. /**
  21033. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  21034. * @param otherVector defines the other vector
  21035. * @param result defines the target vector
  21036. * @returns the unmodified current Vector2
  21037. */
  21038. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  21039. /**
  21040. * Divides the current Vector2 coordinates by the given ones
  21041. * @param otherVector defines the other vector
  21042. * @returns the current updated Vector2
  21043. */
  21044. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  21045. /**
  21046. * Gets a new Vector2 with current Vector2 negated coordinates
  21047. * @returns a new Vector2
  21048. */
  21049. negate(): Vector2;
  21050. /**
  21051. * Multiply the Vector2 coordinates by scale
  21052. * @param scale defines the scaling factor
  21053. * @returns the current updated Vector2
  21054. */
  21055. scaleInPlace(scale: number): Vector2;
  21056. /**
  21057. * Returns a new Vector2 scaled by "scale" from the current Vector2
  21058. * @param scale defines the scaling factor
  21059. * @returns a new Vector2
  21060. */
  21061. scale(scale: number): Vector2;
  21062. /**
  21063. * Scale the current Vector2 values by a factor to a given Vector2
  21064. * @param scale defines the scale factor
  21065. * @param result defines the Vector2 object where to store the result
  21066. * @returns the unmodified current Vector2
  21067. */
  21068. scaleToRef(scale: number, result: Vector2): Vector2;
  21069. /**
  21070. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  21071. * @param scale defines the scale factor
  21072. * @param result defines the Vector2 object where to store the result
  21073. * @returns the unmodified current Vector2
  21074. */
  21075. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  21076. /**
  21077. * Gets a boolean if two vectors are equals
  21078. * @param otherVector defines the other vector
  21079. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  21080. */
  21081. equals(otherVector: DeepImmutable<Vector2>): boolean;
  21082. /**
  21083. * Gets a boolean if two vectors are equals (using an epsilon value)
  21084. * @param otherVector defines the other vector
  21085. * @param epsilon defines the minimal distance to consider equality
  21086. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  21087. */
  21088. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  21089. /**
  21090. * Gets a new Vector2 from current Vector2 floored values
  21091. * @returns a new Vector2
  21092. */
  21093. floor(): Vector2;
  21094. /**
  21095. * Gets a new Vector2 from current Vector2 floored values
  21096. * @returns a new Vector2
  21097. */
  21098. fract(): Vector2;
  21099. /**
  21100. * Gets the length of the vector
  21101. * @returns the vector length (float)
  21102. */
  21103. length(): number;
  21104. /**
  21105. * Gets the vector squared length
  21106. * @returns the vector squared length (float)
  21107. */
  21108. lengthSquared(): number;
  21109. /**
  21110. * Normalize the vector
  21111. * @returns the current updated Vector2
  21112. */
  21113. normalize(): Vector2;
  21114. /**
  21115. * Gets a new Vector2 copied from the Vector2
  21116. * @returns a new Vector2
  21117. */
  21118. clone(): Vector2;
  21119. /**
  21120. * Gets a new Vector2(0, 0)
  21121. * @returns a new Vector2
  21122. */
  21123. static Zero(): Vector2;
  21124. /**
  21125. * Gets a new Vector2(1, 1)
  21126. * @returns a new Vector2
  21127. */
  21128. static One(): Vector2;
  21129. /**
  21130. * Gets a new Vector2 set from the given index element of the given array
  21131. * @param array defines the data source
  21132. * @param offset defines the offset in the data source
  21133. * @returns a new Vector2
  21134. */
  21135. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  21136. /**
  21137. * Sets "result" from the given index element of the given array
  21138. * @param array defines the data source
  21139. * @param offset defines the offset in the data source
  21140. * @param result defines the target vector
  21141. */
  21142. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  21143. /**
  21144. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  21145. * @param value1 defines 1st point of control
  21146. * @param value2 defines 2nd point of control
  21147. * @param value3 defines 3rd point of control
  21148. * @param value4 defines 4th point of control
  21149. * @param amount defines the interpolation factor
  21150. * @returns a new Vector2
  21151. */
  21152. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  21153. /**
  21154. * 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".
  21155. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  21156. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  21157. * @param value defines the value to clamp
  21158. * @param min defines the lower limit
  21159. * @param max defines the upper limit
  21160. * @returns a new Vector2
  21161. */
  21162. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  21163. /**
  21164. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  21165. * @param value1 defines the 1st control point
  21166. * @param tangent1 defines the outgoing tangent
  21167. * @param value2 defines the 2nd control point
  21168. * @param tangent2 defines the incoming tangent
  21169. * @param amount defines the interpolation factor
  21170. * @returns a new Vector2
  21171. */
  21172. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  21173. /**
  21174. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  21175. * @param start defines the start vector
  21176. * @param end defines the end vector
  21177. * @param amount defines the interpolation factor
  21178. * @returns a new Vector2
  21179. */
  21180. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  21181. /**
  21182. * Gets the dot product of the vector "left" and the vector "right"
  21183. * @param left defines first vector
  21184. * @param right defines second vector
  21185. * @returns the dot product (float)
  21186. */
  21187. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  21188. /**
  21189. * Returns a new Vector2 equal to the normalized given vector
  21190. * @param vector defines the vector to normalize
  21191. * @returns a new Vector2
  21192. */
  21193. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  21194. /**
  21195. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  21196. * @param left defines 1st vector
  21197. * @param right defines 2nd vector
  21198. * @returns a new Vector2
  21199. */
  21200. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  21201. /**
  21202. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  21203. * @param left defines 1st vector
  21204. * @param right defines 2nd vector
  21205. * @returns a new Vector2
  21206. */
  21207. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  21208. /**
  21209. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  21210. * @param vector defines the vector to transform
  21211. * @param transformation defines the matrix to apply
  21212. * @returns a new Vector2
  21213. */
  21214. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  21215. /**
  21216. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  21217. * @param vector defines the vector to transform
  21218. * @param transformation defines the matrix to apply
  21219. * @param result defines the target vector
  21220. */
  21221. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  21222. /**
  21223. * Determines if a given vector is included in a triangle
  21224. * @param p defines the vector to test
  21225. * @param p0 defines 1st triangle point
  21226. * @param p1 defines 2nd triangle point
  21227. * @param p2 defines 3rd triangle point
  21228. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  21229. */
  21230. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  21231. /**
  21232. * Gets the distance between the vectors "value1" and "value2"
  21233. * @param value1 defines first vector
  21234. * @param value2 defines second vector
  21235. * @returns the distance between vectors
  21236. */
  21237. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  21238. /**
  21239. * Returns the squared distance between the vectors "value1" and "value2"
  21240. * @param value1 defines first vector
  21241. * @param value2 defines second vector
  21242. * @returns the squared distance between vectors
  21243. */
  21244. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  21245. /**
  21246. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  21247. * @param value1 defines first vector
  21248. * @param value2 defines second vector
  21249. * @returns a new Vector2
  21250. */
  21251. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  21252. /**
  21253. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  21254. * @param p defines the middle point
  21255. * @param segA defines one point of the segment
  21256. * @param segB defines the other point of the segment
  21257. * @returns the shortest distance
  21258. */
  21259. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  21260. }
  21261. /**
  21262. * Classed used to store (x,y,z) vector representation
  21263. * A Vector3 is the main object used in 3D geometry
  21264. * It can represent etiher the coordinates of a point the space, either a direction
  21265. * Reminder: Babylon.js uses a left handed forward facing system
  21266. */
  21267. class Vector3 {
  21268. /**
  21269. * Defines the first coordinates (on X axis)
  21270. */
  21271. x: number;
  21272. /**
  21273. * Defines the second coordinates (on Y axis)
  21274. */
  21275. y: number;
  21276. /**
  21277. * Defines the third coordinates (on Z axis)
  21278. */
  21279. z: number;
  21280. private static _UpReadOnly;
  21281. /**
  21282. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  21283. * @param x defines the first coordinates (on X axis)
  21284. * @param y defines the second coordinates (on Y axis)
  21285. * @param z defines the third coordinates (on Z axis)
  21286. */
  21287. constructor(
  21288. /**
  21289. * Defines the first coordinates (on X axis)
  21290. */
  21291. x?: number,
  21292. /**
  21293. * Defines the second coordinates (on Y axis)
  21294. */
  21295. y?: number,
  21296. /**
  21297. * Defines the third coordinates (on Z axis)
  21298. */
  21299. z?: number);
  21300. /**
  21301. * Creates a string representation of the Vector3
  21302. * @returns a string with the Vector3 coordinates.
  21303. */
  21304. toString(): string;
  21305. /**
  21306. * Gets the class name
  21307. * @returns the string "Vector3"
  21308. */
  21309. getClassName(): string;
  21310. /**
  21311. * Creates the Vector3 hash code
  21312. * @returns a number which tends to be unique between Vector3 instances
  21313. */
  21314. getHashCode(): number;
  21315. /**
  21316. * Creates an array containing three elements : the coordinates of the Vector3
  21317. * @returns a new array of numbers
  21318. */
  21319. asArray(): number[];
  21320. /**
  21321. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  21322. * @param array defines the destination array
  21323. * @param index defines the offset in the destination array
  21324. * @returns the current Vector3
  21325. */
  21326. toArray(array: FloatArray, index?: number): Vector3;
  21327. /**
  21328. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  21329. * @returns a new Quaternion object, computed from the Vector3 coordinates
  21330. */
  21331. toQuaternion(): Quaternion;
  21332. /**
  21333. * Adds the given vector to the current Vector3
  21334. * @param otherVector defines the second operand
  21335. * @returns the current updated Vector3
  21336. */
  21337. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  21338. /**
  21339. * Adds the given coordinates to the current Vector3
  21340. * @param x defines the x coordinate of the operand
  21341. * @param y defines the y coordinate of the operand
  21342. * @param z defines the z coordinate of the operand
  21343. * @returns the current updated Vector3
  21344. */
  21345. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  21346. /**
  21347. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  21348. * @param otherVector defines the second operand
  21349. * @returns the resulting Vector3
  21350. */
  21351. add(otherVector: DeepImmutable<Vector3>): Vector3;
  21352. /**
  21353. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  21354. * @param otherVector defines the second operand
  21355. * @param result defines the Vector3 object where to store the result
  21356. * @returns the current Vector3
  21357. */
  21358. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  21359. /**
  21360. * Subtract the given vector from the current Vector3
  21361. * @param otherVector defines the second operand
  21362. * @returns the current updated Vector3
  21363. */
  21364. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  21365. /**
  21366. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  21367. * @param otherVector defines the second operand
  21368. * @returns the resulting Vector3
  21369. */
  21370. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  21371. /**
  21372. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  21373. * @param otherVector defines the second operand
  21374. * @param result defines the Vector3 object where to store the result
  21375. * @returns the current Vector3
  21376. */
  21377. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  21378. /**
  21379. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  21380. * @param x defines the x coordinate of the operand
  21381. * @param y defines the y coordinate of the operand
  21382. * @param z defines the z coordinate of the operand
  21383. * @returns the resulting Vector3
  21384. */
  21385. subtractFromFloats(x: number, y: number, z: number): Vector3;
  21386. /**
  21387. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  21388. * @param x defines the x coordinate of the operand
  21389. * @param y defines the y coordinate of the operand
  21390. * @param z defines the z coordinate of the operand
  21391. * @param result defines the Vector3 object where to store the result
  21392. * @returns the current Vector3
  21393. */
  21394. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  21395. /**
  21396. * Gets a new Vector3 set with the current Vector3 negated coordinates
  21397. * @returns a new Vector3
  21398. */
  21399. negate(): Vector3;
  21400. /**
  21401. * Multiplies the Vector3 coordinates by the float "scale"
  21402. * @param scale defines the multiplier factor
  21403. * @returns the current updated Vector3
  21404. */
  21405. scaleInPlace(scale: number): Vector3;
  21406. /**
  21407. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  21408. * @param scale defines the multiplier factor
  21409. * @returns a new Vector3
  21410. */
  21411. scale(scale: number): Vector3;
  21412. /**
  21413. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  21414. * @param scale defines the multiplier factor
  21415. * @param result defines the Vector3 object where to store the result
  21416. * @returns the current Vector3
  21417. */
  21418. scaleToRef(scale: number, result: Vector3): Vector3;
  21419. /**
  21420. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  21421. * @param scale defines the scale factor
  21422. * @param result defines the Vector3 object where to store the result
  21423. * @returns the unmodified current Vector3
  21424. */
  21425. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  21426. /**
  21427. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  21428. * @param otherVector defines the second operand
  21429. * @returns true if both vectors are equals
  21430. */
  21431. equals(otherVector: DeepImmutable<Vector3>): boolean;
  21432. /**
  21433. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  21434. * @param otherVector defines the second operand
  21435. * @param epsilon defines the minimal distance to define values as equals
  21436. * @returns true if both vectors are distant less than epsilon
  21437. */
  21438. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  21439. /**
  21440. * Returns true if the current Vector3 coordinates equals the given floats
  21441. * @param x defines the x coordinate of the operand
  21442. * @param y defines the y coordinate of the operand
  21443. * @param z defines the z coordinate of the operand
  21444. * @returns true if both vectors are equals
  21445. */
  21446. equalsToFloats(x: number, y: number, z: number): boolean;
  21447. /**
  21448. * Multiplies the current Vector3 coordinates by the given ones
  21449. * @param otherVector defines the second operand
  21450. * @returns the current updated Vector3
  21451. */
  21452. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  21453. /**
  21454. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  21455. * @param otherVector defines the second operand
  21456. * @returns the new Vector3
  21457. */
  21458. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  21459. /**
  21460. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  21461. * @param otherVector defines the second operand
  21462. * @param result defines the Vector3 object where to store the result
  21463. * @returns the current Vector3
  21464. */
  21465. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  21466. /**
  21467. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  21468. * @param x defines the x coordinate of the operand
  21469. * @param y defines the y coordinate of the operand
  21470. * @param z defines the z coordinate of the operand
  21471. * @returns the new Vector3
  21472. */
  21473. multiplyByFloats(x: number, y: number, z: number): Vector3;
  21474. /**
  21475. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  21476. * @param otherVector defines the second operand
  21477. * @returns the new Vector3
  21478. */
  21479. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  21480. /**
  21481. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  21482. * @param otherVector defines the second operand
  21483. * @param result defines the Vector3 object where to store the result
  21484. * @returns the current Vector3
  21485. */
  21486. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  21487. /**
  21488. * Divides the current Vector3 coordinates by the given ones.
  21489. * @param otherVector defines the second operand
  21490. * @returns the current updated Vector3
  21491. */
  21492. divideInPlace(otherVector: Vector3): Vector3;
  21493. /**
  21494. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  21495. * @param other defines the second operand
  21496. * @returns the current updated Vector3
  21497. */
  21498. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  21499. /**
  21500. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  21501. * @param other defines the second operand
  21502. * @returns the current updated Vector3
  21503. */
  21504. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  21505. /**
  21506. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  21507. * @param x defines the x coordinate of the operand
  21508. * @param y defines the y coordinate of the operand
  21509. * @param z defines the z coordinate of the operand
  21510. * @returns the current updated Vector3
  21511. */
  21512. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  21513. /**
  21514. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  21515. * @param x defines the x coordinate of the operand
  21516. * @param y defines the y coordinate of the operand
  21517. * @param z defines the z coordinate of the operand
  21518. * @returns the current updated Vector3
  21519. */
  21520. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  21521. /**
  21522. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  21523. */
  21524. readonly isNonUniform: boolean;
  21525. /**
  21526. * Gets a new Vector3 from current Vector3 floored values
  21527. * @returns a new Vector3
  21528. */
  21529. floor(): Vector3;
  21530. /**
  21531. * Gets a new Vector3 from current Vector3 floored values
  21532. * @returns a new Vector3
  21533. */
  21534. fract(): Vector3;
  21535. /**
  21536. * Gets the length of the Vector3
  21537. * @returns the length of the Vecto3
  21538. */
  21539. length(): number;
  21540. /**
  21541. * Gets the squared length of the Vector3
  21542. * @returns squared length of the Vector3
  21543. */
  21544. lengthSquared(): number;
  21545. /**
  21546. * Normalize the current Vector3.
  21547. * Please note that this is an in place operation.
  21548. * @returns the current updated Vector3
  21549. */
  21550. normalize(): Vector3;
  21551. /**
  21552. * Reorders the x y z properties of the vector in place
  21553. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  21554. * @returns the current updated vector
  21555. */
  21556. reorderInPlace(order: string): this;
  21557. /**
  21558. * Rotates the vector around 0,0,0 by a quaternion
  21559. * @param quaternion the rotation quaternion
  21560. * @param result vector to store the result
  21561. * @returns the resulting vector
  21562. */
  21563. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  21564. /**
  21565. * Rotates a vector around a given point
  21566. * @param quaternion the rotation quaternion
  21567. * @param point the point to rotate around
  21568. * @param result vector to store the result
  21569. * @returns the resulting vector
  21570. */
  21571. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  21572. /**
  21573. * Normalize the current Vector3 with the given input length.
  21574. * Please note that this is an in place operation.
  21575. * @param len the length of the vector
  21576. * @returns the current updated Vector3
  21577. */
  21578. normalizeFromLength(len: number): Vector3;
  21579. /**
  21580. * Normalize the current Vector3 to a new vector
  21581. * @returns the new Vector3
  21582. */
  21583. normalizeToNew(): Vector3;
  21584. /**
  21585. * Normalize the current Vector3 to the reference
  21586. * @param reference define the Vector3 to update
  21587. * @returns the updated Vector3
  21588. */
  21589. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  21590. /**
  21591. * Creates a new Vector3 copied from the current Vector3
  21592. * @returns the new Vector3
  21593. */
  21594. clone(): Vector3;
  21595. /**
  21596. * Copies the given vector coordinates to the current Vector3 ones
  21597. * @param source defines the source Vector3
  21598. * @returns the current updated Vector3
  21599. */
  21600. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  21601. /**
  21602. * Copies the given floats to the current Vector3 coordinates
  21603. * @param x defines the x coordinate of the operand
  21604. * @param y defines the y coordinate of the operand
  21605. * @param z defines the z coordinate of the operand
  21606. * @returns the current updated Vector3
  21607. */
  21608. copyFromFloats(x: number, y: number, z: number): Vector3;
  21609. /**
  21610. * Copies the given floats to the current Vector3 coordinates
  21611. * @param x defines the x coordinate of the operand
  21612. * @param y defines the y coordinate of the operand
  21613. * @param z defines the z coordinate of the operand
  21614. * @returns the current updated Vector3
  21615. */
  21616. set(x: number, y: number, z: number): Vector3;
  21617. /**
  21618. * Copies the given float to the current Vector3 coordinates
  21619. * @param v defines the x, y and z coordinates of the operand
  21620. * @returns the current updated Vector3
  21621. */
  21622. setAll(v: number): Vector3;
  21623. /**
  21624. * Get the clip factor between two vectors
  21625. * @param vector0 defines the first operand
  21626. * @param vector1 defines the second operand
  21627. * @param axis defines the axis to use
  21628. * @param size defines the size along the axis
  21629. * @returns the clip factor
  21630. */
  21631. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  21632. /**
  21633. * Get angle between two vectors
  21634. * @param vector0 angle between vector0 and vector1
  21635. * @param vector1 angle between vector0 and vector1
  21636. * @param normal direction of the normal
  21637. * @return the angle between vector0 and vector1
  21638. */
  21639. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  21640. /**
  21641. * Returns a new Vector3 set from the index "offset" of the given array
  21642. * @param array defines the source array
  21643. * @param offset defines the offset in the source array
  21644. * @returns the new Vector3
  21645. */
  21646. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  21647. /**
  21648. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  21649. * This function is deprecated. Use FromArray instead
  21650. * @param array defines the source array
  21651. * @param offset defines the offset in the source array
  21652. * @returns the new Vector3
  21653. */
  21654. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  21655. /**
  21656. * Sets the given vector "result" with the element values from the index "offset" of the given array
  21657. * @param array defines the source array
  21658. * @param offset defines the offset in the source array
  21659. * @param result defines the Vector3 where to store the result
  21660. */
  21661. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  21662. /**
  21663. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  21664. * This function is deprecated. Use FromArrayToRef instead.
  21665. * @param array defines the source array
  21666. * @param offset defines the offset in the source array
  21667. * @param result defines the Vector3 where to store the result
  21668. */
  21669. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  21670. /**
  21671. * Sets the given vector "result" with the given floats.
  21672. * @param x defines the x coordinate of the source
  21673. * @param y defines the y coordinate of the source
  21674. * @param z defines the z coordinate of the source
  21675. * @param result defines the Vector3 where to store the result
  21676. */
  21677. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  21678. /**
  21679. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  21680. * @returns a new empty Vector3
  21681. */
  21682. static Zero(): Vector3;
  21683. /**
  21684. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  21685. * @returns a new unit Vector3
  21686. */
  21687. static One(): Vector3;
  21688. /**
  21689. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  21690. * @returns a new up Vector3
  21691. */
  21692. static Up(): Vector3;
  21693. /**
  21694. * Gets a up Vector3 that must not be updated
  21695. */
  21696. static readonly UpReadOnly: DeepImmutable<Vector3>;
  21697. /**
  21698. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  21699. * @returns a new down Vector3
  21700. */
  21701. static Down(): Vector3;
  21702. /**
  21703. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  21704. * @returns a new forward Vector3
  21705. */
  21706. static Forward(): Vector3;
  21707. /**
  21708. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  21709. * @returns a new forward Vector3
  21710. */
  21711. static Backward(): Vector3;
  21712. /**
  21713. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  21714. * @returns a new right Vector3
  21715. */
  21716. static Right(): Vector3;
  21717. /**
  21718. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  21719. * @returns a new left Vector3
  21720. */
  21721. static Left(): Vector3;
  21722. /**
  21723. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  21724. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  21725. * @param vector defines the Vector3 to transform
  21726. * @param transformation defines the transformation matrix
  21727. * @returns the transformed Vector3
  21728. */
  21729. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  21730. /**
  21731. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  21732. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  21733. * @param vector defines the Vector3 to transform
  21734. * @param transformation defines the transformation matrix
  21735. * @param result defines the Vector3 where to store the result
  21736. */
  21737. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  21738. /**
  21739. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  21740. * This method computes tranformed coordinates only, not transformed direction vectors
  21741. * @param x define the x coordinate of the source vector
  21742. * @param y define the y coordinate of the source vector
  21743. * @param z define the z coordinate of the source vector
  21744. * @param transformation defines the transformation matrix
  21745. * @param result defines the Vector3 where to store the result
  21746. */
  21747. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  21748. /**
  21749. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  21750. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  21751. * @param vector defines the Vector3 to transform
  21752. * @param transformation defines the transformation matrix
  21753. * @returns the new Vector3
  21754. */
  21755. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  21756. /**
  21757. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  21758. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  21759. * @param vector defines the Vector3 to transform
  21760. * @param transformation defines the transformation matrix
  21761. * @param result defines the Vector3 where to store the result
  21762. */
  21763. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  21764. /**
  21765. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  21766. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  21767. * @param x define the x coordinate of the source vector
  21768. * @param y define the y coordinate of the source vector
  21769. * @param z define the z coordinate of the source vector
  21770. * @param transformation defines the transformation matrix
  21771. * @param result defines the Vector3 where to store the result
  21772. */
  21773. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  21774. /**
  21775. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  21776. * @param value1 defines the first control point
  21777. * @param value2 defines the second control point
  21778. * @param value3 defines the third control point
  21779. * @param value4 defines the fourth control point
  21780. * @param amount defines the amount on the spline to use
  21781. * @returns the new Vector3
  21782. */
  21783. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  21784. /**
  21785. * 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"
  21786. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  21787. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  21788. * @param value defines the current value
  21789. * @param min defines the lower range value
  21790. * @param max defines the upper range value
  21791. * @returns the new Vector3
  21792. */
  21793. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  21794. /**
  21795. * 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"
  21796. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  21797. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  21798. * @param value defines the current value
  21799. * @param min defines the lower range value
  21800. * @param max defines the upper range value
  21801. * @param result defines the Vector3 where to store the result
  21802. */
  21803. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  21804. /**
  21805. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  21806. * @param value1 defines the first control point
  21807. * @param tangent1 defines the first tangent vector
  21808. * @param value2 defines the second control point
  21809. * @param tangent2 defines the second tangent vector
  21810. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  21811. * @returns the new Vector3
  21812. */
  21813. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  21814. /**
  21815. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  21816. * @param start defines the start value
  21817. * @param end defines the end value
  21818. * @param amount max defines amount between both (between 0 and 1)
  21819. * @returns the new Vector3
  21820. */
  21821. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  21822. /**
  21823. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  21824. * @param start defines the start value
  21825. * @param end defines the end value
  21826. * @param amount max defines amount between both (between 0 and 1)
  21827. * @param result defines the Vector3 where to store the result
  21828. */
  21829. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  21830. /**
  21831. * Returns the dot product (float) between the vectors "left" and "right"
  21832. * @param left defines the left operand
  21833. * @param right defines the right operand
  21834. * @returns the dot product
  21835. */
  21836. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  21837. /**
  21838. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  21839. * The cross product is then orthogonal to both "left" and "right"
  21840. * @param left defines the left operand
  21841. * @param right defines the right operand
  21842. * @returns the cross product
  21843. */
  21844. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  21845. /**
  21846. * Sets the given vector "result" with the cross product of "left" and "right"
  21847. * The cross product is then orthogonal to both "left" and "right"
  21848. * @param left defines the left operand
  21849. * @param right defines the right operand
  21850. * @param result defines the Vector3 where to store the result
  21851. */
  21852. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  21853. /**
  21854. * Returns a new Vector3 as the normalization of the given vector
  21855. * @param vector defines the Vector3 to normalize
  21856. * @returns the new Vector3
  21857. */
  21858. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  21859. /**
  21860. * Sets the given vector "result" with the normalization of the given first vector
  21861. * @param vector defines the Vector3 to normalize
  21862. * @param result defines the Vector3 where to store the result
  21863. */
  21864. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  21865. /**
  21866. * Project a Vector3 onto screen space
  21867. * @param vector defines the Vector3 to project
  21868. * @param world defines the world matrix to use
  21869. * @param transform defines the transform (view x projection) matrix to use
  21870. * @param viewport defines the screen viewport to use
  21871. * @returns the new Vector3
  21872. */
  21873. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  21874. /** @hidden */
  21875. private static UnprojectFromInvertedMatrixToRef;
  21876. /**
  21877. * Unproject from screen space to object space
  21878. * @param source defines the screen space Vector3 to use
  21879. * @param viewportWidth defines the current width of the viewport
  21880. * @param viewportHeight defines the current height of the viewport
  21881. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21882. * @param transform defines the transform (view x projection) matrix to use
  21883. * @returns the new Vector3
  21884. */
  21885. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  21886. /**
  21887. * Unproject from screen space to object space
  21888. * @param source defines the screen space Vector3 to use
  21889. * @param viewportWidth defines the current width of the viewport
  21890. * @param viewportHeight defines the current height of the viewport
  21891. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21892. * @param view defines the view matrix to use
  21893. * @param projection defines the projection matrix to use
  21894. * @returns the new Vector3
  21895. */
  21896. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  21897. /**
  21898. * Unproject from screen space to object space
  21899. * @param source defines the screen space Vector3 to use
  21900. * @param viewportWidth defines the current width of the viewport
  21901. * @param viewportHeight defines the current height of the viewport
  21902. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21903. * @param view defines the view matrix to use
  21904. * @param projection defines the projection matrix to use
  21905. * @param result defines the Vector3 where to store the result
  21906. */
  21907. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  21908. /**
  21909. * Unproject from screen space to object space
  21910. * @param sourceX defines the screen space x coordinate to use
  21911. * @param sourceY defines the screen space y coordinate to use
  21912. * @param sourceZ defines the screen space z coordinate to use
  21913. * @param viewportWidth defines the current width of the viewport
  21914. * @param viewportHeight defines the current height of the viewport
  21915. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21916. * @param view defines the view matrix to use
  21917. * @param projection defines the projection matrix to use
  21918. * @param result defines the Vector3 where to store the result
  21919. */
  21920. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  21921. /**
  21922. * Unproject a ray from screen space to object space
  21923. * @param sourceX defines the screen space x coordinate to use
  21924. * @param sourceY defines the screen space y coordinate to use
  21925. * @param viewportWidth defines the current width of the viewport
  21926. * @param viewportHeight defines the current height of the viewport
  21927. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21928. * @param view defines the view matrix to use
  21929. * @param projection defines the projection matrix to use
  21930. * @param ray defines the Ray where to store the result
  21931. */
  21932. static UnprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, ray: Ray): void;
  21933. /**
  21934. * Gets the minimal coordinate values between two Vector3
  21935. * @param left defines the first operand
  21936. * @param right defines the second operand
  21937. * @returns the new Vector3
  21938. */
  21939. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  21940. /**
  21941. * Gets the maximal coordinate values between two Vector3
  21942. * @param left defines the first operand
  21943. * @param right defines the second operand
  21944. * @returns the new Vector3
  21945. */
  21946. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  21947. /**
  21948. * Returns the distance between the vectors "value1" and "value2"
  21949. * @param value1 defines the first operand
  21950. * @param value2 defines the second operand
  21951. * @returns the distance
  21952. */
  21953. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  21954. /**
  21955. * Returns the squared distance between the vectors "value1" and "value2"
  21956. * @param value1 defines the first operand
  21957. * @param value2 defines the second operand
  21958. * @returns the squared distance
  21959. */
  21960. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  21961. /**
  21962. * Returns a new Vector3 located at the center between "value1" and "value2"
  21963. * @param value1 defines the first operand
  21964. * @param value2 defines the second operand
  21965. * @returns the new Vector3
  21966. */
  21967. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  21968. /**
  21969. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  21970. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  21971. * to something in order to rotate it from its local system to the given target system
  21972. * Note: axis1, axis2 and axis3 are normalized during this operation
  21973. * @param axis1 defines the first axis
  21974. * @param axis2 defines the second axis
  21975. * @param axis3 defines the third axis
  21976. * @returns a new Vector3
  21977. */
  21978. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  21979. /**
  21980. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  21981. * @param axis1 defines the first axis
  21982. * @param axis2 defines the second axis
  21983. * @param axis3 defines the third axis
  21984. * @param ref defines the Vector3 where to store the result
  21985. */
  21986. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  21987. }
  21988. /**
  21989. * Vector4 class created for EulerAngle class conversion to Quaternion
  21990. */
  21991. class Vector4 {
  21992. /** x value of the vector */
  21993. x: number;
  21994. /** y value of the vector */
  21995. y: number;
  21996. /** z value of the vector */
  21997. z: number;
  21998. /** w value of the vector */
  21999. w: number;
  22000. /**
  22001. * Creates a Vector4 object from the given floats.
  22002. * @param x x value of the vector
  22003. * @param y y value of the vector
  22004. * @param z z value of the vector
  22005. * @param w w value of the vector
  22006. */
  22007. constructor(
  22008. /** x value of the vector */
  22009. x: number,
  22010. /** y value of the vector */
  22011. y: number,
  22012. /** z value of the vector */
  22013. z: number,
  22014. /** w value of the vector */
  22015. w: number);
  22016. /**
  22017. * Returns the string with the Vector4 coordinates.
  22018. * @returns a string containing all the vector values
  22019. */
  22020. toString(): string;
  22021. /**
  22022. * Returns the string "Vector4".
  22023. * @returns "Vector4"
  22024. */
  22025. getClassName(): string;
  22026. /**
  22027. * Returns the Vector4 hash code.
  22028. * @returns a unique hash code
  22029. */
  22030. getHashCode(): number;
  22031. /**
  22032. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  22033. * @returns the resulting array
  22034. */
  22035. asArray(): number[];
  22036. /**
  22037. * Populates the given array from the given index with the Vector4 coordinates.
  22038. * @param array array to populate
  22039. * @param index index of the array to start at (default: 0)
  22040. * @returns the Vector4.
  22041. */
  22042. toArray(array: FloatArray, index?: number): Vector4;
  22043. /**
  22044. * Adds the given vector to the current Vector4.
  22045. * @param otherVector the vector to add
  22046. * @returns the updated Vector4.
  22047. */
  22048. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  22049. /**
  22050. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  22051. * @param otherVector the vector to add
  22052. * @returns the resulting vector
  22053. */
  22054. add(otherVector: DeepImmutable<Vector4>): Vector4;
  22055. /**
  22056. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  22057. * @param otherVector the vector to add
  22058. * @param result the vector to store the result
  22059. * @returns the current Vector4.
  22060. */
  22061. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  22062. /**
  22063. * Subtract in place the given vector from the current Vector4.
  22064. * @param otherVector the vector to subtract
  22065. * @returns the updated Vector4.
  22066. */
  22067. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  22068. /**
  22069. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  22070. * @param otherVector the vector to add
  22071. * @returns the new vector with the result
  22072. */
  22073. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  22074. /**
  22075. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  22076. * @param otherVector the vector to subtract
  22077. * @param result the vector to store the result
  22078. * @returns the current Vector4.
  22079. */
  22080. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  22081. /**
  22082. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  22083. */
  22084. /**
  22085. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  22086. * @param x value to subtract
  22087. * @param y value to subtract
  22088. * @param z value to subtract
  22089. * @param w value to subtract
  22090. * @returns new vector containing the result
  22091. */
  22092. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  22093. /**
  22094. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  22095. * @param x value to subtract
  22096. * @param y value to subtract
  22097. * @param z value to subtract
  22098. * @param w value to subtract
  22099. * @param result the vector to store the result in
  22100. * @returns the current Vector4.
  22101. */
  22102. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  22103. /**
  22104. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  22105. * @returns a new vector with the negated values
  22106. */
  22107. negate(): Vector4;
  22108. /**
  22109. * Multiplies the current Vector4 coordinates by scale (float).
  22110. * @param scale the number to scale with
  22111. * @returns the updated Vector4.
  22112. */
  22113. scaleInPlace(scale: number): Vector4;
  22114. /**
  22115. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  22116. * @param scale the number to scale with
  22117. * @returns a new vector with the result
  22118. */
  22119. scale(scale: number): Vector4;
  22120. /**
  22121. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  22122. * @param scale the number to scale with
  22123. * @param result a vector to store the result in
  22124. * @returns the current Vector4.
  22125. */
  22126. scaleToRef(scale: number, result: Vector4): Vector4;
  22127. /**
  22128. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  22129. * @param scale defines the scale factor
  22130. * @param result defines the Vector4 object where to store the result
  22131. * @returns the unmodified current Vector4
  22132. */
  22133. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  22134. /**
  22135. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  22136. * @param otherVector the vector to compare against
  22137. * @returns true if they are equal
  22138. */
  22139. equals(otherVector: DeepImmutable<Vector4>): boolean;
  22140. /**
  22141. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  22142. * @param otherVector vector to compare against
  22143. * @param epsilon (Default: very small number)
  22144. * @returns true if they are equal
  22145. */
  22146. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  22147. /**
  22148. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  22149. * @param x x value to compare against
  22150. * @param y y value to compare against
  22151. * @param z z value to compare against
  22152. * @param w w value to compare against
  22153. * @returns true if equal
  22154. */
  22155. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  22156. /**
  22157. * Multiplies in place the current Vector4 by the given one.
  22158. * @param otherVector vector to multiple with
  22159. * @returns the updated Vector4.
  22160. */
  22161. multiplyInPlace(otherVector: Vector4): Vector4;
  22162. /**
  22163. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  22164. * @param otherVector vector to multiple with
  22165. * @returns resulting new vector
  22166. */
  22167. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  22168. /**
  22169. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  22170. * @param otherVector vector to multiple with
  22171. * @param result vector to store the result
  22172. * @returns the current Vector4.
  22173. */
  22174. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  22175. /**
  22176. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  22177. * @param x x value multiply with
  22178. * @param y y value multiply with
  22179. * @param z z value multiply with
  22180. * @param w w value multiply with
  22181. * @returns resulting new vector
  22182. */
  22183. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  22184. /**
  22185. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  22186. * @param otherVector vector to devide with
  22187. * @returns resulting new vector
  22188. */
  22189. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  22190. /**
  22191. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  22192. * @param otherVector vector to devide with
  22193. * @param result vector to store the result
  22194. * @returns the current Vector4.
  22195. */
  22196. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  22197. /**
  22198. * Divides the current Vector3 coordinates by the given ones.
  22199. * @param otherVector vector to devide with
  22200. * @returns the updated Vector3.
  22201. */
  22202. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  22203. /**
  22204. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  22205. * @param other defines the second operand
  22206. * @returns the current updated Vector4
  22207. */
  22208. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  22209. /**
  22210. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  22211. * @param other defines the second operand
  22212. * @returns the current updated Vector4
  22213. */
  22214. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  22215. /**
  22216. * Gets a new Vector4 from current Vector4 floored values
  22217. * @returns a new Vector4
  22218. */
  22219. floor(): Vector4;
  22220. /**
  22221. * Gets a new Vector4 from current Vector3 floored values
  22222. * @returns a new Vector4
  22223. */
  22224. fract(): Vector4;
  22225. /**
  22226. * Returns the Vector4 length (float).
  22227. * @returns the length
  22228. */
  22229. length(): number;
  22230. /**
  22231. * Returns the Vector4 squared length (float).
  22232. * @returns the length squared
  22233. */
  22234. lengthSquared(): number;
  22235. /**
  22236. * Normalizes in place the Vector4.
  22237. * @returns the updated Vector4.
  22238. */
  22239. normalize(): Vector4;
  22240. /**
  22241. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  22242. * @returns this converted to a new vector3
  22243. */
  22244. toVector3(): Vector3;
  22245. /**
  22246. * Returns a new Vector4 copied from the current one.
  22247. * @returns the new cloned vector
  22248. */
  22249. clone(): Vector4;
  22250. /**
  22251. * Updates the current Vector4 with the given one coordinates.
  22252. * @param source the source vector to copy from
  22253. * @returns the updated Vector4.
  22254. */
  22255. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  22256. /**
  22257. * Updates the current Vector4 coordinates with the given floats.
  22258. * @param x float to copy from
  22259. * @param y float to copy from
  22260. * @param z float to copy from
  22261. * @param w float to copy from
  22262. * @returns the updated Vector4.
  22263. */
  22264. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  22265. /**
  22266. * Updates the current Vector4 coordinates with the given floats.
  22267. * @param x float to set from
  22268. * @param y float to set from
  22269. * @param z float to set from
  22270. * @param w float to set from
  22271. * @returns the updated Vector4.
  22272. */
  22273. set(x: number, y: number, z: number, w: number): Vector4;
  22274. /**
  22275. * Copies the given float to the current Vector3 coordinates
  22276. * @param v defines the x, y, z and w coordinates of the operand
  22277. * @returns the current updated Vector3
  22278. */
  22279. setAll(v: number): Vector4;
  22280. /**
  22281. * Returns a new Vector4 set from the starting index of the given array.
  22282. * @param array the array to pull values from
  22283. * @param offset the offset into the array to start at
  22284. * @returns the new vector
  22285. */
  22286. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  22287. /**
  22288. * Updates the given vector "result" from the starting index of the given array.
  22289. * @param array the array to pull values from
  22290. * @param offset the offset into the array to start at
  22291. * @param result the vector to store the result in
  22292. */
  22293. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  22294. /**
  22295. * Updates the given vector "result" from the starting index of the given Float32Array.
  22296. * @param array the array to pull values from
  22297. * @param offset the offset into the array to start at
  22298. * @param result the vector to store the result in
  22299. */
  22300. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  22301. /**
  22302. * Updates the given vector "result" coordinates from the given floats.
  22303. * @param x float to set from
  22304. * @param y float to set from
  22305. * @param z float to set from
  22306. * @param w float to set from
  22307. * @param result the vector to the floats in
  22308. */
  22309. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  22310. /**
  22311. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  22312. * @returns the new vector
  22313. */
  22314. static Zero(): Vector4;
  22315. /**
  22316. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  22317. * @returns the new vector
  22318. */
  22319. static One(): Vector4;
  22320. /**
  22321. * Returns a new normalized Vector4 from the given one.
  22322. * @param vector the vector to normalize
  22323. * @returns the vector
  22324. */
  22325. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  22326. /**
  22327. * Updates the given vector "result" from the normalization of the given one.
  22328. * @param vector the vector to normalize
  22329. * @param result the vector to store the result in
  22330. */
  22331. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  22332. /**
  22333. * Returns a vector with the minimum values from the left and right vectors
  22334. * @param left left vector to minimize
  22335. * @param right right vector to minimize
  22336. * @returns a new vector with the minimum of the left and right vector values
  22337. */
  22338. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  22339. /**
  22340. * Returns a vector with the maximum values from the left and right vectors
  22341. * @param left left vector to maximize
  22342. * @param right right vector to maximize
  22343. * @returns a new vector with the maximum of the left and right vector values
  22344. */
  22345. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  22346. /**
  22347. * Returns the distance (float) between the vectors "value1" and "value2".
  22348. * @param value1 value to calulate the distance between
  22349. * @param value2 value to calulate the distance between
  22350. * @return the distance between the two vectors
  22351. */
  22352. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  22353. /**
  22354. * Returns the squared distance (float) between the vectors "value1" and "value2".
  22355. * @param value1 value to calulate the distance between
  22356. * @param value2 value to calulate the distance between
  22357. * @return the distance between the two vectors squared
  22358. */
  22359. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  22360. /**
  22361. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  22362. * @param value1 value to calulate the center between
  22363. * @param value2 value to calulate the center between
  22364. * @return the center between the two vectors
  22365. */
  22366. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  22367. /**
  22368. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  22369. * This methods computes transformed normalized direction vectors only.
  22370. * @param vector the vector to transform
  22371. * @param transformation the transformation matrix to apply
  22372. * @returns the new vector
  22373. */
  22374. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  22375. /**
  22376. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  22377. * This methods computes transformed normalized direction vectors only.
  22378. * @param vector the vector to transform
  22379. * @param transformation the transformation matrix to apply
  22380. * @param result the vector to store the result in
  22381. */
  22382. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  22383. /**
  22384. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  22385. * This methods computes transformed normalized direction vectors only.
  22386. * @param x value to transform
  22387. * @param y value to transform
  22388. * @param z value to transform
  22389. * @param w value to transform
  22390. * @param transformation the transformation matrix to apply
  22391. * @param result the vector to store the results in
  22392. */
  22393. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  22394. /**
  22395. * Creates a new Vector4 from a Vector3
  22396. * @param source defines the source data
  22397. * @param w defines the 4th component (default is 0)
  22398. * @returns a new Vector4
  22399. */
  22400. static FromVector3(source: Vector3, w?: number): Vector4;
  22401. }
  22402. /**
  22403. * Interface for the size containing width and height
  22404. */
  22405. interface ISize {
  22406. /**
  22407. * Width
  22408. */
  22409. width: number;
  22410. /**
  22411. * Heighht
  22412. */
  22413. height: number;
  22414. }
  22415. /**
  22416. * Size containing widht and height
  22417. */
  22418. class Size implements ISize {
  22419. /**
  22420. * Width
  22421. */
  22422. width: number;
  22423. /**
  22424. * Height
  22425. */
  22426. height: number;
  22427. /**
  22428. * Creates a Size object from the given width and height (floats).
  22429. * @param width width of the new size
  22430. * @param height height of the new size
  22431. */
  22432. constructor(width: number, height: number);
  22433. /**
  22434. * Returns a string with the Size width and height
  22435. * @returns a string with the Size width and height
  22436. */
  22437. toString(): string;
  22438. /**
  22439. * "Size"
  22440. * @returns the string "Size"
  22441. */
  22442. getClassName(): string;
  22443. /**
  22444. * Returns the Size hash code.
  22445. * @returns a hash code for a unique width and height
  22446. */
  22447. getHashCode(): number;
  22448. /**
  22449. * Updates the current size from the given one.
  22450. * @param src the given size
  22451. */
  22452. copyFrom(src: Size): void;
  22453. /**
  22454. * Updates in place the current Size from the given floats.
  22455. * @param width width of the new size
  22456. * @param height height of the new size
  22457. * @returns the updated Size.
  22458. */
  22459. copyFromFloats(width: number, height: number): Size;
  22460. /**
  22461. * Updates in place the current Size from the given floats.
  22462. * @param width width to set
  22463. * @param height height to set
  22464. * @returns the updated Size.
  22465. */
  22466. set(width: number, height: number): Size;
  22467. /**
  22468. * Multiplies the width and height by numbers
  22469. * @param w factor to multiple the width by
  22470. * @param h factor to multiple the height by
  22471. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  22472. */
  22473. multiplyByFloats(w: number, h: number): Size;
  22474. /**
  22475. * Clones the size
  22476. * @returns a new Size copied from the given one.
  22477. */
  22478. clone(): Size;
  22479. /**
  22480. * True if the current Size and the given one width and height are strictly equal.
  22481. * @param other the other size to compare against
  22482. * @returns True if the current Size and the given one width and height are strictly equal.
  22483. */
  22484. equals(other: Size): boolean;
  22485. /**
  22486. * The surface of the Size : width * height (float).
  22487. */
  22488. readonly surface: number;
  22489. /**
  22490. * Create a new size of zero
  22491. * @returns a new Size set to (0.0, 0.0)
  22492. */
  22493. static Zero(): Size;
  22494. /**
  22495. * Sums the width and height of two sizes
  22496. * @param otherSize size to add to this size
  22497. * @returns a new Size set as the addition result of the current Size and the given one.
  22498. */
  22499. add(otherSize: Size): Size;
  22500. /**
  22501. * Subtracts the width and height of two
  22502. * @param otherSize size to subtract to this size
  22503. * @returns a new Size set as the subtraction result of the given one from the current Size.
  22504. */
  22505. subtract(otherSize: Size): Size;
  22506. /**
  22507. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  22508. * @param start starting size to lerp between
  22509. * @param end end size to lerp between
  22510. * @param amount amount to lerp between the start and end values
  22511. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  22512. */
  22513. static Lerp(start: Size, end: Size, amount: number): Size;
  22514. }
  22515. /**
  22516. * Class used to store quaternion data
  22517. * @see https://en.wikipedia.org/wiki/Quaternion
  22518. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  22519. */
  22520. class Quaternion {
  22521. /** defines the first component (0 by default) */
  22522. x: number;
  22523. /** defines the second component (0 by default) */
  22524. y: number;
  22525. /** defines the third component (0 by default) */
  22526. z: number;
  22527. /** defines the fourth component (1.0 by default) */
  22528. w: number;
  22529. /**
  22530. * Creates a new Quaternion from the given floats
  22531. * @param x defines the first component (0 by default)
  22532. * @param y defines the second component (0 by default)
  22533. * @param z defines the third component (0 by default)
  22534. * @param w defines the fourth component (1.0 by default)
  22535. */
  22536. constructor(
  22537. /** defines the first component (0 by default) */
  22538. x?: number,
  22539. /** defines the second component (0 by default) */
  22540. y?: number,
  22541. /** defines the third component (0 by default) */
  22542. z?: number,
  22543. /** defines the fourth component (1.0 by default) */
  22544. w?: number);
  22545. /**
  22546. * Gets a string representation for the current quaternion
  22547. * @returns a string with the Quaternion coordinates
  22548. */
  22549. toString(): string;
  22550. /**
  22551. * Gets the class name of the quaternion
  22552. * @returns the string "Quaternion"
  22553. */
  22554. getClassName(): string;
  22555. /**
  22556. * Gets a hash code for this quaternion
  22557. * @returns the quaternion hash code
  22558. */
  22559. getHashCode(): number;
  22560. /**
  22561. * Copy the quaternion to an array
  22562. * @returns a new array populated with 4 elements from the quaternion coordinates
  22563. */
  22564. asArray(): number[];
  22565. /**
  22566. * Check if two quaternions are equals
  22567. * @param otherQuaternion defines the second operand
  22568. * @return true if the current quaternion and the given one coordinates are strictly equals
  22569. */
  22570. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  22571. /**
  22572. * Clone the current quaternion
  22573. * @returns a new quaternion copied from the current one
  22574. */
  22575. clone(): Quaternion;
  22576. /**
  22577. * Copy a quaternion to the current one
  22578. * @param other defines the other quaternion
  22579. * @returns the updated current quaternion
  22580. */
  22581. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  22582. /**
  22583. * Updates the current quaternion with the given float coordinates
  22584. * @param x defines the x coordinate
  22585. * @param y defines the y coordinate
  22586. * @param z defines the z coordinate
  22587. * @param w defines the w coordinate
  22588. * @returns the updated current quaternion
  22589. */
  22590. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  22591. /**
  22592. * Updates the current quaternion from the given float coordinates
  22593. * @param x defines the x coordinate
  22594. * @param y defines the y coordinate
  22595. * @param z defines the z coordinate
  22596. * @param w defines the w coordinate
  22597. * @returns the updated current quaternion
  22598. */
  22599. set(x: number, y: number, z: number, w: number): Quaternion;
  22600. /**
  22601. * Adds two quaternions
  22602. * @param other defines the second operand
  22603. * @returns a new quaternion as the addition result of the given one and the current quaternion
  22604. */
  22605. add(other: DeepImmutable<Quaternion>): Quaternion;
  22606. /**
  22607. * Add a quaternion to the current one
  22608. * @param other defines the quaternion to add
  22609. * @returns the current quaternion
  22610. */
  22611. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  22612. /**
  22613. * Subtract two quaternions
  22614. * @param other defines the second operand
  22615. * @returns a new quaternion as the subtraction result of the given one from the current one
  22616. */
  22617. subtract(other: Quaternion): Quaternion;
  22618. /**
  22619. * Multiplies the current quaternion by a scale factor
  22620. * @param value defines the scale factor
  22621. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  22622. */
  22623. scale(value: number): Quaternion;
  22624. /**
  22625. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  22626. * @param scale defines the scale factor
  22627. * @param result defines the Quaternion object where to store the result
  22628. * @returns the unmodified current quaternion
  22629. */
  22630. scaleToRef(scale: number, result: Quaternion): Quaternion;
  22631. /**
  22632. * Multiplies in place the current quaternion by a scale factor
  22633. * @param value defines the scale factor
  22634. * @returns the current modified quaternion
  22635. */
  22636. scaleInPlace(value: number): Quaternion;
  22637. /**
  22638. * Scale the current quaternion values by a factor and add the result to a given quaternion
  22639. * @param scale defines the scale factor
  22640. * @param result defines the Quaternion object where to store the result
  22641. * @returns the unmodified current quaternion
  22642. */
  22643. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  22644. /**
  22645. * Multiplies two quaternions
  22646. * @param q1 defines the second operand
  22647. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  22648. */
  22649. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  22650. /**
  22651. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  22652. * @param q1 defines the second operand
  22653. * @param result defines the target quaternion
  22654. * @returns the current quaternion
  22655. */
  22656. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  22657. /**
  22658. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  22659. * @param q1 defines the second operand
  22660. * @returns the currentupdated quaternion
  22661. */
  22662. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  22663. /**
  22664. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  22665. * @param ref defines the target quaternion
  22666. * @returns the current quaternion
  22667. */
  22668. conjugateToRef(ref: Quaternion): Quaternion;
  22669. /**
  22670. * Conjugates in place (1-q) the current quaternion
  22671. * @returns the current updated quaternion
  22672. */
  22673. conjugateInPlace(): Quaternion;
  22674. /**
  22675. * Conjugates in place (1-q) the current quaternion
  22676. * @returns a new quaternion
  22677. */
  22678. conjugate(): Quaternion;
  22679. /**
  22680. * Gets length of current quaternion
  22681. * @returns the quaternion length (float)
  22682. */
  22683. length(): number;
  22684. /**
  22685. * Normalize in place the current quaternion
  22686. * @returns the current updated quaternion
  22687. */
  22688. normalize(): Quaternion;
  22689. /**
  22690. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  22691. * @param order is a reserved parameter and is ignore for now
  22692. * @returns a new Vector3 containing the Euler angles
  22693. */
  22694. toEulerAngles(order?: string): Vector3;
  22695. /**
  22696. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  22697. * @param result defines the vector which will be filled with the Euler angles
  22698. * @param order is a reserved parameter and is ignore for now
  22699. * @returns the current unchanged quaternion
  22700. */
  22701. toEulerAnglesToRef(result: Vector3, order?: string): Quaternion;
  22702. /**
  22703. * Updates the given rotation matrix with the current quaternion values
  22704. * @param result defines the target matrix
  22705. * @returns the current unchanged quaternion
  22706. */
  22707. toRotationMatrix(result: Matrix): Quaternion;
  22708. /**
  22709. * Updates the current quaternion from the given rotation matrix values
  22710. * @param matrix defines the source matrix
  22711. * @returns the current updated quaternion
  22712. */
  22713. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  22714. /**
  22715. * Creates a new quaternion from a rotation matrix
  22716. * @param matrix defines the source matrix
  22717. * @returns a new quaternion created from the given rotation matrix values
  22718. */
  22719. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  22720. /**
  22721. * Updates the given quaternion with the given rotation matrix values
  22722. * @param matrix defines the source matrix
  22723. * @param result defines the target quaternion
  22724. */
  22725. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  22726. /**
  22727. * Returns the dot product (float) between the quaternions "left" and "right"
  22728. * @param left defines the left operand
  22729. * @param right defines the right operand
  22730. * @returns the dot product
  22731. */
  22732. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  22733. /**
  22734. * Checks if the two quaternions are close to each other
  22735. * @param quat0 defines the first quaternion to check
  22736. * @param quat1 defines the second quaternion to check
  22737. * @returns true if the two quaternions are close to each other
  22738. */
  22739. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  22740. /**
  22741. * Creates an empty quaternion
  22742. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  22743. */
  22744. static Zero(): Quaternion;
  22745. /**
  22746. * Inverse a given quaternion
  22747. * @param q defines the source quaternion
  22748. * @returns a new quaternion as the inverted current quaternion
  22749. */
  22750. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  22751. /**
  22752. * Inverse a given quaternion
  22753. * @param q defines the source quaternion
  22754. * @param result the quaternion the result will be stored in
  22755. * @returns the result quaternion
  22756. */
  22757. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  22758. /**
  22759. * Creates an identity quaternion
  22760. * @returns the identity quaternion
  22761. */
  22762. static Identity(): Quaternion;
  22763. /**
  22764. * Gets a boolean indicating if the given quaternion is identity
  22765. * @param quaternion defines the quaternion to check
  22766. * @returns true if the quaternion is identity
  22767. */
  22768. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  22769. /**
  22770. * Creates a quaternion from a rotation around an axis
  22771. * @param axis defines the axis to use
  22772. * @param angle defines the angle to use
  22773. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  22774. */
  22775. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  22776. /**
  22777. * Creates a rotation around an axis and stores it into the given quaternion
  22778. * @param axis defines the axis to use
  22779. * @param angle defines the angle to use
  22780. * @param result defines the target quaternion
  22781. * @returns the target quaternion
  22782. */
  22783. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  22784. /**
  22785. * Creates a new quaternion from data stored into an array
  22786. * @param array defines the data source
  22787. * @param offset defines the offset in the source array where the data starts
  22788. * @returns a new quaternion
  22789. */
  22790. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  22791. /**
  22792. * Create a quaternion from Euler rotation angles
  22793. * @param x Pitch
  22794. * @param y Yaw
  22795. * @param z Roll
  22796. * @returns the new Quaternion
  22797. */
  22798. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  22799. /**
  22800. * Updates a quaternion from Euler rotation angles
  22801. * @param x Pitch
  22802. * @param y Yaw
  22803. * @param z Roll
  22804. * @param result the quaternion to store the result
  22805. * @returns the updated quaternion
  22806. */
  22807. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  22808. /**
  22809. * Create a quaternion from Euler rotation vector
  22810. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  22811. * @returns the new Quaternion
  22812. */
  22813. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  22814. /**
  22815. * Updates a quaternion from Euler rotation vector
  22816. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  22817. * @param result the quaternion to store the result
  22818. * @returns the updated quaternion
  22819. */
  22820. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  22821. /**
  22822. * Creates a new quaternion from the given Euler float angles (y, x, z)
  22823. * @param yaw defines the rotation around Y axis
  22824. * @param pitch defines the rotation around X axis
  22825. * @param roll defines the rotation around Z axis
  22826. * @returns the new quaternion
  22827. */
  22828. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  22829. /**
  22830. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  22831. * @param yaw defines the rotation around Y axis
  22832. * @param pitch defines the rotation around X axis
  22833. * @param roll defines the rotation around Z axis
  22834. * @param result defines the target quaternion
  22835. */
  22836. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  22837. /**
  22838. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  22839. * @param alpha defines the rotation around first axis
  22840. * @param beta defines the rotation around second axis
  22841. * @param gamma defines the rotation around third axis
  22842. * @returns the new quaternion
  22843. */
  22844. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  22845. /**
  22846. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  22847. * @param alpha defines the rotation around first axis
  22848. * @param beta defines the rotation around second axis
  22849. * @param gamma defines the rotation around third axis
  22850. * @param result defines the target quaternion
  22851. */
  22852. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  22853. /**
  22854. * 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)
  22855. * @param axis1 defines the first axis
  22856. * @param axis2 defines the second axis
  22857. * @param axis3 defines the third axis
  22858. * @returns the new quaternion
  22859. */
  22860. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  22861. /**
  22862. * 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
  22863. * @param axis1 defines the first axis
  22864. * @param axis2 defines the second axis
  22865. * @param axis3 defines the third axis
  22866. * @param ref defines the target quaternion
  22867. */
  22868. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  22869. /**
  22870. * Interpolates between two quaternions
  22871. * @param left defines first quaternion
  22872. * @param right defines second quaternion
  22873. * @param amount defines the gradient to use
  22874. * @returns the new interpolated quaternion
  22875. */
  22876. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  22877. /**
  22878. * Interpolates between two quaternions and stores it into a target quaternion
  22879. * @param left defines first quaternion
  22880. * @param right defines second quaternion
  22881. * @param amount defines the gradient to use
  22882. * @param result defines the target quaternion
  22883. */
  22884. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  22885. /**
  22886. * Interpolate between two quaternions using Hermite interpolation
  22887. * @param value1 defines first quaternion
  22888. * @param tangent1 defines the incoming tangent
  22889. * @param value2 defines second quaternion
  22890. * @param tangent2 defines the outgoing tangent
  22891. * @param amount defines the target quaternion
  22892. * @returns the new interpolated quaternion
  22893. */
  22894. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  22895. }
  22896. /**
  22897. * Class used to store matrix data (4x4)
  22898. */
  22899. class Matrix {
  22900. private static _updateFlagSeed;
  22901. private static _identityReadOnly;
  22902. private _isIdentity;
  22903. private _isIdentityDirty;
  22904. private _isIdentity3x2;
  22905. private _isIdentity3x2Dirty;
  22906. /**
  22907. * Gets the update flag of the matrix which is an unique number for the matrix.
  22908. * It will be incremented every time the matrix data change.
  22909. * You can use it to speed the comparison between two versions of the same matrix.
  22910. */
  22911. updateFlag: number;
  22912. private readonly _m;
  22913. /**
  22914. * Gets the internal data of the matrix
  22915. */
  22916. readonly m: DeepImmutable<Float32Array>;
  22917. /** @hidden */
  22918. _markAsUpdated(): void;
  22919. /** @hidden */
  22920. private _updateIdentityStatus;
  22921. /**
  22922. * Creates an empty matrix (filled with zeros)
  22923. */
  22924. constructor();
  22925. /**
  22926. * Check if the current matrix is identity
  22927. * @returns true is the matrix is the identity matrix
  22928. */
  22929. isIdentity(): boolean;
  22930. /**
  22931. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  22932. * @returns true is the matrix is the identity matrix
  22933. */
  22934. isIdentityAs3x2(): boolean;
  22935. /**
  22936. * Gets the determinant of the matrix
  22937. * @returns the matrix determinant
  22938. */
  22939. determinant(): number;
  22940. /**
  22941. * Returns the matrix as a Float32Array
  22942. * @returns the matrix underlying array
  22943. */
  22944. toArray(): DeepImmutable<Float32Array>;
  22945. /**
  22946. * Returns the matrix as a Float32Array
  22947. * @returns the matrix underlying array.
  22948. */
  22949. asArray(): DeepImmutable<Float32Array>;
  22950. /**
  22951. * Inverts the current matrix in place
  22952. * @returns the current inverted matrix
  22953. */
  22954. invert(): Matrix;
  22955. /**
  22956. * Sets all the matrix elements to zero
  22957. * @returns the current matrix
  22958. */
  22959. reset(): Matrix;
  22960. /**
  22961. * Adds the current matrix with a second one
  22962. * @param other defines the matrix to add
  22963. * @returns a new matrix as the addition of the current matrix and the given one
  22964. */
  22965. add(other: DeepImmutable<Matrix>): Matrix;
  22966. /**
  22967. * Sets the given matrix "result" to the addition of the current matrix and the given one
  22968. * @param other defines the matrix to add
  22969. * @param result defines the target matrix
  22970. * @returns the current matrix
  22971. */
  22972. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  22973. /**
  22974. * Adds in place the given matrix to the current matrix
  22975. * @param other defines the second operand
  22976. * @returns the current updated matrix
  22977. */
  22978. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  22979. /**
  22980. * Sets the given matrix to the current inverted Matrix
  22981. * @param other defines the target matrix
  22982. * @returns the unmodified current matrix
  22983. */
  22984. invertToRef(other: Matrix): Matrix;
  22985. /**
  22986. * add a value at the specified position in the current Matrix
  22987. * @param index the index of the value within the matrix. between 0 and 15.
  22988. * @param value the value to be added
  22989. * @returns the current updated matrix
  22990. */
  22991. addAtIndex(index: number, value: number): Matrix;
  22992. /**
  22993. * mutiply the specified position in the current Matrix by a value
  22994. * @param index the index of the value within the matrix. between 0 and 15.
  22995. * @param value the value to be added
  22996. * @returns the current updated matrix
  22997. */
  22998. multiplyAtIndex(index: number, value: number): Matrix;
  22999. /**
  23000. * Inserts the translation vector (using 3 floats) in the current matrix
  23001. * @param x defines the 1st component of the translation
  23002. * @param y defines the 2nd component of the translation
  23003. * @param z defines the 3rd component of the translation
  23004. * @returns the current updated matrix
  23005. */
  23006. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  23007. /**
  23008. * Inserts the translation vector in the current matrix
  23009. * @param vector3 defines the translation to insert
  23010. * @returns the current updated matrix
  23011. */
  23012. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  23013. /**
  23014. * Gets the translation value of the current matrix
  23015. * @returns a new Vector3 as the extracted translation from the matrix
  23016. */
  23017. getTranslation(): Vector3;
  23018. /**
  23019. * Fill a Vector3 with the extracted translation from the matrix
  23020. * @param result defines the Vector3 where to store the translation
  23021. * @returns the current matrix
  23022. */
  23023. getTranslationToRef(result: Vector3): Matrix;
  23024. /**
  23025. * Remove rotation and scaling part from the matrix
  23026. * @returns the updated matrix
  23027. */
  23028. removeRotationAndScaling(): Matrix;
  23029. /**
  23030. * Multiply two matrices
  23031. * @param other defines the second operand
  23032. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  23033. */
  23034. multiply(other: DeepImmutable<Matrix>): Matrix;
  23035. /**
  23036. * Copy the current matrix from the given one
  23037. * @param other defines the source matrix
  23038. * @returns the current updated matrix
  23039. */
  23040. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  23041. /**
  23042. * Populates the given array from the starting index with the current matrix values
  23043. * @param array defines the target array
  23044. * @param offset defines the offset in the target array where to start storing values
  23045. * @returns the current matrix
  23046. */
  23047. copyToArray(array: Float32Array, offset?: number): Matrix;
  23048. /**
  23049. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  23050. * @param other defines the second operand
  23051. * @param result defines the matrix where to store the multiplication
  23052. * @returns the current matrix
  23053. */
  23054. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  23055. /**
  23056. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  23057. * @param other defines the second operand
  23058. * @param result defines the array where to store the multiplication
  23059. * @param offset defines the offset in the target array where to start storing values
  23060. * @returns the current matrix
  23061. */
  23062. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  23063. /**
  23064. * Check equality between this matrix and a second one
  23065. * @param value defines the second matrix to compare
  23066. * @returns true is the current matrix and the given one values are strictly equal
  23067. */
  23068. equals(value: DeepImmutable<Matrix>): boolean;
  23069. /**
  23070. * Clone the current matrix
  23071. * @returns a new matrix from the current matrix
  23072. */
  23073. clone(): Matrix;
  23074. /**
  23075. * Returns the name of the current matrix class
  23076. * @returns the string "Matrix"
  23077. */
  23078. getClassName(): string;
  23079. /**
  23080. * Gets the hash code of the current matrix
  23081. * @returns the hash code
  23082. */
  23083. getHashCode(): number;
  23084. /**
  23085. * Decomposes the current Matrix into a translation, rotation and scaling components
  23086. * @param scale defines the scale vector3 given as a reference to update
  23087. * @param rotation defines the rotation quaternion given as a reference to update
  23088. * @param translation defines the translation vector3 given as a reference to update
  23089. * @returns true if operation was successful
  23090. */
  23091. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  23092. /**
  23093. * Gets specific row of the matrix
  23094. * @param index defines the number of the row to get
  23095. * @returns the index-th row of the current matrix as a new Vector4
  23096. */
  23097. getRow(index: number): Nullable<Vector4>;
  23098. /**
  23099. * Sets the index-th row of the current matrix to the vector4 values
  23100. * @param index defines the number of the row to set
  23101. * @param row defines the target vector4
  23102. * @returns the updated current matrix
  23103. */
  23104. setRow(index: number, row: Vector4): Matrix;
  23105. /**
  23106. * Compute the transpose of the matrix
  23107. * @returns the new transposed matrix
  23108. */
  23109. transpose(): Matrix;
  23110. /**
  23111. * Compute the transpose of the matrix and store it in a given matrix
  23112. * @param result defines the target matrix
  23113. * @returns the current matrix
  23114. */
  23115. transposeToRef(result: Matrix): Matrix;
  23116. /**
  23117. * Sets the index-th row of the current matrix with the given 4 x float values
  23118. * @param index defines the row index
  23119. * @param x defines the x component to set
  23120. * @param y defines the y component to set
  23121. * @param z defines the z component to set
  23122. * @param w defines the w component to set
  23123. * @returns the updated current matrix
  23124. */
  23125. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  23126. /**
  23127. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  23128. * @param scale defines the scale factor
  23129. * @returns a new matrix
  23130. */
  23131. scale(scale: number): Matrix;
  23132. /**
  23133. * Scale the current matrix values by a factor to a given result matrix
  23134. * @param scale defines the scale factor
  23135. * @param result defines the matrix to store the result
  23136. * @returns the current matrix
  23137. */
  23138. scaleToRef(scale: number, result: Matrix): Matrix;
  23139. /**
  23140. * Scale the current matrix values by a factor and add the result to a given matrix
  23141. * @param scale defines the scale factor
  23142. * @param result defines the Matrix to store the result
  23143. * @returns the current matrix
  23144. */
  23145. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  23146. /**
  23147. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  23148. * @param ref matrix to store the result
  23149. */
  23150. toNormalMatrix(ref: Matrix): void;
  23151. /**
  23152. * Gets only rotation part of the current matrix
  23153. * @returns a new matrix sets to the extracted rotation matrix from the current one
  23154. */
  23155. getRotationMatrix(): Matrix;
  23156. /**
  23157. * Extracts the rotation matrix from the current one and sets it as the given "result"
  23158. * @param result defines the target matrix to store data to
  23159. * @returns the current matrix
  23160. */
  23161. getRotationMatrixToRef(result: Matrix): Matrix;
  23162. /**
  23163. * Toggles model matrix from being right handed to left handed in place and vice versa
  23164. */
  23165. toggleModelMatrixHandInPlace(): void;
  23166. /**
  23167. * Toggles projection matrix from being right handed to left handed in place and vice versa
  23168. */
  23169. toggleProjectionMatrixHandInPlace(): void;
  23170. /**
  23171. * Creates a matrix from an array
  23172. * @param array defines the source array
  23173. * @param offset defines an offset in the source array
  23174. * @returns a new Matrix set from the starting index of the given array
  23175. */
  23176. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  23177. /**
  23178. * Copy the content of an array into a given matrix
  23179. * @param array defines the source array
  23180. * @param offset defines an offset in the source array
  23181. * @param result defines the target matrix
  23182. */
  23183. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  23184. /**
  23185. * Stores an array into a matrix after having multiplied each component by a given factor
  23186. * @param array defines the source array
  23187. * @param offset defines the offset in the source array
  23188. * @param scale defines the scaling factor
  23189. * @param result defines the target matrix
  23190. */
  23191. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  23192. /**
  23193. * Gets an identity matrix that must not be updated
  23194. */
  23195. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  23196. /**
  23197. * Stores a list of values (16) inside a given matrix
  23198. * @param initialM11 defines 1st value of 1st row
  23199. * @param initialM12 defines 2nd value of 1st row
  23200. * @param initialM13 defines 3rd value of 1st row
  23201. * @param initialM14 defines 4th value of 1st row
  23202. * @param initialM21 defines 1st value of 2nd row
  23203. * @param initialM22 defines 2nd value of 2nd row
  23204. * @param initialM23 defines 3rd value of 2nd row
  23205. * @param initialM24 defines 4th value of 2nd row
  23206. * @param initialM31 defines 1st value of 3rd row
  23207. * @param initialM32 defines 2nd value of 3rd row
  23208. * @param initialM33 defines 3rd value of 3rd row
  23209. * @param initialM34 defines 4th value of 3rd row
  23210. * @param initialM41 defines 1st value of 4th row
  23211. * @param initialM42 defines 2nd value of 4th row
  23212. * @param initialM43 defines 3rd value of 4th row
  23213. * @param initialM44 defines 4th value of 4th row
  23214. * @param result defines the target matrix
  23215. */
  23216. 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;
  23217. /**
  23218. * Creates new matrix from a list of values (16)
  23219. * @param initialM11 defines 1st value of 1st row
  23220. * @param initialM12 defines 2nd value of 1st row
  23221. * @param initialM13 defines 3rd value of 1st row
  23222. * @param initialM14 defines 4th value of 1st row
  23223. * @param initialM21 defines 1st value of 2nd row
  23224. * @param initialM22 defines 2nd value of 2nd row
  23225. * @param initialM23 defines 3rd value of 2nd row
  23226. * @param initialM24 defines 4th value of 2nd row
  23227. * @param initialM31 defines 1st value of 3rd row
  23228. * @param initialM32 defines 2nd value of 3rd row
  23229. * @param initialM33 defines 3rd value of 3rd row
  23230. * @param initialM34 defines 4th value of 3rd row
  23231. * @param initialM41 defines 1st value of 4th row
  23232. * @param initialM42 defines 2nd value of 4th row
  23233. * @param initialM43 defines 3rd value of 4th row
  23234. * @param initialM44 defines 4th value of 4th row
  23235. * @returns the new matrix
  23236. */
  23237. 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;
  23238. /**
  23239. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  23240. * @param scale defines the scale vector3
  23241. * @param rotation defines the rotation quaternion
  23242. * @param translation defines the translation vector3
  23243. * @returns a new matrix
  23244. */
  23245. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  23246. /**
  23247. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  23248. * @param scale defines the scale vector3
  23249. * @param rotation defines the rotation quaternion
  23250. * @param translation defines the translation vector3
  23251. * @param result defines the target matrix
  23252. */
  23253. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  23254. /**
  23255. * Creates a new identity matrix
  23256. * @returns a new identity matrix
  23257. */
  23258. static Identity(): Matrix;
  23259. /**
  23260. * Creates a new identity matrix and stores the result in a given matrix
  23261. * @param result defines the target matrix
  23262. */
  23263. static IdentityToRef(result: Matrix): void;
  23264. /**
  23265. * Creates a new zero matrix
  23266. * @returns a new zero matrix
  23267. */
  23268. static Zero(): Matrix;
  23269. /**
  23270. * Creates a new rotation matrix for "angle" radians around the X axis
  23271. * @param angle defines the angle (in radians) to use
  23272. * @return the new matrix
  23273. */
  23274. static RotationX(angle: number): Matrix;
  23275. /**
  23276. * Creates a new matrix as the invert of a given matrix
  23277. * @param source defines the source matrix
  23278. * @returns the new matrix
  23279. */
  23280. static Invert(source: DeepImmutable<Matrix>): Matrix;
  23281. /**
  23282. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  23283. * @param angle defines the angle (in radians) to use
  23284. * @param result defines the target matrix
  23285. */
  23286. static RotationXToRef(angle: number, result: Matrix): void;
  23287. /**
  23288. * Creates a new rotation matrix for "angle" radians around the Y axis
  23289. * @param angle defines the angle (in radians) to use
  23290. * @return the new matrix
  23291. */
  23292. static RotationY(angle: number): Matrix;
  23293. /**
  23294. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  23295. * @param angle defines the angle (in radians) to use
  23296. * @param result defines the target matrix
  23297. */
  23298. static RotationYToRef(angle: number, result: Matrix): void;
  23299. /**
  23300. * Creates a new rotation matrix for "angle" radians around the Z axis
  23301. * @param angle defines the angle (in radians) to use
  23302. * @return the new matrix
  23303. */
  23304. static RotationZ(angle: number): Matrix;
  23305. /**
  23306. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  23307. * @param angle defines the angle (in radians) to use
  23308. * @param result defines the target matrix
  23309. */
  23310. static RotationZToRef(angle: number, result: Matrix): void;
  23311. /**
  23312. * Creates a new rotation matrix for "angle" radians around the given axis
  23313. * @param axis defines the axis to use
  23314. * @param angle defines the angle (in radians) to use
  23315. * @return the new matrix
  23316. */
  23317. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  23318. /**
  23319. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  23320. * @param axis defines the axis to use
  23321. * @param angle defines the angle (in radians) to use
  23322. * @param result defines the target matrix
  23323. */
  23324. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  23325. /**
  23326. * Creates a rotation matrix
  23327. * @param yaw defines the yaw angle in radians (Y axis)
  23328. * @param pitch defines the pitch angle in radians (X axis)
  23329. * @param roll defines the roll angle in radians (X axis)
  23330. * @returns the new rotation matrix
  23331. */
  23332. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  23333. /**
  23334. * Creates a rotation matrix and stores it in a given matrix
  23335. * @param yaw defines the yaw angle in radians (Y axis)
  23336. * @param pitch defines the pitch angle in radians (X axis)
  23337. * @param roll defines the roll angle in radians (X axis)
  23338. * @param result defines the target matrix
  23339. */
  23340. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  23341. /**
  23342. * Creates a scaling matrix
  23343. * @param x defines the scale factor on X axis
  23344. * @param y defines the scale factor on Y axis
  23345. * @param z defines the scale factor on Z axis
  23346. * @returns the new matrix
  23347. */
  23348. static Scaling(x: number, y: number, z: number): Matrix;
  23349. /**
  23350. * Creates a scaling matrix and stores it in a given matrix
  23351. * @param x defines the scale factor on X axis
  23352. * @param y defines the scale factor on Y axis
  23353. * @param z defines the scale factor on Z axis
  23354. * @param result defines the target matrix
  23355. */
  23356. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  23357. /**
  23358. * Creates a translation matrix
  23359. * @param x defines the translation on X axis
  23360. * @param y defines the translation on Y axis
  23361. * @param z defines the translationon Z axis
  23362. * @returns the new matrix
  23363. */
  23364. static Translation(x: number, y: number, z: number): Matrix;
  23365. /**
  23366. * Creates a translation matrix and stores it in a given matrix
  23367. * @param x defines the translation on X axis
  23368. * @param y defines the translation on Y axis
  23369. * @param z defines the translationon Z axis
  23370. * @param result defines the target matrix
  23371. */
  23372. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  23373. /**
  23374. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  23375. * @param startValue defines the start value
  23376. * @param endValue defines the end value
  23377. * @param gradient defines the gradient factor
  23378. * @returns the new matrix
  23379. */
  23380. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  23381. /**
  23382. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  23383. * @param startValue defines the start value
  23384. * @param endValue defines the end value
  23385. * @param gradient defines the gradient factor
  23386. * @param result defines the Matrix object where to store data
  23387. */
  23388. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  23389. /**
  23390. * Builds a new matrix whose values are computed by:
  23391. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  23392. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  23393. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  23394. * @param startValue defines the first matrix
  23395. * @param endValue defines the second matrix
  23396. * @param gradient defines the gradient between the two matrices
  23397. * @returns the new matrix
  23398. */
  23399. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  23400. /**
  23401. * Update a matrix to values which are computed by:
  23402. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  23403. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  23404. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  23405. * @param startValue defines the first matrix
  23406. * @param endValue defines the second matrix
  23407. * @param gradient defines the gradient between the two matrices
  23408. * @param result defines the target matrix
  23409. */
  23410. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  23411. /**
  23412. * 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"
  23413. * This function works in left handed mode
  23414. * @param eye defines the final position of the entity
  23415. * @param target defines where the entity should look at
  23416. * @param up defines the up vector for the entity
  23417. * @returns the new matrix
  23418. */
  23419. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  23420. /**
  23421. * 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".
  23422. * This function works in left handed mode
  23423. * @param eye defines the final position of the entity
  23424. * @param target defines where the entity should look at
  23425. * @param up defines the up vector for the entity
  23426. * @param result defines the target matrix
  23427. */
  23428. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  23429. /**
  23430. * 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"
  23431. * This function works in right handed mode
  23432. * @param eye defines the final position of the entity
  23433. * @param target defines where the entity should look at
  23434. * @param up defines the up vector for the entity
  23435. * @returns the new matrix
  23436. */
  23437. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  23438. /**
  23439. * 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".
  23440. * This function works in right handed mode
  23441. * @param eye defines the final position of the entity
  23442. * @param target defines where the entity should look at
  23443. * @param up defines the up vector for the entity
  23444. * @param result defines the target matrix
  23445. */
  23446. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  23447. /**
  23448. * Create a left-handed orthographic projection matrix
  23449. * @param width defines the viewport width
  23450. * @param height defines the viewport height
  23451. * @param znear defines the near clip plane
  23452. * @param zfar defines the far clip plane
  23453. * @returns a new matrix as a left-handed orthographic projection matrix
  23454. */
  23455. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  23456. /**
  23457. * Store a left-handed orthographic projection to a given matrix
  23458. * @param width defines the viewport width
  23459. * @param height defines the viewport height
  23460. * @param znear defines the near clip plane
  23461. * @param zfar defines the far clip plane
  23462. * @param result defines the target matrix
  23463. */
  23464. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  23465. /**
  23466. * Create a left-handed orthographic projection matrix
  23467. * @param left defines the viewport left coordinate
  23468. * @param right defines the viewport right coordinate
  23469. * @param bottom defines the viewport bottom coordinate
  23470. * @param top defines the viewport top coordinate
  23471. * @param znear defines the near clip plane
  23472. * @param zfar defines the far clip plane
  23473. * @returns a new matrix as a left-handed orthographic projection matrix
  23474. */
  23475. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  23476. /**
  23477. * Stores a left-handed orthographic projection into a given matrix
  23478. * @param left defines the viewport left coordinate
  23479. * @param right defines the viewport right coordinate
  23480. * @param bottom defines the viewport bottom coordinate
  23481. * @param top defines the viewport top coordinate
  23482. * @param znear defines the near clip plane
  23483. * @param zfar defines the far clip plane
  23484. * @param result defines the target matrix
  23485. */
  23486. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  23487. /**
  23488. * Creates a right-handed orthographic projection matrix
  23489. * @param left defines the viewport left coordinate
  23490. * @param right defines the viewport right coordinate
  23491. * @param bottom defines the viewport bottom coordinate
  23492. * @param top defines the viewport top coordinate
  23493. * @param znear defines the near clip plane
  23494. * @param zfar defines the far clip plane
  23495. * @returns a new matrix as a right-handed orthographic projection matrix
  23496. */
  23497. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  23498. /**
  23499. * Stores a right-handed orthographic projection into a given matrix
  23500. * @param left defines the viewport left coordinate
  23501. * @param right defines the viewport right coordinate
  23502. * @param bottom defines the viewport bottom coordinate
  23503. * @param top defines the viewport top coordinate
  23504. * @param znear defines the near clip plane
  23505. * @param zfar defines the far clip plane
  23506. * @param result defines the target matrix
  23507. */
  23508. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  23509. /**
  23510. * Creates a left-handed perspective projection matrix
  23511. * @param width defines the viewport width
  23512. * @param height defines the viewport height
  23513. * @param znear defines the near clip plane
  23514. * @param zfar defines the far clip plane
  23515. * @returns a new matrix as a left-handed perspective projection matrix
  23516. */
  23517. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  23518. /**
  23519. * Creates a left-handed perspective projection matrix
  23520. * @param fov defines the horizontal field of view
  23521. * @param aspect defines the aspect ratio
  23522. * @param znear defines the near clip plane
  23523. * @param zfar defines the far clip plane
  23524. * @returns a new matrix as a left-handed perspective projection matrix
  23525. */
  23526. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  23527. /**
  23528. * Stores a left-handed perspective projection into a given matrix
  23529. * @param fov defines the horizontal field of view
  23530. * @param aspect defines the aspect ratio
  23531. * @param znear defines the near clip plane
  23532. * @param zfar defines the far clip plane
  23533. * @param result defines the target matrix
  23534. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  23535. */
  23536. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  23537. /**
  23538. * Creates a right-handed perspective projection matrix
  23539. * @param fov defines the horizontal field of view
  23540. * @param aspect defines the aspect ratio
  23541. * @param znear defines the near clip plane
  23542. * @param zfar defines the far clip plane
  23543. * @returns a new matrix as a right-handed perspective projection matrix
  23544. */
  23545. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  23546. /**
  23547. * Stores a right-handed perspective projection into a given matrix
  23548. * @param fov defines the horizontal field of view
  23549. * @param aspect defines the aspect ratio
  23550. * @param znear defines the near clip plane
  23551. * @param zfar defines the far clip plane
  23552. * @param result defines the target matrix
  23553. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  23554. */
  23555. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  23556. /**
  23557. * Stores a perspective projection for WebVR info a given matrix
  23558. * @param fov defines the field of view
  23559. * @param znear defines the near clip plane
  23560. * @param zfar defines the far clip plane
  23561. * @param result defines the target matrix
  23562. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  23563. */
  23564. static PerspectiveFovWebVRToRef(fov: {
  23565. upDegrees: number;
  23566. downDegrees: number;
  23567. leftDegrees: number;
  23568. rightDegrees: number;
  23569. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  23570. /**
  23571. * Computes a complete transformation matrix
  23572. * @param viewport defines the viewport to use
  23573. * @param world defines the world matrix
  23574. * @param view defines the view matrix
  23575. * @param projection defines the projection matrix
  23576. * @param zmin defines the near clip plane
  23577. * @param zmax defines the far clip plane
  23578. * @returns the transformation matrix
  23579. */
  23580. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  23581. /**
  23582. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  23583. * @param matrix defines the matrix to use
  23584. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  23585. */
  23586. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  23587. /**
  23588. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  23589. * @param matrix defines the matrix to use
  23590. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  23591. */
  23592. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  23593. /**
  23594. * Compute the transpose of a given matrix
  23595. * @param matrix defines the matrix to transpose
  23596. * @returns the new matrix
  23597. */
  23598. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  23599. /**
  23600. * Compute the transpose of a matrix and store it in a target matrix
  23601. * @param matrix defines the matrix to transpose
  23602. * @param result defines the target matrix
  23603. */
  23604. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  23605. /**
  23606. * Computes a reflection matrix from a plane
  23607. * @param plane defines the reflection plane
  23608. * @returns a new matrix
  23609. */
  23610. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  23611. /**
  23612. * Computes a reflection matrix from a plane
  23613. * @param plane defines the reflection plane
  23614. * @param result defines the target matrix
  23615. */
  23616. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  23617. /**
  23618. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  23619. * @param xaxis defines the value of the 1st axis
  23620. * @param yaxis defines the value of the 2nd axis
  23621. * @param zaxis defines the value of the 3rd axis
  23622. * @param result defines the target matrix
  23623. */
  23624. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  23625. /**
  23626. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  23627. * @param quat defines the quaternion to use
  23628. * @param result defines the target matrix
  23629. */
  23630. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  23631. }
  23632. /**
  23633. * Represens a plane by the equation ax + by + cz + d = 0
  23634. */
  23635. class Plane {
  23636. /**
  23637. * Normal of the plane (a,b,c)
  23638. */
  23639. normal: Vector3;
  23640. /**
  23641. * d component of the plane
  23642. */
  23643. d: number;
  23644. /**
  23645. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  23646. * @param a a component of the plane
  23647. * @param b b component of the plane
  23648. * @param c c component of the plane
  23649. * @param d d component of the plane
  23650. */
  23651. constructor(a: number, b: number, c: number, d: number);
  23652. /**
  23653. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  23654. */
  23655. asArray(): number[];
  23656. /**
  23657. * @returns a new plane copied from the current Plane.
  23658. */
  23659. clone(): Plane;
  23660. /**
  23661. * @returns the string "Plane".
  23662. */
  23663. getClassName(): string;
  23664. /**
  23665. * @returns the Plane hash code.
  23666. */
  23667. getHashCode(): number;
  23668. /**
  23669. * Normalize the current Plane in place.
  23670. * @returns the updated Plane.
  23671. */
  23672. normalize(): Plane;
  23673. /**
  23674. * Applies a transformation the plane and returns the result
  23675. * @param transformation the transformation matrix to be applied to the plane
  23676. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  23677. */
  23678. transform(transformation: DeepImmutable<Matrix>): Plane;
  23679. /**
  23680. * Calcualtte the dot product between the point and the plane normal
  23681. * @param point point to calculate the dot product with
  23682. * @returns the dot product (float) of the point coordinates and the plane normal.
  23683. */
  23684. dotCoordinate(point: DeepImmutable<Vector3>): number;
  23685. /**
  23686. * Updates the current Plane from the plane defined by the three given points.
  23687. * @param point1 one of the points used to contruct the plane
  23688. * @param point2 one of the points used to contruct the plane
  23689. * @param point3 one of the points used to contruct the plane
  23690. * @returns the updated Plane.
  23691. */
  23692. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  23693. /**
  23694. * Checks if the plane is facing a given direction
  23695. * @param direction the direction to check if the plane is facing
  23696. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  23697. * @returns True is the vector "direction" is the same side than the plane normal.
  23698. */
  23699. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  23700. /**
  23701. * Calculates the distance to a point
  23702. * @param point point to calculate distance to
  23703. * @returns the signed distance (float) from the given point to the Plane.
  23704. */
  23705. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  23706. /**
  23707. * Creates a plane from an array
  23708. * @param array the array to create a plane from
  23709. * @returns a new Plane from the given array.
  23710. */
  23711. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  23712. /**
  23713. * Creates a plane from three points
  23714. * @param point1 point used to create the plane
  23715. * @param point2 point used to create the plane
  23716. * @param point3 point used to create the plane
  23717. * @returns a new Plane defined by the three given points.
  23718. */
  23719. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  23720. /**
  23721. * Creates a plane from an origin point and a normal
  23722. * @param origin origin of the plane to be constructed
  23723. * @param normal normal of the plane to be constructed
  23724. * @returns a new Plane the normal vector to this plane at the given origin point.
  23725. * Note : the vector "normal" is updated because normalized.
  23726. */
  23727. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  23728. /**
  23729. * Calculates the distance from a plane and a point
  23730. * @param origin origin of the plane to be constructed
  23731. * @param normal normal of the plane to be constructed
  23732. * @param point point to calculate distance to
  23733. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  23734. */
  23735. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  23736. }
  23737. /**
  23738. * Class used to represent a viewport on screen
  23739. */
  23740. class Viewport {
  23741. /** viewport left coordinate */
  23742. x: number;
  23743. /** viewport top coordinate */
  23744. y: number;
  23745. /**viewport width */
  23746. width: number;
  23747. /** viewport height */
  23748. height: number;
  23749. /**
  23750. * Creates a Viewport object located at (x, y) and sized (width, height)
  23751. * @param x defines viewport left coordinate
  23752. * @param y defines viewport top coordinate
  23753. * @param width defines the viewport width
  23754. * @param height defines the viewport height
  23755. */
  23756. constructor(
  23757. /** viewport left coordinate */
  23758. x: number,
  23759. /** viewport top coordinate */
  23760. y: number,
  23761. /**viewport width */
  23762. width: number,
  23763. /** viewport height */
  23764. height: number);
  23765. /**
  23766. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  23767. * @param renderWidthOrEngine defines either an engine or the rendering width
  23768. * @param renderHeight defines the rendering height
  23769. * @returns a new Viewport
  23770. */
  23771. toGlobal(renderWidthOrEngine: number | Engine, renderHeight: number): Viewport;
  23772. /**
  23773. * Returns a new Viewport copied from the current one
  23774. * @returns a new Viewport
  23775. */
  23776. clone(): Viewport;
  23777. }
  23778. /**
  23779. * Reprasents a camera frustum
  23780. */
  23781. class Frustum {
  23782. /**
  23783. * Gets the planes representing the frustum
  23784. * @param transform matrix to be applied to the returned planes
  23785. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  23786. */
  23787. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  23788. /**
  23789. * Gets the near frustum plane transformed by the transform matrix
  23790. * @param transform transformation matrix to be applied to the resulting frustum plane
  23791. * @param frustumPlane the resuling frustum plane
  23792. */
  23793. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  23794. /**
  23795. * Gets the far frustum plane transformed by the transform matrix
  23796. * @param transform transformation matrix to be applied to the resulting frustum plane
  23797. * @param frustumPlane the resuling frustum plane
  23798. */
  23799. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  23800. /**
  23801. * Gets the left frustum plane transformed by the transform matrix
  23802. * @param transform transformation matrix to be applied to the resulting frustum plane
  23803. * @param frustumPlane the resuling frustum plane
  23804. */
  23805. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  23806. /**
  23807. * Gets the right frustum plane transformed by the transform matrix
  23808. * @param transform transformation matrix to be applied to the resulting frustum plane
  23809. * @param frustumPlane the resuling frustum plane
  23810. */
  23811. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  23812. /**
  23813. * Gets the top frustum plane transformed by the transform matrix
  23814. * @param transform transformation matrix to be applied to the resulting frustum plane
  23815. * @param frustumPlane the resuling frustum plane
  23816. */
  23817. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  23818. /**
  23819. * Gets the bottom frustum plane transformed by the transform matrix
  23820. * @param transform transformation matrix to be applied to the resulting frustum plane
  23821. * @param frustumPlane the resuling frustum plane
  23822. */
  23823. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  23824. /**
  23825. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  23826. * @param transform transformation matrix to be applied to the resulting frustum planes
  23827. * @param frustumPlanes the resuling frustum planes
  23828. */
  23829. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  23830. }
  23831. /** Defines supported spaces */
  23832. enum Space {
  23833. /** Local (object) space */
  23834. LOCAL = 0,
  23835. /** World space */
  23836. WORLD = 1,
  23837. /** Bone space */
  23838. BONE = 2
  23839. }
  23840. /** Defines the 3 main axes */
  23841. class Axis {
  23842. /** X axis */
  23843. static X: Vector3;
  23844. /** Y axis */
  23845. static Y: Vector3;
  23846. /** Z axis */
  23847. static Z: Vector3;
  23848. }
  23849. /** Class used to represent a Bezier curve */
  23850. class BezierCurve {
  23851. /**
  23852. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  23853. * @param t defines the time
  23854. * @param x1 defines the left coordinate on X axis
  23855. * @param y1 defines the left coordinate on Y axis
  23856. * @param x2 defines the right coordinate on X axis
  23857. * @param y2 defines the right coordinate on Y axis
  23858. * @returns the interpolated value
  23859. */
  23860. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  23861. }
  23862. /**
  23863. * Defines potential orientation for back face culling
  23864. */
  23865. enum Orientation {
  23866. /**
  23867. * Clockwise
  23868. */
  23869. CW = 0,
  23870. /** Counter clockwise */
  23871. CCW = 1
  23872. }
  23873. /**
  23874. * Defines angle representation
  23875. */
  23876. class Angle {
  23877. private _radians;
  23878. /**
  23879. * Creates an Angle object of "radians" radians (float).
  23880. */
  23881. constructor(radians: number);
  23882. /**
  23883. * Get value in degrees
  23884. * @returns the Angle value in degrees (float)
  23885. */
  23886. degrees(): number;
  23887. /**
  23888. * Get value in radians
  23889. * @returns the Angle value in radians (float)
  23890. */
  23891. radians(): number;
  23892. /**
  23893. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  23894. * @param a defines first vector
  23895. * @param b defines second vector
  23896. * @returns a new Angle
  23897. */
  23898. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  23899. /**
  23900. * Gets a new Angle object from the given float in radians
  23901. * @param radians defines the angle value in radians
  23902. * @returns a new Angle
  23903. */
  23904. static FromRadians(radians: number): Angle;
  23905. /**
  23906. * Gets a new Angle object from the given float in degrees
  23907. * @param degrees defines the angle value in degrees
  23908. * @returns a new Angle
  23909. */
  23910. static FromDegrees(degrees: number): Angle;
  23911. }
  23912. /**
  23913. * This represents an arc in a 2d space.
  23914. */
  23915. class Arc2 {
  23916. /** Defines the start point of the arc */
  23917. startPoint: Vector2;
  23918. /** Defines the mid point of the arc */
  23919. midPoint: Vector2;
  23920. /** Defines the end point of the arc */
  23921. endPoint: Vector2;
  23922. /**
  23923. * Defines the center point of the arc.
  23924. */
  23925. centerPoint: Vector2;
  23926. /**
  23927. * Defines the radius of the arc.
  23928. */
  23929. radius: number;
  23930. /**
  23931. * Defines the angle of the arc (from mid point to end point).
  23932. */
  23933. angle: Angle;
  23934. /**
  23935. * Defines the start angle of the arc (from start point to middle point).
  23936. */
  23937. startAngle: Angle;
  23938. /**
  23939. * Defines the orientation of the arc (clock wise/counter clock wise).
  23940. */
  23941. orientation: Orientation;
  23942. /**
  23943. * Creates an Arc object from the three given points : start, middle and end.
  23944. * @param startPoint Defines the start point of the arc
  23945. * @param midPoint Defines the midlle point of the arc
  23946. * @param endPoint Defines the end point of the arc
  23947. */
  23948. constructor(
  23949. /** Defines the start point of the arc */
  23950. startPoint: Vector2,
  23951. /** Defines the mid point of the arc */
  23952. midPoint: Vector2,
  23953. /** Defines the end point of the arc */
  23954. endPoint: Vector2);
  23955. }
  23956. /**
  23957. * Represents a 2D path made up of multiple 2D points
  23958. */
  23959. class Path2 {
  23960. private _points;
  23961. private _length;
  23962. /**
  23963. * If the path start and end point are the same
  23964. */
  23965. closed: boolean;
  23966. /**
  23967. * Creates a Path2 object from the starting 2D coordinates x and y.
  23968. * @param x the starting points x value
  23969. * @param y the starting points y value
  23970. */
  23971. constructor(x: number, y: number);
  23972. /**
  23973. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  23974. * @param x the added points x value
  23975. * @param y the added points y value
  23976. * @returns the updated Path2.
  23977. */
  23978. addLineTo(x: number, y: number): Path2;
  23979. /**
  23980. * 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.
  23981. * @param midX middle point x value
  23982. * @param midY middle point y value
  23983. * @param endX end point x value
  23984. * @param endY end point y value
  23985. * @param numberOfSegments (default: 36)
  23986. * @returns the updated Path2.
  23987. */
  23988. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  23989. /**
  23990. * Closes the Path2.
  23991. * @returns the Path2.
  23992. */
  23993. close(): Path2;
  23994. /**
  23995. * Gets the sum of the distance between each sequential point in the path
  23996. * @returns the Path2 total length (float).
  23997. */
  23998. length(): number;
  23999. /**
  24000. * Gets the points which construct the path
  24001. * @returns the Path2 internal array of points.
  24002. */
  24003. getPoints(): Vector2[];
  24004. /**
  24005. * Retreives the point at the distance aways from the starting point
  24006. * @param normalizedLengthPosition the length along the path to retreive the point from
  24007. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  24008. */
  24009. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  24010. /**
  24011. * Creates a new path starting from an x and y position
  24012. * @param x starting x value
  24013. * @param y starting y value
  24014. * @returns a new Path2 starting at the coordinates (x, y).
  24015. */
  24016. static StartingAt(x: number, y: number): Path2;
  24017. }
  24018. /**
  24019. * Represents a 3D path made up of multiple 3D points
  24020. */
  24021. class Path3D {
  24022. /**
  24023. * an array of Vector3, the curve axis of the Path3D
  24024. */
  24025. path: Vector3[];
  24026. private _curve;
  24027. private _distances;
  24028. private _tangents;
  24029. private _normals;
  24030. private _binormals;
  24031. private _raw;
  24032. /**
  24033. * new Path3D(path, normal, raw)
  24034. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  24035. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  24036. * @param path an array of Vector3, the curve axis of the Path3D
  24037. * @param normal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  24038. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  24039. */
  24040. constructor(
  24041. /**
  24042. * an array of Vector3, the curve axis of the Path3D
  24043. */
  24044. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  24045. /**
  24046. * Returns the Path3D array of successive Vector3 designing its curve.
  24047. * @returns the Path3D array of successive Vector3 designing its curve.
  24048. */
  24049. getCurve(): Vector3[];
  24050. /**
  24051. * Returns an array populated with tangent vectors on each Path3D curve point.
  24052. * @returns an array populated with tangent vectors on each Path3D curve point.
  24053. */
  24054. getTangents(): Vector3[];
  24055. /**
  24056. * Returns an array populated with normal vectors on each Path3D curve point.
  24057. * @returns an array populated with normal vectors on each Path3D curve point.
  24058. */
  24059. getNormals(): Vector3[];
  24060. /**
  24061. * Returns an array populated with binormal vectors on each Path3D curve point.
  24062. * @returns an array populated with binormal vectors on each Path3D curve point.
  24063. */
  24064. getBinormals(): Vector3[];
  24065. /**
  24066. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  24067. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  24068. */
  24069. getDistances(): number[];
  24070. /**
  24071. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  24072. * @param path path which all values are copied into the curves points
  24073. * @param firstNormal which should be projected onto the curve
  24074. * @returns the same object updated.
  24075. */
  24076. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  24077. private _compute;
  24078. private _getFirstNonNullVector;
  24079. private _getLastNonNullVector;
  24080. private _normalVector;
  24081. }
  24082. /**
  24083. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  24084. * A Curve3 is designed from a series of successive Vector3.
  24085. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  24086. */
  24087. class Curve3 {
  24088. private _points;
  24089. private _length;
  24090. /**
  24091. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  24092. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  24093. * @param v1 (Vector3) the control point
  24094. * @param v2 (Vector3) the end point of the Quadratic Bezier
  24095. * @param nbPoints (integer) the wanted number of points in the curve
  24096. * @returns the created Curve3
  24097. */
  24098. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  24099. /**
  24100. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  24101. * @param v0 (Vector3) the origin point of the Cubic Bezier
  24102. * @param v1 (Vector3) the first control point
  24103. * @param v2 (Vector3) the second control point
  24104. * @param v3 (Vector3) the end point of the Cubic Bezier
  24105. * @param nbPoints (integer) the wanted number of points in the curve
  24106. * @returns the created Curve3
  24107. */
  24108. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  24109. /**
  24110. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  24111. * @param p1 (Vector3) the origin point of the Hermite Spline
  24112. * @param t1 (Vector3) the tangent vector at the origin point
  24113. * @param p2 (Vector3) the end point of the Hermite Spline
  24114. * @param t2 (Vector3) the tangent vector at the end point
  24115. * @param nbPoints (integer) the wanted number of points in the curve
  24116. * @returns the created Curve3
  24117. */
  24118. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  24119. /**
  24120. * Returns a Curve3 object along a CatmullRom Spline curve :
  24121. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  24122. * @param nbPoints (integer) the wanted number of points between each curve control points
  24123. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  24124. * @returns the created Curve3
  24125. */
  24126. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  24127. /**
  24128. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  24129. * A Curve3 is designed from a series of successive Vector3.
  24130. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  24131. * @param points points which make up the curve
  24132. */
  24133. constructor(points: Vector3[]);
  24134. /**
  24135. * @returns the Curve3 stored array of successive Vector3
  24136. */
  24137. getPoints(): Vector3[];
  24138. /**
  24139. * @returns the computed length (float) of the curve.
  24140. */
  24141. length(): number;
  24142. /**
  24143. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  24144. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  24145. * curveA and curveB keep unchanged.
  24146. * @param curve the curve to continue from this curve
  24147. * @returns the newly constructed curve
  24148. */
  24149. continue(curve: DeepImmutable<Curve3>): Curve3;
  24150. private _computeLength;
  24151. }
  24152. /**
  24153. * Contains position and normal vectors for a vertex
  24154. */
  24155. class PositionNormalVertex {
  24156. /** the position of the vertex (defaut: 0,0,0) */
  24157. position: Vector3;
  24158. /** the normal of the vertex (defaut: 0,1,0) */
  24159. normal: Vector3;
  24160. /**
  24161. * Creates a PositionNormalVertex
  24162. * @param position the position of the vertex (defaut: 0,0,0)
  24163. * @param normal the normal of the vertex (defaut: 0,1,0)
  24164. */
  24165. constructor(
  24166. /** the position of the vertex (defaut: 0,0,0) */
  24167. position?: Vector3,
  24168. /** the normal of the vertex (defaut: 0,1,0) */
  24169. normal?: Vector3);
  24170. /**
  24171. * Clones the PositionNormalVertex
  24172. * @returns the cloned PositionNormalVertex
  24173. */
  24174. clone(): PositionNormalVertex;
  24175. }
  24176. /**
  24177. * Contains position, normal and uv vectors for a vertex
  24178. */
  24179. class PositionNormalTextureVertex {
  24180. /** the position of the vertex (defaut: 0,0,0) */
  24181. position: Vector3;
  24182. /** the normal of the vertex (defaut: 0,1,0) */
  24183. normal: Vector3;
  24184. /** the uv of the vertex (default: 0,0) */
  24185. uv: Vector2;
  24186. /**
  24187. * Creates a PositionNormalTextureVertex
  24188. * @param position the position of the vertex (defaut: 0,0,0)
  24189. * @param normal the normal of the vertex (defaut: 0,1,0)
  24190. * @param uv the uv of the vertex (default: 0,0)
  24191. */
  24192. constructor(
  24193. /** the position of the vertex (defaut: 0,0,0) */
  24194. position?: Vector3,
  24195. /** the normal of the vertex (defaut: 0,1,0) */
  24196. normal?: Vector3,
  24197. /** the uv of the vertex (default: 0,0) */
  24198. uv?: Vector2);
  24199. /**
  24200. * Clones the PositionNormalTextureVertex
  24201. * @returns the cloned PositionNormalTextureVertex
  24202. */
  24203. clone(): PositionNormalTextureVertex;
  24204. }
  24205. /**
  24206. * @hidden
  24207. */
  24208. class Tmp {
  24209. static Color3: Color3[];
  24210. static Color4: Color4[];
  24211. static Vector2: Vector2[];
  24212. static Vector3: Vector3[];
  24213. static Vector4: Vector4[];
  24214. static Quaternion: Quaternion[];
  24215. static Matrix: Matrix[];
  24216. }
  24217. }
  24218. declare module BABYLON {
  24219. /**
  24220. * Class representing spherical polynomial coefficients to the 3rd degree
  24221. */
  24222. class SphericalPolynomial {
  24223. /**
  24224. * The x coefficients of the spherical polynomial
  24225. */
  24226. x: Vector3;
  24227. /**
  24228. * The y coefficients of the spherical polynomial
  24229. */
  24230. y: Vector3;
  24231. /**
  24232. * The z coefficients of the spherical polynomial
  24233. */
  24234. z: Vector3;
  24235. /**
  24236. * The xx coefficients of the spherical polynomial
  24237. */
  24238. xx: Vector3;
  24239. /**
  24240. * The yy coefficients of the spherical polynomial
  24241. */
  24242. yy: Vector3;
  24243. /**
  24244. * The zz coefficients of the spherical polynomial
  24245. */
  24246. zz: Vector3;
  24247. /**
  24248. * The xy coefficients of the spherical polynomial
  24249. */
  24250. xy: Vector3;
  24251. /**
  24252. * The yz coefficients of the spherical polynomial
  24253. */
  24254. yz: Vector3;
  24255. /**
  24256. * The zx coefficients of the spherical polynomial
  24257. */
  24258. zx: Vector3;
  24259. /**
  24260. * Adds an ambient color to the spherical polynomial
  24261. * @param color the color to add
  24262. */
  24263. addAmbient(color: Color3): void;
  24264. /**
  24265. * Scales the spherical polynomial by the given amount
  24266. * @param scale the amount to scale
  24267. */
  24268. scale(scale: number): void;
  24269. /**
  24270. * Gets the spherical polynomial from harmonics
  24271. * @param harmonics the spherical harmonics
  24272. * @returns the spherical polynomial
  24273. */
  24274. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  24275. /**
  24276. * Constructs a spherical polynomial from an array.
  24277. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  24278. * @returns the spherical polynomial
  24279. */
  24280. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  24281. }
  24282. /**
  24283. * Class representing spherical harmonics coefficients to the 3rd degree
  24284. */
  24285. class SphericalHarmonics {
  24286. /**
  24287. * The l0,0 coefficients of the spherical harmonics
  24288. */
  24289. l00: Vector3;
  24290. /**
  24291. * The l1,-1 coefficients of the spherical harmonics
  24292. */
  24293. l1_1: Vector3;
  24294. /**
  24295. * The l1,0 coefficients of the spherical harmonics
  24296. */
  24297. l10: Vector3;
  24298. /**
  24299. * The l1,1 coefficients of the spherical harmonics
  24300. */
  24301. l11: Vector3;
  24302. /**
  24303. * The l2,-2 coefficients of the spherical harmonics
  24304. */
  24305. l2_2: Vector3;
  24306. /**
  24307. * The l2,-1 coefficients of the spherical harmonics
  24308. */
  24309. l2_1: Vector3;
  24310. /**
  24311. * The l2,0 coefficients of the spherical harmonics
  24312. */
  24313. l20: Vector3;
  24314. /**
  24315. * The l2,1 coefficients of the spherical harmonics
  24316. */
  24317. l21: Vector3;
  24318. /**
  24319. * The l2,2 coefficients of the spherical harmonics
  24320. */
  24321. lL22: Vector3;
  24322. /**
  24323. * Adds a light to the spherical harmonics
  24324. * @param direction the direction of the light
  24325. * @param color the color of the light
  24326. * @param deltaSolidAngle the delta solid angle of the light
  24327. */
  24328. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  24329. /**
  24330. * Scales the spherical harmonics by the given amount
  24331. * @param scale the amount to scale
  24332. */
  24333. scale(scale: number): void;
  24334. /**
  24335. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  24336. *
  24337. * ```
  24338. * E_lm = A_l * L_lm
  24339. * ```
  24340. *
  24341. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  24342. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  24343. * the scaling factors are given in equation 9.
  24344. */
  24345. convertIncidentRadianceToIrradiance(): void;
  24346. /**
  24347. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  24348. *
  24349. * ```
  24350. * L = (1/pi) * E * rho
  24351. * ```
  24352. *
  24353. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  24354. */
  24355. convertIrradianceToLambertianRadiance(): void;
  24356. /**
  24357. * Gets the spherical harmonics from polynomial
  24358. * @param polynomial the spherical polynomial
  24359. * @returns the spherical harmonics
  24360. */
  24361. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  24362. /**
  24363. * Constructs a spherical harmonics from an array.
  24364. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  24365. * @returns the spherical harmonics
  24366. */
  24367. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  24368. }
  24369. }
  24370. declare module BABYLON {
  24371. /**
  24372. * Class used to store all common mesh properties
  24373. */
  24374. class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  24375. /** No occlusion */
  24376. static OCCLUSION_TYPE_NONE: number;
  24377. /** Occlusion set to optimisitic */
  24378. static OCCLUSION_TYPE_OPTIMISTIC: number;
  24379. /** Occlusion set to strict */
  24380. static OCCLUSION_TYPE_STRICT: number;
  24381. /** Use an accurante occlusion algorithm */
  24382. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  24383. /** Use a conservative occlusion algorithm */
  24384. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  24385. /** Default culling strategy with bounding box and bounding sphere and then frustum culling */
  24386. static readonly CULLINGSTRATEGY_STANDARD: number;
  24387. /** Culling strategy with bounding sphere only and then frustum culling */
  24388. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  24389. /**
  24390. * No billboard
  24391. */
  24392. static readonly BILLBOARDMODE_NONE: number;
  24393. /** Billboard on X axis */
  24394. static readonly BILLBOARDMODE_X: number;
  24395. /** Billboard on Y axis */
  24396. static readonly BILLBOARDMODE_Y: number;
  24397. /** Billboard on Z axis */
  24398. static readonly BILLBOARDMODE_Z: number;
  24399. /** Billboard on all axes */
  24400. static readonly BILLBOARDMODE_ALL: number;
  24401. private _facetData;
  24402. /** Gets ot sets the culling strategy to use to find visible meshes */
  24403. cullingStrategy: number;
  24404. /**
  24405. * Gets the number of facets in the mesh
  24406. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24407. */
  24408. readonly facetNb: number;
  24409. /**
  24410. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  24411. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24412. */
  24413. partitioningSubdivisions: number;
  24414. /**
  24415. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  24416. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  24417. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24418. */
  24419. partitioningBBoxRatio: number;
  24420. /**
  24421. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  24422. * Works only for updatable meshes.
  24423. * Doesn't work with multi-materials
  24424. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24425. */
  24426. mustDepthSortFacets: boolean;
  24427. /**
  24428. * The location (Vector3) where the facet depth sort must be computed from.
  24429. * By default, the active camera position.
  24430. * Used only when facet depth sort is enabled
  24431. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24432. */
  24433. facetDepthSortFrom: Vector3;
  24434. /**
  24435. * gets a boolean indicating if facetData is enabled
  24436. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24437. */
  24438. readonly isFacetDataEnabled: boolean;
  24439. /** @hidden */
  24440. _updateNonUniformScalingState(value: boolean): boolean;
  24441. /**
  24442. * An event triggered when this mesh collides with another one
  24443. */
  24444. onCollideObservable: Observable<AbstractMesh>;
  24445. private _onCollideObserver;
  24446. /** Set a function to call when this mesh collides with another one */
  24447. onCollide: () => void;
  24448. /**
  24449. * An event triggered when the collision's position changes
  24450. */
  24451. onCollisionPositionChangeObservable: Observable<Vector3>;
  24452. private _onCollisionPositionChangeObserver;
  24453. /** Set a function to call when the collision's position changes */
  24454. onCollisionPositionChange: () => void;
  24455. /**
  24456. * An event triggered when material is changed
  24457. */
  24458. onMaterialChangedObservable: Observable<AbstractMesh>;
  24459. /**
  24460. * Gets or sets the orientation for POV movement & rotation
  24461. */
  24462. definedFacingForward: boolean;
  24463. /** @hidden */
  24464. _occlusionQuery: Nullable<WebGLQuery>;
  24465. private _visibility;
  24466. /**
  24467. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24468. */
  24469. /**
  24470. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24471. */
  24472. visibility: number;
  24473. /** Gets or sets the alpha index used to sort transparent meshes
  24474. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  24475. */
  24476. alphaIndex: number;
  24477. /**
  24478. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  24479. */
  24480. isVisible: boolean;
  24481. /**
  24482. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24483. */
  24484. isPickable: boolean;
  24485. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  24486. showSubMeshesBoundingBox: boolean;
  24487. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  24488. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  24489. */
  24490. isBlocker: boolean;
  24491. /**
  24492. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  24493. */
  24494. enablePointerMoveEvents: boolean;
  24495. /**
  24496. * Specifies the rendering group id for this mesh (0 by default)
  24497. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24498. */
  24499. renderingGroupId: number;
  24500. private _material;
  24501. /** Gets or sets current material */
  24502. material: Nullable<Material>;
  24503. private _receiveShadows;
  24504. /**
  24505. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  24506. * @see http://doc.babylonjs.com/babylon101/shadows
  24507. */
  24508. receiveShadows: boolean;
  24509. /** Defines color to use when rendering outline */
  24510. outlineColor: Color3;
  24511. /** Define width to use when rendering outline */
  24512. outlineWidth: number;
  24513. /** Defines color to use when rendering overlay */
  24514. overlayColor: Color3;
  24515. /** Defines alpha to use when rendering overlay */
  24516. overlayAlpha: number;
  24517. private _hasVertexAlpha;
  24518. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  24519. hasVertexAlpha: boolean;
  24520. private _useVertexColors;
  24521. /** 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) */
  24522. useVertexColors: boolean;
  24523. private _computeBonesUsingShaders;
  24524. /**
  24525. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  24526. */
  24527. computeBonesUsingShaders: boolean;
  24528. private _numBoneInfluencers;
  24529. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  24530. numBoneInfluencers: number;
  24531. private _applyFog;
  24532. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24533. applyFog: boolean;
  24534. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24535. useOctreeForRenderingSelection: boolean;
  24536. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24537. useOctreeForPicking: boolean;
  24538. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24539. useOctreeForCollisions: boolean;
  24540. private _layerMask;
  24541. /**
  24542. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24543. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24544. */
  24545. layerMask: number;
  24546. /**
  24547. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24548. */
  24549. alwaysSelectAsActiveMesh: boolean;
  24550. /**
  24551. * Gets or sets the current action manager
  24552. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24553. */
  24554. actionManager: Nullable<ActionManager>;
  24555. private _checkCollisions;
  24556. private _collisionMask;
  24557. private _collisionGroup;
  24558. /**
  24559. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24560. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24561. */
  24562. ellipsoid: Vector3;
  24563. /**
  24564. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24565. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24566. */
  24567. ellipsoidOffset: Vector3;
  24568. private _collider;
  24569. private _oldPositionForCollisions;
  24570. private _diffPositionForCollisions;
  24571. /**
  24572. * Gets or sets a collision mask used to mask collisions (default is -1).
  24573. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24574. */
  24575. collisionMask: number;
  24576. /**
  24577. * Gets or sets the current collision group mask (-1 by default).
  24578. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24579. */
  24580. collisionGroup: number;
  24581. /**
  24582. * Defines edge width used when edgesRenderer is enabled
  24583. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24584. */
  24585. edgesWidth: number;
  24586. /**
  24587. * Defines edge color used when edgesRenderer is enabled
  24588. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24589. */
  24590. edgesColor: Color4;
  24591. /** @hidden */
  24592. _edgesRenderer: Nullable<IEdgesRenderer>;
  24593. /** @hidden */
  24594. _masterMesh: Nullable<AbstractMesh>;
  24595. /** @hidden */
  24596. _boundingInfo: Nullable<BoundingInfo>;
  24597. /** @hidden */
  24598. _renderId: number;
  24599. /**
  24600. * Gets or sets the list of subMeshes
  24601. * @see http://doc.babylonjs.com/how_to/multi_materials
  24602. */
  24603. subMeshes: SubMesh[];
  24604. /** @hidden */
  24605. _intersectionsInProgress: AbstractMesh[];
  24606. /** @hidden */
  24607. _unIndexed: boolean;
  24608. /** @hidden */
  24609. _lightSources: Light[];
  24610. /** @hidden */
  24611. readonly _positions: Nullable<Vector3[]>;
  24612. /** @hidden */
  24613. _waitingActions: any;
  24614. /** @hidden */
  24615. _waitingFreezeWorldMatrix: Nullable<boolean>;
  24616. private _skeleton;
  24617. /** @hidden */
  24618. _bonesTransformMatrices: Nullable<Float32Array>;
  24619. /**
  24620. * Gets or sets a skeleton to apply skining transformations
  24621. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24622. */
  24623. skeleton: Nullable<Skeleton>;
  24624. /**
  24625. * An event triggered when the mesh is rebuilt.
  24626. */
  24627. onRebuildObservable: Observable<AbstractMesh>;
  24628. /**
  24629. * Creates a new AbstractMesh
  24630. * @param name defines the name of the mesh
  24631. * @param scene defines the hosting scene
  24632. */
  24633. constructor(name: string, scene?: Nullable<Scene>);
  24634. /**
  24635. * Returns the string "AbstractMesh"
  24636. * @returns "AbstractMesh"
  24637. */
  24638. getClassName(): string;
  24639. /**
  24640. * Gets a string representation of the current mesh
  24641. * @param fullDetails defines a boolean indicating if full details must be included
  24642. * @returns a string representation of the current mesh
  24643. */
  24644. toString(fullDetails?: boolean): string;
  24645. /** @hidden */
  24646. _rebuild(): void;
  24647. /** @hidden */
  24648. _resyncLightSources(): void;
  24649. /** @hidden */
  24650. _resyncLighSource(light: Light): void;
  24651. /** @hidden */
  24652. _unBindEffect(): void;
  24653. /** @hidden */
  24654. _removeLightSource(light: Light): void;
  24655. private _markSubMeshesAsDirty;
  24656. /** @hidden */
  24657. _markSubMeshesAsLightDirty(): void;
  24658. /** @hidden */
  24659. _markSubMeshesAsAttributesDirty(): void;
  24660. /** @hidden */
  24661. _markSubMeshesAsMiscDirty(): void;
  24662. /**
  24663. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24664. */
  24665. scaling: Vector3;
  24666. /**
  24667. * Returns true if the mesh is blocked. Implemented by child classes
  24668. */
  24669. readonly isBlocked: boolean;
  24670. /**
  24671. * Returns the mesh itself by default. Implemented by child classes
  24672. * @param camera defines the camera to use to pick the right LOD level
  24673. * @returns the currentAbstractMesh
  24674. */
  24675. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24676. /**
  24677. * Returns 0 by default. Implemented by child classes
  24678. * @returns an integer
  24679. */
  24680. getTotalVertices(): number;
  24681. /**
  24682. * Returns a positive integer : the total number of indices in this mesh geometry.
  24683. * @returns the numner of indices or zero if the mesh has no geometry.
  24684. */
  24685. getTotalIndices(): number;
  24686. /**
  24687. * Returns null by default. Implemented by child classes
  24688. * @returns null
  24689. */
  24690. getIndices(): Nullable<IndicesArray>;
  24691. /**
  24692. * Returns the array of the requested vertex data kind. Implemented by child classes
  24693. * @param kind defines the vertex data kind to use
  24694. * @returns null
  24695. */
  24696. getVerticesData(kind: string): Nullable<FloatArray>;
  24697. /**
  24698. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24699. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24700. * Note that a new underlying VertexBuffer object is created each call.
  24701. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24702. * @param kind defines vertex data kind:
  24703. * * BABYLON.VertexBuffer.PositionKind
  24704. * * BABYLON.VertexBuffer.UVKind
  24705. * * BABYLON.VertexBuffer.UV2Kind
  24706. * * BABYLON.VertexBuffer.UV3Kind
  24707. * * BABYLON.VertexBuffer.UV4Kind
  24708. * * BABYLON.VertexBuffer.UV5Kind
  24709. * * BABYLON.VertexBuffer.UV6Kind
  24710. * * BABYLON.VertexBuffer.ColorKind
  24711. * * BABYLON.VertexBuffer.MatricesIndicesKind
  24712. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  24713. * * BABYLON.VertexBuffer.MatricesWeightsKind
  24714. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  24715. * @param data defines the data source
  24716. * @param updatable defines if the data must be flagged as updatable (or static)
  24717. * @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
  24718. * @returns the current mesh
  24719. */
  24720. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24721. /**
  24722. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24723. * If the mesh has no geometry, it is simply returned as it is.
  24724. * @param kind defines vertex data kind:
  24725. * * BABYLON.VertexBuffer.PositionKind
  24726. * * BABYLON.VertexBuffer.UVKind
  24727. * * BABYLON.VertexBuffer.UV2Kind
  24728. * * BABYLON.VertexBuffer.UV3Kind
  24729. * * BABYLON.VertexBuffer.UV4Kind
  24730. * * BABYLON.VertexBuffer.UV5Kind
  24731. * * BABYLON.VertexBuffer.UV6Kind
  24732. * * BABYLON.VertexBuffer.ColorKind
  24733. * * BABYLON.VertexBuffer.MatricesIndicesKind
  24734. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  24735. * * BABYLON.VertexBuffer.MatricesWeightsKind
  24736. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  24737. * @param data defines the data source
  24738. * @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
  24739. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24740. * @returns the current mesh
  24741. */
  24742. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24743. /**
  24744. * Sets the mesh indices,
  24745. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24746. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24747. * @param totalVertices Defines the total number of vertices
  24748. * @returns the current mesh
  24749. */
  24750. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24751. /**
  24752. * Gets a boolean indicating if specific vertex data is present
  24753. * @param kind defines the vertex data kind to use
  24754. * @returns true is data kind is present
  24755. */
  24756. isVerticesDataPresent(kind: string): boolean;
  24757. /**
  24758. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  24759. * @returns a BoundingInfo
  24760. */
  24761. getBoundingInfo(): BoundingInfo;
  24762. /**
  24763. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24764. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  24765. * @returns the current mesh
  24766. */
  24767. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  24768. /**
  24769. * Overwrite the current bounding info
  24770. * @param boundingInfo defines the new bounding info
  24771. * @returns the current mesh
  24772. */
  24773. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24774. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24775. readonly useBones: boolean;
  24776. /** @hidden */
  24777. _preActivate(): void;
  24778. /** @hidden */
  24779. _preActivateForIntermediateRendering(renderId: number): void;
  24780. /** @hidden */
  24781. _activate(renderId: number): void;
  24782. /**
  24783. * Gets the current world matrix
  24784. * @returns a Matrix
  24785. */
  24786. getWorldMatrix(): Matrix;
  24787. /** @hidden */
  24788. _getWorldMatrixDeterminant(): number;
  24789. /**
  24790. * Perform relative position change from the point of view of behind the front of the mesh.
  24791. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24792. * Supports definition of mesh facing forward or backward
  24793. * @param amountRight defines the distance on the right axis
  24794. * @param amountUp defines the distance on the up axis
  24795. * @param amountForward defines the distance on the forward axis
  24796. * @returns the current mesh
  24797. */
  24798. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  24799. /**
  24800. * Calculate relative position change from the point of view of behind the front of the mesh.
  24801. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24802. * Supports definition of mesh facing forward or backward
  24803. * @param amountRight defines the distance on the right axis
  24804. * @param amountUp defines the distance on the up axis
  24805. * @param amountForward defines the distance on the forward axis
  24806. * @returns the new displacement vector
  24807. */
  24808. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  24809. /**
  24810. * Perform relative rotation change from the point of view of behind the front of the mesh.
  24811. * Supports definition of mesh facing forward or backward
  24812. * @param flipBack defines the flip
  24813. * @param twirlClockwise defines the twirl
  24814. * @param tiltRight defines the tilt
  24815. * @returns the current mesh
  24816. */
  24817. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  24818. /**
  24819. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  24820. * Supports definition of mesh facing forward or backward.
  24821. * @param flipBack defines the flip
  24822. * @param twirlClockwise defines the twirl
  24823. * @param tiltRight defines the tilt
  24824. * @returns the new rotation vector
  24825. */
  24826. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  24827. /**
  24828. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  24829. * @param includeDescendants Include bounding info from descendants as well (true by default)
  24830. * @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
  24831. * @returns the new bounding vectors
  24832. */
  24833. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  24834. min: Vector3;
  24835. max: Vector3;
  24836. };
  24837. /**
  24838. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24839. * This means the mesh underlying bounding box and sphere are recomputed.
  24840. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24841. * @returns the current mesh
  24842. */
  24843. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  24844. /** @hidden */
  24845. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  24846. /** @hidden */
  24847. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  24848. /** @hidden */
  24849. _updateBoundingInfo(): AbstractMesh;
  24850. /** @hidden */
  24851. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  24852. /** @hidden */
  24853. protected _afterComputeWorldMatrix(): void;
  24854. /**
  24855. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24856. * A mesh is in the frustum if its bounding box intersects the frustum
  24857. * @param frustumPlanes defines the frustum to test
  24858. * @returns true if the mesh is in the frustum planes
  24859. */
  24860. isInFrustum(frustumPlanes: Plane[]): boolean;
  24861. /**
  24862. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  24863. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  24864. * @param frustumPlanes defines the frustum to test
  24865. * @returns true if the mesh is completely in the frustum planes
  24866. */
  24867. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24868. /**
  24869. * True if the mesh intersects another mesh or a SolidParticle object
  24870. * @param mesh defines a target mesh or SolidParticle to test
  24871. * @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)
  24872. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  24873. * @returns true if there is an intersection
  24874. */
  24875. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  24876. /**
  24877. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  24878. * @param point defines the point to test
  24879. * @returns true if there is an intersection
  24880. */
  24881. intersectsPoint(point: Vector3): boolean;
  24882. /**
  24883. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  24884. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24885. */
  24886. checkCollisions: boolean;
  24887. /**
  24888. * Gets Collider object used to compute collisions (not physics)
  24889. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24890. */
  24891. readonly collider: Collider;
  24892. /**
  24893. * Move the mesh using collision engine
  24894. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24895. * @param displacement defines the requested displacement vector
  24896. * @returns the current mesh
  24897. */
  24898. moveWithCollisions(displacement: Vector3): AbstractMesh;
  24899. private _onCollisionPositionChange;
  24900. /** @hidden */
  24901. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  24902. /** @hidden */
  24903. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  24904. /** @hidden */
  24905. _checkCollision(collider: Collider): AbstractMesh;
  24906. /** @hidden */
  24907. _generatePointsArray(): boolean;
  24908. /**
  24909. * Checks if the passed Ray intersects with the mesh
  24910. * @param ray defines the ray to use
  24911. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  24912. * @returns the picking info
  24913. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24914. */
  24915. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  24916. /**
  24917. * Clones the current mesh
  24918. * @param name defines the mesh name
  24919. * @param newParent defines the new mesh parent
  24920. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  24921. * @returns the new mesh
  24922. */
  24923. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  24924. /**
  24925. * Disposes all the submeshes of the current meshnp
  24926. * @returns the current mesh
  24927. */
  24928. releaseSubMeshes(): AbstractMesh;
  24929. /**
  24930. * Releases resources associated with this abstract mesh.
  24931. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24932. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24933. */
  24934. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24935. /**
  24936. * Adds the passed mesh as a child to the current mesh
  24937. * @param mesh defines the child mesh
  24938. * @returns the current mesh
  24939. */
  24940. addChild(mesh: AbstractMesh): AbstractMesh;
  24941. /**
  24942. * Removes the passed mesh from the current mesh children list
  24943. * @param mesh defines the child mesh
  24944. * @returns the current mesh
  24945. */
  24946. removeChild(mesh: AbstractMesh): AbstractMesh;
  24947. /** @hidden */
  24948. private _initFacetData;
  24949. /**
  24950. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  24951. * This method can be called within the render loop.
  24952. * 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
  24953. * @returns the current mesh
  24954. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24955. */
  24956. updateFacetData(): AbstractMesh;
  24957. /**
  24958. * Returns the facetLocalNormals array.
  24959. * The normals are expressed in the mesh local spac
  24960. * @returns an array of Vector3
  24961. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24962. */
  24963. getFacetLocalNormals(): Vector3[];
  24964. /**
  24965. * Returns the facetLocalPositions array.
  24966. * The facet positions are expressed in the mesh local space
  24967. * @returns an array of Vector3
  24968. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24969. */
  24970. getFacetLocalPositions(): Vector3[];
  24971. /**
  24972. * Returns the facetLocalPartioning array
  24973. * @returns an array of array of numbers
  24974. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24975. */
  24976. getFacetLocalPartitioning(): number[][];
  24977. /**
  24978. * Returns the i-th facet position in the world system.
  24979. * This method allocates a new Vector3 per call
  24980. * @param i defines the facet index
  24981. * @returns a new Vector3
  24982. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24983. */
  24984. getFacetPosition(i: number): Vector3;
  24985. /**
  24986. * Sets the reference Vector3 with the i-th facet position in the world system
  24987. * @param i defines the facet index
  24988. * @param ref defines the target vector
  24989. * @returns the current mesh
  24990. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24991. */
  24992. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  24993. /**
  24994. * Returns the i-th facet normal in the world system.
  24995. * This method allocates a new Vector3 per call
  24996. * @param i defines the facet index
  24997. * @returns a new Vector3
  24998. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24999. */
  25000. getFacetNormal(i: number): Vector3;
  25001. /**
  25002. * Sets the reference Vector3 with the i-th facet normal in the world system
  25003. * @param i defines the facet index
  25004. * @param ref defines the target vector
  25005. * @returns the current mesh
  25006. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25007. */
  25008. getFacetNormalToRef(i: number, ref: Vector3): this;
  25009. /**
  25010. * 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)
  25011. * @param x defines x coordinate
  25012. * @param y defines y coordinate
  25013. * @param z defines z coordinate
  25014. * @returns the array of facet indexes
  25015. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25016. */
  25017. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  25018. /**
  25019. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  25020. * @param projected sets as the (x,y,z) world projection on the facet
  25021. * @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
  25022. * @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
  25023. * @param x defines x coordinate
  25024. * @param y defines y coordinate
  25025. * @param z defines z coordinate
  25026. * @returns the face index if found (or null instead)
  25027. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25028. */
  25029. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25030. /**
  25031. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  25032. * @param projected sets as the (x,y,z) local projection on the facet
  25033. * @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
  25034. * @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
  25035. * @param x defines x coordinate
  25036. * @param y defines y coordinate
  25037. * @param z defines z coordinate
  25038. * @returns the face index if found (or null instead)
  25039. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25040. */
  25041. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25042. /**
  25043. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  25044. * @returns the parameters
  25045. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25046. */
  25047. getFacetDataParameters(): any;
  25048. /**
  25049. * Disables the feature FacetData and frees the related memory
  25050. * @returns the current mesh
  25051. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25052. */
  25053. disableFacetData(): AbstractMesh;
  25054. /**
  25055. * Updates the AbstractMesh indices array
  25056. * @param indices defines the data source
  25057. * @returns the current mesh
  25058. */
  25059. updateIndices(indices: IndicesArray): AbstractMesh;
  25060. /**
  25061. * Creates new normals data for the mesh
  25062. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  25063. * @returns the current mesh
  25064. */
  25065. createNormals(updatable: boolean): AbstractMesh;
  25066. /**
  25067. * Align the mesh with a normal
  25068. * @param normal defines the normal to use
  25069. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  25070. * @returns the current mesh
  25071. */
  25072. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  25073. /** @hidden */
  25074. _checkOcclusionQuery(): boolean;
  25075. }
  25076. }
  25077. declare module BABYLON {
  25078. /**
  25079. * Class used to store data that will be store in GPU memory
  25080. */
  25081. class Buffer {
  25082. private _engine;
  25083. private _buffer;
  25084. /** @hidden */
  25085. _data: Nullable<DataArray>;
  25086. private _updatable;
  25087. private _instanced;
  25088. /**
  25089. * Gets the byte stride.
  25090. */
  25091. readonly byteStride: number;
  25092. /**
  25093. * Constructor
  25094. * @param engine the engine
  25095. * @param data the data to use for this buffer
  25096. * @param updatable whether the data is updatable
  25097. * @param stride the stride (optional)
  25098. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  25099. * @param instanced whether the buffer is instanced (optional)
  25100. * @param useBytes set to true if the stride in in bytes (optional)
  25101. */
  25102. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  25103. /**
  25104. * Create a new VertexBuffer based on the current buffer
  25105. * @param kind defines the vertex buffer kind (position, normal, etc.)
  25106. * @param offset defines offset in the buffer (0 by default)
  25107. * @param size defines the size in floats of attributes (position is 3 for instance)
  25108. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  25109. * @param instanced defines if the vertex buffer contains indexed data
  25110. * @param useBytes defines if the offset and stride are in bytes
  25111. * @returns the new vertex buffer
  25112. */
  25113. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  25114. /**
  25115. * Gets a boolean indicating if the Buffer is updatable?
  25116. * @returns true if the buffer is updatable
  25117. */
  25118. isUpdatable(): boolean;
  25119. /**
  25120. * Gets current buffer's data
  25121. * @returns a DataArray or null
  25122. */
  25123. getData(): Nullable<DataArray>;
  25124. /**
  25125. * Gets underlying native buffer
  25126. * @returns underlying native buffer
  25127. */
  25128. getBuffer(): Nullable<WebGLBuffer>;
  25129. /**
  25130. * Gets the stride in float32 units (i.e. byte stride / 4).
  25131. * May not be an integer if the byte stride is not divisible by 4.
  25132. * DEPRECATED. Use byteStride instead.
  25133. * @returns the stride in float32 units
  25134. */
  25135. getStrideSize(): number;
  25136. /**
  25137. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  25138. * @param data defines the data to store
  25139. */
  25140. create(data?: Nullable<DataArray>): void;
  25141. /** @hidden */
  25142. _rebuild(): void;
  25143. /**
  25144. * Update current buffer data
  25145. * @param data defines the data to store
  25146. */
  25147. update(data: DataArray): void;
  25148. /**
  25149. * Updates the data directly.
  25150. * @param data the new data
  25151. * @param offset the new offset
  25152. * @param vertexCount the vertex count (optional)
  25153. * @param useBytes set to true if the offset is in bytes
  25154. */
  25155. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  25156. /**
  25157. * Release all resources
  25158. */
  25159. dispose(): void;
  25160. }
  25161. }
  25162. declare module BABYLON {
  25163. /**
  25164. * Class for building Constructive Solid Geometry
  25165. */
  25166. class CSG {
  25167. private polygons;
  25168. /**
  25169. * The world matrix
  25170. */
  25171. matrix: Matrix;
  25172. /**
  25173. * Stores the position
  25174. */
  25175. position: Vector3;
  25176. /**
  25177. * Stores the rotation
  25178. */
  25179. rotation: Vector3;
  25180. /**
  25181. * Stores the rotation quaternion
  25182. */
  25183. rotationQuaternion: Nullable<Quaternion>;
  25184. /**
  25185. * Stores the scaling vector
  25186. */
  25187. scaling: Vector3;
  25188. /**
  25189. * Convert the BABYLON.Mesh to BABYLON.CSG
  25190. * @param mesh The BABYLON.Mesh to convert to BABYLON.CSG
  25191. * @returns A new BABYLON.CSG from the BABYLON.Mesh
  25192. */
  25193. static FromMesh(mesh: Mesh): CSG;
  25194. /**
  25195. * Construct a BABYLON.CSG solid from a list of `BABYLON.CSG.Polygon` instances.
  25196. * @param polygons Polygons used to construct a BABYLON.CSG solid
  25197. */
  25198. private static FromPolygons;
  25199. /**
  25200. * Clones, or makes a deep copy, of the BABYLON.CSG
  25201. * @returns A new BABYLON.CSG
  25202. */
  25203. clone(): CSG;
  25204. /**
  25205. * Unions this CSG with another CSG
  25206. * @param csg The CSG to union against this CSG
  25207. * @returns The unioned CSG
  25208. */
  25209. union(csg: CSG): CSG;
  25210. /**
  25211. * Unions this CSG with another CSG in place
  25212. * @param csg The CSG to union against this CSG
  25213. */
  25214. unionInPlace(csg: CSG): void;
  25215. /**
  25216. * Subtracts this CSG with another CSG
  25217. * @param csg The CSG to subtract against this CSG
  25218. * @returns A new BABYLON.CSG
  25219. */
  25220. subtract(csg: CSG): CSG;
  25221. /**
  25222. * Subtracts this CSG with another CSG in place
  25223. * @param csg The CSG to subtact against this CSG
  25224. */
  25225. subtractInPlace(csg: CSG): void;
  25226. /**
  25227. * Intersect this CSG with another CSG
  25228. * @param csg The CSG to intersect against this CSG
  25229. * @returns A new BABYLON.CSG
  25230. */
  25231. intersect(csg: CSG): CSG;
  25232. /**
  25233. * Intersects this CSG with another CSG in place
  25234. * @param csg The CSG to intersect against this CSG
  25235. */
  25236. intersectInPlace(csg: CSG): void;
  25237. /**
  25238. * Return a new BABYLON.CSG solid with solid and empty space switched. This solid is
  25239. * not modified.
  25240. * @returns A new BABYLON.CSG solid with solid and empty space switched
  25241. */
  25242. inverse(): CSG;
  25243. /**
  25244. * Inverses the BABYLON.CSG in place
  25245. */
  25246. inverseInPlace(): void;
  25247. /**
  25248. * This is used to keep meshes transformations so they can be restored
  25249. * when we build back a Babylon Mesh
  25250. * NB : All CSG operations are performed in world coordinates
  25251. * @param csg The BABYLON.CSG to copy the transform attributes from
  25252. * @returns This BABYLON.CSG
  25253. */
  25254. copyTransformAttributes(csg: CSG): CSG;
  25255. /**
  25256. * Build Raw mesh from CSG
  25257. * Coordinates here are in world space
  25258. * @param name The name of the mesh geometry
  25259. * @param scene The BABYLON.Scene
  25260. * @param keepSubMeshes Specifies if the submeshes should be kept
  25261. * @returns A new BABYLON.Mesh
  25262. */
  25263. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  25264. /**
  25265. * Build Mesh from CSG taking material and transforms into account
  25266. * @param name The name of the BABYLON.Mesh
  25267. * @param material The material of the BABYLON.Mesh
  25268. * @param scene The BABYLON.Scene
  25269. * @param keepSubMeshes Specifies if submeshes should be kept
  25270. * @returns The new BABYLON.Mesh
  25271. */
  25272. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  25273. }
  25274. }
  25275. declare module BABYLON {
  25276. /**
  25277. * Class used to store geometry data (vertex buffers + index buffer)
  25278. */
  25279. class Geometry implements IGetSetVerticesData {
  25280. /**
  25281. * Gets or sets the ID of the geometry
  25282. */
  25283. id: string;
  25284. /**
  25285. * Gets or sets the unique ID of the geometry
  25286. */
  25287. uniqueId: number;
  25288. /**
  25289. * Gets the delay loading state of the geometry (none by default which means not delayed)
  25290. */
  25291. delayLoadState: number;
  25292. /**
  25293. * Gets the file containing the data to load when running in delay load state
  25294. */
  25295. delayLoadingFile: Nullable<string>;
  25296. /**
  25297. * Callback called when the geometry is updated
  25298. */
  25299. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  25300. private _scene;
  25301. private _engine;
  25302. private _meshes;
  25303. private _totalVertices;
  25304. /** @hidden */
  25305. _indices: IndicesArray;
  25306. /** @hidden */
  25307. _vertexBuffers: {
  25308. [key: string]: VertexBuffer;
  25309. };
  25310. private _isDisposed;
  25311. private _extend;
  25312. private _boundingBias;
  25313. /** @hidden */
  25314. _delayInfo: Array<string>;
  25315. private _indexBuffer;
  25316. private _indexBufferIsUpdatable;
  25317. /** @hidden */
  25318. _boundingInfo: Nullable<BoundingInfo>;
  25319. /** @hidden */
  25320. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  25321. /** @hidden */
  25322. _softwareSkinningFrameId: number;
  25323. private _vertexArrayObjects;
  25324. private _updatable;
  25325. /** @hidden */
  25326. _positions: Nullable<Vector3[]>;
  25327. /**
  25328. * 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
  25329. */
  25330. /**
  25331. * 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
  25332. */
  25333. boundingBias: Vector2;
  25334. /**
  25335. * Static function used to attach a new empty geometry to a mesh
  25336. * @param mesh defines the mesh to attach the geometry to
  25337. * @returns the new Geometry
  25338. */
  25339. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  25340. /**
  25341. * Creates a new geometry
  25342. * @param id defines the unique ID
  25343. * @param scene defines the hosting scene
  25344. * @param vertexData defines the VertexData used to get geometry data
  25345. * @param updatable defines if geometry must be updatable (false by default)
  25346. * @param mesh defines the mesh that will be associated with the geometry
  25347. */
  25348. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  25349. /**
  25350. * Gets the current extend of the geometry
  25351. */
  25352. readonly extend: {
  25353. minimum: Vector3;
  25354. maximum: Vector3;
  25355. };
  25356. /**
  25357. * Gets the hosting scene
  25358. * @returns the hosting Scene
  25359. */
  25360. getScene(): Scene;
  25361. /**
  25362. * Gets the hosting engine
  25363. * @returns the hosting Engine
  25364. */
  25365. getEngine(): Engine;
  25366. /**
  25367. * Defines if the geometry is ready to use
  25368. * @returns true if the geometry is ready to be used
  25369. */
  25370. isReady(): boolean;
  25371. /**
  25372. * Gets a value indicating that the geometry should not be serialized
  25373. */
  25374. readonly doNotSerialize: boolean;
  25375. /** @hidden */
  25376. _rebuild(): void;
  25377. /**
  25378. * Affects all geometry data in one call
  25379. * @param vertexData defines the geometry data
  25380. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  25381. */
  25382. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  25383. /**
  25384. * Set specific vertex data
  25385. * @param kind defines the data kind (Position, normal, etc...)
  25386. * @param data defines the vertex data to use
  25387. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25388. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25389. */
  25390. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  25391. /**
  25392. * Removes a specific vertex data
  25393. * @param kind defines the data kind (Position, normal, etc...)
  25394. */
  25395. removeVerticesData(kind: string): void;
  25396. /**
  25397. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  25398. * @param buffer defines the vertex buffer to use
  25399. * @param totalVertices defines the total number of vertices for position kind (could be null)
  25400. */
  25401. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  25402. /**
  25403. * Update a specific vertex buffer
  25404. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  25405. * It will do nothing if the buffer is not updatable
  25406. * @param kind defines the data kind (Position, normal, etc...)
  25407. * @param data defines the data to use
  25408. * @param offset defines the offset in the target buffer where to store the data
  25409. * @param useBytes set to true if the offset is in bytes
  25410. */
  25411. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  25412. /**
  25413. * Update a specific vertex buffer
  25414. * This function will create a new buffer if the current one is not updatable
  25415. * @param kind defines the data kind (Position, normal, etc...)
  25416. * @param data defines the data to use
  25417. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  25418. */
  25419. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  25420. private _updateBoundingInfo;
  25421. /** @hidden */
  25422. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  25423. /**
  25424. * Gets total number of vertices
  25425. * @returns the total number of vertices
  25426. */
  25427. getTotalVertices(): number;
  25428. /**
  25429. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25430. * @param kind defines the data kind (Position, normal, etc...)
  25431. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25432. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25433. * @returns a float array containing vertex data
  25434. */
  25435. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25436. /**
  25437. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  25438. * @param kind defines the data kind (Position, normal, etc...)
  25439. * @returns true if the vertex buffer with the specified kind is updatable
  25440. */
  25441. isVertexBufferUpdatable(kind: string): boolean;
  25442. /**
  25443. * Gets a specific vertex buffer
  25444. * @param kind defines the data kind (Position, normal, etc...)
  25445. * @returns a VertexBuffer
  25446. */
  25447. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25448. /**
  25449. * Returns all vertex buffers
  25450. * @return an object holding all vertex buffers indexed by kind
  25451. */
  25452. getVertexBuffers(): Nullable<{
  25453. [key: string]: VertexBuffer;
  25454. }>;
  25455. /**
  25456. * Gets a boolean indicating if specific vertex buffer is present
  25457. * @param kind defines the data kind (Position, normal, etc...)
  25458. * @returns true if data is present
  25459. */
  25460. isVerticesDataPresent(kind: string): boolean;
  25461. /**
  25462. * Gets a list of all attached data kinds (Position, normal, etc...)
  25463. * @returns a list of string containing all kinds
  25464. */
  25465. getVerticesDataKinds(): string[];
  25466. /**
  25467. * Update index buffer
  25468. * @param indices defines the indices to store in the index buffer
  25469. * @param offset defines the offset in the target buffer where to store the data
  25470. */
  25471. updateIndices(indices: IndicesArray, offset?: number): void;
  25472. /**
  25473. * Creates a new index buffer
  25474. * @param indices defines the indices to store in the index buffer
  25475. * @param totalVertices defines the total number of vertices (could be null)
  25476. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25477. */
  25478. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  25479. /**
  25480. * Return the total number of indices
  25481. * @returns the total number of indices
  25482. */
  25483. getTotalIndices(): number;
  25484. /**
  25485. * Gets the index buffer array
  25486. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25487. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25488. * @returns the index buffer array
  25489. */
  25490. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25491. /**
  25492. * Gets the index buffer
  25493. * @return the index buffer
  25494. */
  25495. getIndexBuffer(): Nullable<WebGLBuffer>;
  25496. /** @hidden */
  25497. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  25498. /**
  25499. * Release the associated resources for a specific mesh
  25500. * @param mesh defines the source mesh
  25501. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  25502. */
  25503. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  25504. /**
  25505. * Apply current geometry to a given mesh
  25506. * @param mesh defines the mesh to apply geometry to
  25507. */
  25508. applyToMesh(mesh: Mesh): void;
  25509. private _updateExtend;
  25510. private _applyToMesh;
  25511. private notifyUpdate;
  25512. /**
  25513. * Load the geometry if it was flagged as delay loaded
  25514. * @param scene defines the hosting scene
  25515. * @param onLoaded defines a callback called when the geometry is loaded
  25516. */
  25517. load(scene: Scene, onLoaded?: () => void): void;
  25518. private _queueLoad;
  25519. /**
  25520. * Invert the geometry to move from a right handed system to a left handed one.
  25521. */
  25522. toLeftHanded(): void;
  25523. /** @hidden */
  25524. _resetPointsArrayCache(): void;
  25525. /** @hidden */
  25526. _generatePointsArray(): boolean;
  25527. /**
  25528. * Gets a value indicating if the geometry is disposed
  25529. * @returns true if the geometry was disposed
  25530. */
  25531. isDisposed(): boolean;
  25532. private _disposeVertexArrayObjects;
  25533. /**
  25534. * Free all associated resources
  25535. */
  25536. dispose(): void;
  25537. /**
  25538. * Clone the current geometry into a new geometry
  25539. * @param id defines the unique ID of the new geometry
  25540. * @returns a new geometry object
  25541. */
  25542. copy(id: string): Geometry;
  25543. /**
  25544. * Serialize the current geometry info (and not the vertices data) into a JSON object
  25545. * @return a JSON representation of the current geometry data (without the vertices data)
  25546. */
  25547. serialize(): any;
  25548. private toNumberArray;
  25549. /**
  25550. * Serialize all vertices data into a JSON oject
  25551. * @returns a JSON representation of the current geometry data
  25552. */
  25553. serializeVerticeData(): any;
  25554. /**
  25555. * Extracts a clone of a mesh geometry
  25556. * @param mesh defines the source mesh
  25557. * @param id defines the unique ID of the new geometry object
  25558. * @returns the new geometry object
  25559. */
  25560. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  25561. /**
  25562. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  25563. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  25564. * Be aware Math.random() could cause collisions, but:
  25565. * "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"
  25566. * @returns a string containing a new GUID
  25567. */
  25568. static RandomId(): string;
  25569. /** @hidden */
  25570. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  25571. private static _CleanMatricesWeights;
  25572. /**
  25573. * Create a new geometry from persisted data (Using .babylon file format)
  25574. * @param parsedVertexData defines the persisted data
  25575. * @param scene defines the hosting scene
  25576. * @param rootUrl defines the root url to use to load assets (like delayed data)
  25577. * @returns the new geometry object
  25578. */
  25579. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  25580. }
  25581. /**
  25582. * Abstract class used to provide common services for all typed geometries
  25583. * @hidden
  25584. */
  25585. class _PrimitiveGeometry extends Geometry {
  25586. private _canBeRegenerated;
  25587. private _beingRegenerated;
  25588. /**
  25589. * Creates a new typed geometry
  25590. * @param id defines the unique ID of the geometry
  25591. * @param scene defines the hosting scene
  25592. * @param _canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25593. * @param mesh defines the hosting mesh (can be null)
  25594. */
  25595. constructor(id: string, scene: Scene, _canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  25596. /**
  25597. * Gets a value indicating if the geometry supports being regenerated with new parameters (false by default)
  25598. * @returns true if the geometry can be regenerated
  25599. */
  25600. canBeRegenerated(): boolean;
  25601. /**
  25602. * If the geometry supports regeneration, the function will recreates the geometry with updated parameter values
  25603. */
  25604. regenerate(): void;
  25605. /**
  25606. * Clone the geometry
  25607. * @param id defines the unique ID of the new geometry
  25608. * @returns the new geometry
  25609. */
  25610. asNewGeometry(id: string): Geometry;
  25611. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  25612. setVerticesData(kind: string, data: FloatArray, updatable?: boolean): void;
  25613. /** @hidden */
  25614. _regenerateVertexData(): VertexData;
  25615. copy(id: string): Geometry;
  25616. serialize(): any;
  25617. }
  25618. /**
  25619. * Creates a ribbon geometry
  25620. * @description See http://doc.babylonjs.com/how_to/ribbon_tutorial, http://doc.babylonjs.com/resources/maths_make_ribbons
  25621. */
  25622. class RibbonGeometry extends _PrimitiveGeometry {
  25623. /**
  25624. * Defines the array of paths to use
  25625. */
  25626. pathArray: Vector3[][];
  25627. /**
  25628. * Defines if the last and first points of each path in your pathArray must be joined
  25629. */
  25630. closeArray: boolean;
  25631. /**
  25632. * Defines if the last and first points of each path in your pathArray must be joined
  25633. */
  25634. closePath: boolean;
  25635. /**
  25636. * Defines the offset between points
  25637. */
  25638. offset: number;
  25639. /**
  25640. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25641. */
  25642. side: number;
  25643. /**
  25644. * Creates a ribbon geometry
  25645. * @param id defines the unique ID of the geometry
  25646. * @param scene defines the hosting scene
  25647. * @param pathArray defines the array of paths to use
  25648. * @param closeArray defines if the last path and the first path must be joined
  25649. * @param closePath defines if the last and first points of each path in your pathArray must be joined
  25650. * @param offset defines the offset between points
  25651. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25652. * @param mesh defines the hosting mesh (can be null)
  25653. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25654. */
  25655. constructor(id: string, scene: Scene,
  25656. /**
  25657. * Defines the array of paths to use
  25658. */
  25659. pathArray: Vector3[][],
  25660. /**
  25661. * Defines if the last and first points of each path in your pathArray must be joined
  25662. */
  25663. closeArray: boolean,
  25664. /**
  25665. * Defines if the last and first points of each path in your pathArray must be joined
  25666. */
  25667. closePath: boolean,
  25668. /**
  25669. * Defines the offset between points
  25670. */
  25671. offset: number, canBeRegenerated?: boolean, mesh?: Mesh,
  25672. /**
  25673. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25674. */
  25675. side?: number);
  25676. /** @hidden */
  25677. _regenerateVertexData(): VertexData;
  25678. copy(id: string): Geometry;
  25679. }
  25680. /**
  25681. * Creates a box geometry
  25682. * @description see http://doc.babylonjs.com/how_to/set_shapes#box
  25683. */
  25684. class BoxGeometry extends _PrimitiveGeometry {
  25685. /**
  25686. * Defines the zise of the box (width, height and depth are the same)
  25687. */
  25688. size: number;
  25689. /**
  25690. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25691. */
  25692. side: number;
  25693. /**
  25694. * Creates a box geometry
  25695. * @param id defines the unique ID of the geometry
  25696. * @param scene defines the hosting scene
  25697. * @param size defines the zise of the box (width, height and depth are the same)
  25698. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25699. * @param mesh defines the hosting mesh (can be null)
  25700. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25701. */
  25702. constructor(id: string, scene: Scene,
  25703. /**
  25704. * Defines the zise of the box (width, height and depth are the same)
  25705. */
  25706. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25707. /**
  25708. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25709. */
  25710. side?: number);
  25711. /** @hidden */
  25712. _regenerateVertexData(): VertexData;
  25713. copy(id: string): Geometry;
  25714. serialize(): any;
  25715. static Parse(parsedBox: any, scene: Scene): Nullable<BoxGeometry>;
  25716. }
  25717. /**
  25718. * Creates a sphere geometry
  25719. * @description see http://doc.babylonjs.com/how_to/set_shapes#sphere
  25720. */
  25721. class SphereGeometry extends _PrimitiveGeometry {
  25722. /**
  25723. * Defines the number of segments to use to create the sphere
  25724. */
  25725. segments: number;
  25726. /**
  25727. * Defines the diameter of the sphere
  25728. */
  25729. diameter: number;
  25730. /**
  25731. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25732. */
  25733. side: number;
  25734. /**
  25735. * Create a new sphere geometry
  25736. * @param id defines the unique ID of the geometry
  25737. * @param scene defines the hosting scene
  25738. * @param segments defines the number of segments to use to create the sphere
  25739. * @param diameter defines the diameter of the sphere
  25740. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25741. * @param mesh defines the hosting mesh (can be null)
  25742. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25743. */
  25744. constructor(id: string, scene: Scene,
  25745. /**
  25746. * Defines the number of segments to use to create the sphere
  25747. */
  25748. segments: number,
  25749. /**
  25750. * Defines the diameter of the sphere
  25751. */
  25752. diameter: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25753. /**
  25754. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25755. */
  25756. side?: number);
  25757. /** @hidden */
  25758. _regenerateVertexData(): VertexData;
  25759. copy(id: string): Geometry;
  25760. serialize(): any;
  25761. static Parse(parsedSphere: any, scene: Scene): Nullable<SphereGeometry>;
  25762. }
  25763. /**
  25764. * Creates a disc geometry
  25765. * @description see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25766. */
  25767. class DiscGeometry extends _PrimitiveGeometry {
  25768. /**
  25769. * Defines the radius of the disc
  25770. */
  25771. radius: number;
  25772. /**
  25773. * Defines the tesselation factor to apply to the disc
  25774. */
  25775. tessellation: number;
  25776. /**
  25777. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25778. */
  25779. side: number;
  25780. /**
  25781. * Creates a new disc geometry
  25782. * @param id defines the unique ID of the geometry
  25783. * @param scene defines the hosting scene
  25784. * @param radius defines the radius of the disc
  25785. * @param tessellation defines the tesselation factor to apply to the disc
  25786. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25787. * @param mesh defines the hosting mesh (can be null)
  25788. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25789. */
  25790. constructor(id: string, scene: Scene,
  25791. /**
  25792. * Defines the radius of the disc
  25793. */
  25794. radius: number,
  25795. /**
  25796. * Defines the tesselation factor to apply to the disc
  25797. */
  25798. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25799. /**
  25800. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25801. */
  25802. side?: number);
  25803. /** @hidden */
  25804. _regenerateVertexData(): VertexData;
  25805. copy(id: string): Geometry;
  25806. }
  25807. /**
  25808. * Creates a new cylinder geometry
  25809. * @description see http://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  25810. */
  25811. class CylinderGeometry extends _PrimitiveGeometry {
  25812. /**
  25813. * Defines the height of the cylinder
  25814. */
  25815. height: number;
  25816. /**
  25817. * Defines the diameter of the cylinder's top cap
  25818. */
  25819. diameterTop: number;
  25820. /**
  25821. * Defines the diameter of the cylinder's bottom cap
  25822. */
  25823. diameterBottom: number;
  25824. /**
  25825. * Defines the tessellation factor to apply to the cylinder
  25826. */
  25827. tessellation: number;
  25828. /**
  25829. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  25830. */
  25831. subdivisions: number;
  25832. /**
  25833. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25834. */
  25835. side: number;
  25836. /**
  25837. * Creates a new cylinder geometry
  25838. * @param id defines the unique ID of the geometry
  25839. * @param scene defines the hosting scene
  25840. * @param height defines the height of the cylinder
  25841. * @param diameterTop defines the diameter of the cylinder's top cap
  25842. * @param diameterBottom defines the diameter of the cylinder's bottom cap
  25843. * @param tessellation defines the tessellation factor to apply to the cylinder (number of radial sides)
  25844. * @param subdivisions defines the number of subdivisions to apply to the cylinder (number of rings) (1 by default)
  25845. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25846. * @param mesh defines the hosting mesh (can be null)
  25847. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25848. */
  25849. constructor(id: string, scene: Scene,
  25850. /**
  25851. * Defines the height of the cylinder
  25852. */
  25853. height: number,
  25854. /**
  25855. * Defines the diameter of the cylinder's top cap
  25856. */
  25857. diameterTop: number,
  25858. /**
  25859. * Defines the diameter of the cylinder's bottom cap
  25860. */
  25861. diameterBottom: number,
  25862. /**
  25863. * Defines the tessellation factor to apply to the cylinder
  25864. */
  25865. tessellation: number,
  25866. /**
  25867. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  25868. */
  25869. subdivisions?: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25870. /**
  25871. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25872. */
  25873. side?: number);
  25874. /** @hidden */
  25875. _regenerateVertexData(): VertexData;
  25876. copy(id: string): Geometry;
  25877. serialize(): any;
  25878. static Parse(parsedCylinder: any, scene: Scene): Nullable<CylinderGeometry>;
  25879. }
  25880. /**
  25881. * Creates a new torus geometry
  25882. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus
  25883. */
  25884. class TorusGeometry extends _PrimitiveGeometry {
  25885. /**
  25886. * Defines the diameter of the torus
  25887. */
  25888. diameter: number;
  25889. /**
  25890. * Defines the thickness of the torus (ie. internal diameter)
  25891. */
  25892. thickness: number;
  25893. /**
  25894. * Defines the tesselation factor to apply to the torus
  25895. */
  25896. tessellation: number;
  25897. /**
  25898. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25899. */
  25900. side: number;
  25901. /**
  25902. * Creates a new torus geometry
  25903. * @param id defines the unique ID of the geometry
  25904. * @param scene defines the hosting scene
  25905. * @param diameter defines the diameter of the torus
  25906. * @param thickness defines the thickness of the torus (ie. internal diameter)
  25907. * @param tessellation defines the tesselation factor to apply to the torus (number of segments along the circle)
  25908. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25909. * @param mesh defines the hosting mesh (can be null)
  25910. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25911. */
  25912. constructor(id: string, scene: Scene,
  25913. /**
  25914. * Defines the diameter of the torus
  25915. */
  25916. diameter: number,
  25917. /**
  25918. * Defines the thickness of the torus (ie. internal diameter)
  25919. */
  25920. thickness: number,
  25921. /**
  25922. * Defines the tesselation factor to apply to the torus
  25923. */
  25924. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25925. /**
  25926. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25927. */
  25928. side?: number);
  25929. /** @hidden */
  25930. _regenerateVertexData(): VertexData;
  25931. copy(id: string): Geometry;
  25932. serialize(): any;
  25933. static Parse(parsedTorus: any, scene: Scene): Nullable<TorusGeometry>;
  25934. }
  25935. /**
  25936. * Creates a new ground geometry
  25937. * @description see http://doc.babylonjs.com/how_to/set_shapes#ground
  25938. */
  25939. class GroundGeometry extends _PrimitiveGeometry {
  25940. /**
  25941. * Defines the width of the ground
  25942. */
  25943. width: number;
  25944. /**
  25945. * Defines the height of the ground
  25946. */
  25947. height: number;
  25948. /**
  25949. * Defines the subdivisions to apply to the ground
  25950. */
  25951. subdivisions: number;
  25952. /**
  25953. * Creates a new ground geometry
  25954. * @param id defines the unique ID of the geometry
  25955. * @param scene defines the hosting scene
  25956. * @param width defines the width of the ground
  25957. * @param height defines the height of the ground
  25958. * @param subdivisions defines the subdivisions to apply to the ground
  25959. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25960. * @param mesh defines the hosting mesh (can be null)
  25961. */
  25962. constructor(id: string, scene: Scene,
  25963. /**
  25964. * Defines the width of the ground
  25965. */
  25966. width: number,
  25967. /**
  25968. * Defines the height of the ground
  25969. */
  25970. height: number,
  25971. /**
  25972. * Defines the subdivisions to apply to the ground
  25973. */
  25974. subdivisions: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  25975. /** @hidden */
  25976. _regenerateVertexData(): VertexData;
  25977. copy(id: string): Geometry;
  25978. serialize(): any;
  25979. static Parse(parsedGround: any, scene: Scene): Nullable<GroundGeometry>;
  25980. }
  25981. /**
  25982. * Creates a tiled ground geometry
  25983. * @description see http://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  25984. */
  25985. class TiledGroundGeometry extends _PrimitiveGeometry {
  25986. /**
  25987. * Defines the minimum value on X axis
  25988. */
  25989. xmin: number;
  25990. /**
  25991. * Defines the minimum value on Z axis
  25992. */
  25993. zmin: number;
  25994. /**
  25995. * Defines the maximum value on X axis
  25996. */
  25997. xmax: number;
  25998. /**
  25999. * Defines the maximum value on Z axis
  26000. */
  26001. zmax: number;
  26002. /**
  26003. * Defines the subdivisions to apply to the ground
  26004. */
  26005. subdivisions: {
  26006. w: number;
  26007. h: number;
  26008. };
  26009. /**
  26010. * Defines the precision to use when computing the tiles
  26011. */
  26012. precision: {
  26013. w: number;
  26014. h: number;
  26015. };
  26016. /**
  26017. * Creates a tiled ground geometry
  26018. * @param id defines the unique ID of the geometry
  26019. * @param scene defines the hosting scene
  26020. * @param xmin defines the minimum value on X axis
  26021. * @param zmin defines the minimum value on Z axis
  26022. * @param xmax defines the maximum value on X axis
  26023. * @param zmax defines the maximum value on Z axis
  26024. * @param subdivisions defines the subdivisions to apply to the ground (number of subdivisions (tiles) on the height and the width of the map)
  26025. * @param precision defines the precision to use when computing the tiles
  26026. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  26027. * @param mesh defines the hosting mesh (can be null)
  26028. */
  26029. constructor(id: string, scene: Scene,
  26030. /**
  26031. * Defines the minimum value on X axis
  26032. */
  26033. xmin: number,
  26034. /**
  26035. * Defines the minimum value on Z axis
  26036. */
  26037. zmin: number,
  26038. /**
  26039. * Defines the maximum value on X axis
  26040. */
  26041. xmax: number,
  26042. /**
  26043. * Defines the maximum value on Z axis
  26044. */
  26045. zmax: number,
  26046. /**
  26047. * Defines the subdivisions to apply to the ground
  26048. */
  26049. subdivisions: {
  26050. w: number;
  26051. h: number;
  26052. },
  26053. /**
  26054. * Defines the precision to use when computing the tiles
  26055. */
  26056. precision: {
  26057. w: number;
  26058. h: number;
  26059. }, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  26060. /** @hidden */
  26061. _regenerateVertexData(): VertexData;
  26062. copy(id: string): Geometry;
  26063. }
  26064. /**
  26065. * Creates a plane geometry
  26066. * @description see http://doc.babylonjs.com/how_to/set_shapes#plane
  26067. */
  26068. class PlaneGeometry extends _PrimitiveGeometry {
  26069. /**
  26070. * Defines the size of the plane (width === height)
  26071. */
  26072. size: number;
  26073. /**
  26074. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26075. */
  26076. side: number;
  26077. /**
  26078. * Creates a plane geometry
  26079. * @param id defines the unique ID of the geometry
  26080. * @param scene defines the hosting scene
  26081. * @param size defines the size of the plane (width === height)
  26082. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  26083. * @param mesh defines the hosting mesh (can be null)
  26084. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26085. */
  26086. constructor(id: string, scene: Scene,
  26087. /**
  26088. * Defines the size of the plane (width === height)
  26089. */
  26090. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  26091. /**
  26092. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26093. */
  26094. side?: number);
  26095. /** @hidden */
  26096. _regenerateVertexData(): VertexData;
  26097. copy(id: string): Geometry;
  26098. serialize(): any;
  26099. static Parse(parsedPlane: any, scene: Scene): Nullable<PlaneGeometry>;
  26100. }
  26101. /**
  26102. * Creates a torus knot geometry
  26103. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus-knot
  26104. */
  26105. class TorusKnotGeometry extends _PrimitiveGeometry {
  26106. /**
  26107. * Defines the radius of the torus knot
  26108. */
  26109. radius: number;
  26110. /**
  26111. * Defines the thickness of the torus knot tube
  26112. */
  26113. tube: number;
  26114. /**
  26115. * Defines the number of radial segments
  26116. */
  26117. radialSegments: number;
  26118. /**
  26119. * Defines the number of tubular segments
  26120. */
  26121. tubularSegments: number;
  26122. /**
  26123. * Defines the first number of windings
  26124. */
  26125. p: number;
  26126. /**
  26127. * Defines the second number of windings
  26128. */
  26129. q: number;
  26130. /**
  26131. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26132. */
  26133. side: number;
  26134. /**
  26135. * Creates a torus knot geometry
  26136. * @param id defines the unique ID of the geometry
  26137. * @param scene defines the hosting scene
  26138. * @param radius defines the radius of the torus knot
  26139. * @param tube defines the thickness of the torus knot tube
  26140. * @param radialSegments defines the number of radial segments
  26141. * @param tubularSegments defines the number of tubular segments
  26142. * @param p defines the first number of windings
  26143. * @param q defines the second number of windings
  26144. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  26145. * @param mesh defines the hosting mesh (can be null)
  26146. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26147. */
  26148. constructor(id: string, scene: Scene,
  26149. /**
  26150. * Defines the radius of the torus knot
  26151. */
  26152. radius: number,
  26153. /**
  26154. * Defines the thickness of the torus knot tube
  26155. */
  26156. tube: number,
  26157. /**
  26158. * Defines the number of radial segments
  26159. */
  26160. radialSegments: number,
  26161. /**
  26162. * Defines the number of tubular segments
  26163. */
  26164. tubularSegments: number,
  26165. /**
  26166. * Defines the first number of windings
  26167. */
  26168. p: number,
  26169. /**
  26170. * Defines the second number of windings
  26171. */
  26172. q: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  26173. /**
  26174. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26175. */
  26176. side?: number);
  26177. /** @hidden */
  26178. _regenerateVertexData(): VertexData;
  26179. copy(id: string): Geometry;
  26180. serialize(): any;
  26181. static Parse(parsedTorusKnot: any, scene: Scene): Nullable<TorusKnotGeometry>;
  26182. }
  26183. }
  26184. declare module BABYLON {
  26185. /**
  26186. * Mesh representing the gorund
  26187. */
  26188. class GroundMesh extends Mesh {
  26189. /** If octree should be generated */
  26190. generateOctree: boolean;
  26191. private _heightQuads;
  26192. /** @hidden */
  26193. _subdivisionsX: number;
  26194. /** @hidden */
  26195. _subdivisionsY: number;
  26196. /** @hidden */
  26197. _width: number;
  26198. /** @hidden */
  26199. _height: number;
  26200. /** @hidden */
  26201. _minX: number;
  26202. /** @hidden */
  26203. _maxX: number;
  26204. /** @hidden */
  26205. _minZ: number;
  26206. /** @hidden */
  26207. _maxZ: number;
  26208. constructor(name: string, scene: Scene);
  26209. /**
  26210. * "GroundMesh"
  26211. * @returns "GroundMesh"
  26212. */
  26213. getClassName(): string;
  26214. /**
  26215. * The minimum of x and y subdivisions
  26216. */
  26217. readonly subdivisions: number;
  26218. /**
  26219. * X subdivisions
  26220. */
  26221. readonly subdivisionsX: number;
  26222. /**
  26223. * Y subdivisions
  26224. */
  26225. readonly subdivisionsY: number;
  26226. /**
  26227. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  26228. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  26229. * @param chunksCount the number of subdivisions for x and y
  26230. * @param octreeBlocksSize (Default: 32)
  26231. */
  26232. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  26233. /**
  26234. * Returns a height (y) value in the Worl system :
  26235. * the ground altitude at the coordinates (x, z) expressed in the World system.
  26236. * @param x x coordinate
  26237. * @param z z coordinate
  26238. * @returns the ground y position if (x, z) are outside the ground surface.
  26239. */
  26240. getHeightAtCoordinates(x: number, z: number): number;
  26241. /**
  26242. * Returns a normalized vector (Vector3) orthogonal to the ground
  26243. * at the ground coordinates (x, z) expressed in the World system.
  26244. * @param x x coordinate
  26245. * @param z z coordinate
  26246. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  26247. */
  26248. getNormalAtCoordinates(x: number, z: number): Vector3;
  26249. /**
  26250. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  26251. * at the ground coordinates (x, z) expressed in the World system.
  26252. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  26253. * @param x x coordinate
  26254. * @param z z coordinate
  26255. * @param ref vector to store the result
  26256. * @returns the GroundMesh.
  26257. */
  26258. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  26259. /**
  26260. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  26261. * if the ground has been updated.
  26262. * This can be used in the render loop.
  26263. * @returns the GroundMesh.
  26264. */
  26265. updateCoordinateHeights(): GroundMesh;
  26266. private _getFacetAt;
  26267. private _initHeightQuads;
  26268. private _computeHeightQuads;
  26269. /**
  26270. * Serializes this ground mesh
  26271. * @param serializationObject object to write serialization to
  26272. */
  26273. serialize(serializationObject: any): void;
  26274. /**
  26275. * Parses a serialized ground mesh
  26276. * @param parsedMesh the serialized mesh
  26277. * @param scene the scene to create the ground mesh in
  26278. * @returns the created ground mesh
  26279. */
  26280. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  26281. }
  26282. }
  26283. declare module BABYLON {
  26284. /**
  26285. * Creates an instance based on a source mesh.
  26286. */
  26287. class InstancedMesh extends AbstractMesh {
  26288. private _sourceMesh;
  26289. private _currentLOD;
  26290. /** @hidden */
  26291. _indexInSourceMeshInstanceArray: number;
  26292. constructor(name: string, source: Mesh);
  26293. /**
  26294. * Returns the string "InstancedMesh".
  26295. */
  26296. getClassName(): string;
  26297. /**
  26298. * If the source mesh receives shadows
  26299. */
  26300. readonly receiveShadows: boolean;
  26301. /**
  26302. * The material of the source mesh
  26303. */
  26304. readonly material: Nullable<Material>;
  26305. /**
  26306. * Visibility of the source mesh
  26307. */
  26308. readonly visibility: number;
  26309. /**
  26310. * Skeleton of the source mesh
  26311. */
  26312. readonly skeleton: Nullable<Skeleton>;
  26313. /**
  26314. * Rendering ground id of the source mesh
  26315. */
  26316. renderingGroupId: number;
  26317. /**
  26318. * Returns the total number of vertices (integer).
  26319. */
  26320. getTotalVertices(): number;
  26321. /**
  26322. * Returns a positive integer : the total number of indices in this mesh geometry.
  26323. * @returns the numner of indices or zero if the mesh has no geometry.
  26324. */
  26325. getTotalIndices(): number;
  26326. /**
  26327. * The source mesh of the instance
  26328. */
  26329. readonly sourceMesh: Mesh;
  26330. /**
  26331. * Is this node ready to be used/rendered
  26332. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26333. * @return {boolean} is it ready
  26334. */
  26335. isReady(completeCheck?: boolean): boolean;
  26336. /**
  26337. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  26338. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  26339. * @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.
  26340. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  26341. */
  26342. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  26343. /**
  26344. * Sets the vertex data of the mesh geometry for the requested `kind`.
  26345. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  26346. * The `data` are either a numeric array either a Float32Array.
  26347. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  26348. * 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).
  26349. * Note that a new underlying VertexBuffer object is created each call.
  26350. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  26351. *
  26352. * Possible `kind` values :
  26353. * - BABYLON.VertexBuffer.PositionKind
  26354. * - BABYLON.VertexBuffer.UVKind
  26355. * - BABYLON.VertexBuffer.UV2Kind
  26356. * - BABYLON.VertexBuffer.UV3Kind
  26357. * - BABYLON.VertexBuffer.UV4Kind
  26358. * - BABYLON.VertexBuffer.UV5Kind
  26359. * - BABYLON.VertexBuffer.UV6Kind
  26360. * - BABYLON.VertexBuffer.ColorKind
  26361. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26362. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26363. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26364. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26365. *
  26366. * Returns the Mesh.
  26367. */
  26368. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  26369. /**
  26370. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  26371. * If the mesh has no geometry, it is simply returned as it is.
  26372. * The `data` are either a numeric array either a Float32Array.
  26373. * No new underlying VertexBuffer object is created.
  26374. * 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.
  26375. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  26376. *
  26377. * Possible `kind` values :
  26378. * - BABYLON.VertexBuffer.PositionKind
  26379. * - BABYLON.VertexBuffer.UVKind
  26380. * - BABYLON.VertexBuffer.UV2Kind
  26381. * - BABYLON.VertexBuffer.UV3Kind
  26382. * - BABYLON.VertexBuffer.UV4Kind
  26383. * - BABYLON.VertexBuffer.UV5Kind
  26384. * - BABYLON.VertexBuffer.UV6Kind
  26385. * - BABYLON.VertexBuffer.ColorKind
  26386. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26387. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26388. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26389. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26390. *
  26391. * Returns the Mesh.
  26392. */
  26393. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  26394. /**
  26395. * Sets the mesh indices.
  26396. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  26397. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  26398. * This method creates a new index buffer each call.
  26399. * Returns the Mesh.
  26400. */
  26401. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  26402. /**
  26403. * Boolean : True if the mesh owns the requested kind of data.
  26404. */
  26405. isVerticesDataPresent(kind: string): boolean;
  26406. /**
  26407. * Returns an array of indices (IndicesArray).
  26408. */
  26409. getIndices(): Nullable<IndicesArray>;
  26410. readonly _positions: Nullable<Vector3[]>;
  26411. /**
  26412. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26413. * This means the mesh underlying bounding box and sphere are recomputed.
  26414. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26415. * @returns the current mesh
  26416. */
  26417. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  26418. /** @hidden */
  26419. _preActivate(): InstancedMesh;
  26420. /** @hidden */
  26421. _activate(renderId: number): InstancedMesh;
  26422. /**
  26423. * Returns the current associated LOD AbstractMesh.
  26424. */
  26425. getLOD(camera: Camera): AbstractMesh;
  26426. /** @hidden */
  26427. _syncSubMeshes(): InstancedMesh;
  26428. /** @hidden */
  26429. _generatePointsArray(): boolean;
  26430. /**
  26431. * Creates a new InstancedMesh from the current mesh.
  26432. * - name (string) : the cloned mesh name
  26433. * - newParent (optional Node) : the optional Node to parent the clone to.
  26434. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  26435. *
  26436. * Returns the clone.
  26437. */
  26438. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  26439. /**
  26440. * Disposes the InstancedMesh.
  26441. * Returns nothing.
  26442. */
  26443. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26444. }
  26445. }
  26446. declare module BABYLON {
  26447. /**
  26448. * Line mesh
  26449. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  26450. */
  26451. class LinesMesh extends Mesh {
  26452. /**
  26453. * If vertex color should be applied to the mesh
  26454. */
  26455. useVertexColor?: boolean | undefined;
  26456. /**
  26457. * If vertex alpha should be applied to the mesh
  26458. */
  26459. useVertexAlpha?: boolean | undefined;
  26460. /**
  26461. * Color of the line (Default: White)
  26462. */
  26463. color: Color3;
  26464. /**
  26465. * Alpha of the line (Default: 1)
  26466. */
  26467. alpha: number;
  26468. /**
  26469. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  26470. * This margin is expressed in world space coordinates, so its value may vary.
  26471. * Default value is 0.1
  26472. */
  26473. intersectionThreshold: number;
  26474. private _colorShader;
  26475. /**
  26476. * Creates a new LinesMesh
  26477. * @param name defines the name
  26478. * @param scene defines the hosting scene
  26479. * @param parent defines the parent mesh if any
  26480. * @param source defines the optional source LinesMesh used to clone data from
  26481. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  26482. * When false, achieved by calling a clone(), also passing False.
  26483. * This will make creation of children, recursive.
  26484. * @param useVertexColor defines if this LinesMesh supports vertex color
  26485. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  26486. */
  26487. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  26488. /**
  26489. * If vertex color should be applied to the mesh
  26490. */
  26491. useVertexColor?: boolean | undefined,
  26492. /**
  26493. * If vertex alpha should be applied to the mesh
  26494. */
  26495. useVertexAlpha?: boolean | undefined);
  26496. /**
  26497. * Returns the string "LineMesh"
  26498. */
  26499. getClassName(): string;
  26500. /**
  26501. * @hidden
  26502. */
  26503. /**
  26504. * @hidden
  26505. */
  26506. material: Material;
  26507. /**
  26508. * @hidden
  26509. */
  26510. readonly checkCollisions: boolean;
  26511. /** @hidden */
  26512. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  26513. /** @hidden */
  26514. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  26515. /**
  26516. * Disposes of the line mesh
  26517. * @param doNotRecurse If children should be disposed
  26518. */
  26519. dispose(doNotRecurse?: boolean): void;
  26520. /**
  26521. * Returns a new LineMesh object cloned from the current one.
  26522. */
  26523. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  26524. /**
  26525. * Creates a new InstancedLinesMesh object from the mesh model.
  26526. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  26527. * @param name defines the name of the new instance
  26528. * @returns a new InstancedLinesMesh
  26529. */
  26530. createInstance(name: string): InstancedLinesMesh;
  26531. }
  26532. /**
  26533. * Creates an instance based on a source LinesMesh
  26534. */
  26535. class InstancedLinesMesh extends InstancedMesh {
  26536. /**
  26537. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  26538. * This margin is expressed in world space coordinates, so its value may vary.
  26539. * Initilized with the intersectionThreshold value of the source LinesMesh
  26540. */
  26541. intersectionThreshold: number;
  26542. constructor(name: string, source: LinesMesh);
  26543. /**
  26544. * Returns the string "InstancedLinesMesh".
  26545. */
  26546. getClassName(): string;
  26547. }
  26548. }
  26549. declare module BABYLON {
  26550. /**
  26551. * @hidden
  26552. **/
  26553. class _CreationDataStorage {
  26554. closePath?: boolean;
  26555. closeArray?: boolean;
  26556. idx: number[];
  26557. dashSize: number;
  26558. gapSize: number;
  26559. path3D: Path3D;
  26560. pathArray: Vector3[][];
  26561. arc: number;
  26562. radius: number;
  26563. cap: number;
  26564. tessellation: number;
  26565. }
  26566. /**
  26567. * @hidden
  26568. **/
  26569. class _InstanceDataStorage {
  26570. visibleInstances: any;
  26571. renderIdForInstances: number[];
  26572. batchCache: _InstancesBatch;
  26573. instancesBufferSize: number;
  26574. instancesBuffer: Nullable<Buffer>;
  26575. instancesData: Float32Array;
  26576. overridenInstanceCount: number;
  26577. }
  26578. /**
  26579. * @hidden
  26580. **/
  26581. class _InstancesBatch {
  26582. mustReturn: boolean;
  26583. visibleInstances: Nullable<InstancedMesh[]>[];
  26584. renderSelf: boolean[];
  26585. }
  26586. /**
  26587. * Class used to represent renderable models
  26588. */
  26589. class Mesh extends AbstractMesh implements IGetSetVerticesData {
  26590. /**
  26591. * Mesh side orientation : usually the external or front surface
  26592. */
  26593. static readonly FRONTSIDE: number;
  26594. /**
  26595. * Mesh side orientation : usually the internal or back surface
  26596. */
  26597. static readonly BACKSIDE: number;
  26598. /**
  26599. * Mesh side orientation : both internal and external or front and back surfaces
  26600. */
  26601. static readonly DOUBLESIDE: number;
  26602. /**
  26603. * Mesh side orientation : by default, `FRONTSIDE`
  26604. */
  26605. static readonly DEFAULTSIDE: number;
  26606. /**
  26607. * Mesh cap setting : no cap
  26608. */
  26609. static readonly NO_CAP: number;
  26610. /**
  26611. * Mesh cap setting : one cap at the beginning of the mesh
  26612. */
  26613. static readonly CAP_START: number;
  26614. /**
  26615. * Mesh cap setting : one cap at the end of the mesh
  26616. */
  26617. static readonly CAP_END: number;
  26618. /**
  26619. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  26620. */
  26621. static readonly CAP_ALL: number;
  26622. private _onBeforeRenderObservable;
  26623. private _onAfterRenderObservable;
  26624. private _onBeforeDrawObservable;
  26625. /**
  26626. * An event triggered before rendering the mesh
  26627. */
  26628. readonly onBeforeRenderObservable: Observable<Mesh>;
  26629. /**
  26630. * An event triggered after rendering the mesh
  26631. */
  26632. readonly onAfterRenderObservable: Observable<Mesh>;
  26633. /**
  26634. * An event triggered before drawing the mesh
  26635. */
  26636. readonly onBeforeDrawObservable: Observable<Mesh>;
  26637. private _onBeforeDrawObserver;
  26638. /**
  26639. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  26640. */
  26641. onBeforeDraw: () => void;
  26642. /**
  26643. * Gets the delay loading state of the mesh (when delay loading is turned on)
  26644. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  26645. */
  26646. delayLoadState: number;
  26647. /**
  26648. * Gets the list of instances created from this mesh
  26649. * it is not supposed to be modified manually.
  26650. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  26651. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  26652. */
  26653. instances: InstancedMesh[];
  26654. /**
  26655. * Gets the file containing delay loading data for this mesh
  26656. */
  26657. delayLoadingFile: string;
  26658. /** @hidden */
  26659. _binaryInfo: any;
  26660. private _LODLevels;
  26661. /**
  26662. * User defined function used to change how LOD level selection is done
  26663. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  26664. */
  26665. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  26666. private _morphTargetManager;
  26667. /**
  26668. * Gets or sets the morph target manager
  26669. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26670. */
  26671. morphTargetManager: Nullable<MorphTargetManager>;
  26672. /** @hidden */
  26673. _creationDataStorage: Nullable<_CreationDataStorage>;
  26674. /** @hidden */
  26675. _geometry: Nullable<Geometry>;
  26676. /** @hidden */
  26677. _delayInfo: Array<string>;
  26678. /** @hidden */
  26679. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  26680. /** @hidden */
  26681. _instanceDataStorage: _InstanceDataStorage;
  26682. private _effectiveMaterial;
  26683. /** @hidden */
  26684. _shouldGenerateFlatShading: boolean;
  26685. private _preActivateId;
  26686. /** @hidden */
  26687. _originalBuilderSideOrientation: number;
  26688. /**
  26689. * Use this property to change the original side orientation defined at construction time
  26690. */
  26691. overrideMaterialSideOrientation: Nullable<number>;
  26692. private _areNormalsFrozen;
  26693. private _sourcePositions;
  26694. private _sourceNormals;
  26695. private _source;
  26696. private meshMap;
  26697. /**
  26698. * Gets the source mesh (the one used to clone this one from)
  26699. */
  26700. readonly source: Nullable<Mesh>;
  26701. /**
  26702. * Gets or sets a boolean indicating that this mesh does not use index buffer
  26703. */
  26704. isUnIndexed: boolean;
  26705. /**
  26706. * @constructor
  26707. * @param name The value used by scene.getMeshByName() to do a lookup.
  26708. * @param scene The scene to add this mesh to.
  26709. * @param parent The parent of this mesh, if it has one
  26710. * @param source An optional Mesh from which geometry is shared, cloned.
  26711. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  26712. * When false, achieved by calling a clone(), also passing False.
  26713. * This will make creation of children, recursive.
  26714. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  26715. */
  26716. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  26717. /**
  26718. * Gets the class name
  26719. * @returns the string "Mesh".
  26720. */
  26721. getClassName(): string;
  26722. /**
  26723. * Returns a description of this mesh
  26724. * @param fullDetails define if full details about this mesh must be used
  26725. * @returns a descriptive string representing this mesh
  26726. */
  26727. toString(fullDetails?: boolean): string;
  26728. /** @hidden */
  26729. _unBindEffect(): void;
  26730. /**
  26731. * Gets a boolean indicating if this mesh has LOD
  26732. */
  26733. readonly hasLODLevels: boolean;
  26734. /**
  26735. * Gets the list of MeshLODLevel associated with the current mesh
  26736. * @returns an array of MeshLODLevel
  26737. */
  26738. getLODLevels(): MeshLODLevel[];
  26739. private _sortLODLevels;
  26740. /**
  26741. * Add a mesh as LOD level triggered at the given distance.
  26742. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26743. * @param distance The distance from the center of the object to show this level
  26744. * @param mesh The mesh to be added as LOD level (can be null)
  26745. * @return This mesh (for chaining)
  26746. */
  26747. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  26748. /**
  26749. * Returns the LOD level mesh at the passed distance or null if not found.
  26750. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26751. * @param distance The distance from the center of the object to show this level
  26752. * @returns a Mesh or `null`
  26753. */
  26754. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  26755. /**
  26756. * Remove a mesh from the LOD array
  26757. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26758. * @param mesh defines the mesh to be removed
  26759. * @return This mesh (for chaining)
  26760. */
  26761. removeLODLevel(mesh: Mesh): Mesh;
  26762. /**
  26763. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  26764. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26765. * @param camera defines the camera to use to compute distance
  26766. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  26767. * @return This mesh (for chaining)
  26768. */
  26769. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  26770. /**
  26771. * Gets the mesh internal Geometry object
  26772. */
  26773. readonly geometry: Nullable<Geometry>;
  26774. /**
  26775. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  26776. * @returns the total number of vertices
  26777. */
  26778. getTotalVertices(): number;
  26779. /**
  26780. * Returns the content of an associated vertex buffer
  26781. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  26782. * - BABYLON.VertexBuffer.PositionKind
  26783. * - BABYLON.VertexBuffer.UVKind
  26784. * - BABYLON.VertexBuffer.UV2Kind
  26785. * - BABYLON.VertexBuffer.UV3Kind
  26786. * - BABYLON.VertexBuffer.UV4Kind
  26787. * - BABYLON.VertexBuffer.UV5Kind
  26788. * - BABYLON.VertexBuffer.UV6Kind
  26789. * - BABYLON.VertexBuffer.ColorKind
  26790. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26791. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26792. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26793. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26794. * @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
  26795. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  26796. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  26797. */
  26798. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  26799. /**
  26800. * Returns the mesh VertexBuffer object from the requested `kind`
  26801. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  26802. * - BABYLON.VertexBuffer.PositionKind
  26803. * - BABYLON.VertexBuffer.UVKind
  26804. * - BABYLON.VertexBuffer.UV2Kind
  26805. * - BABYLON.VertexBuffer.UV3Kind
  26806. * - BABYLON.VertexBuffer.UV4Kind
  26807. * - BABYLON.VertexBuffer.UV5Kind
  26808. * - BABYLON.VertexBuffer.UV6Kind
  26809. * - BABYLON.VertexBuffer.ColorKind
  26810. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26811. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26812. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26813. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26814. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  26815. */
  26816. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  26817. /**
  26818. * Tests if a specific vertex buffer is associated with this mesh
  26819. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  26820. * - BABYLON.VertexBuffer.PositionKind
  26821. * - BABYLON.VertexBuffer.UVKind
  26822. * - BABYLON.VertexBuffer.UV2Kind
  26823. * - BABYLON.VertexBuffer.UV3Kind
  26824. * - BABYLON.VertexBuffer.UV4Kind
  26825. * - BABYLON.VertexBuffer.UV5Kind
  26826. * - BABYLON.VertexBuffer.UV6Kind
  26827. * - BABYLON.VertexBuffer.ColorKind
  26828. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26829. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26830. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26831. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26832. * @returns a boolean
  26833. */
  26834. isVerticesDataPresent(kind: string): boolean;
  26835. /**
  26836. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  26837. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  26838. * - BABYLON.VertexBuffer.PositionKind
  26839. * - BABYLON.VertexBuffer.UVKind
  26840. * - BABYLON.VertexBuffer.UV2Kind
  26841. * - BABYLON.VertexBuffer.UV3Kind
  26842. * - BABYLON.VertexBuffer.UV4Kind
  26843. * - BABYLON.VertexBuffer.UV5Kind
  26844. * - BABYLON.VertexBuffer.UV6Kind
  26845. * - BABYLON.VertexBuffer.ColorKind
  26846. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26847. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26848. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26849. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26850. * @returns a boolean
  26851. */
  26852. isVertexBufferUpdatable(kind: string): boolean;
  26853. /**
  26854. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  26855. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  26856. * - BABYLON.VertexBuffer.PositionKind
  26857. * - BABYLON.VertexBuffer.UVKind
  26858. * - BABYLON.VertexBuffer.UV2Kind
  26859. * - BABYLON.VertexBuffer.UV3Kind
  26860. * - BABYLON.VertexBuffer.UV4Kind
  26861. * - BABYLON.VertexBuffer.UV5Kind
  26862. * - BABYLON.VertexBuffer.UV6Kind
  26863. * - BABYLON.VertexBuffer.ColorKind
  26864. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26865. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26866. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26867. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26868. * @returns an array of strings
  26869. */
  26870. getVerticesDataKinds(): string[];
  26871. /**
  26872. * Returns a positive integer : the total number of indices in this mesh geometry.
  26873. * @returns the numner of indices or zero if the mesh has no geometry.
  26874. */
  26875. getTotalIndices(): number;
  26876. /**
  26877. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  26878. * @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.
  26879. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26880. * @returns the indices array or an empty array if the mesh has no geometry
  26881. */
  26882. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  26883. readonly isBlocked: boolean;
  26884. /**
  26885. * Determine if the current mesh is ready to be rendered
  26886. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26887. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  26888. * @returns true if all associated assets are ready (material, textures, shaders)
  26889. */
  26890. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  26891. /**
  26892. * 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.
  26893. */
  26894. readonly areNormalsFrozen: boolean;
  26895. /**
  26896. * 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.
  26897. * @returns the current mesh
  26898. */
  26899. freezeNormals(): Mesh;
  26900. /**
  26901. * 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
  26902. * @returns the current mesh
  26903. */
  26904. unfreezeNormals(): Mesh;
  26905. /**
  26906. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  26907. */
  26908. overridenInstanceCount: number;
  26909. /** @hidden */
  26910. _preActivate(): Mesh;
  26911. /** @hidden */
  26912. _preActivateForIntermediateRendering(renderId: number): Mesh;
  26913. /** @hidden */
  26914. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  26915. /**
  26916. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26917. * This means the mesh underlying bounding box and sphere are recomputed.
  26918. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26919. * @returns the current mesh
  26920. */
  26921. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  26922. /** @hidden */
  26923. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  26924. /**
  26925. * This function will subdivide the mesh into multiple submeshes
  26926. * @param count defines the expected number of submeshes
  26927. */
  26928. subdivide(count: number): void;
  26929. /**
  26930. * Copy a FloatArray into a specific associated vertex buffer
  26931. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  26932. * - BABYLON.VertexBuffer.PositionKind
  26933. * - BABYLON.VertexBuffer.UVKind
  26934. * - BABYLON.VertexBuffer.UV2Kind
  26935. * - BABYLON.VertexBuffer.UV3Kind
  26936. * - BABYLON.VertexBuffer.UV4Kind
  26937. * - BABYLON.VertexBuffer.UV5Kind
  26938. * - BABYLON.VertexBuffer.UV6Kind
  26939. * - BABYLON.VertexBuffer.ColorKind
  26940. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26941. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26942. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26943. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26944. * @param data defines the data source
  26945. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  26946. * @param stride defines the data stride size (can be null)
  26947. * @returns the current mesh
  26948. */
  26949. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  26950. /**
  26951. * Flags an associated vertex buffer as updatable
  26952. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  26953. * - BABYLON.VertexBuffer.PositionKind
  26954. * - BABYLON.VertexBuffer.UVKind
  26955. * - BABYLON.VertexBuffer.UV2Kind
  26956. * - BABYLON.VertexBuffer.UV3Kind
  26957. * - BABYLON.VertexBuffer.UV4Kind
  26958. * - BABYLON.VertexBuffer.UV5Kind
  26959. * - BABYLON.VertexBuffer.UV6Kind
  26960. * - BABYLON.VertexBuffer.ColorKind
  26961. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26962. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26963. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26964. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26965. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  26966. */
  26967. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  26968. /**
  26969. * Sets the mesh global Vertex Buffer
  26970. * @param buffer defines the buffer to use
  26971. * @returns the current mesh
  26972. */
  26973. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  26974. /**
  26975. * Update a specific associated vertex buffer
  26976. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  26977. * - BABYLON.VertexBuffer.PositionKind
  26978. * - BABYLON.VertexBuffer.UVKind
  26979. * - BABYLON.VertexBuffer.UV2Kind
  26980. * - BABYLON.VertexBuffer.UV3Kind
  26981. * - BABYLON.VertexBuffer.UV4Kind
  26982. * - BABYLON.VertexBuffer.UV5Kind
  26983. * - BABYLON.VertexBuffer.UV6Kind
  26984. * - BABYLON.VertexBuffer.ColorKind
  26985. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26986. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26987. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26988. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26989. * @param data defines the data source
  26990. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  26991. * @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)
  26992. * @returns the current mesh
  26993. */
  26994. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  26995. /**
  26996. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  26997. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  26998. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  26999. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  27000. * @returns the current mesh
  27001. */
  27002. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  27003. /**
  27004. * Creates a un-shared specific occurence of the geometry for the mesh.
  27005. * @returns the current mesh
  27006. */
  27007. makeGeometryUnique(): Mesh;
  27008. /**
  27009. * Set the index buffer of this mesh
  27010. * @param indices defines the source data
  27011. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  27012. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  27013. * @returns the current mesh
  27014. */
  27015. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  27016. /**
  27017. * Update the current index buffer
  27018. * @param indices defines the source data
  27019. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27020. * @returns the current mesh
  27021. */
  27022. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  27023. /**
  27024. * Invert the geometry to move from a right handed system to a left handed one.
  27025. * @returns the current mesh
  27026. */
  27027. toLeftHanded(): Mesh;
  27028. /** @hidden */
  27029. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  27030. /** @hidden */
  27031. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  27032. /**
  27033. * Registers for this mesh a javascript function called just before the rendering process
  27034. * @param func defines the function to call before rendering this mesh
  27035. * @returns the current mesh
  27036. */
  27037. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  27038. /**
  27039. * Disposes a previously registered javascript function called before the rendering
  27040. * @param func defines the function to remove
  27041. * @returns the current mesh
  27042. */
  27043. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  27044. /**
  27045. * Registers for this mesh a javascript function called just after the rendering is complete
  27046. * @param func defines the function to call after rendering this mesh
  27047. * @returns the current mesh
  27048. */
  27049. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  27050. /**
  27051. * Disposes a previously registered javascript function called after the rendering.
  27052. * @param func defines the function to remove
  27053. * @returns the current mesh
  27054. */
  27055. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  27056. /** @hidden */
  27057. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  27058. /** @hidden */
  27059. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  27060. /** @hidden */
  27061. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  27062. /**
  27063. * 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
  27064. * @param subMesh defines the subMesh to render
  27065. * @param enableAlphaMode defines if alpha mode can be changed
  27066. * @returns the current mesh
  27067. */
  27068. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  27069. private _onBeforeDraw;
  27070. /**
  27071. * Renormalize the mesh and patch it up if there are no weights
  27072. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  27073. * However in the case of zero weights then we set just a single influence to 1.
  27074. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  27075. */
  27076. cleanMatrixWeights(): void;
  27077. private normalizeSkinFourWeights;
  27078. private normalizeSkinWeightsAndExtra;
  27079. /**
  27080. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  27081. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  27082. * the user know there was an issue with importing the mesh
  27083. * @returns a validation object with skinned, valid and report string
  27084. */
  27085. validateSkinning(): {
  27086. skinned: boolean;
  27087. valid: boolean;
  27088. report: string;
  27089. };
  27090. /** @hidden */
  27091. _checkDelayState(): Mesh;
  27092. private _queueLoad;
  27093. /**
  27094. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  27095. * A mesh is in the frustum if its bounding box intersects the frustum
  27096. * @param frustumPlanes defines the frustum to test
  27097. * @returns true if the mesh is in the frustum planes
  27098. */
  27099. isInFrustum(frustumPlanes: Plane[]): boolean;
  27100. /**
  27101. * Sets the mesh material by the material or multiMaterial `id` property
  27102. * @param id is a string identifying the material or the multiMaterial
  27103. * @returns the current mesh
  27104. */
  27105. setMaterialByID(id: string): Mesh;
  27106. /**
  27107. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  27108. * @returns an array of IAnimatable
  27109. */
  27110. getAnimatables(): IAnimatable[];
  27111. /**
  27112. * Modifies the mesh geometry according to the passed transformation matrix.
  27113. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  27114. * The mesh normals are modified using the same transformation.
  27115. * Note that, under the hood, this method sets a new VertexBuffer each call.
  27116. * @param transform defines the transform matrix to use
  27117. * @see http://doc.babylonjs.com/resources/baking_transformations
  27118. * @returns the current mesh
  27119. */
  27120. bakeTransformIntoVertices(transform: Matrix): Mesh;
  27121. /**
  27122. * Modifies the mesh geometry according to its own current World Matrix.
  27123. * The mesh World Matrix is then reset.
  27124. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  27125. * Note that, under the hood, this method sets a new VertexBuffer each call.
  27126. * @see http://doc.babylonjs.com/resources/baking_transformations
  27127. * @returns the current mesh
  27128. */
  27129. bakeCurrentTransformIntoVertices(): Mesh;
  27130. /** @hidden */
  27131. readonly _positions: Nullable<Vector3[]>;
  27132. /** @hidden */
  27133. _resetPointsArrayCache(): Mesh;
  27134. /** @hidden */
  27135. _generatePointsArray(): boolean;
  27136. /**
  27137. * Returns a new Mesh object generated from the current mesh properties.
  27138. * This method must not get confused with createInstance()
  27139. * @param name is a string, the name given to the new mesh
  27140. * @param newParent can be any Node object (default `null`)
  27141. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  27142. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  27143. * @returns a new mesh
  27144. */
  27145. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  27146. /**
  27147. * Releases resources associated with this mesh.
  27148. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27149. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27150. */
  27151. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27152. /**
  27153. * Modifies the mesh geometry according to a displacement map.
  27154. * 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.
  27155. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  27156. * @param url is a string, the URL from the image file is to be downloaded.
  27157. * @param minHeight is the lower limit of the displacement.
  27158. * @param maxHeight is the upper limit of the displacement.
  27159. * @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.
  27160. * @param uvOffset is an optional vector2 used to offset UV.
  27161. * @param uvScale is an optional vector2 used to scale UV.
  27162. * @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.
  27163. * @returns the Mesh.
  27164. */
  27165. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  27166. /**
  27167. * Modifies the mesh geometry according to a displacementMap buffer.
  27168. * 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.
  27169. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  27170. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  27171. * @param heightMapWidth is the width of the buffer image.
  27172. * @param heightMapHeight is the height of the buffer image.
  27173. * @param minHeight is the lower limit of the displacement.
  27174. * @param maxHeight is the upper limit of the displacement.
  27175. * @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.
  27176. * @param uvOffset is an optional vector2 used to offset UV.
  27177. * @param uvScale is an optional vector2 used to scale UV.
  27178. * @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.
  27179. * @returns the Mesh.
  27180. */
  27181. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  27182. /**
  27183. * Modify the mesh to get a flat shading rendering.
  27184. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  27185. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  27186. * @returns current mesh
  27187. */
  27188. convertToFlatShadedMesh(): Mesh;
  27189. /**
  27190. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  27191. * In other words, more vertices, no more indices and a single bigger VBO.
  27192. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  27193. * @returns current mesh
  27194. */
  27195. convertToUnIndexedMesh(): Mesh;
  27196. /**
  27197. * Inverses facet orientations.
  27198. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  27199. * @param flipNormals will also inverts the normals
  27200. * @returns current mesh
  27201. */
  27202. flipFaces(flipNormals?: boolean): Mesh;
  27203. /**
  27204. * Creates a new InstancedMesh object from the mesh model.
  27205. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  27206. * @param name defines the name of the new instance
  27207. * @returns a new InstancedMesh
  27208. */
  27209. createInstance(name: string): InstancedMesh;
  27210. /**
  27211. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  27212. * After this call, all the mesh instances have the same submeshes than the current mesh.
  27213. * @returns the current mesh
  27214. */
  27215. synchronizeInstances(): Mesh;
  27216. /**
  27217. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  27218. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  27219. * This should be used together with the simplification to avoid disappearing triangles.
  27220. * @param successCallback an optional success callback to be called after the optimization finished.
  27221. * @returns the current mesh
  27222. */
  27223. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  27224. /**
  27225. * Serialize current mesh
  27226. * @param serializationObject defines the object which will receive the serialization data
  27227. */
  27228. serialize(serializationObject: any): void;
  27229. /** @hidden */
  27230. _syncGeometryWithMorphTargetManager(): void;
  27231. /**
  27232. * Returns a new Mesh object parsed from the source provided.
  27233. * @param parsedMesh is the source
  27234. * @param scene defines the hosting scene
  27235. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  27236. * @returns a new Mesh
  27237. */
  27238. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  27239. /**
  27240. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  27241. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  27242. * @param name defines the name of the mesh to create
  27243. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  27244. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  27245. * @param closePath creates a seam between the first and the last points of each path of the path array
  27246. * @param offset is taken in account only if the `pathArray` is containing a single path
  27247. * @param scene defines the hosting scene
  27248. * @param updatable defines if the mesh must be flagged as updatable
  27249. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27250. * @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)
  27251. * @returns a new Mesh
  27252. */
  27253. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean | undefined, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  27254. /**
  27255. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  27256. * @param name defines the name of the mesh to create
  27257. * @param radius sets the radius size (float) of the polygon (default 0.5)
  27258. * @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
  27259. * @param scene defines the hosting scene
  27260. * @param updatable defines if the mesh must be flagged as updatable
  27261. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27262. * @returns a new Mesh
  27263. */
  27264. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  27265. /**
  27266. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  27267. * @param name defines the name of the mesh to create
  27268. * @param size sets the size (float) of each box side (default 1)
  27269. * @param scene defines the hosting scene
  27270. * @param updatable defines if the mesh must be flagged as updatable
  27271. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27272. * @returns a new Mesh
  27273. */
  27274. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  27275. /**
  27276. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  27277. * @param name defines the name of the mesh to create
  27278. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  27279. * @param diameter sets the diameter size (float) of the sphere (default 1)
  27280. * @param scene defines the hosting scene
  27281. * @param updatable defines if the mesh must be flagged as updatable
  27282. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27283. * @returns a new Mesh
  27284. */
  27285. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27286. /**
  27287. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  27288. * @param name defines the name of the mesh to create
  27289. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  27290. * @param diameterTop set the top cap diameter (floats, default 1)
  27291. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  27292. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  27293. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  27294. * @param scene defines the hosting scene
  27295. * @param updatable defines if the mesh must be flagged as updatable
  27296. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27297. * @returns a new Mesh
  27298. */
  27299. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  27300. /**
  27301. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  27302. * @param name defines the name of the mesh to create
  27303. * @param diameter sets the diameter size (float) of the torus (default 1)
  27304. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  27305. * @param tessellation sets the number of torus sides (postive integer, default 16)
  27306. * @param scene defines the hosting scene
  27307. * @param updatable defines if the mesh must be flagged as updatable
  27308. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27309. * @returns a new Mesh
  27310. */
  27311. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27312. /**
  27313. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  27314. * @param name defines the name of the mesh to create
  27315. * @param radius sets the global radius size (float) of the torus knot (default 2)
  27316. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  27317. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  27318. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  27319. * @param p the number of windings on X axis (positive integers, default 2)
  27320. * @param q the number of windings on Y axis (positive integers, default 3)
  27321. * @param scene defines the hosting scene
  27322. * @param updatable defines if the mesh must be flagged as updatable
  27323. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27324. * @returns a new Mesh
  27325. */
  27326. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27327. /**
  27328. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  27329. * @param name defines the name of the mesh to create
  27330. * @param points is an array successive Vector3
  27331. * @param scene defines the hosting scene
  27332. * @param updatable defines if the mesh must be flagged as updatable
  27333. * @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).
  27334. * @returns a new Mesh
  27335. */
  27336. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  27337. /**
  27338. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  27339. * @param name defines the name of the mesh to create
  27340. * @param points is an array successive Vector3
  27341. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  27342. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  27343. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  27344. * @param scene defines the hosting scene
  27345. * @param updatable defines if the mesh must be flagged as updatable
  27346. * @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)
  27347. * @returns a new Mesh
  27348. */
  27349. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  27350. /**
  27351. * Creates a polygon mesh.
  27352. * Please consider using the same method from the MeshBuilder class instead.
  27353. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  27354. * 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.
  27355. * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27356. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  27357. * Remember you can only change the shape positions, not their number when updating a polygon.
  27358. */
  27359. /**
  27360. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  27361. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  27362. * @param name defines the name of the mesh to create
  27363. * @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
  27364. * @param scene defines the hosting scene
  27365. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  27366. * @param updatable defines if the mesh must be flagged as updatable
  27367. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27368. * @returns a new Mesh
  27369. */
  27370. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  27371. /**
  27372. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  27373. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  27374. * @param name defines the name of the mesh to create
  27375. * @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
  27376. * @param depth defines the height of extrusion
  27377. * @param scene defines the hosting scene
  27378. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  27379. * @param updatable defines if the mesh must be flagged as updatable
  27380. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27381. * @returns a new Mesh
  27382. */
  27383. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  27384. /**
  27385. * Creates an extruded shape mesh.
  27386. * 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
  27387. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  27388. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  27389. * @param name defines the name of the mesh to create
  27390. * @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
  27391. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  27392. * @param scale is the value to scale the shape
  27393. * @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
  27394. * @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
  27395. * @param scene defines the hosting scene
  27396. * @param updatable defines if the mesh must be flagged as updatable
  27397. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27398. * @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)
  27399. * @returns a new Mesh
  27400. */
  27401. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  27402. /**
  27403. * Creates an custom extruded shape mesh.
  27404. * The custom extrusion is a parametric shape.
  27405. * It has no predefined shape. Its final shape will depend on the input parameters.
  27406. * Please consider using the same method from the MeshBuilder class instead
  27407. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  27408. * @param name defines the name of the mesh to create
  27409. * @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
  27410. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  27411. * @param scaleFunction is a custom Javascript function called on each path point
  27412. * @param rotationFunction is a custom Javascript function called on each path point
  27413. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  27414. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  27415. * @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
  27416. * @param scene defines the hosting scene
  27417. * @param updatable defines if the mesh must be flagged as updatable
  27418. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27419. * @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)
  27420. * @returns a new Mesh
  27421. */
  27422. 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;
  27423. /**
  27424. * Creates lathe mesh.
  27425. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  27426. * Please consider using the same method from the MeshBuilder class instead
  27427. * @param name defines the name of the mesh to create
  27428. * @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
  27429. * @param radius is the radius value of the lathe
  27430. * @param tessellation is the side number of the lathe.
  27431. * @param scene defines the hosting scene
  27432. * @param updatable defines if the mesh must be flagged as updatable
  27433. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27434. * @returns a new Mesh
  27435. */
  27436. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27437. /**
  27438. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  27439. * @param name defines the name of the mesh to create
  27440. * @param size sets the size (float) of both sides of the plane at once (default 1)
  27441. * @param scene defines the hosting scene
  27442. * @param updatable defines if the mesh must be flagged as updatable
  27443. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27444. * @returns a new Mesh
  27445. */
  27446. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27447. /**
  27448. * Creates a ground mesh.
  27449. * Please consider using the same method from the MeshBuilder class instead
  27450. * @param name defines the name of the mesh to create
  27451. * @param width set the width of the ground
  27452. * @param height set the height of the ground
  27453. * @param subdivisions sets the number of subdivisions per side
  27454. * @param scene defines the hosting scene
  27455. * @param updatable defines if the mesh must be flagged as updatable
  27456. * @returns a new Mesh
  27457. */
  27458. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  27459. /**
  27460. * Creates a tiled ground mesh.
  27461. * Please consider using the same method from the MeshBuilder class instead
  27462. * @param name defines the name of the mesh to create
  27463. * @param xmin set the ground minimum X coordinate
  27464. * @param zmin set the ground minimum Y coordinate
  27465. * @param xmax set the ground maximum X coordinate
  27466. * @param zmax set the ground maximum Z coordinate
  27467. * @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
  27468. * @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
  27469. * @param scene defines the hosting scene
  27470. * @param updatable defines if the mesh must be flagged as updatable
  27471. * @returns a new Mesh
  27472. */
  27473. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  27474. w: number;
  27475. h: number;
  27476. }, precision: {
  27477. w: number;
  27478. h: number;
  27479. }, scene: Scene, updatable?: boolean): Mesh;
  27480. /**
  27481. * Creates a ground mesh from a height map.
  27482. * Please consider using the same method from the MeshBuilder class instead
  27483. * @see http://doc.babylonjs.com/babylon101/height_map
  27484. * @param name defines the name of the mesh to create
  27485. * @param url sets the URL of the height map image resource
  27486. * @param width set the ground width size
  27487. * @param height set the ground height size
  27488. * @param subdivisions sets the number of subdivision per side
  27489. * @param minHeight is the minimum altitude on the ground
  27490. * @param maxHeight is the maximum altitude on the ground
  27491. * @param scene defines the hosting scene
  27492. * @param updatable defines if the mesh must be flagged as updatable
  27493. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  27494. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  27495. * @returns a new Mesh
  27496. */
  27497. 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;
  27498. /**
  27499. * Creates a tube mesh.
  27500. * The tube is a parametric shape.
  27501. * It has no predefined shape. Its final shape will depend on the input parameters.
  27502. * Please consider using the same method from the MeshBuilder class instead
  27503. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  27504. * @param name defines the name of the mesh to create
  27505. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  27506. * @param radius sets the tube radius size
  27507. * @param tessellation is the number of sides on the tubular surface
  27508. * @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
  27509. * @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
  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. * @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)
  27514. * @returns a new Mesh
  27515. */
  27516. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  27517. (i: number, distance: number): number;
  27518. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  27519. /**
  27520. * Creates a polyhedron mesh.
  27521. * Please consider using the same method from the MeshBuilder class instead.
  27522. * * 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
  27523. * * The parameter `size` (positive float, default 1) sets the polygon size
  27524. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  27525. * * 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`
  27526. * * 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
  27527. * * 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)`)
  27528. * * 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
  27529. * * 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
  27530. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27531. * * 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
  27532. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27533. * @param name defines the name of the mesh to create
  27534. * @param options defines the options used to create the mesh
  27535. * @param scene defines the hosting scene
  27536. * @returns a new Mesh
  27537. */
  27538. static CreatePolyhedron(name: string, options: {
  27539. type?: number;
  27540. size?: number;
  27541. sizeX?: number;
  27542. sizeY?: number;
  27543. sizeZ?: number;
  27544. custom?: any;
  27545. faceUV?: Vector4[];
  27546. faceColors?: Color4[];
  27547. updatable?: boolean;
  27548. sideOrientation?: number;
  27549. }, scene: Scene): Mesh;
  27550. /**
  27551. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  27552. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  27553. * * 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`)
  27554. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  27555. * * 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
  27556. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27557. * * 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
  27558. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27559. * @param name defines the name of the mesh
  27560. * @param options defines the options used to create the mesh
  27561. * @param scene defines the hosting scene
  27562. * @returns a new Mesh
  27563. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  27564. */
  27565. static CreateIcoSphere(name: string, options: {
  27566. radius?: number;
  27567. flat?: boolean;
  27568. subdivisions?: number;
  27569. sideOrientation?: number;
  27570. updatable?: boolean;
  27571. }, scene: Scene): Mesh;
  27572. /**
  27573. * Creates a decal mesh.
  27574. * Please consider using the same method from the MeshBuilder class instead.
  27575. * A decal is a mesh usually applied as a model onto the surface of another mesh
  27576. * @param name defines the name of the mesh
  27577. * @param sourceMesh defines the mesh receiving the decal
  27578. * @param position sets the position of the decal in world coordinates
  27579. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  27580. * @param size sets the decal scaling
  27581. * @param angle sets the angle to rotate the decal
  27582. * @returns a new Mesh
  27583. */
  27584. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  27585. /**
  27586. * Prepare internal position array for software CPU skinning
  27587. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  27588. */
  27589. setPositionsForCPUSkinning(): Float32Array;
  27590. /**
  27591. * Prepare internal normal array for software CPU skinning
  27592. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  27593. */
  27594. setNormalsForCPUSkinning(): Float32Array;
  27595. /**
  27596. * Updates the vertex buffer by applying transformation from the bones
  27597. * @param skeleton defines the skeleton to apply to current mesh
  27598. * @returns the current mesh
  27599. */
  27600. applySkeleton(skeleton: Skeleton): Mesh;
  27601. /**
  27602. * 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
  27603. * @param meshes defines the list of meshes to scan
  27604. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  27605. */
  27606. static MinMax(meshes: AbstractMesh[]): {
  27607. min: Vector3;
  27608. max: Vector3;
  27609. };
  27610. /**
  27611. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  27612. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  27613. * @returns a vector3
  27614. */
  27615. static Center(meshesOrMinMaxVector: {
  27616. min: Vector3;
  27617. max: Vector3;
  27618. } | AbstractMesh[]): Vector3;
  27619. /**
  27620. * Merge the array of meshes into a single mesh for performance reasons.
  27621. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  27622. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  27623. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  27624. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  27625. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  27626. * @returns a new mesh
  27627. */
  27628. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean): Nullable<Mesh>;
  27629. /** @hidden */
  27630. addInstance(instance: InstancedMesh): void;
  27631. /** @hidden */
  27632. removeInstance(instance: InstancedMesh): void;
  27633. }
  27634. }
  27635. declare module BABYLON {
  27636. /**
  27637. * Define an interface for all classes that will get and set the data on vertices
  27638. */
  27639. interface IGetSetVerticesData {
  27640. /**
  27641. * Gets a boolean indicating if specific vertex data is present
  27642. * @param kind defines the vertex data kind to use
  27643. * @returns true is data kind is present
  27644. */
  27645. isVerticesDataPresent(kind: string): boolean;
  27646. /**
  27647. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  27648. * @param kind defines the data kind (Position, normal, etc...)
  27649. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  27650. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  27651. * @returns a float array containing vertex data
  27652. */
  27653. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  27654. /**
  27655. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  27656. * @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.
  27657. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  27658. * @returns the indices array or an empty array if the mesh has no geometry
  27659. */
  27660. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  27661. /**
  27662. * Set specific vertex data
  27663. * @param kind defines the data kind (Position, normal, etc...)
  27664. * @param data defines the vertex data to use
  27665. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  27666. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  27667. */
  27668. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  27669. /**
  27670. * Update a specific associated vertex buffer
  27671. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  27672. * - BABYLON.VertexBuffer.PositionKind
  27673. * - BABYLON.VertexBuffer.UVKind
  27674. * - BABYLON.VertexBuffer.UV2Kind
  27675. * - BABYLON.VertexBuffer.UV3Kind
  27676. * - BABYLON.VertexBuffer.UV4Kind
  27677. * - BABYLON.VertexBuffer.UV5Kind
  27678. * - BABYLON.VertexBuffer.UV6Kind
  27679. * - BABYLON.VertexBuffer.ColorKind
  27680. * - BABYLON.VertexBuffer.MatricesIndicesKind
  27681. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  27682. * - BABYLON.VertexBuffer.MatricesWeightsKind
  27683. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  27684. * @param data defines the data source
  27685. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  27686. * @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)
  27687. */
  27688. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  27689. /**
  27690. * Creates a new index buffer
  27691. * @param indices defines the indices to store in the index buffer
  27692. * @param totalVertices defines the total number of vertices (could be null)
  27693. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  27694. */
  27695. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  27696. }
  27697. /**
  27698. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  27699. */
  27700. class VertexData {
  27701. /**
  27702. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  27703. */
  27704. positions: Nullable<FloatArray>;
  27705. /**
  27706. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  27707. */
  27708. normals: Nullable<FloatArray>;
  27709. /**
  27710. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  27711. */
  27712. tangents: Nullable<FloatArray>;
  27713. /**
  27714. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27715. */
  27716. uvs: Nullable<FloatArray>;
  27717. /**
  27718. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27719. */
  27720. uvs2: Nullable<FloatArray>;
  27721. /**
  27722. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27723. */
  27724. uvs3: Nullable<FloatArray>;
  27725. /**
  27726. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27727. */
  27728. uvs4: Nullable<FloatArray>;
  27729. /**
  27730. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27731. */
  27732. uvs5: Nullable<FloatArray>;
  27733. /**
  27734. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27735. */
  27736. uvs6: Nullable<FloatArray>;
  27737. /**
  27738. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  27739. */
  27740. colors: Nullable<FloatArray>;
  27741. /**
  27742. * 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).
  27743. */
  27744. matricesIndices: Nullable<FloatArray>;
  27745. /**
  27746. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  27747. */
  27748. matricesWeights: Nullable<FloatArray>;
  27749. /**
  27750. * An array extending the number of possible indices
  27751. */
  27752. matricesIndicesExtra: Nullable<FloatArray>;
  27753. /**
  27754. * An array extending the number of possible weights when the number of indices is extended
  27755. */
  27756. matricesWeightsExtra: Nullable<FloatArray>;
  27757. /**
  27758. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  27759. */
  27760. indices: Nullable<IndicesArray>;
  27761. /**
  27762. * Uses the passed data array to set the set the values for the specified kind of data
  27763. * @param data a linear array of floating numbers
  27764. * @param kind the type of data that is being set, eg positions, colors etc
  27765. */
  27766. set(data: FloatArray, kind: string): void;
  27767. /**
  27768. * Associates the vertexData to the passed Mesh.
  27769. * Sets it as updatable or not (default `false`)
  27770. * @param mesh the mesh the vertexData is applied to
  27771. * @param updatable when used and having the value true allows new data to update the vertexData
  27772. * @returns the VertexData
  27773. */
  27774. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  27775. /**
  27776. * Associates the vertexData to the passed Geometry.
  27777. * Sets it as updatable or not (default `false`)
  27778. * @param geometry the geometry the vertexData is applied to
  27779. * @param updatable when used and having the value true allows new data to update the vertexData
  27780. * @returns VertexData
  27781. */
  27782. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  27783. /**
  27784. * Updates the associated mesh
  27785. * @param mesh the mesh to be updated
  27786. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  27787. * @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
  27788. * @returns VertexData
  27789. */
  27790. updateMesh(mesh: Mesh, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  27791. /**
  27792. * Updates the associated geometry
  27793. * @param geometry the geometry to be updated
  27794. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  27795. * @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
  27796. * @returns VertexData.
  27797. */
  27798. updateGeometry(geometry: Geometry, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  27799. private _applyTo;
  27800. private _update;
  27801. /**
  27802. * Transforms each position and each normal of the vertexData according to the passed Matrix
  27803. * @param matrix the transforming matrix
  27804. * @returns the VertexData
  27805. */
  27806. transform(matrix: Matrix): VertexData;
  27807. /**
  27808. * Merges the passed VertexData into the current one
  27809. * @param other the VertexData to be merged into the current one
  27810. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  27811. * @returns the modified VertexData
  27812. */
  27813. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  27814. private _mergeElement;
  27815. private _validate;
  27816. /**
  27817. * Serializes the VertexData
  27818. * @returns a serialized object
  27819. */
  27820. serialize(): any;
  27821. /**
  27822. * Extracts the vertexData from a mesh
  27823. * @param mesh the mesh from which to extract the VertexData
  27824. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  27825. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  27826. * @returns the object VertexData associated to the passed mesh
  27827. */
  27828. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  27829. /**
  27830. * Extracts the vertexData from the geometry
  27831. * @param geometry the geometry from which to extract the VertexData
  27832. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  27833. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  27834. * @returns the object VertexData associated to the passed mesh
  27835. */
  27836. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  27837. private static _ExtractFrom;
  27838. /**
  27839. * Creates the VertexData for a Ribbon
  27840. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  27841. * * pathArray array of paths, each of which an array of successive Vector3
  27842. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  27843. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  27844. * * 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
  27845. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27846. * * 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)
  27847. * * 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)
  27848. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  27849. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  27850. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  27851. * @returns the VertexData of the ribbon
  27852. */
  27853. static CreateRibbon(options: {
  27854. pathArray: Vector3[][];
  27855. closeArray?: boolean;
  27856. closePath?: boolean;
  27857. offset?: number;
  27858. sideOrientation?: number;
  27859. frontUVs?: Vector4;
  27860. backUVs?: Vector4;
  27861. invertUV?: boolean;
  27862. uvs?: Vector2[];
  27863. colors?: Color4[];
  27864. }): VertexData;
  27865. /**
  27866. * Creates the VertexData for a box
  27867. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27868. * * size sets the width, height and depth of the box to the value of size, optional default 1
  27869. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  27870. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  27871. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  27872. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  27873. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  27874. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27875. * * 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)
  27876. * * 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)
  27877. * @returns the VertexData of the box
  27878. */
  27879. static CreateBox(options: {
  27880. size?: number;
  27881. width?: number;
  27882. height?: number;
  27883. depth?: number;
  27884. faceUV?: Vector4[];
  27885. faceColors?: Color4[];
  27886. sideOrientation?: number;
  27887. frontUVs?: Vector4;
  27888. backUVs?: Vector4;
  27889. }): VertexData;
  27890. /**
  27891. * Creates the VertexData for an ellipsoid, defaults to a sphere
  27892. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27893. * * segments sets the number of horizontal strips optional, default 32
  27894. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  27895. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  27896. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  27897. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  27898. * * 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
  27899. * * 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
  27900. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27901. * * 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)
  27902. * * 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)
  27903. * @returns the VertexData of the ellipsoid
  27904. */
  27905. static CreateSphere(options: {
  27906. segments?: number;
  27907. diameter?: number;
  27908. diameterX?: number;
  27909. diameterY?: number;
  27910. diameterZ?: number;
  27911. arc?: number;
  27912. slice?: number;
  27913. sideOrientation?: number;
  27914. frontUVs?: Vector4;
  27915. backUVs?: Vector4;
  27916. }): VertexData;
  27917. /**
  27918. * Creates the VertexData for a cylinder, cone or prism
  27919. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27920. * * height sets the height (y direction) of the cylinder, optional, default 2
  27921. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  27922. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  27923. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  27924. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  27925. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  27926. * * 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
  27927. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27928. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27929. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  27930. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  27931. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27932. * * 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)
  27933. * * 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)
  27934. * @returns the VertexData of the cylinder, cone or prism
  27935. */
  27936. static CreateCylinder(options: {
  27937. height?: number;
  27938. diameterTop?: number;
  27939. diameterBottom?: number;
  27940. diameter?: number;
  27941. tessellation?: number;
  27942. subdivisions?: number;
  27943. arc?: number;
  27944. faceColors?: Color4[];
  27945. faceUV?: Vector4[];
  27946. hasRings?: boolean;
  27947. enclose?: boolean;
  27948. sideOrientation?: number;
  27949. frontUVs?: Vector4;
  27950. backUVs?: Vector4;
  27951. }): VertexData;
  27952. /**
  27953. * Creates the VertexData for a torus
  27954. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27955. * * diameter the diameter of the torus, optional default 1
  27956. * * thickness the diameter of the tube forming the torus, optional default 0.5
  27957. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  27958. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27959. * * 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)
  27960. * * 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)
  27961. * @returns the VertexData of the torus
  27962. */
  27963. static CreateTorus(options: {
  27964. diameter?: number;
  27965. thickness?: number;
  27966. tessellation?: number;
  27967. sideOrientation?: number;
  27968. frontUVs?: Vector4;
  27969. backUVs?: Vector4;
  27970. }): VertexData;
  27971. /**
  27972. * Creates the VertexData of the LineSystem
  27973. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  27974. * - lines an array of lines, each line being an array of successive Vector3
  27975. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  27976. * @returns the VertexData of the LineSystem
  27977. */
  27978. static CreateLineSystem(options: {
  27979. lines: Vector3[][];
  27980. colors?: Nullable<Color4[][]>;
  27981. }): VertexData;
  27982. /**
  27983. * Create the VertexData for a DashedLines
  27984. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  27985. * - points an array successive Vector3
  27986. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  27987. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  27988. * - dashNb the intended total number of dashes, optional, default 200
  27989. * @returns the VertexData for the DashedLines
  27990. */
  27991. static CreateDashedLines(options: {
  27992. points: Vector3[];
  27993. dashSize?: number;
  27994. gapSize?: number;
  27995. dashNb?: number;
  27996. }): VertexData;
  27997. /**
  27998. * Creates the VertexData for a Ground
  27999. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  28000. * - width the width (x direction) of the ground, optional, default 1
  28001. * - height the height (z direction) of the ground, optional, default 1
  28002. * - subdivisions the number of subdivisions per side, optional, default 1
  28003. * @returns the VertexData of the Ground
  28004. */
  28005. static CreateGround(options: {
  28006. width?: number;
  28007. height?: number;
  28008. subdivisions?: number;
  28009. subdivisionsX?: number;
  28010. subdivisionsY?: number;
  28011. }): VertexData;
  28012. /**
  28013. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  28014. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  28015. * * xmin the ground minimum X coordinate, optional, default -1
  28016. * * zmin the ground minimum Z coordinate, optional, default -1
  28017. * * xmax the ground maximum X coordinate, optional, default 1
  28018. * * zmax the ground maximum Z coordinate, optional, default 1
  28019. * * 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}
  28020. * * 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}
  28021. * @returns the VertexData of the TiledGround
  28022. */
  28023. static CreateTiledGround(options: {
  28024. xmin: number;
  28025. zmin: number;
  28026. xmax: number;
  28027. zmax: number;
  28028. subdivisions?: {
  28029. w: number;
  28030. h: number;
  28031. };
  28032. precision?: {
  28033. w: number;
  28034. h: number;
  28035. };
  28036. }): VertexData;
  28037. /**
  28038. * Creates the VertexData of the Ground designed from a heightmap
  28039. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  28040. * * width the width (x direction) of the ground
  28041. * * height the height (z direction) of the ground
  28042. * * subdivisions the number of subdivisions per side
  28043. * * minHeight the minimum altitude on the ground, optional, default 0
  28044. * * maxHeight the maximum altitude on the ground, optional default 1
  28045. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  28046. * * buffer the array holding the image color data
  28047. * * bufferWidth the width of image
  28048. * * bufferHeight the height of image
  28049. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  28050. * @returns the VertexData of the Ground designed from a heightmap
  28051. */
  28052. static CreateGroundFromHeightMap(options: {
  28053. width: number;
  28054. height: number;
  28055. subdivisions: number;
  28056. minHeight: number;
  28057. maxHeight: number;
  28058. colorFilter: Color3;
  28059. buffer: Uint8Array;
  28060. bufferWidth: number;
  28061. bufferHeight: number;
  28062. alphaFilter: number;
  28063. }): VertexData;
  28064. /**
  28065. * Creates the VertexData for a Plane
  28066. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  28067. * * size sets the width and height of the plane to the value of size, optional default 1
  28068. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  28069. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  28070. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28071. * * 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)
  28072. * * 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)
  28073. * @returns the VertexData of the box
  28074. */
  28075. static CreatePlane(options: {
  28076. size?: number;
  28077. width?: number;
  28078. height?: number;
  28079. sideOrientation?: number;
  28080. frontUVs?: Vector4;
  28081. backUVs?: Vector4;
  28082. }): VertexData;
  28083. /**
  28084. * Creates the VertexData of the Disc or regular Polygon
  28085. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  28086. * * radius the radius of the disc, optional default 0.5
  28087. * * tessellation the number of polygon sides, optional, default 64
  28088. * * 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
  28089. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28090. * * 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)
  28091. * * 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)
  28092. * @returns the VertexData of the box
  28093. */
  28094. static CreateDisc(options: {
  28095. radius?: number;
  28096. tessellation?: number;
  28097. arc?: number;
  28098. sideOrientation?: number;
  28099. frontUVs?: Vector4;
  28100. backUVs?: Vector4;
  28101. }): VertexData;
  28102. /**
  28103. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  28104. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  28105. * @param polygon a mesh built from polygonTriangulation.build()
  28106. * @param sideOrientation takes the values BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28107. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  28108. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  28109. * @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)
  28110. * @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)
  28111. * @returns the VertexData of the Polygon
  28112. */
  28113. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  28114. /**
  28115. * Creates the VertexData of the IcoSphere
  28116. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  28117. * * radius the radius of the IcoSphere, optional default 1
  28118. * * radiusX allows stretching in the x direction, optional, default radius
  28119. * * radiusY allows stretching in the y direction, optional, default radius
  28120. * * radiusZ allows stretching in the z direction, optional, default radius
  28121. * * flat when true creates a flat shaded mesh, optional, default true
  28122. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  28123. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28124. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  28125. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  28126. * @returns the VertexData of the IcoSphere
  28127. */
  28128. static CreateIcoSphere(options: {
  28129. radius?: number;
  28130. radiusX?: number;
  28131. radiusY?: number;
  28132. radiusZ?: number;
  28133. flat?: boolean;
  28134. subdivisions?: number;
  28135. sideOrientation?: number;
  28136. frontUVs?: Vector4;
  28137. backUVs?: Vector4;
  28138. }): VertexData;
  28139. /**
  28140. * Creates the VertexData for a Polyhedron
  28141. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  28142. * * type provided types are:
  28143. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  28144. * * 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)
  28145. * * size the size of the IcoSphere, optional default 1
  28146. * * sizeX allows stretching in the x direction, optional, default size
  28147. * * sizeY allows stretching in the y direction, optional, default size
  28148. * * sizeZ allows stretching in the z direction, optional, default size
  28149. * * 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
  28150. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  28151. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  28152. * * flat when true creates a flat shaded mesh, optional, default true
  28153. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  28154. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28155. * * 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)
  28156. * * 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)
  28157. * @returns the VertexData of the Polyhedron
  28158. */
  28159. static CreatePolyhedron(options: {
  28160. type?: number;
  28161. size?: number;
  28162. sizeX?: number;
  28163. sizeY?: number;
  28164. sizeZ?: number;
  28165. custom?: any;
  28166. faceUV?: Vector4[];
  28167. faceColors?: Color4[];
  28168. flat?: boolean;
  28169. sideOrientation?: number;
  28170. frontUVs?: Vector4;
  28171. backUVs?: Vector4;
  28172. }): VertexData;
  28173. /**
  28174. * Creates the VertexData for a TorusKnot
  28175. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  28176. * * radius the radius of the torus knot, optional, default 2
  28177. * * tube the thickness of the tube, optional, default 0.5
  28178. * * radialSegments the number of sides on each tube segments, optional, default 32
  28179. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  28180. * * p the number of windings around the z axis, optional, default 2
  28181. * * q the number of windings around the x axis, optional, default 3
  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 Torus Knot
  28186. */
  28187. static CreateTorusKnot(options: {
  28188. radius?: number;
  28189. tube?: number;
  28190. radialSegments?: number;
  28191. tubularSegments?: number;
  28192. p?: number;
  28193. q?: number;
  28194. sideOrientation?: number;
  28195. frontUVs?: Vector4;
  28196. backUVs?: Vector4;
  28197. }): VertexData;
  28198. /**
  28199. * Compute normals for given positions and indices
  28200. * @param positions an array of vertex positions, [...., x, y, z, ......]
  28201. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  28202. * @param normals an array of vertex normals, [...., x, y, z, ......]
  28203. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  28204. * * facetNormals : optional array of facet normals (vector3)
  28205. * * facetPositions : optional array of facet positions (vector3)
  28206. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  28207. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  28208. * * bInfo : optional bounding info, required for facetPartitioning computation
  28209. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  28210. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  28211. * * useRightHandedSystem: optional boolean to for right handed system computation
  28212. * * depthSort : optional boolean to enable the facet depth sort computation
  28213. * * distanceTo : optional Vector3 to compute the facet depth from this location
  28214. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  28215. */
  28216. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  28217. facetNormals?: any;
  28218. facetPositions?: any;
  28219. facetPartitioning?: any;
  28220. ratio?: number;
  28221. bInfo?: any;
  28222. bbSize?: Vector3;
  28223. subDiv?: any;
  28224. useRightHandedSystem?: boolean;
  28225. depthSort?: boolean;
  28226. distanceTo?: Vector3;
  28227. depthSortedFacets?: any;
  28228. }): void;
  28229. private static _ComputeSides;
  28230. /**
  28231. * Applies VertexData created from the imported parameters to the geometry
  28232. * @param parsedVertexData the parsed data from an imported file
  28233. * @param geometry the geometry to apply the VertexData to
  28234. */
  28235. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  28236. }
  28237. }
  28238. declare module BABYLON {
  28239. /**
  28240. * Class containing static functions to help procedurally build meshes
  28241. */
  28242. class MeshBuilder {
  28243. private static updateSideOrientation;
  28244. /**
  28245. * Creates a box mesh
  28246. * * The parameter `size` sets the size (float) of each box side (default 1)
  28247. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  28248. * * 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)
  28249. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  28250. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28251. * * 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
  28252. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28253. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  28254. * @param name defines the name of the mesh
  28255. * @param options defines the options used to create the mesh
  28256. * @param scene defines the hosting scene
  28257. * @returns the box mesh
  28258. */
  28259. static CreateBox(name: string, options: {
  28260. size?: number;
  28261. width?: number;
  28262. height?: number;
  28263. depth?: number;
  28264. faceUV?: Vector4[];
  28265. faceColors?: Color4[];
  28266. sideOrientation?: number;
  28267. frontUVs?: Vector4;
  28268. backUVs?: Vector4;
  28269. updatable?: boolean;
  28270. }, scene?: Nullable<Scene>): Mesh;
  28271. /**
  28272. * Creates a sphere mesh
  28273. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  28274. * * 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`)
  28275. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  28276. * * 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
  28277. * * 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)
  28278. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28279. * * 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
  28280. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28281. * @param name defines the name of the mesh
  28282. * @param options defines the options used to create the mesh
  28283. * @param scene defines the hosting scene
  28284. * @returns the sphere mesh
  28285. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  28286. */
  28287. static CreateSphere(name: string, options: {
  28288. segments?: number;
  28289. diameter?: number;
  28290. diameterX?: number;
  28291. diameterY?: number;
  28292. diameterZ?: number;
  28293. arc?: number;
  28294. slice?: number;
  28295. sideOrientation?: number;
  28296. frontUVs?: Vector4;
  28297. backUVs?: Vector4;
  28298. updatable?: boolean;
  28299. }, scene: any): Mesh;
  28300. /**
  28301. * Creates a plane polygonal mesh. By default, this is a disc
  28302. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  28303. * * 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
  28304. * * 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
  28305. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28306. * * 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
  28307. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28308. * @param name defines the name of the mesh
  28309. * @param options defines the options used to create the mesh
  28310. * @param scene defines the hosting scene
  28311. * @returns the plane polygonal mesh
  28312. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  28313. */
  28314. static CreateDisc(name: string, options: {
  28315. radius?: number;
  28316. tessellation?: number;
  28317. arc?: number;
  28318. updatable?: boolean;
  28319. sideOrientation?: number;
  28320. frontUVs?: Vector4;
  28321. backUVs?: Vector4;
  28322. }, scene?: Nullable<Scene>): Mesh;
  28323. /**
  28324. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  28325. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  28326. * * 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`)
  28327. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  28328. * * 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
  28329. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28330. * * 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
  28331. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28332. * @param name defines the name of the mesh
  28333. * @param options defines the options used to create the mesh
  28334. * @param scene defines the hosting scene
  28335. * @returns the icosahedron mesh
  28336. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  28337. */
  28338. static CreateIcoSphere(name: string, options: {
  28339. radius?: number;
  28340. radiusX?: number;
  28341. radiusY?: number;
  28342. radiusZ?: number;
  28343. flat?: boolean;
  28344. subdivisions?: number;
  28345. sideOrientation?: number;
  28346. frontUVs?: Vector4;
  28347. backUVs?: Vector4;
  28348. updatable?: boolean;
  28349. }, scene: Scene): Mesh;
  28350. /**
  28351. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  28352. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  28353. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  28354. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  28355. * * 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
  28356. * * 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
  28357. * * 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
  28358. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28359. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  28360. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  28361. * * 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
  28362. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  28363. * * 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
  28364. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  28365. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28366. * @param name defines the name of the mesh
  28367. * @param options defines the options used to create the mesh
  28368. * @param scene defines the hosting scene
  28369. * @returns the ribbon mesh
  28370. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  28371. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28372. */
  28373. static CreateRibbon(name: string, options: {
  28374. pathArray: Vector3[][];
  28375. closeArray?: boolean;
  28376. closePath?: boolean;
  28377. offset?: number;
  28378. updatable?: boolean;
  28379. sideOrientation?: number;
  28380. frontUVs?: Vector4;
  28381. backUVs?: Vector4;
  28382. instance?: Mesh;
  28383. invertUV?: boolean;
  28384. uvs?: Vector2[];
  28385. colors?: Color4[];
  28386. }, scene?: Nullable<Scene>): Mesh;
  28387. /**
  28388. * Creates a cylinder or a cone mesh
  28389. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  28390. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  28391. * * 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.
  28392. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  28393. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  28394. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  28395. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  28396. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  28397. * * 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).
  28398. * * 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
  28399. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  28400. * * 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
  28401. * * 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.
  28402. * * If `enclose` is false, a ring surface is one element.
  28403. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  28404. * * 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
  28405. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28406. * * 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
  28407. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28408. * @param name defines the name of the mesh
  28409. * @param options defines the options used to create the mesh
  28410. * @param scene defines the hosting scene
  28411. * @returns the cylinder mesh
  28412. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  28413. */
  28414. static CreateCylinder(name: string, options: {
  28415. height?: number;
  28416. diameterTop?: number;
  28417. diameterBottom?: number;
  28418. diameter?: number;
  28419. tessellation?: number;
  28420. subdivisions?: number;
  28421. arc?: number;
  28422. faceColors?: Color4[];
  28423. faceUV?: Vector4[];
  28424. updatable?: boolean;
  28425. hasRings?: boolean;
  28426. enclose?: boolean;
  28427. sideOrientation?: number;
  28428. frontUVs?: Vector4;
  28429. backUVs?: Vector4;
  28430. }, scene: any): Mesh;
  28431. /**
  28432. * Creates a torus mesh
  28433. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  28434. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  28435. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  28436. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28437. * * 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
  28438. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28439. * @param name defines the name of the mesh
  28440. * @param options defines the options used to create the mesh
  28441. * @param scene defines the hosting scene
  28442. * @returns the torus mesh
  28443. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  28444. */
  28445. static CreateTorus(name: string, options: {
  28446. diameter?: number;
  28447. thickness?: number;
  28448. tessellation?: number;
  28449. updatable?: boolean;
  28450. sideOrientation?: number;
  28451. frontUVs?: Vector4;
  28452. backUVs?: Vector4;
  28453. }, scene: any): Mesh;
  28454. /**
  28455. * Creates a torus knot mesh
  28456. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  28457. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  28458. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  28459. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  28460. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28461. * * 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
  28462. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28463. * @param name defines the name of the mesh
  28464. * @param options defines the options used to create the mesh
  28465. * @param scene defines the hosting scene
  28466. * @returns the torus knot mesh
  28467. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  28468. */
  28469. static CreateTorusKnot(name: string, options: {
  28470. radius?: number;
  28471. tube?: number;
  28472. radialSegments?: number;
  28473. tubularSegments?: number;
  28474. p?: number;
  28475. q?: number;
  28476. updatable?: boolean;
  28477. sideOrientation?: number;
  28478. frontUVs?: Vector4;
  28479. backUVs?: Vector4;
  28480. }, scene: any): Mesh;
  28481. /**
  28482. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  28483. * * 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
  28484. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  28485. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  28486. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  28487. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  28488. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  28489. * * 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
  28490. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  28491. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28492. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  28493. * @param name defines the name of the new line system
  28494. * @param options defines the options used to create the line system
  28495. * @param scene defines the hosting scene
  28496. * @returns a new line system mesh
  28497. */
  28498. static CreateLineSystem(name: string, options: {
  28499. lines: Vector3[][];
  28500. updatable?: boolean;
  28501. instance?: Nullable<LinesMesh>;
  28502. colors?: Nullable<Color4[][]>;
  28503. useVertexAlpha?: boolean;
  28504. }, scene: Nullable<Scene>): LinesMesh;
  28505. /**
  28506. * Creates a line mesh
  28507. * 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
  28508. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  28509. * * The parameter `points` is an array successive Vector3
  28510. * * 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
  28511. * * The optional parameter `colors` is an array of successive Color4, one per line point
  28512. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  28513. * * When updating an instance, remember that only point positions can change, not the number of points
  28514. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28515. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  28516. * @param name defines the name of the new line system
  28517. * @param options defines the options used to create the line system
  28518. * @param scene defines the hosting scene
  28519. * @returns a new line mesh
  28520. */
  28521. static CreateLines(name: string, options: {
  28522. points: Vector3[];
  28523. updatable?: boolean;
  28524. instance?: Nullable<LinesMesh>;
  28525. colors?: Color4[];
  28526. useVertexAlpha?: boolean;
  28527. }, scene?: Nullable<Scene>): LinesMesh;
  28528. /**
  28529. * Creates a dashed line mesh
  28530. * * 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
  28531. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  28532. * * The parameter `points` is an array successive Vector3
  28533. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  28534. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  28535. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  28536. * * 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
  28537. * * When updating an instance, remember that only point positions can change, not the number of points
  28538. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28539. * @param name defines the name of the mesh
  28540. * @param options defines the options used to create the mesh
  28541. * @param scene defines the hosting scene
  28542. * @returns the dashed line mesh
  28543. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  28544. */
  28545. static CreateDashedLines(name: string, options: {
  28546. points: Vector3[];
  28547. dashSize?: number;
  28548. gapSize?: number;
  28549. dashNb?: number;
  28550. updatable?: boolean;
  28551. instance?: LinesMesh;
  28552. }, scene?: Nullable<Scene>): LinesMesh;
  28553. /**
  28554. * 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.
  28555. * * 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.
  28556. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  28557. * * 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.
  28558. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  28559. * * 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
  28560. * * 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
  28561. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  28562. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28563. * * 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
  28564. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  28565. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28566. * @param name defines the name of the mesh
  28567. * @param options defines the options used to create the mesh
  28568. * @param scene defines the hosting scene
  28569. * @returns the extruded shape mesh
  28570. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28571. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28572. */
  28573. static ExtrudeShape(name: string, options: {
  28574. shape: Vector3[];
  28575. path: Vector3[];
  28576. scale?: number;
  28577. rotation?: number;
  28578. cap?: number;
  28579. updatable?: boolean;
  28580. sideOrientation?: number;
  28581. frontUVs?: Vector4;
  28582. backUVs?: Vector4;
  28583. instance?: Mesh;
  28584. invertUV?: boolean;
  28585. }, scene?: Nullable<Scene>): Mesh;
  28586. /**
  28587. * Creates an custom extruded shape mesh.
  28588. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  28589. * * 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.
  28590. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  28591. * * 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
  28592. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  28593. * * 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
  28594. * * It must returns a float value that will be the scale value applied to the shape on each path point
  28595. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  28596. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  28597. * * 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
  28598. * * 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
  28599. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  28600. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28601. * * 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
  28602. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  28603. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28604. * @param name defines the name of the mesh
  28605. * @param options defines the options used to create the mesh
  28606. * @param scene defines the hosting scene
  28607. * @returns the custom extruded shape mesh
  28608. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  28609. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28610. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28611. */
  28612. static ExtrudeShapeCustom(name: string, options: {
  28613. shape: Vector3[];
  28614. path: Vector3[];
  28615. scaleFunction?: any;
  28616. rotationFunction?: any;
  28617. ribbonCloseArray?: boolean;
  28618. ribbonClosePath?: boolean;
  28619. cap?: number;
  28620. updatable?: boolean;
  28621. sideOrientation?: number;
  28622. frontUVs?: Vector4;
  28623. backUVs?: Vector4;
  28624. instance?: Mesh;
  28625. invertUV?: boolean;
  28626. }, scene: Scene): Mesh;
  28627. /**
  28628. * Creates lathe mesh.
  28629. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  28630. * * 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
  28631. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  28632. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  28633. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  28634. * * 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
  28635. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  28636. * * 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
  28637. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28638. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  28639. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  28640. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28641. * @param name defines the name of the mesh
  28642. * @param options defines the options used to create the mesh
  28643. * @param scene defines the hosting scene
  28644. * @returns the lathe mesh
  28645. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  28646. */
  28647. static CreateLathe(name: string, options: {
  28648. shape: Vector3[];
  28649. radius?: number;
  28650. tessellation?: number;
  28651. clip?: number;
  28652. arc?: number;
  28653. closed?: boolean;
  28654. updatable?: boolean;
  28655. sideOrientation?: number;
  28656. frontUVs?: Vector4;
  28657. backUVs?: Vector4;
  28658. cap?: number;
  28659. invertUV?: boolean;
  28660. }, scene: Scene): Mesh;
  28661. /**
  28662. * Creates a plane mesh
  28663. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  28664. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  28665. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  28666. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28667. * * 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
  28668. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28669. * @param name defines the name of the mesh
  28670. * @param options defines the options used to create the mesh
  28671. * @param scene defines the hosting scene
  28672. * @returns the plane mesh
  28673. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  28674. */
  28675. static CreatePlane(name: string, options: {
  28676. size?: number;
  28677. width?: number;
  28678. height?: number;
  28679. sideOrientation?: number;
  28680. frontUVs?: Vector4;
  28681. backUVs?: Vector4;
  28682. updatable?: boolean;
  28683. sourcePlane?: Plane;
  28684. }, scene: Scene): Mesh;
  28685. /**
  28686. * Creates a ground mesh
  28687. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  28688. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  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 ground mesh
  28694. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  28695. */
  28696. static CreateGround(name: string, options: {
  28697. width?: number;
  28698. height?: number;
  28699. subdivisions?: number;
  28700. subdivisionsX?: number;
  28701. subdivisionsY?: number;
  28702. updatable?: boolean;
  28703. }, scene: any): Mesh;
  28704. /**
  28705. * Creates a tiled ground mesh
  28706. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  28707. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  28708. * * 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
  28709. * * 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
  28710. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28711. * @param name defines the name of the mesh
  28712. * @param options defines the options used to create the mesh
  28713. * @param scene defines the hosting scene
  28714. * @returns the tiled ground mesh
  28715. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  28716. */
  28717. static CreateTiledGround(name: string, options: {
  28718. xmin: number;
  28719. zmin: number;
  28720. xmax: number;
  28721. zmax: number;
  28722. subdivisions?: {
  28723. w: number;
  28724. h: number;
  28725. };
  28726. precision?: {
  28727. w: number;
  28728. h: number;
  28729. };
  28730. updatable?: boolean;
  28731. }, scene: Scene): Mesh;
  28732. /**
  28733. * Creates a ground mesh from a height map
  28734. * * The parameter `url` sets the URL of the height map image resource.
  28735. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  28736. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  28737. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  28738. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  28739. * * 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.
  28740. * * 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).
  28741. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  28742. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28743. * @param name defines the name of the mesh
  28744. * @param url defines the url to the height map
  28745. * @param options defines the options used to create the mesh
  28746. * @param scene defines the hosting scene
  28747. * @returns the ground mesh
  28748. * @see https://doc.babylonjs.com/babylon101/height_map
  28749. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  28750. */
  28751. static CreateGroundFromHeightMap(name: string, url: string, options: {
  28752. width?: number;
  28753. height?: number;
  28754. subdivisions?: number;
  28755. minHeight?: number;
  28756. maxHeight?: number;
  28757. colorFilter?: Color3;
  28758. alphaFilter?: number;
  28759. updatable?: boolean;
  28760. onReady?: (mesh: GroundMesh) => void;
  28761. }, scene: Scene): GroundMesh;
  28762. /**
  28763. * Creates a polygon mesh
  28764. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  28765. * * 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
  28766. * * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28767. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28768. * * 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)
  28769. * * Remember you can only change the shape positions, not their number when updating a polygon
  28770. * @param name defines the name of the mesh
  28771. * @param options defines the options used to create the mesh
  28772. * @param scene defines the hosting scene
  28773. * @returns the polygon mesh
  28774. */
  28775. static CreatePolygon(name: string, options: {
  28776. shape: Vector3[];
  28777. holes?: Vector3[][];
  28778. depth?: number;
  28779. faceUV?: Vector4[];
  28780. faceColors?: Color4[];
  28781. updatable?: boolean;
  28782. sideOrientation?: number;
  28783. frontUVs?: Vector4;
  28784. backUVs?: Vector4;
  28785. }, scene: Scene): Mesh;
  28786. /**
  28787. * Creates an extruded polygon mesh, with depth in the Y direction.
  28788. * * 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)
  28789. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  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 polygon mesh
  28794. */
  28795. static ExtrudePolygon(name: string, options: {
  28796. shape: Vector3[];
  28797. holes?: Vector3[][];
  28798. depth?: number;
  28799. faceUV?: Vector4[];
  28800. faceColors?: Color4[];
  28801. updatable?: boolean;
  28802. sideOrientation?: number;
  28803. frontUVs?: Vector4;
  28804. backUVs?: Vector4;
  28805. }, scene: Scene): Mesh;
  28806. /**
  28807. * Creates a tube mesh.
  28808. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  28809. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  28810. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  28811. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  28812. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  28813. * * 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)
  28814. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  28815. * * 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
  28816. * * 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
  28817. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28818. * * 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
  28819. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  28820. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28821. * @param name defines the name of the mesh
  28822. * @param options defines the options used to create the mesh
  28823. * @param scene defines the hosting scene
  28824. * @returns the tube mesh
  28825. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28826. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  28827. */
  28828. static CreateTube(name: string, options: {
  28829. path: Vector3[];
  28830. radius?: number;
  28831. tessellation?: number;
  28832. radiusFunction?: {
  28833. (i: number, distance: number): number;
  28834. };
  28835. cap?: number;
  28836. arc?: number;
  28837. updatable?: boolean;
  28838. sideOrientation?: number;
  28839. frontUVs?: Vector4;
  28840. backUVs?: Vector4;
  28841. instance?: Mesh;
  28842. invertUV?: boolean;
  28843. }, scene: Scene): Mesh;
  28844. /**
  28845. * Creates a polyhedron mesh
  28846. * * 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
  28847. * * The parameter `size` (positive float, default 1) sets the polygon size
  28848. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  28849. * * 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`
  28850. * * 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
  28851. * * 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)`)
  28852. * * 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
  28853. * * 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
  28854. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28855. * * 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
  28856. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28857. * @param name defines the name of the mesh
  28858. * @param options defines the options used to create the mesh
  28859. * @param scene defines the hosting scene
  28860. * @returns the polyhedron mesh
  28861. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  28862. */
  28863. static CreatePolyhedron(name: string, options: {
  28864. type?: number;
  28865. size?: number;
  28866. sizeX?: number;
  28867. sizeY?: number;
  28868. sizeZ?: number;
  28869. custom?: any;
  28870. faceUV?: Vector4[];
  28871. faceColors?: Color4[];
  28872. flat?: boolean;
  28873. updatable?: boolean;
  28874. sideOrientation?: number;
  28875. frontUVs?: Vector4;
  28876. backUVs?: Vector4;
  28877. }, scene: Scene): Mesh;
  28878. /**
  28879. * Creates a decal mesh.
  28880. * 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
  28881. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  28882. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  28883. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  28884. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  28885. * @param name defines the name of the mesh
  28886. * @param sourceMesh defines the mesh where the decal must be applied
  28887. * @param options defines the options used to create the mesh
  28888. * @param scene defines the hosting scene
  28889. * @returns the decal mesh
  28890. * @see https://doc.babylonjs.com/how_to/decals
  28891. */
  28892. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  28893. position?: Vector3;
  28894. normal?: Vector3;
  28895. size?: Vector3;
  28896. angle?: number;
  28897. }): Mesh;
  28898. private static _ExtrudeShapeGeneric;
  28899. }
  28900. }
  28901. declare module BABYLON {
  28902. /**
  28903. * Class used to represent a specific level of detail of a mesh
  28904. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  28905. */
  28906. class MeshLODLevel {
  28907. /** Defines the distance where this level should star being displayed */
  28908. distance: number;
  28909. /** Defines the mesh to use to render this level */
  28910. mesh: Nullable<Mesh>;
  28911. /**
  28912. * Creates a new LOD level
  28913. * @param distance defines the distance where this level should star being displayed
  28914. * @param mesh defines the mesh to use to render this level
  28915. */
  28916. constructor(
  28917. /** Defines the distance where this level should star being displayed */
  28918. distance: number,
  28919. /** Defines the mesh to use to render this level */
  28920. mesh: Nullable<Mesh>);
  28921. }
  28922. }
  28923. declare module BABYLON {
  28924. /**
  28925. * A simplifier interface for future simplification implementations
  28926. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28927. */
  28928. interface ISimplifier {
  28929. /**
  28930. * Simplification of a given mesh according to the given settings.
  28931. * Since this requires computation, it is assumed that the function runs async.
  28932. * @param settings The settings of the simplification, including quality and distance
  28933. * @param successCallback A callback that will be called after the mesh was simplified.
  28934. * @param errorCallback in case of an error, this callback will be called. optional.
  28935. */
  28936. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  28937. }
  28938. /**
  28939. * Expected simplification settings.
  28940. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  28941. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28942. */
  28943. interface ISimplificationSettings {
  28944. /**
  28945. * Gets or sets the expected quality
  28946. */
  28947. quality: number;
  28948. /**
  28949. * Gets or sets the distance when this optimized version should be used
  28950. */
  28951. distance: number;
  28952. /**
  28953. * Gets an already optimized mesh
  28954. */
  28955. optimizeMesh?: boolean;
  28956. }
  28957. /**
  28958. * Class used to specify simplification options
  28959. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28960. */
  28961. class SimplificationSettings implements ISimplificationSettings {
  28962. /** expected quality */
  28963. quality: number;
  28964. /** distance when this optimized version should be used */
  28965. distance: number;
  28966. /** already optimized mesh */
  28967. optimizeMesh?: boolean | undefined;
  28968. /**
  28969. * Creates a SimplificationSettings
  28970. * @param quality expected quality
  28971. * @param distance distance when this optimized version should be used
  28972. * @param optimizeMesh already optimized mesh
  28973. */
  28974. constructor(
  28975. /** expected quality */
  28976. quality: number,
  28977. /** distance when this optimized version should be used */
  28978. distance: number,
  28979. /** already optimized mesh */
  28980. optimizeMesh?: boolean | undefined);
  28981. }
  28982. /**
  28983. * Interface used to define a simplification task
  28984. */
  28985. interface ISimplificationTask {
  28986. /**
  28987. * Array of settings
  28988. */
  28989. settings: Array<ISimplificationSettings>;
  28990. /**
  28991. * Simplification type
  28992. */
  28993. simplificationType: SimplificationType;
  28994. /**
  28995. * Mesh to simplify
  28996. */
  28997. mesh: Mesh;
  28998. /**
  28999. * Callback called on success
  29000. */
  29001. successCallback?: () => void;
  29002. /**
  29003. * Defines if parallel processing can be used
  29004. */
  29005. parallelProcessing: boolean;
  29006. }
  29007. /**
  29008. * Queue used to order the simplification tasks
  29009. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  29010. */
  29011. class SimplificationQueue {
  29012. private _simplificationArray;
  29013. /**
  29014. * Gets a boolean indicating that the process is still running
  29015. */
  29016. running: boolean;
  29017. /**
  29018. * Creates a new queue
  29019. */
  29020. constructor();
  29021. /**
  29022. * Adds a new simplification task
  29023. * @param task defines a task to add
  29024. */
  29025. addTask(task: ISimplificationTask): void;
  29026. /**
  29027. * Execute next task
  29028. */
  29029. executeNext(): void;
  29030. /**
  29031. * Execute a simplification task
  29032. * @param task defines the task to run
  29033. */
  29034. runSimplification(task: ISimplificationTask): void;
  29035. private getSimplifier;
  29036. }
  29037. /**
  29038. * The implemented types of simplification
  29039. * At the moment only Quadratic Error Decimation is implemented
  29040. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  29041. */
  29042. enum SimplificationType {
  29043. /** Quadratic error decimation */
  29044. QUADRATIC = 0
  29045. }
  29046. }
  29047. declare module BABYLON {
  29048. interface Scene {
  29049. /** @hidden (Backing field) */
  29050. _simplificationQueue: SimplificationQueue;
  29051. /**
  29052. * Gets or sets the simplification queue attached to the scene
  29053. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  29054. */
  29055. simplificationQueue: SimplificationQueue;
  29056. }
  29057. interface Mesh {
  29058. /**
  29059. * Simplify the mesh according to the given array of settings.
  29060. * Function will return immediately and will simplify async
  29061. * @param settings a collection of simplification settings
  29062. * @param parallelProcessing should all levels calculate parallel or one after the other
  29063. * @param simplificationType the type of simplification to run
  29064. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  29065. * @returns the current mesh
  29066. */
  29067. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  29068. }
  29069. /**
  29070. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  29071. * created in a scene
  29072. */
  29073. class SimplicationQueueSceneComponent implements ISceneComponent {
  29074. /**
  29075. * The component name helpfull to identify the component in the list of scene components.
  29076. */
  29077. readonly name: string;
  29078. /**
  29079. * The scene the component belongs to.
  29080. */
  29081. scene: Scene;
  29082. /**
  29083. * Creates a new instance of the component for the given scene
  29084. * @param scene Defines the scene to register the component in
  29085. */
  29086. constructor(scene: Scene);
  29087. /**
  29088. * Registers the component in a given scene
  29089. */
  29090. register(): void;
  29091. /**
  29092. * Rebuilds the elements related to this component in case of
  29093. * context lost for instance.
  29094. */
  29095. rebuild(): void;
  29096. /**
  29097. * Disposes the component and the associated ressources
  29098. */
  29099. dispose(): void;
  29100. private _beforeCameraUpdate;
  29101. }
  29102. }
  29103. declare module BABYLON {
  29104. /**
  29105. * Polygon
  29106. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  29107. */
  29108. class Polygon {
  29109. /**
  29110. * Creates a rectangle
  29111. * @param xmin bottom X coord
  29112. * @param ymin bottom Y coord
  29113. * @param xmax top X coord
  29114. * @param ymax top Y coord
  29115. * @returns points that make the resulting rectation
  29116. */
  29117. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  29118. /**
  29119. * Creates a circle
  29120. * @param radius radius of circle
  29121. * @param cx scale in x
  29122. * @param cy scale in y
  29123. * @param numberOfSides number of sides that make up the circle
  29124. * @returns points that make the resulting circle
  29125. */
  29126. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  29127. /**
  29128. * Creates a polygon from input string
  29129. * @param input Input polygon data
  29130. * @returns the parsed points
  29131. */
  29132. static Parse(input: string): Vector2[];
  29133. /**
  29134. * Starts building a polygon from x and y coordinates
  29135. * @param x x coordinate
  29136. * @param y y coordinate
  29137. * @returns the started path2
  29138. */
  29139. static StartingAt(x: number, y: number): Path2;
  29140. }
  29141. /**
  29142. * Builds a polygon
  29143. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  29144. */
  29145. class PolygonMeshBuilder {
  29146. private _points;
  29147. private _outlinepoints;
  29148. private _holes;
  29149. private _name;
  29150. private _scene;
  29151. private _epoints;
  29152. private _eholes;
  29153. private _addToepoint;
  29154. /**
  29155. * Creates a PolygonMeshBuilder
  29156. * @param name name of the builder
  29157. * @param contours Path of the polygon
  29158. * @param scene scene to add to
  29159. */
  29160. constructor(name: string, contours: Path2 | Vector2[] | any, scene: Scene);
  29161. /**
  29162. * Adds a whole within the polygon
  29163. * @param hole Array of points defining the hole
  29164. * @returns this
  29165. */
  29166. addHole(hole: Vector2[]): PolygonMeshBuilder;
  29167. /**
  29168. * Creates the polygon
  29169. * @param updatable If the mesh should be updatable
  29170. * @param depth The depth of the mesh created
  29171. * @returns the created mesh
  29172. */
  29173. build(updatable?: boolean, depth?: number): Mesh;
  29174. /**
  29175. * Adds a side to the polygon
  29176. * @param positions points that make the polygon
  29177. * @param normals normals of the polygon
  29178. * @param uvs uvs of the polygon
  29179. * @param indices indices of the polygon
  29180. * @param bounds bounds of the polygon
  29181. * @param points points of the polygon
  29182. * @param depth depth of the polygon
  29183. * @param flip flip of the polygon
  29184. */
  29185. private addSide;
  29186. }
  29187. }
  29188. declare module BABYLON {
  29189. /**
  29190. * Base class for submeshes
  29191. */
  29192. class BaseSubMesh {
  29193. /** @hidden */
  29194. _materialDefines: Nullable<MaterialDefines>;
  29195. /** @hidden */
  29196. _materialEffect: Nullable<Effect>;
  29197. /**
  29198. * Gets associated effect
  29199. */
  29200. readonly effect: Nullable<Effect>;
  29201. /**
  29202. * Sets associated effect (effect used to render this submesh)
  29203. * @param effect defines the effect to associate with
  29204. * @param defines defines the set of defines used to compile this effect
  29205. */
  29206. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  29207. }
  29208. /**
  29209. * Defines a subdivision inside a mesh
  29210. */
  29211. class SubMesh extends BaseSubMesh implements ICullable {
  29212. /** the material index to use */
  29213. materialIndex: number;
  29214. /** vertex index start */
  29215. verticesStart: number;
  29216. /** vertices count */
  29217. verticesCount: number;
  29218. /** index start */
  29219. indexStart: number;
  29220. /** indices count */
  29221. indexCount: number;
  29222. /** @hidden */
  29223. _linesIndexCount: number;
  29224. private _mesh;
  29225. private _renderingMesh;
  29226. private _boundingInfo;
  29227. private _linesIndexBuffer;
  29228. /** @hidden */
  29229. _lastColliderWorldVertices: Nullable<Vector3[]>;
  29230. /** @hidden */
  29231. _trianglePlanes: Plane[];
  29232. /** @hidden */
  29233. _lastColliderTransformMatrix: Matrix;
  29234. /** @hidden */
  29235. _renderId: number;
  29236. /** @hidden */
  29237. _alphaIndex: number;
  29238. /** @hidden */
  29239. _distanceToCamera: number;
  29240. /** @hidden */
  29241. _id: number;
  29242. private _currentMaterial;
  29243. /**
  29244. * Add a new submesh to a mesh
  29245. * @param materialIndex defines the material index to use
  29246. * @param verticesStart defines vertex index start
  29247. * @param verticesCount defines vertices count
  29248. * @param indexStart defines index start
  29249. * @param indexCount defines indices count
  29250. * @param mesh defines the parent mesh
  29251. * @param renderingMesh defines an optional rendering mesh
  29252. * @param createBoundingBox defines if bounding box should be created for this submesh
  29253. * @returns the new submesh
  29254. */
  29255. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  29256. /**
  29257. * Creates a new submesh
  29258. * @param materialIndex defines the material index to use
  29259. * @param verticesStart defines vertex index start
  29260. * @param verticesCount defines vertices count
  29261. * @param indexStart defines index start
  29262. * @param indexCount defines indices count
  29263. * @param mesh defines the parent mesh
  29264. * @param renderingMesh defines an optional rendering mesh
  29265. * @param createBoundingBox defines if bounding box should be created for this submesh
  29266. */
  29267. constructor(
  29268. /** the material index to use */
  29269. materialIndex: number,
  29270. /** vertex index start */
  29271. verticesStart: number,
  29272. /** vertices count */
  29273. verticesCount: number,
  29274. /** index start */
  29275. indexStart: number,
  29276. /** indices count */
  29277. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  29278. /**
  29279. * Returns true if this submesh covers the entire parent mesh
  29280. * @ignorenaming
  29281. */
  29282. readonly IsGlobal: boolean;
  29283. /**
  29284. * Returns the submesh BoudingInfo object
  29285. * @returns current bounding info (or mesh's one if the submesh is global)
  29286. */
  29287. getBoundingInfo(): BoundingInfo;
  29288. /**
  29289. * Sets the submesh BoundingInfo
  29290. * @param boundingInfo defines the new bounding info to use
  29291. * @returns the SubMesh
  29292. */
  29293. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  29294. /**
  29295. * Returns the mesh of the current submesh
  29296. * @return the parent mesh
  29297. */
  29298. getMesh(): AbstractMesh;
  29299. /**
  29300. * Returns the rendering mesh of the submesh
  29301. * @returns the rendering mesh (could be different from parent mesh)
  29302. */
  29303. getRenderingMesh(): Mesh;
  29304. /**
  29305. * Returns the submesh material
  29306. * @returns null or the current material
  29307. */
  29308. getMaterial(): Nullable<Material>;
  29309. /**
  29310. * Sets a new updated BoundingInfo object to the submesh
  29311. * @returns the SubMesh
  29312. */
  29313. refreshBoundingInfo(): SubMesh;
  29314. /** @hidden */
  29315. _checkCollision(collider: Collider): boolean;
  29316. /**
  29317. * Updates the submesh BoundingInfo
  29318. * @param world defines the world matrix to use to update the bounding info
  29319. * @returns the submesh
  29320. */
  29321. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  29322. /**
  29323. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  29324. * @param frustumPlanes defines the frustum planes
  29325. * @returns true if the submesh is intersecting with the frustum
  29326. */
  29327. isInFrustum(frustumPlanes: Plane[]): boolean;
  29328. /**
  29329. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  29330. * @param frustumPlanes defines the frustum planes
  29331. * @returns true if the submesh is inside the frustum
  29332. */
  29333. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  29334. /**
  29335. * Renders the submesh
  29336. * @param enableAlphaMode defines if alpha needs to be used
  29337. * @returns the submesh
  29338. */
  29339. render(enableAlphaMode: boolean): SubMesh;
  29340. /**
  29341. * @hidden
  29342. */
  29343. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  29344. /**
  29345. * Checks if the submesh intersects with a ray
  29346. * @param ray defines the ray to test
  29347. * @returns true is the passed ray intersects the submesh bounding box
  29348. */
  29349. canIntersects(ray: Ray): boolean;
  29350. /**
  29351. * Intersects current submesh with a ray
  29352. * @param ray defines the ray to test
  29353. * @param positions defines mesh's positions array
  29354. * @param indices defines mesh's indices array
  29355. * @param fastCheck defines if only bounding info should be used
  29356. * @returns intersection info or null if no intersection
  29357. */
  29358. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  29359. /** @hidden */
  29360. private _intersectLines;
  29361. /** @hidden */
  29362. private _intersectTriangles;
  29363. /** @hidden */
  29364. _rebuild(): void;
  29365. /**
  29366. * Creates a new submesh from the passed mesh
  29367. * @param newMesh defines the new hosting mesh
  29368. * @param newRenderingMesh defines an optional rendering mesh
  29369. * @returns the new submesh
  29370. */
  29371. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  29372. /**
  29373. * Release associated resources
  29374. */
  29375. dispose(): void;
  29376. /**
  29377. * Creates a new submesh from indices data
  29378. * @param materialIndex the index of the main mesh material
  29379. * @param startIndex the index where to start the copy in the mesh indices array
  29380. * @param indexCount the number of indices to copy then from the startIndex
  29381. * @param mesh the main mesh to create the submesh from
  29382. * @param renderingMesh the optional rendering mesh
  29383. * @returns a new submesh
  29384. */
  29385. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  29386. }
  29387. }
  29388. declare module BABYLON {
  29389. /**
  29390. * 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.
  29391. * @see https://doc.babylonjs.com/how_to/transformnode
  29392. */
  29393. class TransformNode extends Node {
  29394. /**
  29395. * Object will not rotate to face the camera
  29396. */
  29397. static BILLBOARDMODE_NONE: number;
  29398. /**
  29399. * Object will rotate to face the camera but only on the x axis
  29400. */
  29401. static BILLBOARDMODE_X: number;
  29402. /**
  29403. * Object will rotate to face the camera but only on the y axis
  29404. */
  29405. static BILLBOARDMODE_Y: number;
  29406. /**
  29407. * Object will rotate to face the camera but only on the z axis
  29408. */
  29409. static BILLBOARDMODE_Z: number;
  29410. /**
  29411. * Object will rotate to face the camera
  29412. */
  29413. static BILLBOARDMODE_ALL: number;
  29414. private _forward;
  29415. private _forwardInverted;
  29416. private _up;
  29417. private _right;
  29418. private _rightInverted;
  29419. private _position;
  29420. private _rotation;
  29421. private _rotationQuaternion;
  29422. protected _scaling: Vector3;
  29423. protected _isDirty: boolean;
  29424. private _transformToBoneReferal;
  29425. /**
  29426. * Set the billboard mode. Default is 0.
  29427. *
  29428. * | Value | Type | Description |
  29429. * | --- | --- | --- |
  29430. * | 0 | BILLBOARDMODE_NONE | |
  29431. * | 1 | BILLBOARDMODE_X | |
  29432. * | 2 | BILLBOARDMODE_Y | |
  29433. * | 4 | BILLBOARDMODE_Z | |
  29434. * | 7 | BILLBOARDMODE_ALL | |
  29435. *
  29436. */
  29437. billboardMode: number;
  29438. /**
  29439. * 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
  29440. */
  29441. scalingDeterminant: number;
  29442. /**
  29443. * Sets the distance of the object to max, often used by skybox
  29444. */
  29445. infiniteDistance: boolean;
  29446. /**
  29447. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  29448. * By default the system will update normals to compensate
  29449. */
  29450. ignoreNonUniformScaling: boolean;
  29451. /** @hidden */
  29452. _poseMatrix: Matrix;
  29453. /** @hidden */
  29454. _localMatrix: Matrix;
  29455. private _absolutePosition;
  29456. private _pivotMatrix;
  29457. private _pivotMatrixInverse;
  29458. protected _postMultiplyPivotMatrix: boolean;
  29459. protected _isWorldMatrixFrozen: boolean;
  29460. /** @hidden */
  29461. _indexInSceneTransformNodesArray: number;
  29462. /**
  29463. * An event triggered after the world matrix is updated
  29464. */
  29465. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  29466. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  29467. /**
  29468. * Gets a string identifying the name of the class
  29469. * @returns "TransformNode" string
  29470. */
  29471. getClassName(): string;
  29472. /**
  29473. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  29474. */
  29475. position: Vector3;
  29476. /**
  29477. * 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)).
  29478. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  29479. */
  29480. rotation: Vector3;
  29481. /**
  29482. * 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)).
  29483. */
  29484. scaling: Vector3;
  29485. /**
  29486. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (null by default).
  29487. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  29488. */
  29489. rotationQuaternion: Nullable<Quaternion>;
  29490. /**
  29491. * The forward direction of that transform in world space.
  29492. */
  29493. readonly forward: Vector3;
  29494. /**
  29495. * The up direction of that transform in world space.
  29496. */
  29497. readonly up: Vector3;
  29498. /**
  29499. * The right direction of that transform in world space.
  29500. */
  29501. readonly right: Vector3;
  29502. /**
  29503. * Copies the parameter passed Matrix into the mesh Pose matrix.
  29504. * @param matrix the matrix to copy the pose from
  29505. * @returns this TransformNode.
  29506. */
  29507. updatePoseMatrix(matrix: Matrix): TransformNode;
  29508. /**
  29509. * Returns the mesh Pose matrix.
  29510. * @returns the pose matrix
  29511. */
  29512. getPoseMatrix(): Matrix;
  29513. /** @hidden */
  29514. _isSynchronized(): boolean;
  29515. /** @hidden */
  29516. _initCache(): void;
  29517. /**
  29518. * Flag the transform node as dirty (Forcing it to update everything)
  29519. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  29520. * @returns this transform node
  29521. */
  29522. markAsDirty(property: string): TransformNode;
  29523. /**
  29524. * Returns the current mesh absolute position.
  29525. * Returns a Vector3.
  29526. */
  29527. readonly absolutePosition: Vector3;
  29528. /**
  29529. * Sets a new matrix to apply before all other transformation
  29530. * @param matrix defines the transform matrix
  29531. * @returns the current TransformNode
  29532. */
  29533. setPreTransformMatrix(matrix: Matrix): TransformNode;
  29534. /**
  29535. * Sets a new pivot matrix to the current node
  29536. * @param matrix defines the new pivot matrix to use
  29537. * @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
  29538. * @returns the current TransformNode
  29539. */
  29540. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  29541. /**
  29542. * Returns the mesh pivot matrix.
  29543. * Default : Identity.
  29544. * @returns the matrix
  29545. */
  29546. getPivotMatrix(): Matrix;
  29547. /**
  29548. * Prevents the World matrix to be computed any longer.
  29549. * @returns the TransformNode.
  29550. */
  29551. freezeWorldMatrix(): TransformNode;
  29552. /**
  29553. * Allows back the World matrix computation.
  29554. * @returns the TransformNode.
  29555. */
  29556. unfreezeWorldMatrix(): this;
  29557. /**
  29558. * True if the World matrix has been frozen.
  29559. */
  29560. readonly isWorldMatrixFrozen: boolean;
  29561. /**
  29562. * Retuns the mesh absolute position in the World.
  29563. * @returns a Vector3.
  29564. */
  29565. getAbsolutePosition(): Vector3;
  29566. /**
  29567. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  29568. * @param absolutePosition the absolute position to set
  29569. * @returns the TransformNode.
  29570. */
  29571. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  29572. /**
  29573. * Sets the mesh position in its local space.
  29574. * @param vector3 the position to set in localspace
  29575. * @returns the TransformNode.
  29576. */
  29577. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  29578. /**
  29579. * Returns the mesh position in the local space from the current World matrix values.
  29580. * @returns a new Vector3.
  29581. */
  29582. getPositionExpressedInLocalSpace(): Vector3;
  29583. /**
  29584. * Translates the mesh along the passed Vector3 in its local space.
  29585. * @param vector3 the distance to translate in localspace
  29586. * @returns the TransformNode.
  29587. */
  29588. locallyTranslate(vector3: Vector3): TransformNode;
  29589. private static _lookAtVectorCache;
  29590. /**
  29591. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  29592. * @param targetPoint the position (must be in same space as current mesh) to look at
  29593. * @param yawCor optional yaw (y-axis) correction in radians
  29594. * @param pitchCor optional pitch (x-axis) correction in radians
  29595. * @param rollCor optional roll (z-axis) correction in radians
  29596. * @param space the choosen space of the target
  29597. * @returns the TransformNode.
  29598. */
  29599. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  29600. /**
  29601. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  29602. * This Vector3 is expressed in the World space.
  29603. * @param localAxis axis to rotate
  29604. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  29605. */
  29606. getDirection(localAxis: Vector3): Vector3;
  29607. /**
  29608. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  29609. * localAxis is expressed in the mesh local space.
  29610. * result is computed in the Wordl space from the mesh World matrix.
  29611. * @param localAxis axis to rotate
  29612. * @param result the resulting transformnode
  29613. * @returns this TransformNode.
  29614. */
  29615. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  29616. /**
  29617. * Sets this transform node rotation to the given local axis.
  29618. * @param localAxis the axis in local space
  29619. * @param yawCor optional yaw (y-axis) correction in radians
  29620. * @param pitchCor optional pitch (x-axis) correction in radians
  29621. * @param rollCor optional roll (z-axis) correction in radians
  29622. * @returns this TransformNode
  29623. */
  29624. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  29625. /**
  29626. * Sets a new pivot point to the current node
  29627. * @param point defines the new pivot point to use
  29628. * @param space defines if the point is in world or local space (local by default)
  29629. * @returns the current TransformNode
  29630. */
  29631. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  29632. /**
  29633. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  29634. * @returns the pivot point
  29635. */
  29636. getPivotPoint(): Vector3;
  29637. /**
  29638. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  29639. * @param result the vector3 to store the result
  29640. * @returns this TransformNode.
  29641. */
  29642. getPivotPointToRef(result: Vector3): TransformNode;
  29643. /**
  29644. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  29645. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  29646. */
  29647. getAbsolutePivotPoint(): Vector3;
  29648. /**
  29649. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  29650. * @param result vector3 to store the result
  29651. * @returns this TransformNode.
  29652. */
  29653. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  29654. /**
  29655. * Defines the passed node as the parent of the current node.
  29656. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  29657. * @param node the node ot set as the parent
  29658. * @returns this TransformNode.
  29659. */
  29660. setParent(node: Nullable<Node>): TransformNode;
  29661. private _nonUniformScaling;
  29662. /**
  29663. * True if the scaling property of this object is non uniform eg. (1,2,1)
  29664. */
  29665. readonly nonUniformScaling: boolean;
  29666. /** @hidden */
  29667. _updateNonUniformScalingState(value: boolean): boolean;
  29668. /**
  29669. * Attach the current TransformNode to another TransformNode associated with a bone
  29670. * @param bone Bone affecting the TransformNode
  29671. * @param affectedTransformNode TransformNode associated with the bone
  29672. * @returns this object
  29673. */
  29674. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  29675. /**
  29676. * Detach the transform node if its associated with a bone
  29677. * @returns this object
  29678. */
  29679. detachFromBone(): TransformNode;
  29680. private static _rotationAxisCache;
  29681. /**
  29682. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  29683. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  29684. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  29685. * The passed axis is also normalized.
  29686. * @param axis the axis to rotate around
  29687. * @param amount the amount to rotate in radians
  29688. * @param space Space to rotate in (Default: local)
  29689. * @returns the TransformNode.
  29690. */
  29691. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  29692. /**
  29693. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  29694. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  29695. * The passed axis is also normalized. .
  29696. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  29697. * @param point the point to rotate around
  29698. * @param axis the axis to rotate around
  29699. * @param amount the amount to rotate in radians
  29700. * @returns the TransformNode
  29701. */
  29702. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  29703. /**
  29704. * Translates the mesh along the axis vector for the passed distance in the given space.
  29705. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  29706. * @param axis the axis to translate in
  29707. * @param distance the distance to translate
  29708. * @param space Space to rotate in (Default: local)
  29709. * @returns the TransformNode.
  29710. */
  29711. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  29712. /**
  29713. * Adds a rotation step to the mesh current rotation.
  29714. * x, y, z are Euler angles expressed in radians.
  29715. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  29716. * This means this rotation is made in the mesh local space only.
  29717. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  29718. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  29719. * ```javascript
  29720. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  29721. * ```
  29722. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  29723. * 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.
  29724. * @param x Rotation to add
  29725. * @param y Rotation to add
  29726. * @param z Rotation to add
  29727. * @returns the TransformNode.
  29728. */
  29729. addRotation(x: number, y: number, z: number): TransformNode;
  29730. /**
  29731. * Computes the world matrix of the node
  29732. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29733. * @returns the world matrix
  29734. */
  29735. computeWorldMatrix(force?: boolean): Matrix;
  29736. protected _afterComputeWorldMatrix(): void;
  29737. /**
  29738. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  29739. * @param func callback function to add
  29740. *
  29741. * @returns the TransformNode.
  29742. */
  29743. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  29744. /**
  29745. * Removes a registered callback function.
  29746. * @param func callback function to remove
  29747. * @returns the TransformNode.
  29748. */
  29749. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  29750. /**
  29751. * Gets the position of the current mesh in camera space
  29752. * @param camera defines the camera to use
  29753. * @returns a position
  29754. */
  29755. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  29756. /**
  29757. * Returns the distance from the mesh to the active camera
  29758. * @param camera defines the camera to use
  29759. * @returns the distance
  29760. */
  29761. getDistanceToCamera(camera?: Nullable<Camera>): number;
  29762. /**
  29763. * Clone the current transform node
  29764. * @param name Name of the new clone
  29765. * @param newParent New parent for the clone
  29766. * @param doNotCloneChildren Do not clone children hierarchy
  29767. * @returns the new transform node
  29768. */
  29769. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  29770. /**
  29771. * Serializes the objects information.
  29772. * @param currentSerializationObject defines the object to serialize in
  29773. * @returns the serialized object
  29774. */
  29775. serialize(currentSerializationObject?: any): any;
  29776. /**
  29777. * Returns a new TransformNode object parsed from the source provided.
  29778. * @param parsedTransformNode is the source.
  29779. * @param scene the scne the object belongs to
  29780. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  29781. * @returns a new TransformNode object parsed from the source provided.
  29782. */
  29783. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  29784. /**
  29785. * Releases resources associated with this transform node.
  29786. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29787. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29788. */
  29789. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29790. }
  29791. }
  29792. declare module BABYLON {
  29793. /**
  29794. * Specialized buffer used to store vertex data
  29795. */
  29796. class VertexBuffer {
  29797. /** @hidden */
  29798. _buffer: Buffer;
  29799. private _kind;
  29800. private _size;
  29801. private _ownsBuffer;
  29802. private _instanced;
  29803. private _instanceDivisor;
  29804. /**
  29805. * The byte type.
  29806. */
  29807. static readonly BYTE: number;
  29808. /**
  29809. * The unsigned byte type.
  29810. */
  29811. static readonly UNSIGNED_BYTE: number;
  29812. /**
  29813. * The short type.
  29814. */
  29815. static readonly SHORT: number;
  29816. /**
  29817. * The unsigned short type.
  29818. */
  29819. static readonly UNSIGNED_SHORT: number;
  29820. /**
  29821. * The integer type.
  29822. */
  29823. static readonly INT: number;
  29824. /**
  29825. * The unsigned integer type.
  29826. */
  29827. static readonly UNSIGNED_INT: number;
  29828. /**
  29829. * The float type.
  29830. */
  29831. static readonly FLOAT: number;
  29832. /**
  29833. * Gets or sets the instance divisor when in instanced mode
  29834. */
  29835. instanceDivisor: number;
  29836. /**
  29837. * Gets the byte stride.
  29838. */
  29839. readonly byteStride: number;
  29840. /**
  29841. * Gets the byte offset.
  29842. */
  29843. readonly byteOffset: number;
  29844. /**
  29845. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  29846. */
  29847. readonly normalized: boolean;
  29848. /**
  29849. * Gets the data type of each component in the array.
  29850. */
  29851. readonly type: number;
  29852. /**
  29853. * Constructor
  29854. * @param engine the engine
  29855. * @param data the data to use for this vertex buffer
  29856. * @param kind the vertex buffer kind
  29857. * @param updatable whether the data is updatable
  29858. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  29859. * @param stride the stride (optional)
  29860. * @param instanced whether the buffer is instanced (optional)
  29861. * @param offset the offset of the data (optional)
  29862. * @param size the number of components (optional)
  29863. * @param type the type of the component (optional)
  29864. * @param normalized whether the data contains normalized data (optional)
  29865. * @param useBytes set to true if stride and offset are in bytes (optional)
  29866. */
  29867. 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);
  29868. /** @hidden */
  29869. _rebuild(): void;
  29870. /**
  29871. * Returns the kind of the VertexBuffer (string)
  29872. * @returns a string
  29873. */
  29874. getKind(): string;
  29875. /**
  29876. * Gets a boolean indicating if the VertexBuffer is updatable?
  29877. * @returns true if the buffer is updatable
  29878. */
  29879. isUpdatable(): boolean;
  29880. /**
  29881. * Gets current buffer's data
  29882. * @returns a DataArray or null
  29883. */
  29884. getData(): Nullable<DataArray>;
  29885. /**
  29886. * Gets underlying native buffer
  29887. * @returns underlying native buffer
  29888. */
  29889. getBuffer(): Nullable<WebGLBuffer>;
  29890. /**
  29891. * Gets the stride in float32 units (i.e. byte stride / 4).
  29892. * May not be an integer if the byte stride is not divisible by 4.
  29893. * DEPRECATED. Use byteStride instead.
  29894. * @returns the stride in float32 units
  29895. */
  29896. getStrideSize(): number;
  29897. /**
  29898. * Returns the offset as a multiple of the type byte length.
  29899. * DEPRECATED. Use byteOffset instead.
  29900. * @returns the offset in bytes
  29901. */
  29902. getOffset(): number;
  29903. /**
  29904. * Returns the number of components per vertex attribute (integer)
  29905. * @returns the size in float
  29906. */
  29907. getSize(): number;
  29908. /**
  29909. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  29910. * @returns true if this buffer is instanced
  29911. */
  29912. getIsInstanced(): boolean;
  29913. /**
  29914. * Returns the instancing divisor, zero for non-instanced (integer).
  29915. * @returns a number
  29916. */
  29917. getInstanceDivisor(): number;
  29918. /**
  29919. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  29920. * @param data defines the data to store
  29921. */
  29922. create(data?: DataArray): void;
  29923. /**
  29924. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  29925. * This function will create a new buffer if the current one is not updatable
  29926. * @param data defines the data to store
  29927. */
  29928. update(data: DataArray): void;
  29929. /**
  29930. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  29931. * Returns the directly updated WebGLBuffer.
  29932. * @param data the new data
  29933. * @param offset the new offset
  29934. * @param useBytes set to true if the offset is in bytes
  29935. */
  29936. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  29937. /**
  29938. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  29939. */
  29940. dispose(): void;
  29941. /**
  29942. * Enumerates each value of this vertex buffer as numbers.
  29943. * @param count the number of values to enumerate
  29944. * @param callback the callback function called for each value
  29945. */
  29946. forEach(count: number, callback: (value: number, index: number) => void): void;
  29947. /**
  29948. * Positions
  29949. */
  29950. static readonly PositionKind: string;
  29951. /**
  29952. * Normals
  29953. */
  29954. static readonly NormalKind: string;
  29955. /**
  29956. * Tangents
  29957. */
  29958. static readonly TangentKind: string;
  29959. /**
  29960. * Texture coordinates
  29961. */
  29962. static readonly UVKind: string;
  29963. /**
  29964. * Texture coordinates 2
  29965. */
  29966. static readonly UV2Kind: string;
  29967. /**
  29968. * Texture coordinates 3
  29969. */
  29970. static readonly UV3Kind: string;
  29971. /**
  29972. * Texture coordinates 4
  29973. */
  29974. static readonly UV4Kind: string;
  29975. /**
  29976. * Texture coordinates 5
  29977. */
  29978. static readonly UV5Kind: string;
  29979. /**
  29980. * Texture coordinates 6
  29981. */
  29982. static readonly UV6Kind: string;
  29983. /**
  29984. * Colors
  29985. */
  29986. static readonly ColorKind: string;
  29987. /**
  29988. * Matrix indices (for bones)
  29989. */
  29990. static readonly MatricesIndicesKind: string;
  29991. /**
  29992. * Matrix weights (for bones)
  29993. */
  29994. static readonly MatricesWeightsKind: string;
  29995. /**
  29996. * Additional matrix indices (for bones)
  29997. */
  29998. static readonly MatricesIndicesExtraKind: string;
  29999. /**
  30000. * Additional matrix weights (for bones)
  30001. */
  30002. static readonly MatricesWeightsExtraKind: string;
  30003. /**
  30004. * Deduces the stride given a kind.
  30005. * @param kind The kind string to deduce
  30006. * @returns The deduced stride
  30007. */
  30008. static DeduceStride(kind: string): number;
  30009. /**
  30010. * Gets the byte length of the given type.
  30011. * @param type the type
  30012. * @returns the number of bytes
  30013. */
  30014. static GetTypeByteLength(type: number): number;
  30015. /**
  30016. * Enumerates each value of the given parameters as numbers.
  30017. * @param data the data to enumerate
  30018. * @param byteOffset the byte offset of the data
  30019. * @param byteStride the byte stride of the data
  30020. * @param componentCount the number of components per element
  30021. * @param componentType the type of the component
  30022. * @param count the total number of components
  30023. * @param normalized whether the data is normalized
  30024. * @param callback the callback function called for each value
  30025. */
  30026. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  30027. private static _GetFloatValue;
  30028. }
  30029. }
  30030. declare module BABYLON {
  30031. /**
  30032. * Defines a target to use with MorphTargetManager
  30033. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  30034. */
  30035. class MorphTarget implements IAnimatable {
  30036. /** defines the name of the target */
  30037. name: string;
  30038. /**
  30039. * Gets or sets the list of animations
  30040. */
  30041. animations: Animation[];
  30042. private _scene;
  30043. private _positions;
  30044. private _normals;
  30045. private _tangents;
  30046. private _influence;
  30047. /**
  30048. * Observable raised when the influence changes
  30049. */
  30050. onInfluenceChanged: Observable<boolean>;
  30051. /** @hidden */
  30052. _onDataLayoutChanged: Observable<void>;
  30053. /**
  30054. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  30055. */
  30056. influence: number;
  30057. /**
  30058. * Gets or sets the id of the morph Target
  30059. */
  30060. id: string;
  30061. private _animationPropertiesOverride;
  30062. /**
  30063. * Gets or sets the animation properties override
  30064. */
  30065. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  30066. /**
  30067. * Creates a new MorphTarget
  30068. * @param name defines the name of the target
  30069. * @param influence defines the influence to use
  30070. */
  30071. constructor(
  30072. /** defines the name of the target */
  30073. name: string, influence?: number, scene?: Nullable<Scene>);
  30074. /**
  30075. * Gets a boolean defining if the target contains position data
  30076. */
  30077. readonly hasPositions: boolean;
  30078. /**
  30079. * Gets a boolean defining if the target contains normal data
  30080. */
  30081. readonly hasNormals: boolean;
  30082. /**
  30083. * Gets a boolean defining if the target contains tangent data
  30084. */
  30085. readonly hasTangents: boolean;
  30086. /**
  30087. * Affects position data to this target
  30088. * @param data defines the position data to use
  30089. */
  30090. setPositions(data: Nullable<FloatArray>): void;
  30091. /**
  30092. * Gets the position data stored in this target
  30093. * @returns a FloatArray containing the position data (or null if not present)
  30094. */
  30095. getPositions(): Nullable<FloatArray>;
  30096. /**
  30097. * Affects normal data to this target
  30098. * @param data defines the normal data to use
  30099. */
  30100. setNormals(data: Nullable<FloatArray>): void;
  30101. /**
  30102. * Gets the normal data stored in this target
  30103. * @returns a FloatArray containing the normal data (or null if not present)
  30104. */
  30105. getNormals(): Nullable<FloatArray>;
  30106. /**
  30107. * Affects tangent data to this target
  30108. * @param data defines the tangent data to use
  30109. */
  30110. setTangents(data: Nullable<FloatArray>): void;
  30111. /**
  30112. * Gets the tangent data stored in this target
  30113. * @returns a FloatArray containing the tangent data (or null if not present)
  30114. */
  30115. getTangents(): Nullable<FloatArray>;
  30116. /**
  30117. * Serializes the current target into a Serialization object
  30118. * @returns the serialized object
  30119. */
  30120. serialize(): any;
  30121. /**
  30122. * Returns the string "MorphTarget"
  30123. * @returns "MorphTarget"
  30124. */
  30125. getClassName(): string;
  30126. /**
  30127. * Creates a new target from serialized data
  30128. * @param serializationObject defines the serialized data to use
  30129. * @returns a new MorphTarget
  30130. */
  30131. static Parse(serializationObject: any): MorphTarget;
  30132. /**
  30133. * Creates a MorphTarget from mesh data
  30134. * @param mesh defines the source mesh
  30135. * @param name defines the name to use for the new target
  30136. * @param influence defines the influence to attach to the target
  30137. * @returns a new MorphTarget
  30138. */
  30139. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  30140. }
  30141. }
  30142. declare module BABYLON {
  30143. /**
  30144. * This class is used to deform meshes using morphing between different targets
  30145. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  30146. */
  30147. class MorphTargetManager {
  30148. private _targets;
  30149. private _targetInfluenceChangedObservers;
  30150. private _targetDataLayoutChangedObservers;
  30151. private _activeTargets;
  30152. private _scene;
  30153. private _influences;
  30154. private _supportsNormals;
  30155. private _supportsTangents;
  30156. private _vertexCount;
  30157. private _uniqueId;
  30158. private _tempInfluences;
  30159. /**
  30160. * Creates a new MorphTargetManager
  30161. * @param scene defines the current scene
  30162. */
  30163. constructor(scene?: Nullable<Scene>);
  30164. /**
  30165. * Gets the unique ID of this manager
  30166. */
  30167. readonly uniqueId: number;
  30168. /**
  30169. * Gets the number of vertices handled by this manager
  30170. */
  30171. readonly vertexCount: number;
  30172. /**
  30173. * Gets a boolean indicating if this manager supports morphing of normals
  30174. */
  30175. readonly supportsNormals: boolean;
  30176. /**
  30177. * Gets a boolean indicating if this manager supports morphing of tangents
  30178. */
  30179. readonly supportsTangents: boolean;
  30180. /**
  30181. * Gets the number of targets stored in this manager
  30182. */
  30183. readonly numTargets: number;
  30184. /**
  30185. * Gets the number of influencers (ie. the number of targets with influences > 0)
  30186. */
  30187. readonly numInfluencers: number;
  30188. /**
  30189. * Gets the list of influences (one per target)
  30190. */
  30191. readonly influences: Float32Array;
  30192. /**
  30193. * Gets the active target at specified index. An active target is a target with an influence > 0
  30194. * @param index defines the index to check
  30195. * @returns the requested target
  30196. */
  30197. getActiveTarget(index: number): MorphTarget;
  30198. /**
  30199. * Gets the target at specified index
  30200. * @param index defines the index to check
  30201. * @returns the requested target
  30202. */
  30203. getTarget(index: number): MorphTarget;
  30204. /**
  30205. * Add a new target to this manager
  30206. * @param target defines the target to add
  30207. */
  30208. addTarget(target: MorphTarget): void;
  30209. /**
  30210. * Removes a target from the manager
  30211. * @param target defines the target to remove
  30212. */
  30213. removeTarget(target: MorphTarget): void;
  30214. /**
  30215. * Serializes the current manager into a Serialization object
  30216. * @returns the serialized object
  30217. */
  30218. serialize(): any;
  30219. private _syncActiveTargets;
  30220. /**
  30221. * Syncrhonize the targets with all the meshes using this morph target manager
  30222. */
  30223. synchronize(): void;
  30224. /**
  30225. * Creates a new MorphTargetManager from serialized data
  30226. * @param serializationObject defines the serialized data
  30227. * @param scene defines the hosting scene
  30228. * @returns the new MorphTargetManager
  30229. */
  30230. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  30231. }
  30232. }
  30233. declare module BABYLON {
  30234. /**
  30235. * Class used to enable access to IndexedDB
  30236. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  30237. */
  30238. class Database implements IOfflineProvider {
  30239. private _callbackManifestChecked;
  30240. private _currentSceneUrl;
  30241. private _db;
  30242. private _enableSceneOffline;
  30243. private _enableTexturesOffline;
  30244. private _manifestVersionFound;
  30245. private _mustUpdateRessources;
  30246. private _hasReachedQuota;
  30247. private _isSupported;
  30248. private _idbFactory;
  30249. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  30250. private static IsUASupportingBlobStorage;
  30251. /**
  30252. * Gets a boolean indicating if Database storate is enabled (off by default)
  30253. */
  30254. static IDBStorageEnabled: boolean;
  30255. /**
  30256. * Gets a boolean indicating if scene must be saved in the database
  30257. */
  30258. readonly enableSceneOffline: boolean;
  30259. /**
  30260. * Gets a boolean indicating if textures must be saved in the database
  30261. */
  30262. readonly enableTexturesOffline: boolean;
  30263. /**
  30264. * Creates a new Database
  30265. * @param urlToScene defines the url to load the scene
  30266. * @param callbackManifestChecked defines the callback to use when manifest is checked
  30267. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  30268. */
  30269. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  30270. private static _ParseURL;
  30271. private static _ReturnFullUrlLocation;
  30272. private _checkManifestFile;
  30273. /**
  30274. * Open the database and make it available
  30275. * @param successCallback defines the callback to call on success
  30276. * @param errorCallback defines the callback to call on error
  30277. */
  30278. open(successCallback: () => void, errorCallback: () => void): void;
  30279. /**
  30280. * Loads an image from the database
  30281. * @param url defines the url to load from
  30282. * @param image defines the target DOM image
  30283. */
  30284. loadImage(url: string, image: HTMLImageElement): void;
  30285. private _loadImageFromDBAsync;
  30286. private _saveImageIntoDBAsync;
  30287. private _checkVersionFromDB;
  30288. private _loadVersionFromDBAsync;
  30289. private _saveVersionIntoDBAsync;
  30290. /**
  30291. * Loads a file from database
  30292. * @param url defines the URL to load from
  30293. * @param sceneLoaded defines a callback to call on success
  30294. * @param progressCallBack defines a callback to call when progress changed
  30295. * @param errorCallback defines a callback to call on error
  30296. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  30297. */
  30298. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  30299. private _loadFileAsync;
  30300. private _saveFileAsync;
  30301. }
  30302. }
  30303. declare module BABYLON {
  30304. /**
  30305. * Class used to enable access to offline support
  30306. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  30307. */
  30308. interface IOfflineProvider {
  30309. /**
  30310. * Gets a boolean indicating if scene must be saved in the database
  30311. */
  30312. enableSceneOffline: boolean;
  30313. /**
  30314. * Gets a boolean indicating if textures must be saved in the database
  30315. */
  30316. enableTexturesOffline: boolean;
  30317. /**
  30318. * Open the offline support and make it available
  30319. * @param successCallback defines the callback to call on success
  30320. * @param errorCallback defines the callback to call on error
  30321. */
  30322. open(successCallback: () => void, errorCallback: () => void): void;
  30323. /**
  30324. * Loads an image from the offline support
  30325. * @param url defines the url to load from
  30326. * @param image defines the target DOM image
  30327. */
  30328. loadImage(url: string, image: HTMLImageElement): void;
  30329. /**
  30330. * Loads a file from offline support
  30331. * @param url defines the URL to load from
  30332. * @param sceneLoaded defines a callback to call on success
  30333. * @param progressCallBack defines a callback to call when progress changed
  30334. * @param errorCallback defines a callback to call on error
  30335. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  30336. */
  30337. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  30338. }
  30339. }
  30340. declare module BABYLON {
  30341. /**
  30342. * This represents the base class for particle system in Babylon.
  30343. * 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.
  30344. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  30345. * @example https://doc.babylonjs.com/babylon101/particles
  30346. */
  30347. class BaseParticleSystem {
  30348. /**
  30349. * Source color is added to the destination color without alpha affecting the result
  30350. */
  30351. static BLENDMODE_ONEONE: number;
  30352. /**
  30353. * Blend current color and particle color using particle’s alpha
  30354. */
  30355. static BLENDMODE_STANDARD: number;
  30356. /**
  30357. * Add current color and particle color multiplied by particle’s alpha
  30358. */
  30359. static BLENDMODE_ADD: number;
  30360. /**
  30361. * Multiply current color with particle color
  30362. */
  30363. static BLENDMODE_MULTIPLY: number;
  30364. /**
  30365. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  30366. */
  30367. static BLENDMODE_MULTIPLYADD: number;
  30368. /**
  30369. * List of animations used by the particle system.
  30370. */
  30371. animations: Animation[];
  30372. /**
  30373. * The id of the Particle system.
  30374. */
  30375. id: string;
  30376. /**
  30377. * The friendly name of the Particle system.
  30378. */
  30379. name: string;
  30380. /**
  30381. * The rendering group used by the Particle system to chose when to render.
  30382. */
  30383. renderingGroupId: number;
  30384. /**
  30385. * The emitter represents the Mesh or position we are attaching the particle system to.
  30386. */
  30387. emitter: Nullable<AbstractMesh | Vector3>;
  30388. /**
  30389. * The maximum number of particles to emit per frame
  30390. */
  30391. emitRate: number;
  30392. /**
  30393. * If you want to launch only a few particles at once, that can be done, as well.
  30394. */
  30395. manualEmitCount: number;
  30396. /**
  30397. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  30398. */
  30399. updateSpeed: number;
  30400. /**
  30401. * The amount of time the particle system is running (depends of the overall update speed).
  30402. */
  30403. targetStopDuration: number;
  30404. /**
  30405. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  30406. */
  30407. disposeOnStop: boolean;
  30408. /**
  30409. * Minimum power of emitting particles.
  30410. */
  30411. minEmitPower: number;
  30412. /**
  30413. * Maximum power of emitting particles.
  30414. */
  30415. maxEmitPower: number;
  30416. /**
  30417. * Minimum life time of emitting particles.
  30418. */
  30419. minLifeTime: number;
  30420. /**
  30421. * Maximum life time of emitting particles.
  30422. */
  30423. maxLifeTime: number;
  30424. /**
  30425. * Minimum Size of emitting particles.
  30426. */
  30427. minSize: number;
  30428. /**
  30429. * Maximum Size of emitting particles.
  30430. */
  30431. maxSize: number;
  30432. /**
  30433. * Minimum scale of emitting particles on X axis.
  30434. */
  30435. minScaleX: number;
  30436. /**
  30437. * Maximum scale of emitting particles on X axis.
  30438. */
  30439. maxScaleX: number;
  30440. /**
  30441. * Minimum scale of emitting particles on Y axis.
  30442. */
  30443. minScaleY: number;
  30444. /**
  30445. * Maximum scale of emitting particles on Y axis.
  30446. */
  30447. maxScaleY: number;
  30448. /**
  30449. * Gets or sets the minimal initial rotation in radians.
  30450. */
  30451. minInitialRotation: number;
  30452. /**
  30453. * Gets or sets the maximal initial rotation in radians.
  30454. */
  30455. maxInitialRotation: number;
  30456. /**
  30457. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  30458. */
  30459. minAngularSpeed: number;
  30460. /**
  30461. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  30462. */
  30463. maxAngularSpeed: number;
  30464. /**
  30465. * The texture used to render each particle. (this can be a spritesheet)
  30466. */
  30467. particleTexture: Nullable<Texture>;
  30468. /**
  30469. * The layer mask we are rendering the particles through.
  30470. */
  30471. layerMask: number;
  30472. /**
  30473. * This can help using your own shader to render the particle system.
  30474. * The according effect will be created
  30475. */
  30476. customShader: any;
  30477. /**
  30478. * By default particle system starts as soon as they are created. This prevents the
  30479. * automatic start to happen and let you decide when to start emitting particles.
  30480. */
  30481. preventAutoStart: boolean;
  30482. private _noiseTexture;
  30483. /**
  30484. * Gets or sets a texture used to add random noise to particle positions
  30485. */
  30486. noiseTexture: Nullable<ProceduralTexture>;
  30487. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  30488. noiseStrength: Vector3;
  30489. /**
  30490. * Callback triggered when the particle animation is ending.
  30491. */
  30492. onAnimationEnd: Nullable<() => void>;
  30493. /**
  30494. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  30495. */
  30496. blendMode: number;
  30497. /**
  30498. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  30499. * to override the particles.
  30500. */
  30501. forceDepthWrite: boolean;
  30502. /** 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 */
  30503. preWarmCycles: number;
  30504. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  30505. preWarmStepOffset: number;
  30506. /**
  30507. * 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)
  30508. */
  30509. spriteCellChangeSpeed: number;
  30510. /**
  30511. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  30512. */
  30513. startSpriteCellID: number;
  30514. /**
  30515. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  30516. */
  30517. endSpriteCellID: number;
  30518. /**
  30519. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  30520. */
  30521. spriteCellWidth: number;
  30522. /**
  30523. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  30524. */
  30525. spriteCellHeight: number;
  30526. /**
  30527. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  30528. */
  30529. spriteRandomStartCell: boolean;
  30530. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  30531. translationPivot: Vector2;
  30532. /** @hidden */
  30533. protected _isAnimationSheetEnabled: boolean;
  30534. /**
  30535. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  30536. */
  30537. beginAnimationOnStart: boolean;
  30538. /**
  30539. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  30540. */
  30541. beginAnimationFrom: number;
  30542. /**
  30543. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  30544. */
  30545. beginAnimationTo: number;
  30546. /**
  30547. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  30548. */
  30549. beginAnimationLoop: boolean;
  30550. /**
  30551. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  30552. */
  30553. isAnimationSheetEnabled: boolean;
  30554. /**
  30555. * Get hosting scene
  30556. * @returns the scene
  30557. */
  30558. getScene(): Scene;
  30559. /**
  30560. * You can use gravity if you want to give an orientation to your particles.
  30561. */
  30562. gravity: Vector3;
  30563. protected _colorGradients: Nullable<Array<ColorGradient>>;
  30564. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  30565. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  30566. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  30567. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  30568. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  30569. protected _dragGradients: Nullable<Array<FactorGradient>>;
  30570. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  30571. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  30572. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  30573. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  30574. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  30575. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  30576. /**
  30577. * Defines the delay in milliseconds before starting the system (0 by default)
  30578. */
  30579. startDelay: number;
  30580. /**
  30581. * Gets the current list of drag gradients.
  30582. * You must use addDragGradient and removeDragGradient to udpate this list
  30583. * @returns the list of drag gradients
  30584. */
  30585. getDragGradients(): Nullable<Array<FactorGradient>>;
  30586. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  30587. limitVelocityDamping: number;
  30588. /**
  30589. * Gets the current list of limit velocity gradients.
  30590. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  30591. * @returns the list of limit velocity gradients
  30592. */
  30593. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  30594. /**
  30595. * Gets the current list of color gradients.
  30596. * You must use addColorGradient and removeColorGradient to udpate this list
  30597. * @returns the list of color gradients
  30598. */
  30599. getColorGradients(): Nullable<Array<ColorGradient>>;
  30600. /**
  30601. * Gets the current list of size gradients.
  30602. * You must use addSizeGradient and removeSizeGradient to udpate this list
  30603. * @returns the list of size gradients
  30604. */
  30605. getSizeGradients(): Nullable<Array<FactorGradient>>;
  30606. /**
  30607. * Gets the current list of color remap gradients.
  30608. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  30609. * @returns the list of color remap gradients
  30610. */
  30611. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  30612. /**
  30613. * Gets the current list of alpha remap gradients.
  30614. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  30615. * @returns the list of alpha remap gradients
  30616. */
  30617. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  30618. /**
  30619. * Gets the current list of life time gradients.
  30620. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  30621. * @returns the list of life time gradients
  30622. */
  30623. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  30624. /**
  30625. * Gets the current list of angular speed gradients.
  30626. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  30627. * @returns the list of angular speed gradients
  30628. */
  30629. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  30630. /**
  30631. * Gets the current list of velocity gradients.
  30632. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  30633. * @returns the list of velocity gradients
  30634. */
  30635. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  30636. /**
  30637. * Gets the current list of start size gradients.
  30638. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  30639. * @returns the list of start size gradients
  30640. */
  30641. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  30642. /**
  30643. * Gets the current list of emit rate gradients.
  30644. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  30645. * @returns the list of emit rate gradients
  30646. */
  30647. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  30648. /**
  30649. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  30650. * This only works when particleEmitterTyps is a BoxParticleEmitter
  30651. */
  30652. direction1: Vector3;
  30653. /**
  30654. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  30655. * This only works when particleEmitterTyps is a BoxParticleEmitter
  30656. */
  30657. direction2: Vector3;
  30658. /**
  30659. * 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.
  30660. * This only works when particleEmitterTyps is a BoxParticleEmitter
  30661. */
  30662. minEmitBox: Vector3;
  30663. /**
  30664. * 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.
  30665. * This only works when particleEmitterTyps is a BoxParticleEmitter
  30666. */
  30667. maxEmitBox: Vector3;
  30668. /**
  30669. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  30670. */
  30671. color1: Color4;
  30672. /**
  30673. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  30674. */
  30675. color2: Color4;
  30676. /**
  30677. * Color the particle will have at the end of its lifetime
  30678. */
  30679. colorDead: Color4;
  30680. /**
  30681. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  30682. */
  30683. textureMask: Color4;
  30684. /**
  30685. * The particle emitter type defines the emitter used by the particle system.
  30686. * It can be for example box, sphere, or cone...
  30687. */
  30688. particleEmitterType: IParticleEmitterType;
  30689. /** @hidden */
  30690. _isSubEmitter: boolean;
  30691. /**
  30692. * Gets or sets the billboard mode to use when isBillboardBased = true.
  30693. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  30694. */
  30695. billboardMode: number;
  30696. protected _isBillboardBased: boolean;
  30697. /**
  30698. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  30699. */
  30700. isBillboardBased: boolean;
  30701. /**
  30702. * The scene the particle system belongs to.
  30703. */
  30704. protected _scene: Scene;
  30705. /**
  30706. * Local cache of defines for image processing.
  30707. */
  30708. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  30709. /**
  30710. * Default configuration related to image processing available in the standard Material.
  30711. */
  30712. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  30713. /**
  30714. * Gets the image processing configuration used either in this material.
  30715. */
  30716. /**
  30717. * Sets the Default image processing configuration used either in the this material.
  30718. *
  30719. * If sets to null, the scene one is in use.
  30720. */
  30721. imageProcessingConfiguration: ImageProcessingConfiguration;
  30722. /**
  30723. * Attaches a new image processing configuration to the Standard Material.
  30724. * @param configuration
  30725. */
  30726. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  30727. /** @hidden */
  30728. protected _reset(): void;
  30729. /** @hidden */
  30730. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  30731. /**
  30732. * Instantiates a particle system.
  30733. * 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.
  30734. * @param name The name of the particle system
  30735. */
  30736. constructor(name: string);
  30737. /**
  30738. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  30739. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  30740. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  30741. * @returns the emitter
  30742. */
  30743. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  30744. /**
  30745. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  30746. * @param radius The radius of the hemisphere to emit from
  30747. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  30748. * @returns the emitter
  30749. */
  30750. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  30751. /**
  30752. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  30753. * @param radius The radius of the sphere to emit from
  30754. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  30755. * @returns the emitter
  30756. */
  30757. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  30758. /**
  30759. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  30760. * @param radius The radius of the sphere to emit from
  30761. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  30762. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  30763. * @returns the emitter
  30764. */
  30765. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  30766. /**
  30767. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  30768. * @param radius The radius of the emission cylinder
  30769. * @param height The height of the emission cylinder
  30770. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  30771. * @param directionRandomizer How much to randomize the particle direction [0-1]
  30772. * @returns the emitter
  30773. */
  30774. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  30775. /**
  30776. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  30777. * @param radius The radius of the cylinder to emit from
  30778. * @param height The height of the emission cylinder
  30779. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  30780. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  30781. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  30782. * @returns the emitter
  30783. */
  30784. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  30785. /**
  30786. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  30787. * @param radius The radius of the cone to emit from
  30788. * @param angle The base angle of the cone
  30789. * @returns the emitter
  30790. */
  30791. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  30792. /**
  30793. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  30794. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  30795. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  30796. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  30797. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  30798. * @returns the emitter
  30799. */
  30800. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  30801. }
  30802. }
  30803. declare module BABYLON {
  30804. /**
  30805. * This represents a GPU particle system in Babylon
  30806. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  30807. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  30808. */
  30809. class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  30810. /**
  30811. * The layer mask we are rendering the particles through.
  30812. */
  30813. layerMask: number;
  30814. private _capacity;
  30815. private _activeCount;
  30816. private _currentActiveCount;
  30817. private _accumulatedCount;
  30818. private _renderEffect;
  30819. private _updateEffect;
  30820. private _buffer0;
  30821. private _buffer1;
  30822. private _spriteBuffer;
  30823. private _updateVAO;
  30824. private _renderVAO;
  30825. private _targetIndex;
  30826. private _sourceBuffer;
  30827. private _targetBuffer;
  30828. private _engine;
  30829. private _currentRenderId;
  30830. private _started;
  30831. private _stopped;
  30832. private _timeDelta;
  30833. private _randomTexture;
  30834. private _randomTexture2;
  30835. private _attributesStrideSize;
  30836. private _updateEffectOptions;
  30837. private _randomTextureSize;
  30838. private _actualFrame;
  30839. private readonly _rawTextureWidth;
  30840. /**
  30841. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  30842. */
  30843. static readonly IsSupported: boolean;
  30844. /**
  30845. * An event triggered when the system is disposed.
  30846. */
  30847. onDisposeObservable: Observable<GPUParticleSystem>;
  30848. /**
  30849. * Gets the maximum number of particles active at the same time.
  30850. * @returns The max number of active particles.
  30851. */
  30852. getCapacity(): number;
  30853. /**
  30854. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  30855. * to override the particles.
  30856. */
  30857. forceDepthWrite: boolean;
  30858. /**
  30859. * Gets or set the number of active particles
  30860. */
  30861. activeParticleCount: number;
  30862. private _preWarmDone;
  30863. /**
  30864. * Is this system ready to be used/rendered
  30865. * @return true if the system is ready
  30866. */
  30867. isReady(): boolean;
  30868. /**
  30869. * Gets if the system has been started. (Note: this will still be true after stop is called)
  30870. * @returns True if it has been started, otherwise false.
  30871. */
  30872. isStarted(): boolean;
  30873. /**
  30874. * Starts the particle system and begins to emit
  30875. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  30876. */
  30877. start(delay?: number): void;
  30878. /**
  30879. * Stops the particle system.
  30880. */
  30881. stop(): void;
  30882. /**
  30883. * Remove all active particles
  30884. */
  30885. reset(): void;
  30886. /**
  30887. * Returns the string "GPUParticleSystem"
  30888. * @returns a string containing the class name
  30889. */
  30890. getClassName(): string;
  30891. private _colorGradientsTexture;
  30892. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  30893. /**
  30894. * Adds a new color gradient
  30895. * @param gradient defines the gradient to use (between 0 and 1)
  30896. * @param color1 defines the color to affect to the specified gradient
  30897. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  30898. * @returns the current particle system
  30899. */
  30900. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  30901. /**
  30902. * Remove a specific color gradient
  30903. * @param gradient defines the gradient to remove
  30904. * @returns the current particle system
  30905. */
  30906. removeColorGradient(gradient: number): GPUParticleSystem;
  30907. private _angularSpeedGradientsTexture;
  30908. private _sizeGradientsTexture;
  30909. private _velocityGradientsTexture;
  30910. private _limitVelocityGradientsTexture;
  30911. private _dragGradientsTexture;
  30912. private _addFactorGradient;
  30913. /**
  30914. * Adds a new size gradient
  30915. * @param gradient defines the gradient to use (between 0 and 1)
  30916. * @param factor defines the size factor to affect to the specified gradient
  30917. * @returns the current particle system
  30918. */
  30919. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  30920. /**
  30921. * Remove a specific size gradient
  30922. * @param gradient defines the gradient to remove
  30923. * @returns the current particle system
  30924. */
  30925. removeSizeGradient(gradient: number): GPUParticleSystem;
  30926. /**
  30927. * Adds a new angular speed gradient
  30928. * @param gradient defines the gradient to use (between 0 and 1)
  30929. * @param factor defines the angular speed to affect to the specified gradient
  30930. * @returns the current particle system
  30931. */
  30932. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  30933. /**
  30934. * Remove a specific angular speed gradient
  30935. * @param gradient defines the gradient to remove
  30936. * @returns the current particle system
  30937. */
  30938. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  30939. /**
  30940. * Adds a new velocity gradient
  30941. * @param gradient defines the gradient to use (between 0 and 1)
  30942. * @param factor defines the velocity to affect to the specified gradient
  30943. * @returns the current particle system
  30944. */
  30945. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  30946. /**
  30947. * Remove a specific velocity gradient
  30948. * @param gradient defines the gradient to remove
  30949. * @returns the current particle system
  30950. */
  30951. removeVelocityGradient(gradient: number): GPUParticleSystem;
  30952. /**
  30953. * Adds a new limit velocity gradient
  30954. * @param gradient defines the gradient to use (between 0 and 1)
  30955. * @param factor defines the limit velocity value to affect to the specified gradient
  30956. * @returns the current particle system
  30957. */
  30958. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  30959. /**
  30960. * Remove a specific limit velocity gradient
  30961. * @param gradient defines the gradient to remove
  30962. * @returns the current particle system
  30963. */
  30964. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  30965. /**
  30966. * Adds a new drag gradient
  30967. * @param gradient defines the gradient to use (between 0 and 1)
  30968. * @param factor defines the drag value to affect to the specified gradient
  30969. * @returns the current particle system
  30970. */
  30971. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  30972. /**
  30973. * Remove a specific drag gradient
  30974. * @param gradient defines the gradient to remove
  30975. * @returns the current particle system
  30976. */
  30977. removeDragGradient(gradient: number): GPUParticleSystem;
  30978. /**
  30979. * Not supported by GPUParticleSystem
  30980. * @param gradient defines the gradient to use (between 0 and 1)
  30981. * @param factor defines the emit rate value to affect to the specified gradient
  30982. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  30983. * @returns the current particle system
  30984. */
  30985. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  30986. /**
  30987. * Not supported by GPUParticleSystem
  30988. * @param gradient defines the gradient to remove
  30989. * @returns the current particle system
  30990. */
  30991. removeEmitRateGradient(gradient: number): IParticleSystem;
  30992. /**
  30993. * Not supported by GPUParticleSystem
  30994. * @param gradient defines the gradient to use (between 0 and 1)
  30995. * @param factor defines the start size value to affect to the specified gradient
  30996. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  30997. * @returns the current particle system
  30998. */
  30999. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31000. /**
  31001. * Not supported by GPUParticleSystem
  31002. * @param gradient defines the gradient to remove
  31003. * @returns the current particle system
  31004. */
  31005. removeStartSizeGradient(gradient: number): IParticleSystem;
  31006. /**
  31007. * Not supported by GPUParticleSystem
  31008. * @param gradient defines the gradient to use (between 0 and 1)
  31009. * @param min defines the color remap minimal range
  31010. * @param max defines the color remap maximal range
  31011. * @returns the current particle system
  31012. */
  31013. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  31014. /**
  31015. * Not supported by GPUParticleSystem
  31016. * @param gradient defines the gradient to remove
  31017. * @returns the current particle system
  31018. */
  31019. removeColorRemapGradient(gradient: number): IParticleSystem;
  31020. /**
  31021. * Not supported by GPUParticleSystem
  31022. * @param gradient defines the gradient to use (between 0 and 1)
  31023. * @param min defines the alpha remap minimal range
  31024. * @param max defines the alpha remap maximal range
  31025. * @returns the current particle system
  31026. */
  31027. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  31028. /**
  31029. * Not supported by GPUParticleSystem
  31030. * @param gradient defines the gradient to remove
  31031. * @returns the current particle system
  31032. */
  31033. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  31034. /**
  31035. * Not supported by GPUParticleSystem
  31036. * @param gradient defines the gradient to use (between 0 and 1)
  31037. * @param color defines the color to affect to the specified gradient
  31038. * @returns the current particle system
  31039. */
  31040. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  31041. /**
  31042. * Not supported by GPUParticleSystem
  31043. * @param gradient defines the gradient to remove
  31044. * @returns the current particle system
  31045. */
  31046. removeRampGradient(gradient: number): IParticleSystem;
  31047. /**
  31048. * Not supported by GPUParticleSystem
  31049. * @returns the list of ramp gradients
  31050. */
  31051. getRampGradients(): Nullable<Array<Color3Gradient>>;
  31052. /**
  31053. * Not supported by GPUParticleSystem
  31054. * Gets or sets a boolean indicating that ramp gradients must be used
  31055. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  31056. */
  31057. useRampGradients: boolean;
  31058. /**
  31059. * Not supported by GPUParticleSystem
  31060. * @param gradient defines the gradient to use (between 0 and 1)
  31061. * @param factor defines the life time factor to affect to the specified gradient
  31062. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31063. * @returns the current particle system
  31064. */
  31065. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31066. /**
  31067. * Not supported by GPUParticleSystem
  31068. * @param gradient defines the gradient to remove
  31069. * @returns the current particle system
  31070. */
  31071. removeLifeTimeGradient(gradient: number): IParticleSystem;
  31072. /**
  31073. * Instantiates a GPU particle system.
  31074. * 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.
  31075. * @param name The name of the particle system
  31076. * @param options The options used to create the system
  31077. * @param scene The scene the particle system belongs to
  31078. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  31079. */
  31080. constructor(name: string, options: Partial<{
  31081. capacity: number;
  31082. randomTextureSize: number;
  31083. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  31084. protected _reset(): void;
  31085. private _createUpdateVAO;
  31086. private _createRenderVAO;
  31087. private _initialize;
  31088. /** @hidden */
  31089. _recreateUpdateEffect(): void;
  31090. /** @hidden */
  31091. _recreateRenderEffect(): void;
  31092. /**
  31093. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  31094. * @param preWarm defines if we are in the pre-warmimg phase
  31095. */
  31096. animate(preWarm?: boolean): void;
  31097. private _createFactorGradientTexture;
  31098. private _createSizeGradientTexture;
  31099. private _createAngularSpeedGradientTexture;
  31100. private _createVelocityGradientTexture;
  31101. private _createLimitVelocityGradientTexture;
  31102. private _createDragGradientTexture;
  31103. private _createColorGradientTexture;
  31104. /**
  31105. * Renders the particle system in its current state
  31106. * @param preWarm defines if the system should only update the particles but not render them
  31107. * @returns the current number of particles
  31108. */
  31109. render(preWarm?: boolean): number;
  31110. /**
  31111. * Rebuilds the particle system
  31112. */
  31113. rebuild(): void;
  31114. private _releaseBuffers;
  31115. private _releaseVAOs;
  31116. /**
  31117. * Disposes the particle system and free the associated resources
  31118. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  31119. */
  31120. dispose(disposeTexture?: boolean): void;
  31121. /**
  31122. * Clones the particle system.
  31123. * @param name The name of the cloned object
  31124. * @param newEmitter The new emitter to use
  31125. * @returns the cloned particle system
  31126. */
  31127. clone(name: string, newEmitter: any): GPUParticleSystem;
  31128. /**
  31129. * Serializes the particle system to a JSON object.
  31130. * @returns the JSON object
  31131. */
  31132. serialize(): any;
  31133. /**
  31134. * Parses a JSON object to create a GPU particle system.
  31135. * @param parsedParticleSystem The JSON object to parse
  31136. * @param scene The scene to create the particle system in
  31137. * @param rootUrl The root url to use to load external dependencies like texture
  31138. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  31139. * @returns the parsed GPU particle system
  31140. */
  31141. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  31142. }
  31143. }
  31144. declare module BABYLON {
  31145. /**
  31146. * Interface representing a particle system in Babylon.js.
  31147. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  31148. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  31149. */
  31150. interface IParticleSystem {
  31151. /**
  31152. * List of animations used by the particle system.
  31153. */
  31154. animations: Animation[];
  31155. /**
  31156. * The id of the Particle system.
  31157. */
  31158. id: string;
  31159. /**
  31160. * The name of the Particle system.
  31161. */
  31162. name: string;
  31163. /**
  31164. * The emitter represents the Mesh or position we are attaching the particle system to.
  31165. */
  31166. emitter: Nullable<AbstractMesh | Vector3>;
  31167. /**
  31168. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  31169. */
  31170. isBillboardBased: boolean;
  31171. /**
  31172. * The rendering group used by the Particle system to chose when to render.
  31173. */
  31174. renderingGroupId: number;
  31175. /**
  31176. * The layer mask we are rendering the particles through.
  31177. */
  31178. layerMask: number;
  31179. /**
  31180. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  31181. */
  31182. updateSpeed: number;
  31183. /**
  31184. * The amount of time the particle system is running (depends of the overall update speed).
  31185. */
  31186. targetStopDuration: number;
  31187. /**
  31188. * The texture used to render each particle. (this can be a spritesheet)
  31189. */
  31190. particleTexture: Nullable<Texture>;
  31191. /**
  31192. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  31193. */
  31194. blendMode: number;
  31195. /**
  31196. * Minimum life time of emitting particles.
  31197. */
  31198. minLifeTime: number;
  31199. /**
  31200. * Maximum life time of emitting particles.
  31201. */
  31202. maxLifeTime: number;
  31203. /**
  31204. * Minimum Size of emitting particles.
  31205. */
  31206. minSize: number;
  31207. /**
  31208. * Maximum Size of emitting particles.
  31209. */
  31210. maxSize: number;
  31211. /**
  31212. * Minimum scale of emitting particles on X axis.
  31213. */
  31214. minScaleX: number;
  31215. /**
  31216. * Maximum scale of emitting particles on X axis.
  31217. */
  31218. maxScaleX: number;
  31219. /**
  31220. * Minimum scale of emitting particles on Y axis.
  31221. */
  31222. minScaleY: number;
  31223. /**
  31224. * Maximum scale of emitting particles on Y axis.
  31225. */
  31226. maxScaleY: number;
  31227. /**
  31228. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  31229. */
  31230. color1: Color4;
  31231. /**
  31232. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  31233. */
  31234. color2: Color4;
  31235. /**
  31236. * Color the particle will have at the end of its lifetime.
  31237. */
  31238. colorDead: Color4;
  31239. /**
  31240. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  31241. */
  31242. emitRate: number;
  31243. /**
  31244. * You can use gravity if you want to give an orientation to your particles.
  31245. */
  31246. gravity: Vector3;
  31247. /**
  31248. * Minimum power of emitting particles.
  31249. */
  31250. minEmitPower: number;
  31251. /**
  31252. * Maximum power of emitting particles.
  31253. */
  31254. maxEmitPower: number;
  31255. /**
  31256. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  31257. */
  31258. minAngularSpeed: number;
  31259. /**
  31260. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  31261. */
  31262. maxAngularSpeed: number;
  31263. /**
  31264. * Gets or sets the minimal initial rotation in radians.
  31265. */
  31266. minInitialRotation: number;
  31267. /**
  31268. * Gets or sets the maximal initial rotation in radians.
  31269. */
  31270. maxInitialRotation: number;
  31271. /**
  31272. * The particle emitter type defines the emitter used by the particle system.
  31273. * It can be for example box, sphere, or cone...
  31274. */
  31275. particleEmitterType: Nullable<IParticleEmitterType>;
  31276. /**
  31277. * Defines the delay in milliseconds before starting the system (0 by default)
  31278. */
  31279. startDelay: number;
  31280. /**
  31281. * 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
  31282. */
  31283. preWarmCycles: number;
  31284. /**
  31285. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  31286. */
  31287. preWarmStepOffset: number;
  31288. /**
  31289. * 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)
  31290. */
  31291. spriteCellChangeSpeed: number;
  31292. /**
  31293. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  31294. */
  31295. startSpriteCellID: number;
  31296. /**
  31297. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  31298. */
  31299. endSpriteCellID: number;
  31300. /**
  31301. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  31302. */
  31303. spriteCellWidth: number;
  31304. /**
  31305. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  31306. */
  31307. spriteCellHeight: number;
  31308. /**
  31309. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  31310. */
  31311. spriteRandomStartCell: boolean;
  31312. /**
  31313. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  31314. */
  31315. isAnimationSheetEnabled: boolean;
  31316. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  31317. translationPivot: Vector2;
  31318. /**
  31319. * Gets or sets a texture used to add random noise to particle positions
  31320. */
  31321. noiseTexture: Nullable<BaseTexture>;
  31322. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  31323. noiseStrength: Vector3;
  31324. /**
  31325. * Gets or sets the billboard mode to use when isBillboardBased = true.
  31326. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  31327. */
  31328. billboardMode: number;
  31329. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  31330. limitVelocityDamping: number;
  31331. /**
  31332. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  31333. */
  31334. beginAnimationOnStart: boolean;
  31335. /**
  31336. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  31337. */
  31338. beginAnimationFrom: number;
  31339. /**
  31340. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  31341. */
  31342. beginAnimationTo: number;
  31343. /**
  31344. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  31345. */
  31346. beginAnimationLoop: boolean;
  31347. /**
  31348. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  31349. */
  31350. disposeOnStop: boolean;
  31351. /**
  31352. * Gets the maximum number of particles active at the same time.
  31353. * @returns The max number of active particles.
  31354. */
  31355. getCapacity(): number;
  31356. /**
  31357. * Gets if the system has been started. (Note: this will still be true after stop is called)
  31358. * @returns True if it has been started, otherwise false.
  31359. */
  31360. isStarted(): boolean;
  31361. /**
  31362. * Animates the particle system for this frame.
  31363. */
  31364. animate(): void;
  31365. /**
  31366. * Renders the particle system in its current state.
  31367. * @returns the current number of particles
  31368. */
  31369. render(): number;
  31370. /**
  31371. * Dispose the particle system and frees its associated resources.
  31372. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  31373. */
  31374. dispose(disposeTexture?: boolean): void;
  31375. /**
  31376. * Clones the particle system.
  31377. * @param name The name of the cloned object
  31378. * @param newEmitter The new emitter to use
  31379. * @returns the cloned particle system
  31380. */
  31381. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  31382. /**
  31383. * Serializes the particle system to a JSON object.
  31384. * @returns the JSON object
  31385. */
  31386. serialize(): any;
  31387. /**
  31388. * Rebuild the particle system
  31389. */
  31390. rebuild(): void;
  31391. /**
  31392. * Starts the particle system and begins to emit
  31393. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  31394. */
  31395. start(delay?: number): void;
  31396. /**
  31397. * Stops the particle system.
  31398. */
  31399. stop(): void;
  31400. /**
  31401. * Remove all active particles
  31402. */
  31403. reset(): void;
  31404. /**
  31405. * Is this system ready to be used/rendered
  31406. * @return true if the system is ready
  31407. */
  31408. isReady(): boolean;
  31409. /**
  31410. * Adds a new color gradient
  31411. * @param gradient defines the gradient to use (between 0 and 1)
  31412. * @param color1 defines the color to affect to the specified gradient
  31413. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  31414. * @returns the current particle system
  31415. */
  31416. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  31417. /**
  31418. * Remove a specific color gradient
  31419. * @param gradient defines the gradient to remove
  31420. * @returns the current particle system
  31421. */
  31422. removeColorGradient(gradient: number): IParticleSystem;
  31423. /**
  31424. * Adds a new size gradient
  31425. * @param gradient defines the gradient to use (between 0 and 1)
  31426. * @param factor defines the size factor to affect to the specified gradient
  31427. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31428. * @returns the current particle system
  31429. */
  31430. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31431. /**
  31432. * Remove a specific size gradient
  31433. * @param gradient defines the gradient to remove
  31434. * @returns the current particle system
  31435. */
  31436. removeSizeGradient(gradient: number): IParticleSystem;
  31437. /**
  31438. * Gets the current list of color gradients.
  31439. * You must use addColorGradient and removeColorGradient to udpate this list
  31440. * @returns the list of color gradients
  31441. */
  31442. getColorGradients(): Nullable<Array<ColorGradient>>;
  31443. /**
  31444. * Gets the current list of size gradients.
  31445. * You must use addSizeGradient and removeSizeGradient to udpate this list
  31446. * @returns the list of size gradients
  31447. */
  31448. getSizeGradients(): Nullable<Array<FactorGradient>>;
  31449. /**
  31450. * Gets the current list of angular speed gradients.
  31451. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  31452. * @returns the list of angular speed gradients
  31453. */
  31454. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  31455. /**
  31456. * Adds a new angular speed gradient
  31457. * @param gradient defines the gradient to use (between 0 and 1)
  31458. * @param factor defines the angular speed to affect to the specified gradient
  31459. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31460. * @returns the current particle system
  31461. */
  31462. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31463. /**
  31464. * Remove a specific angular speed gradient
  31465. * @param gradient defines the gradient to remove
  31466. * @returns the current particle system
  31467. */
  31468. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  31469. /**
  31470. * Gets the current list of velocity gradients.
  31471. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  31472. * @returns the list of velocity gradients
  31473. */
  31474. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  31475. /**
  31476. * Adds a new velocity gradient
  31477. * @param gradient defines the gradient to use (between 0 and 1)
  31478. * @param factor defines the velocity to affect to the specified gradient
  31479. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31480. * @returns the current particle system
  31481. */
  31482. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31483. /**
  31484. * Remove a specific velocity gradient
  31485. * @param gradient defines the gradient to remove
  31486. * @returns the current particle system
  31487. */
  31488. removeVelocityGradient(gradient: number): IParticleSystem;
  31489. /**
  31490. * Gets the current list of limit velocity gradients.
  31491. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  31492. * @returns the list of limit velocity gradients
  31493. */
  31494. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  31495. /**
  31496. * Adds a new limit velocity gradient
  31497. * @param gradient defines the gradient to use (between 0 and 1)
  31498. * @param factor defines the limit velocity to affect to the specified gradient
  31499. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31500. * @returns the current particle system
  31501. */
  31502. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31503. /**
  31504. * Remove a specific limit velocity gradient
  31505. * @param gradient defines the gradient to remove
  31506. * @returns the current particle system
  31507. */
  31508. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  31509. /**
  31510. * Adds a new drag gradient
  31511. * @param gradient defines the gradient to use (between 0 and 1)
  31512. * @param factor defines the drag to affect to the specified gradient
  31513. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31514. * @returns the current particle system
  31515. */
  31516. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31517. /**
  31518. * Remove a specific drag gradient
  31519. * @param gradient defines the gradient to remove
  31520. * @returns the current particle system
  31521. */
  31522. removeDragGradient(gradient: number): IParticleSystem;
  31523. /**
  31524. * Gets the current list of drag gradients.
  31525. * You must use addDragGradient and removeDragGradient to udpate this list
  31526. * @returns the list of drag gradients
  31527. */
  31528. getDragGradients(): Nullable<Array<FactorGradient>>;
  31529. /**
  31530. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  31531. * @param gradient defines the gradient to use (between 0 and 1)
  31532. * @param factor defines the emit rate to affect to the specified gradient
  31533. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31534. * @returns the current particle system
  31535. */
  31536. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31537. /**
  31538. * Remove a specific emit rate gradient
  31539. * @param gradient defines the gradient to remove
  31540. * @returns the current particle system
  31541. */
  31542. removeEmitRateGradient(gradient: number): IParticleSystem;
  31543. /**
  31544. * Gets the current list of emit rate gradients.
  31545. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  31546. * @returns the list of emit rate gradients
  31547. */
  31548. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  31549. /**
  31550. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  31551. * @param gradient defines the gradient to use (between 0 and 1)
  31552. * @param factor defines the start size to affect to the specified gradient
  31553. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31554. * @returns the current particle system
  31555. */
  31556. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31557. /**
  31558. * Remove a specific start size gradient
  31559. * @param gradient defines the gradient to remove
  31560. * @returns the current particle system
  31561. */
  31562. removeStartSizeGradient(gradient: number): IParticleSystem;
  31563. /**
  31564. * Gets the current list of start size gradients.
  31565. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  31566. * @returns the list of start size gradients
  31567. */
  31568. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  31569. /**
  31570. * Adds a new life time gradient
  31571. * @param gradient defines the gradient to use (between 0 and 1)
  31572. * @param factor defines the life time factor to affect to the specified gradient
  31573. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31574. * @returns the current particle system
  31575. */
  31576. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31577. /**
  31578. * Remove a specific life time gradient
  31579. * @param gradient defines the gradient to remove
  31580. * @returns the current particle system
  31581. */
  31582. removeLifeTimeGradient(gradient: number): IParticleSystem;
  31583. /**
  31584. * Gets the current list of life time gradients.
  31585. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  31586. * @returns the list of life time gradients
  31587. */
  31588. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  31589. /**
  31590. * Gets the current list of color gradients.
  31591. * You must use addColorGradient and removeColorGradient to udpate this list
  31592. * @returns the list of color gradients
  31593. */
  31594. getColorGradients(): Nullable<Array<ColorGradient>>;
  31595. /**
  31596. * Adds a new ramp gradient used to remap particle colors
  31597. * @param gradient defines the gradient to use (between 0 and 1)
  31598. * @param color defines the color to affect to the specified gradient
  31599. * @returns the current particle system
  31600. */
  31601. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  31602. /**
  31603. * Gets the current list of ramp gradients.
  31604. * You must use addRampGradient and removeRampGradient to udpate this list
  31605. * @returns the list of ramp gradients
  31606. */
  31607. getRampGradients(): Nullable<Array<Color3Gradient>>;
  31608. /** Gets or sets a boolean indicating that ramp gradients must be used
  31609. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  31610. */
  31611. useRampGradients: boolean;
  31612. /**
  31613. * Adds a new color remap gradient
  31614. * @param gradient defines the gradient to use (between 0 and 1)
  31615. * @param min defines the color remap minimal range
  31616. * @param max defines the color remap maximal range
  31617. * @returns the current particle system
  31618. */
  31619. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  31620. /**
  31621. * Gets the current list of color remap gradients.
  31622. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  31623. * @returns the list of color remap gradients
  31624. */
  31625. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  31626. /**
  31627. * Adds a new alpha remap gradient
  31628. * @param gradient defines the gradient to use (between 0 and 1)
  31629. * @param min defines the alpha remap minimal range
  31630. * @param max defines the alpha remap maximal range
  31631. * @returns the current particle system
  31632. */
  31633. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  31634. /**
  31635. * Gets the current list of alpha remap gradients.
  31636. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  31637. * @returns the list of alpha remap gradients
  31638. */
  31639. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  31640. /**
  31641. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  31642. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  31643. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  31644. * @returns the emitter
  31645. */
  31646. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  31647. /**
  31648. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  31649. * @param radius The radius of the hemisphere to emit from
  31650. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  31651. * @returns the emitter
  31652. */
  31653. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  31654. /**
  31655. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  31656. * @param radius The radius of the sphere to emit from
  31657. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  31658. * @returns the emitter
  31659. */
  31660. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  31661. /**
  31662. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  31663. * @param radius The radius of the sphere to emit from
  31664. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  31665. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  31666. * @returns the emitter
  31667. */
  31668. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  31669. /**
  31670. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  31671. * @param radius The radius of the emission cylinder
  31672. * @param height The height of the emission cylinder
  31673. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  31674. * @param directionRandomizer How much to randomize the particle direction [0-1]
  31675. * @returns the emitter
  31676. */
  31677. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  31678. /**
  31679. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  31680. * @param radius The radius of the cylinder to emit from
  31681. * @param height The height of the emission cylinder
  31682. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  31683. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  31684. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  31685. * @returns the emitter
  31686. */
  31687. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  31688. /**
  31689. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  31690. * @param radius The radius of the cone to emit from
  31691. * @param angle The base angle of the cone
  31692. * @returns the emitter
  31693. */
  31694. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  31695. /**
  31696. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  31697. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  31698. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  31699. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  31700. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  31701. * @returns the emitter
  31702. */
  31703. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  31704. /**
  31705. * Get hosting scene
  31706. * @returns the scene
  31707. */
  31708. getScene(): Scene;
  31709. }
  31710. }
  31711. declare module BABYLON {
  31712. /**
  31713. * A particle represents one of the element emitted by a particle system.
  31714. * This is mainly define by its coordinates, direction, velocity and age.
  31715. */
  31716. class Particle {
  31717. /**
  31718. * The particle system the particle belongs to.
  31719. */
  31720. particleSystem: ParticleSystem;
  31721. private static _Count;
  31722. /**
  31723. * Unique ID of the particle
  31724. */
  31725. id: number;
  31726. /**
  31727. * The world position of the particle in the scene.
  31728. */
  31729. position: Vector3;
  31730. /**
  31731. * The world direction of the particle in the scene.
  31732. */
  31733. direction: Vector3;
  31734. /**
  31735. * The color of the particle.
  31736. */
  31737. color: Color4;
  31738. /**
  31739. * The color change of the particle per step.
  31740. */
  31741. colorStep: Color4;
  31742. /**
  31743. * Defines how long will the life of the particle be.
  31744. */
  31745. lifeTime: number;
  31746. /**
  31747. * The current age of the particle.
  31748. */
  31749. age: number;
  31750. /**
  31751. * The current size of the particle.
  31752. */
  31753. size: number;
  31754. /**
  31755. * The current scale of the particle.
  31756. */
  31757. scale: Vector2;
  31758. /**
  31759. * The current angle of the particle.
  31760. */
  31761. angle: number;
  31762. /**
  31763. * Defines how fast is the angle changing.
  31764. */
  31765. angularSpeed: number;
  31766. /**
  31767. * Defines the cell index used by the particle to be rendered from a sprite.
  31768. */
  31769. cellIndex: number;
  31770. /**
  31771. * The information required to support color remapping
  31772. */
  31773. remapData: Vector4;
  31774. /** @hidden */
  31775. _randomCellOffset?: number;
  31776. /** @hidden */
  31777. _initialDirection: Nullable<Vector3>;
  31778. /** @hidden */
  31779. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  31780. /** @hidden */
  31781. _initialStartSpriteCellID: number;
  31782. /** @hidden */
  31783. _initialEndSpriteCellID: number;
  31784. /** @hidden */
  31785. _currentColorGradient: Nullable<ColorGradient>;
  31786. /** @hidden */
  31787. _currentColor1: Color4;
  31788. /** @hidden */
  31789. _currentColor2: Color4;
  31790. /** @hidden */
  31791. _currentSizeGradient: Nullable<FactorGradient>;
  31792. /** @hidden */
  31793. _currentSize1: number;
  31794. /** @hidden */
  31795. _currentSize2: number;
  31796. /** @hidden */
  31797. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  31798. /** @hidden */
  31799. _currentAngularSpeed1: number;
  31800. /** @hidden */
  31801. _currentAngularSpeed2: number;
  31802. /** @hidden */
  31803. _currentVelocityGradient: Nullable<FactorGradient>;
  31804. /** @hidden */
  31805. _currentVelocity1: number;
  31806. /** @hidden */
  31807. _currentVelocity2: number;
  31808. /** @hidden */
  31809. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  31810. /** @hidden */
  31811. _currentLimitVelocity1: number;
  31812. /** @hidden */
  31813. _currentLimitVelocity2: number;
  31814. /** @hidden */
  31815. _currentDragGradient: Nullable<FactorGradient>;
  31816. /** @hidden */
  31817. _currentDrag1: number;
  31818. /** @hidden */
  31819. _currentDrag2: number;
  31820. /** @hidden */
  31821. _randomNoiseCoordinates1: Vector3;
  31822. /** @hidden */
  31823. _randomNoiseCoordinates2: Vector3;
  31824. /**
  31825. * Creates a new instance Particle
  31826. * @param particleSystem the particle system the particle belongs to
  31827. */
  31828. constructor(
  31829. /**
  31830. * The particle system the particle belongs to.
  31831. */
  31832. particleSystem: ParticleSystem);
  31833. private updateCellInfoFromSystem;
  31834. /**
  31835. * Defines how the sprite cell index is updated for the particle
  31836. */
  31837. updateCellIndex(): void;
  31838. /** @hidden */
  31839. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  31840. /** @hidden */
  31841. _inheritParticleInfoToSubEmitters(): void;
  31842. /** @hidden */
  31843. _reset(): void;
  31844. /**
  31845. * Copy the properties of particle to another one.
  31846. * @param other the particle to copy the information to.
  31847. */
  31848. copyTo(other: Particle): void;
  31849. }
  31850. }
  31851. declare module BABYLON {
  31852. /**
  31853. * This class is made for on one-liner static method to help creating particle system set.
  31854. */
  31855. class ParticleHelper {
  31856. /**
  31857. * Gets or sets base Assets URL
  31858. */
  31859. static BaseAssetsUrl: string;
  31860. /**
  31861. * Create a default particle system that you can tweak
  31862. * @param emitter defines the emitter to use
  31863. * @param capacity defines the system capacity (default is 500 particles)
  31864. * @param scene defines the hosting scene
  31865. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  31866. * @returns the new Particle system
  31867. */
  31868. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  31869. /**
  31870. * This is the main static method (one-liner) of this helper to create different particle systems
  31871. * @param type This string represents the type to the particle system to create
  31872. * @param scene The scene where the particle system should live
  31873. * @param gpu If the system will use gpu
  31874. * @returns the ParticleSystemSet created
  31875. */
  31876. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  31877. /**
  31878. * Static function used to export a particle system to a ParticleSystemSet variable.
  31879. * Please note that the emitter shape is not exported
  31880. * @param systems defines the particle systems to export
  31881. * @returns the created particle system set
  31882. */
  31883. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  31884. }
  31885. }
  31886. declare module BABYLON {
  31887. /**
  31888. * This represents a particle system in Babylon.
  31889. * 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.
  31890. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  31891. * @example https://doc.babylonjs.com/babylon101/particles
  31892. */
  31893. class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  31894. /**
  31895. * Billboard mode will only apply to Y axis
  31896. */
  31897. static readonly BILLBOARDMODE_Y: number;
  31898. /**
  31899. * Billboard mode will apply to all axes
  31900. */
  31901. static readonly BILLBOARDMODE_ALL: number;
  31902. /**
  31903. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  31904. */
  31905. static readonly BILLBOARDMODE_STRETCHED: number;
  31906. /**
  31907. * This function can be defined to provide custom update for active particles.
  31908. * This function will be called instead of regular update (age, position, color, etc.).
  31909. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  31910. */
  31911. updateFunction: (particles: Particle[]) => void;
  31912. private _emitterWorldMatrix;
  31913. /**
  31914. * This function can be defined to specify initial direction for every new particle.
  31915. * It by default use the emitterType defined function
  31916. */
  31917. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  31918. /**
  31919. * This function can be defined to specify initial position for every new particle.
  31920. * It by default use the emitterType defined function
  31921. */
  31922. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  31923. /**
  31924. * @hidden
  31925. */
  31926. _inheritedVelocityOffset: Vector3;
  31927. /**
  31928. * An event triggered when the system is disposed
  31929. */
  31930. onDisposeObservable: Observable<ParticleSystem>;
  31931. private _onDisposeObserver;
  31932. /**
  31933. * Sets a callback that will be triggered when the system is disposed
  31934. */
  31935. onDispose: () => void;
  31936. private _particles;
  31937. private _epsilon;
  31938. private _capacity;
  31939. private _stockParticles;
  31940. private _newPartsExcess;
  31941. private _vertexData;
  31942. private _vertexBuffer;
  31943. private _vertexBuffers;
  31944. private _spriteBuffer;
  31945. private _indexBuffer;
  31946. private _effect;
  31947. private _customEffect;
  31948. private _cachedDefines;
  31949. private _scaledColorStep;
  31950. private _colorDiff;
  31951. private _scaledDirection;
  31952. private _scaledGravity;
  31953. private _currentRenderId;
  31954. private _alive;
  31955. private _useInstancing;
  31956. private _started;
  31957. private _stopped;
  31958. private _actualFrame;
  31959. private _scaledUpdateSpeed;
  31960. private _vertexBufferSize;
  31961. /** @hidden */
  31962. _currentEmitRateGradient: Nullable<FactorGradient>;
  31963. /** @hidden */
  31964. _currentEmitRate1: number;
  31965. /** @hidden */
  31966. _currentEmitRate2: number;
  31967. /** @hidden */
  31968. _currentStartSizeGradient: Nullable<FactorGradient>;
  31969. /** @hidden */
  31970. _currentStartSize1: number;
  31971. /** @hidden */
  31972. _currentStartSize2: number;
  31973. private readonly _rawTextureWidth;
  31974. private _rampGradientsTexture;
  31975. private _useRampGradients;
  31976. /** Gets or sets a boolean indicating that ramp gradients must be used
  31977. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  31978. */
  31979. useRampGradients: boolean;
  31980. /**
  31981. * 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.
  31982. * 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: [])
  31983. */
  31984. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  31985. private _subEmitters;
  31986. /**
  31987. * @hidden
  31988. * If the particle systems emitter should be disposed when the particle system is disposed
  31989. */
  31990. _disposeEmitterOnDispose: boolean;
  31991. /**
  31992. * The current active Sub-systems, this property is used by the root particle system only.
  31993. */
  31994. activeSubSystems: Array<ParticleSystem>;
  31995. private _rootParticleSystem;
  31996. /**
  31997. * Gets the current list of active particles
  31998. */
  31999. readonly particles: Particle[];
  32000. /**
  32001. * Returns the string "ParticleSystem"
  32002. * @returns a string containing the class name
  32003. */
  32004. getClassName(): string;
  32005. /**
  32006. * Instantiates a particle system.
  32007. * 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.
  32008. * @param name The name of the particle system
  32009. * @param capacity The max number of particles alive at the same time
  32010. * @param scene The scene the particle system belongs to
  32011. * @param customEffect a custom effect used to change the way particles are rendered by default
  32012. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  32013. * @param epsilon Offset used to render the particles
  32014. */
  32015. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  32016. private _addFactorGradient;
  32017. private _removeFactorGradient;
  32018. /**
  32019. * Adds a new life time gradient
  32020. * @param gradient defines the gradient to use (between 0 and 1)
  32021. * @param factor defines the life time factor to affect to the specified gradient
  32022. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32023. * @returns the current particle system
  32024. */
  32025. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32026. /**
  32027. * Remove a specific life time gradient
  32028. * @param gradient defines the gradient to remove
  32029. * @returns the current particle system
  32030. */
  32031. removeLifeTimeGradient(gradient: number): IParticleSystem;
  32032. /**
  32033. * Adds a new size gradient
  32034. * @param gradient defines the gradient to use (between 0 and 1)
  32035. * @param factor defines the size factor to affect to the specified gradient
  32036. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32037. * @returns the current particle system
  32038. */
  32039. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32040. /**
  32041. * Remove a specific size gradient
  32042. * @param gradient defines the gradient to remove
  32043. * @returns the current particle system
  32044. */
  32045. removeSizeGradient(gradient: number): IParticleSystem;
  32046. /**
  32047. * Adds a new color remap gradient
  32048. * @param gradient defines the gradient to use (between 0 and 1)
  32049. * @param min defines the color remap minimal range
  32050. * @param max defines the color remap maximal range
  32051. * @returns the current particle system
  32052. */
  32053. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  32054. /**
  32055. * Remove a specific color remap gradient
  32056. * @param gradient defines the gradient to remove
  32057. * @returns the current particle system
  32058. */
  32059. removeColorRemapGradient(gradient: number): IParticleSystem;
  32060. /**
  32061. * Adds a new alpha remap gradient
  32062. * @param gradient defines the gradient to use (between 0 and 1)
  32063. * @param min defines the alpha remap minimal range
  32064. * @param max defines the alpha remap maximal range
  32065. * @returns the current particle system
  32066. */
  32067. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  32068. /**
  32069. * Remove a specific alpha remap gradient
  32070. * @param gradient defines the gradient to remove
  32071. * @returns the current particle system
  32072. */
  32073. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  32074. /**
  32075. * Adds a new angular speed gradient
  32076. * @param gradient defines the gradient to use (between 0 and 1)
  32077. * @param factor defines the angular speed to affect to the specified gradient
  32078. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32079. * @returns the current particle system
  32080. */
  32081. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32082. /**
  32083. * Remove a specific angular speed gradient
  32084. * @param gradient defines the gradient to remove
  32085. * @returns the current particle system
  32086. */
  32087. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  32088. /**
  32089. * Adds a new velocity gradient
  32090. * @param gradient defines the gradient to use (between 0 and 1)
  32091. * @param factor defines the velocity to affect to the specified gradient
  32092. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32093. * @returns the current particle system
  32094. */
  32095. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32096. /**
  32097. * Remove a specific velocity gradient
  32098. * @param gradient defines the gradient to remove
  32099. * @returns the current particle system
  32100. */
  32101. removeVelocityGradient(gradient: number): IParticleSystem;
  32102. /**
  32103. * Adds a new limit velocity gradient
  32104. * @param gradient defines the gradient to use (between 0 and 1)
  32105. * @param factor defines the limit velocity value to affect to the specified gradient
  32106. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32107. * @returns the current particle system
  32108. */
  32109. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32110. /**
  32111. * Remove a specific limit velocity gradient
  32112. * @param gradient defines the gradient to remove
  32113. * @returns the current particle system
  32114. */
  32115. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  32116. /**
  32117. * Adds a new drag gradient
  32118. * @param gradient defines the gradient to use (between 0 and 1)
  32119. * @param factor defines the drag value to affect to the specified gradient
  32120. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32121. * @returns the current particle system
  32122. */
  32123. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32124. /**
  32125. * Remove a specific drag gradient
  32126. * @param gradient defines the gradient to remove
  32127. * @returns the current particle system
  32128. */
  32129. removeDragGradient(gradient: number): IParticleSystem;
  32130. /**
  32131. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  32132. * @param gradient defines the gradient to use (between 0 and 1)
  32133. * @param factor defines the emit rate value to affect to the specified gradient
  32134. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32135. * @returns the current particle system
  32136. */
  32137. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32138. /**
  32139. * Remove a specific emit rate gradient
  32140. * @param gradient defines the gradient to remove
  32141. * @returns the current particle system
  32142. */
  32143. removeEmitRateGradient(gradient: number): IParticleSystem;
  32144. /**
  32145. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  32146. * @param gradient defines the gradient to use (between 0 and 1)
  32147. * @param factor defines the start size value to affect to the specified gradient
  32148. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32149. * @returns the current particle system
  32150. */
  32151. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32152. /**
  32153. * Remove a specific start size gradient
  32154. * @param gradient defines the gradient to remove
  32155. * @returns the current particle system
  32156. */
  32157. removeStartSizeGradient(gradient: number): IParticleSystem;
  32158. private _createRampGradientTexture;
  32159. /**
  32160. * Gets the current list of ramp gradients.
  32161. * You must use addRampGradient and removeRampGradient to udpate this list
  32162. * @returns the list of ramp gradients
  32163. */
  32164. getRampGradients(): Nullable<Array<Color3Gradient>>;
  32165. /**
  32166. * Adds a new ramp gradient used to remap particle colors
  32167. * @param gradient defines the gradient to use (between 0 and 1)
  32168. * @param color defines the color to affect to the specified gradient
  32169. * @returns the current particle system
  32170. */
  32171. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  32172. /**
  32173. * Remove a specific ramp gradient
  32174. * @param gradient defines the gradient to remove
  32175. * @returns the current particle system
  32176. */
  32177. removeRampGradient(gradient: number): ParticleSystem;
  32178. /**
  32179. * Adds a new color gradient
  32180. * @param gradient defines the gradient to use (between 0 and 1)
  32181. * @param color1 defines the color to affect to the specified gradient
  32182. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  32183. * @returns this particle system
  32184. */
  32185. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  32186. /**
  32187. * Remove a specific color gradient
  32188. * @param gradient defines the gradient to remove
  32189. * @returns this particle system
  32190. */
  32191. removeColorGradient(gradient: number): IParticleSystem;
  32192. private _fetchR;
  32193. protected _reset(): void;
  32194. private _resetEffect;
  32195. private _createVertexBuffers;
  32196. private _createIndexBuffer;
  32197. /**
  32198. * Gets the maximum number of particles active at the same time.
  32199. * @returns The max number of active particles.
  32200. */
  32201. getCapacity(): number;
  32202. /**
  32203. * Gets whether there are still active particles in the system.
  32204. * @returns True if it is alive, otherwise false.
  32205. */
  32206. isAlive(): boolean;
  32207. /**
  32208. * Gets if the system has been started. (Note: this will still be true after stop is called)
  32209. * @returns True if it has been started, otherwise false.
  32210. */
  32211. isStarted(): boolean;
  32212. private _prepareSubEmitterInternalArray;
  32213. /**
  32214. * Starts the particle system and begins to emit
  32215. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  32216. */
  32217. start(delay?: number): void;
  32218. /**
  32219. * Stops the particle system.
  32220. * @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.
  32221. */
  32222. stop(stopSubEmitters?: boolean): void;
  32223. /**
  32224. * Remove all active particles
  32225. */
  32226. reset(): void;
  32227. /**
  32228. * @hidden (for internal use only)
  32229. */
  32230. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  32231. /**
  32232. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  32233. * Its lifetime will start back at 0.
  32234. */
  32235. recycleParticle: (particle: Particle) => void;
  32236. private _stopSubEmitters;
  32237. private _createParticle;
  32238. private _removeFromRoot;
  32239. private _emitFromParticle;
  32240. private _update;
  32241. /** @hidden */
  32242. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  32243. /** @hidden */
  32244. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  32245. /** @hidden */
  32246. private _getEffect;
  32247. /**
  32248. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  32249. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  32250. */
  32251. animate(preWarmOnly?: boolean): void;
  32252. private _appendParticleVertices;
  32253. /**
  32254. * Rebuilds the particle system.
  32255. */
  32256. rebuild(): void;
  32257. /**
  32258. * Is this system ready to be used/rendered
  32259. * @return true if the system is ready
  32260. */
  32261. isReady(): boolean;
  32262. private _render;
  32263. /**
  32264. * Renders the particle system in its current state.
  32265. * @returns the current number of particles
  32266. */
  32267. render(): number;
  32268. /**
  32269. * Disposes the particle system and free the associated resources
  32270. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  32271. */
  32272. dispose(disposeTexture?: boolean): void;
  32273. /**
  32274. * Clones the particle system.
  32275. * @param name The name of the cloned object
  32276. * @param newEmitter The new emitter to use
  32277. * @returns the cloned particle system
  32278. */
  32279. clone(name: string, newEmitter: any): ParticleSystem;
  32280. /**
  32281. * Serializes the particle system to a JSON object.
  32282. * @returns the JSON object
  32283. */
  32284. serialize(): any;
  32285. /** @hidden */
  32286. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  32287. /** @hidden */
  32288. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  32289. /**
  32290. * Parses a JSON object to create a particle system.
  32291. * @param parsedParticleSystem The JSON object to parse
  32292. * @param scene The scene to create the particle system in
  32293. * @param rootUrl The root url to use to load external dependencies like texture
  32294. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  32295. * @returns the Parsed particle system
  32296. */
  32297. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  32298. }
  32299. }
  32300. declare module BABYLON {
  32301. interface Engine {
  32302. /**
  32303. * Create an effect to use with particle systems.
  32304. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  32305. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  32306. * @param uniformsNames defines a list of attribute names
  32307. * @param samplers defines an array of string used to represent textures
  32308. * @param defines defines the string containing the defines to use to compile the shaders
  32309. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  32310. * @param onCompiled defines a function to call when the effect creation is successful
  32311. * @param onError defines a function to call when the effect creation has failed
  32312. * @returns the new Effect
  32313. */
  32314. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  32315. }
  32316. interface Mesh {
  32317. /**
  32318. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  32319. * @returns an array of IParticleSystem
  32320. */
  32321. getEmittedParticleSystems(): IParticleSystem[];
  32322. /**
  32323. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  32324. * @returns an array of IParticleSystem
  32325. */
  32326. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  32327. }
  32328. }
  32329. declare module BABYLON {
  32330. /**
  32331. * Represents a set of particle systems working together to create a specific effect
  32332. */
  32333. class ParticleSystemSet implements IDisposable {
  32334. private _emitterCreationOptions;
  32335. private _emitterNode;
  32336. /**
  32337. * Gets the particle system list
  32338. */
  32339. systems: IParticleSystem[];
  32340. /**
  32341. * Gets the emitter node used with this set
  32342. */
  32343. readonly emitterNode: Nullable<TransformNode>;
  32344. /**
  32345. * Creates a new emitter mesh as a sphere
  32346. * @param options defines the options used to create the sphere
  32347. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  32348. * @param scene defines the hosting scene
  32349. */
  32350. setEmitterAsSphere(options: {
  32351. diameter: number;
  32352. segments: number;
  32353. color: Color3;
  32354. }, renderingGroupId: number, scene: Scene): void;
  32355. /**
  32356. * Starts all particle systems of the set
  32357. * @param emitter defines an optional mesh to use as emitter for the particle systems
  32358. */
  32359. start(emitter?: AbstractMesh): void;
  32360. /**
  32361. * Release all associated resources
  32362. */
  32363. dispose(): void;
  32364. /**
  32365. * Serialize the set into a JSON compatible object
  32366. * @returns a JSON compatible representation of the set
  32367. */
  32368. serialize(): any;
  32369. /**
  32370. * Parse a new ParticleSystemSet from a serialized source
  32371. * @param data defines a JSON compatible representation of the set
  32372. * @param scene defines the hosting scene
  32373. * @param gpu defines if we want GPU particles or CPU particles
  32374. * @returns a new ParticleSystemSet
  32375. */
  32376. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  32377. }
  32378. }
  32379. declare module BABYLON {
  32380. /**
  32381. * Represents one particle of a solid particle system.
  32382. */
  32383. class SolidParticle {
  32384. /**
  32385. * particle global index
  32386. */
  32387. idx: number;
  32388. /**
  32389. * The color of the particle
  32390. */
  32391. color: Nullable<Color4>;
  32392. /**
  32393. * The world space position of the particle.
  32394. */
  32395. position: Vector3;
  32396. /**
  32397. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  32398. */
  32399. rotation: Vector3;
  32400. /**
  32401. * The world space rotation quaternion of the particle.
  32402. */
  32403. rotationQuaternion: Nullable<Quaternion>;
  32404. /**
  32405. * The scaling of the particle.
  32406. */
  32407. scaling: Vector3;
  32408. /**
  32409. * The uvs of the particle.
  32410. */
  32411. uvs: Vector4;
  32412. /**
  32413. * The current speed of the particle.
  32414. */
  32415. velocity: Vector3;
  32416. /**
  32417. * The pivot point in the particle local space.
  32418. */
  32419. pivot: Vector3;
  32420. /**
  32421. * Must the particle be translated from its pivot point in its local space ?
  32422. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  32423. * Default : false
  32424. */
  32425. translateFromPivot: boolean;
  32426. /**
  32427. * Is the particle active or not ?
  32428. */
  32429. alive: boolean;
  32430. /**
  32431. * Is the particle visible or not ?
  32432. */
  32433. isVisible: boolean;
  32434. /**
  32435. * Index of this particle in the global "positions" array (Internal use)
  32436. * @hidden
  32437. */
  32438. _pos: number;
  32439. /**
  32440. * @hidden Index of this particle in the global "indices" array (Internal use)
  32441. */
  32442. _ind: number;
  32443. /**
  32444. * @hidden ModelShape of this particle (Internal use)
  32445. */
  32446. _model: ModelShape;
  32447. /**
  32448. * ModelShape id of this particle
  32449. */
  32450. shapeId: number;
  32451. /**
  32452. * Index of the particle in its shape id (Internal use)
  32453. */
  32454. idxInShape: number;
  32455. /**
  32456. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  32457. */
  32458. _modelBoundingInfo: BoundingInfo;
  32459. /**
  32460. * @hidden Particle BoundingInfo object (Internal use)
  32461. */
  32462. _boundingInfo: BoundingInfo;
  32463. /**
  32464. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  32465. */
  32466. _sps: SolidParticleSystem;
  32467. /**
  32468. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  32469. */
  32470. _stillInvisible: boolean;
  32471. /**
  32472. * @hidden Last computed particle rotation matrix
  32473. */
  32474. _rotationMatrix: number[];
  32475. /**
  32476. * Parent particle Id, if any.
  32477. * Default null.
  32478. */
  32479. parentId: Nullable<number>;
  32480. /**
  32481. * @hidden Internal global position in the SPS.
  32482. */
  32483. _globalPosition: Vector3;
  32484. /**
  32485. * Creates a Solid Particle object.
  32486. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  32487. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  32488. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  32489. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  32490. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  32491. * @param shapeId (integer) is the model shape identifier in the SPS.
  32492. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  32493. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  32494. */
  32495. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  32496. /**
  32497. * Legacy support, changed scale to scaling
  32498. */
  32499. /**
  32500. * Legacy support, changed scale to scaling
  32501. */
  32502. scale: Vector3;
  32503. /**
  32504. * Legacy support, changed quaternion to rotationQuaternion
  32505. */
  32506. /**
  32507. * Legacy support, changed quaternion to rotationQuaternion
  32508. */
  32509. quaternion: Nullable<Quaternion>;
  32510. /**
  32511. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  32512. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  32513. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  32514. * @returns true if it intersects
  32515. */
  32516. intersectsMesh(target: Mesh | SolidParticle): boolean;
  32517. /**
  32518. * get the rotation matrix of the particle
  32519. * @hidden
  32520. */
  32521. getRotationMatrix(m: Matrix): void;
  32522. }
  32523. /**
  32524. * Represents the shape of the model used by one particle of a solid particle system.
  32525. * SPS internal tool, don't use it manually.
  32526. */
  32527. class ModelShape {
  32528. /**
  32529. * The shape id
  32530. * @hidden
  32531. */
  32532. shapeID: number;
  32533. /**
  32534. * flat array of model positions (internal use)
  32535. * @hidden
  32536. */
  32537. _shape: Vector3[];
  32538. /**
  32539. * flat array of model UVs (internal use)
  32540. * @hidden
  32541. */
  32542. _shapeUV: number[];
  32543. /**
  32544. * length of the shape in the model indices array (internal use)
  32545. * @hidden
  32546. */
  32547. _indicesLength: number;
  32548. /**
  32549. * Custom position function (internal use)
  32550. * @hidden
  32551. */
  32552. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  32553. /**
  32554. * Custom vertex function (internal use)
  32555. * @hidden
  32556. */
  32557. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  32558. /**
  32559. * 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.
  32560. * SPS internal tool, don't use it manually.
  32561. * @hidden
  32562. */
  32563. 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>);
  32564. }
  32565. /**
  32566. * Represents a Depth Sorted Particle in the solid particle system.
  32567. */
  32568. class DepthSortedParticle {
  32569. /**
  32570. * Index of the particle in the "indices" array
  32571. */
  32572. ind: number;
  32573. /**
  32574. * Length of the particle shape in the "indices" array
  32575. */
  32576. indicesLength: number;
  32577. /**
  32578. * Squared distance from the particle to the camera
  32579. */
  32580. sqDistance: number;
  32581. }
  32582. }
  32583. declare module BABYLON {
  32584. /**
  32585. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  32586. *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.
  32587. * The SPS is also a particle system. It provides some methods to manage the particles.
  32588. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  32589. *
  32590. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  32591. */
  32592. class SolidParticleSystem implements IDisposable {
  32593. /**
  32594. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  32595. * Example : var p = SPS.particles[i];
  32596. */
  32597. particles: SolidParticle[];
  32598. /**
  32599. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  32600. */
  32601. nbParticles: number;
  32602. /**
  32603. * If the particles must ever face the camera (default false). Useful for planar particles.
  32604. */
  32605. billboard: boolean;
  32606. /**
  32607. * Recompute normals when adding a shape
  32608. */
  32609. recomputeNormals: boolean;
  32610. /**
  32611. * This a counter ofr your own usage. It's not set by any SPS functions.
  32612. */
  32613. counter: number;
  32614. /**
  32615. * The SPS name. This name is also given to the underlying mesh.
  32616. */
  32617. name: string;
  32618. /**
  32619. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  32620. */
  32621. mesh: Mesh;
  32622. /**
  32623. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  32624. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  32625. */
  32626. vars: any;
  32627. /**
  32628. * This array is populated when the SPS is set as 'pickable'.
  32629. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  32630. * Each element of this array is an object `{idx: int, faceId: int}`.
  32631. * `idx` is the picked particle index in the `SPS.particles` array
  32632. * `faceId` is the picked face index counted within this particle.
  32633. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  32634. */
  32635. pickedParticles: {
  32636. idx: number;
  32637. faceId: number;
  32638. }[];
  32639. /**
  32640. * This array is populated when `enableDepthSort` is set to true.
  32641. * Each element of this array is an instance of the class DepthSortedParticle.
  32642. */
  32643. depthSortedParticles: DepthSortedParticle[];
  32644. /**
  32645. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  32646. * @hidden
  32647. */
  32648. _bSphereOnly: boolean;
  32649. /**
  32650. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  32651. * @hidden
  32652. */
  32653. _bSphereRadiusFactor: number;
  32654. private _scene;
  32655. private _positions;
  32656. private _indices;
  32657. private _normals;
  32658. private _colors;
  32659. private _uvs;
  32660. private _indices32;
  32661. private _positions32;
  32662. private _normals32;
  32663. private _fixedNormal32;
  32664. private _colors32;
  32665. private _uvs32;
  32666. private _index;
  32667. private _updatable;
  32668. private _pickable;
  32669. private _isVisibilityBoxLocked;
  32670. private _alwaysVisible;
  32671. private _depthSort;
  32672. private _shapeCounter;
  32673. private _copy;
  32674. private _color;
  32675. private _computeParticleColor;
  32676. private _computeParticleTexture;
  32677. private _computeParticleRotation;
  32678. private _computeParticleVertex;
  32679. private _computeBoundingBox;
  32680. private _depthSortParticles;
  32681. private _camera;
  32682. private _mustUnrotateFixedNormals;
  32683. private _particlesIntersect;
  32684. private _needs32Bits;
  32685. /**
  32686. * Creates a SPS (Solid Particle System) object.
  32687. * @param name (String) is the SPS name, this will be the underlying mesh name.
  32688. * @param scene (Scene) is the scene in which the SPS is added.
  32689. * @param updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  32690. * @param isPickable (optional boolean, default false) : if the solid particles must be pickable.
  32691. * @param enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  32692. * @param particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  32693. * @param boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  32694. * @param bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  32695. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  32696. */
  32697. constructor(name: string, scene: Scene, options?: {
  32698. updatable?: boolean;
  32699. isPickable?: boolean;
  32700. enableDepthSort?: boolean;
  32701. particleIntersection?: boolean;
  32702. boundingSphereOnly?: boolean;
  32703. bSphereRadiusFactor?: number;
  32704. });
  32705. /**
  32706. * Builds the SPS underlying mesh. Returns a standard Mesh.
  32707. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  32708. * @returns the created mesh
  32709. */
  32710. buildMesh(): Mesh;
  32711. /**
  32712. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  32713. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  32714. * Thus the particles generated from `digest()` have their property `position` set yet.
  32715. * @param mesh ( Mesh ) is the mesh to be digested
  32716. * @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
  32717. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  32718. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  32719. * @returns the current SPS
  32720. */
  32721. digest(mesh: Mesh, options?: {
  32722. facetNb?: number;
  32723. number?: number;
  32724. delta?: number;
  32725. }): SolidParticleSystem;
  32726. private _unrotateFixedNormals;
  32727. private _resetCopy;
  32728. private _meshBuilder;
  32729. private _posToShape;
  32730. private _uvsToShapeUV;
  32731. private _addParticle;
  32732. /**
  32733. * Adds some particles to the SPS from the model shape. Returns the shape id.
  32734. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  32735. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  32736. * @param nb (positive integer) the number of particles to be created from this model
  32737. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  32738. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  32739. * @returns the number of shapes in the system
  32740. */
  32741. addShape(mesh: Mesh, nb: number, options?: {
  32742. positionFunction?: any;
  32743. vertexFunction?: any;
  32744. }): number;
  32745. private _rebuildParticle;
  32746. /**
  32747. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  32748. * @returns the SPS.
  32749. */
  32750. rebuildMesh(): SolidParticleSystem;
  32751. /**
  32752. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  32753. * This method calls `updateParticle()` for each particle of the SPS.
  32754. * For an animated SPS, it is usually called within the render loop.
  32755. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  32756. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  32757. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  32758. * @returns the SPS.
  32759. */
  32760. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  32761. /**
  32762. * Disposes the SPS.
  32763. */
  32764. dispose(): void;
  32765. /**
  32766. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  32767. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32768. * @returns the SPS.
  32769. */
  32770. refreshVisibleSize(): SolidParticleSystem;
  32771. /**
  32772. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  32773. * @param size the size (float) of the visibility box
  32774. * note : this doesn't lock the SPS mesh bounding box.
  32775. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32776. */
  32777. setVisibilityBox(size: number): void;
  32778. /**
  32779. * Gets whether the SPS as always visible or not
  32780. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32781. */
  32782. /**
  32783. * Sets the SPS as always visible or not
  32784. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32785. */
  32786. isAlwaysVisible: boolean;
  32787. /**
  32788. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  32789. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32790. */
  32791. /**
  32792. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  32793. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32794. */
  32795. isVisibilityBoxLocked: boolean;
  32796. /**
  32797. * Tells to `setParticles()` to compute the particle rotations or not.
  32798. * Default value : true. The SPS is faster when it's set to false.
  32799. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  32800. */
  32801. /**
  32802. * Gets if `setParticles()` computes the particle rotations or not.
  32803. * Default value : true. The SPS is faster when it's set to false.
  32804. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  32805. */
  32806. computeParticleRotation: boolean;
  32807. /**
  32808. * Tells to `setParticles()` to compute the particle colors or not.
  32809. * Default value : true. The SPS is faster when it's set to false.
  32810. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  32811. */
  32812. /**
  32813. * Gets if `setParticles()` computes the particle colors or not.
  32814. * Default value : true. The SPS is faster when it's set to false.
  32815. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  32816. */
  32817. computeParticleColor: boolean;
  32818. /**
  32819. * Gets if `setParticles()` computes the particle textures or not.
  32820. * Default value : true. The SPS is faster when it's set to false.
  32821. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  32822. */
  32823. computeParticleTexture: boolean;
  32824. /**
  32825. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  32826. * Default value : false. The SPS is faster when it's set to false.
  32827. * Note : the particle custom vertex positions aren't stored values.
  32828. */
  32829. /**
  32830. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  32831. * Default value : false. The SPS is faster when it's set to false.
  32832. * Note : the particle custom vertex positions aren't stored values.
  32833. */
  32834. computeParticleVertex: boolean;
  32835. /**
  32836. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  32837. */
  32838. /**
  32839. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  32840. */
  32841. computeBoundingBox: boolean;
  32842. /**
  32843. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  32844. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  32845. * Default : `true`
  32846. */
  32847. /**
  32848. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  32849. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  32850. * Default : `true`
  32851. */
  32852. depthSortParticles: boolean;
  32853. /**
  32854. * This function does nothing. It may be overwritten to set all the particle first values.
  32855. * The SPS doesn't call this function, you may have to call it by your own.
  32856. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  32857. */
  32858. initParticles(): void;
  32859. /**
  32860. * This function does nothing. It may be overwritten to recycle a particle.
  32861. * The SPS doesn't call this function, you may have to call it by your own.
  32862. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  32863. * @param particle The particle to recycle
  32864. * @returns the recycled particle
  32865. */
  32866. recycleParticle(particle: SolidParticle): SolidParticle;
  32867. /**
  32868. * Updates a particle : this function should be overwritten by the user.
  32869. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  32870. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  32871. * @example : just set a particle position or velocity and recycle conditions
  32872. * @param particle The particle to update
  32873. * @returns the updated particle
  32874. */
  32875. updateParticle(particle: SolidParticle): SolidParticle;
  32876. /**
  32877. * Updates a vertex of a particle : it can be overwritten by the user.
  32878. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  32879. * @param particle the current particle
  32880. * @param vertex the current index of the current particle
  32881. * @param pt the index of the current vertex in the particle shape
  32882. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  32883. * @example : just set a vertex particle position
  32884. * @returns the updated vertex
  32885. */
  32886. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  32887. /**
  32888. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  32889. * This does nothing and may be overwritten by the user.
  32890. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32891. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32892. * @param update the boolean update value actually passed to setParticles()
  32893. */
  32894. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  32895. /**
  32896. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  32897. * This will be passed three parameters.
  32898. * This does nothing and may be overwritten by the user.
  32899. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32900. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32901. * @param update the boolean update value actually passed to setParticles()
  32902. */
  32903. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  32904. }
  32905. }
  32906. declare module BABYLON {
  32907. /**
  32908. * Type of sub emitter
  32909. */
  32910. enum SubEmitterType {
  32911. /**
  32912. * Attached to the particle over it's lifetime
  32913. */
  32914. ATTACHED = 0,
  32915. /**
  32916. * Created when the particle dies
  32917. */
  32918. END = 1
  32919. }
  32920. /**
  32921. * Sub emitter class used to emit particles from an existing particle
  32922. */
  32923. class SubEmitter {
  32924. /**
  32925. * the particle system to be used by the sub emitter
  32926. */
  32927. particleSystem: ParticleSystem;
  32928. /**
  32929. * Type of the submitter (Default: END)
  32930. */
  32931. type: SubEmitterType;
  32932. /**
  32933. * 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)
  32934. * Note: This only is supported when using an emitter of type Mesh
  32935. */
  32936. inheritDirection: boolean;
  32937. /**
  32938. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  32939. */
  32940. inheritedVelocityAmount: number;
  32941. /**
  32942. * Creates a sub emitter
  32943. * @param particleSystem the particle system to be used by the sub emitter
  32944. */
  32945. constructor(
  32946. /**
  32947. * the particle system to be used by the sub emitter
  32948. */
  32949. particleSystem: ParticleSystem);
  32950. /**
  32951. * Clones the sub emitter
  32952. * @returns the cloned sub emitter
  32953. */
  32954. clone(): SubEmitter;
  32955. /**
  32956. * Serialize current object to a JSON object
  32957. * @returns the serialized object
  32958. */
  32959. serialize(): any;
  32960. /**
  32961. * Creates a new SubEmitter from a serialized JSON version
  32962. * @param serializationObject defines the JSON object to read from
  32963. * @param scene defines the hosting scene
  32964. * @param rootUrl defines the rootUrl for data loading
  32965. * @returns a new SubEmitter
  32966. */
  32967. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  32968. /** Release associated resources */
  32969. dispose(): void;
  32970. }
  32971. }
  32972. declare module BABYLON {
  32973. /**
  32974. * Interface used to describe a physics joint
  32975. */
  32976. interface PhysicsImpostorJoint {
  32977. /** Defines the main impostor to which the joint is linked */
  32978. mainImpostor: PhysicsImpostor;
  32979. /** Defines the impostor that is connected to the main impostor using this joint */
  32980. connectedImpostor: PhysicsImpostor;
  32981. /** Defines the joint itself */
  32982. joint: PhysicsJoint;
  32983. }
  32984. /** @hidden */
  32985. interface IPhysicsEnginePlugin {
  32986. world: any;
  32987. name: string;
  32988. setGravity(gravity: Vector3): void;
  32989. setTimeStep(timeStep: number): void;
  32990. getTimeStep(): number;
  32991. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  32992. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32993. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32994. generatePhysicsBody(impostor: PhysicsImpostor): void;
  32995. removePhysicsBody(impostor: PhysicsImpostor): void;
  32996. generateJoint(joint: PhysicsImpostorJoint): void;
  32997. removeJoint(joint: PhysicsImpostorJoint): void;
  32998. isSupported(): boolean;
  32999. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  33000. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  33001. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  33002. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  33003. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  33004. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  33005. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  33006. getBodyMass(impostor: PhysicsImpostor): number;
  33007. getBodyFriction(impostor: PhysicsImpostor): number;
  33008. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  33009. getBodyRestitution(impostor: PhysicsImpostor): number;
  33010. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  33011. sleepBody(impostor: PhysicsImpostor): void;
  33012. wakeUpBody(impostor: PhysicsImpostor): void;
  33013. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  33014. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  33015. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  33016. getRadius(impostor: PhysicsImpostor): number;
  33017. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  33018. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  33019. dispose(): void;
  33020. }
  33021. /**
  33022. * Interface used to define a physics engine
  33023. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  33024. */
  33025. interface IPhysicsEngine {
  33026. /**
  33027. * Gets the gravity vector used by the simulation
  33028. */
  33029. gravity: Vector3;
  33030. /**
  33031. * Sets the gravity vector used by the simulation
  33032. * @param gravity defines the gravity vector to use
  33033. */
  33034. setGravity(gravity: Vector3): void;
  33035. /**
  33036. * Set the time step of the physics engine.
  33037. * Default is 1/60.
  33038. * To slow it down, enter 1/600 for example.
  33039. * To speed it up, 1/30
  33040. * @param newTimeStep the new timestep to apply to this world.
  33041. */
  33042. setTimeStep(newTimeStep: number): void;
  33043. /**
  33044. * Get the time step of the physics engine.
  33045. * @returns the current time step
  33046. */
  33047. getTimeStep(): number;
  33048. /**
  33049. * Release all resources
  33050. */
  33051. dispose(): void;
  33052. /**
  33053. * Gets the name of the current physics plugin
  33054. * @returns the name of the plugin
  33055. */
  33056. getPhysicsPluginName(): string;
  33057. /**
  33058. * Adding a new impostor for the impostor tracking.
  33059. * This will be done by the impostor itself.
  33060. * @param impostor the impostor to add
  33061. */
  33062. addImpostor(impostor: PhysicsImpostor): void;
  33063. /**
  33064. * Remove an impostor from the engine.
  33065. * This impostor and its mesh will not longer be updated by the physics engine.
  33066. * @param impostor the impostor to remove
  33067. */
  33068. removeImpostor(impostor: PhysicsImpostor): void;
  33069. /**
  33070. * Add a joint to the physics engine
  33071. * @param mainImpostor defines the main impostor to which the joint is added.
  33072. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  33073. * @param joint defines the joint that will connect both impostors.
  33074. */
  33075. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  33076. /**
  33077. * Removes a joint from the simulation
  33078. * @param mainImpostor defines the impostor used with the joint
  33079. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  33080. * @param joint defines the joint to remove
  33081. */
  33082. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  33083. /**
  33084. * Gets the current plugin used to run the simulation
  33085. * @returns current plugin
  33086. */
  33087. getPhysicsPlugin(): IPhysicsEnginePlugin;
  33088. /**
  33089. * Gets the list of physic impostors
  33090. * @returns an array of PhysicsImpostor
  33091. */
  33092. getImpostors(): Array<PhysicsImpostor>;
  33093. /**
  33094. * Gets the impostor for a physics enabled object
  33095. * @param object defines the object impersonated by the impostor
  33096. * @returns the PhysicsImpostor or null if not found
  33097. */
  33098. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  33099. /**
  33100. * Gets the impostor for a physics body object
  33101. * @param body defines physics body used by the impostor
  33102. * @returns the PhysicsImpostor or null if not found
  33103. */
  33104. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  33105. /**
  33106. * Called by the scene. No need to call it.
  33107. * @param delta defines the timespam between frames
  33108. */
  33109. _step(delta: number): void;
  33110. }
  33111. }
  33112. declare module BABYLON {
  33113. /**
  33114. * Class used to control physics engine
  33115. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  33116. */
  33117. class PhysicsEngine implements IPhysicsEngine {
  33118. private _physicsPlugin;
  33119. /**
  33120. * Global value used to control the smallest number supported by the simulation
  33121. */
  33122. static Epsilon: number;
  33123. private _impostors;
  33124. private _joints;
  33125. /**
  33126. * Gets the gravity vector used by the simulation
  33127. */
  33128. gravity: Vector3;
  33129. /**
  33130. * Creates a new Physics Engine
  33131. * @param gravity defines the gravity vector used by the simulation
  33132. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  33133. */
  33134. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  33135. /**
  33136. * Sets the gravity vector used by the simulation
  33137. * @param gravity defines the gravity vector to use
  33138. */
  33139. setGravity(gravity: Vector3): void;
  33140. /**
  33141. * Set the time step of the physics engine.
  33142. * Default is 1/60.
  33143. * To slow it down, enter 1/600 for example.
  33144. * To speed it up, 1/30
  33145. * @param newTimeStep defines the new timestep to apply to this world.
  33146. */
  33147. setTimeStep(newTimeStep?: number): void;
  33148. /**
  33149. * Get the time step of the physics engine.
  33150. * @returns the current time step
  33151. */
  33152. getTimeStep(): number;
  33153. /**
  33154. * Release all resources
  33155. */
  33156. dispose(): void;
  33157. /**
  33158. * Gets the name of the current physics plugin
  33159. * @returns the name of the plugin
  33160. */
  33161. getPhysicsPluginName(): string;
  33162. /**
  33163. * Adding a new impostor for the impostor tracking.
  33164. * This will be done by the impostor itself.
  33165. * @param impostor the impostor to add
  33166. */
  33167. addImpostor(impostor: PhysicsImpostor): void;
  33168. /**
  33169. * Remove an impostor from the engine.
  33170. * This impostor and its mesh will not longer be updated by the physics engine.
  33171. * @param impostor the impostor to remove
  33172. */
  33173. removeImpostor(impostor: PhysicsImpostor): void;
  33174. /**
  33175. * Add a joint to the physics engine
  33176. * @param mainImpostor defines the main impostor to which the joint is added.
  33177. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  33178. * @param joint defines the joint that will connect both impostors.
  33179. */
  33180. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  33181. /**
  33182. * Removes a joint from the simulation
  33183. * @param mainImpostor defines the impostor used with the joint
  33184. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  33185. * @param joint defines the joint to remove
  33186. */
  33187. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  33188. /**
  33189. * Called by the scene. No need to call it.
  33190. * @param delta defines the timespam between frames
  33191. */
  33192. _step(delta: number): void;
  33193. /**
  33194. * Gets the current plugin used to run the simulation
  33195. * @returns current plugin
  33196. */
  33197. getPhysicsPlugin(): IPhysicsEnginePlugin;
  33198. /**
  33199. * Gets the list of physic impostors
  33200. * @returns an array of PhysicsImpostor
  33201. */
  33202. getImpostors(): Array<PhysicsImpostor>;
  33203. /**
  33204. * Gets the impostor for a physics enabled object
  33205. * @param object defines the object impersonated by the impostor
  33206. * @returns the PhysicsImpostor or null if not found
  33207. */
  33208. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  33209. /**
  33210. * Gets the impostor for a physics body object
  33211. * @param body defines physics body used by the impostor
  33212. * @returns the PhysicsImpostor or null if not found
  33213. */
  33214. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  33215. }
  33216. }
  33217. declare module BABYLON {
  33218. interface Scene {
  33219. /** @hidden (Backing field) */
  33220. _physicsEngine: Nullable<IPhysicsEngine>;
  33221. /**
  33222. * Gets the current physics engine
  33223. * @returns a IPhysicsEngine or null if none attached
  33224. */
  33225. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  33226. /**
  33227. * Enables physics to the current scene
  33228. * @param gravity defines the scene's gravity for the physics engine
  33229. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  33230. * @return a boolean indicating if the physics engine was initialized
  33231. */
  33232. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  33233. /**
  33234. * Disables and disposes the physics engine associated with the scene
  33235. */
  33236. disablePhysicsEngine(): void;
  33237. /**
  33238. * Gets a boolean indicating if there is an active physics engine
  33239. * @returns a boolean indicating if there is an active physics engine
  33240. */
  33241. isPhysicsEnabled(): boolean;
  33242. /**
  33243. * Deletes a physics compound impostor
  33244. * @param compound defines the compound to delete
  33245. */
  33246. deleteCompoundImpostor(compound: any): void;
  33247. /**
  33248. * An event triggered when physic simulation is about to be run
  33249. */
  33250. onBeforePhysicsObservable: Observable<Scene>;
  33251. /**
  33252. * An event triggered when physic simulation has been done
  33253. */
  33254. onAfterPhysicsObservable: Observable<Scene>;
  33255. }
  33256. interface AbstractMesh {
  33257. /** @hidden */
  33258. _physicsImpostor: Nullable<PhysicsImpostor>;
  33259. /**
  33260. * Gets or sets impostor used for physic simulation
  33261. * @see http://doc.babylonjs.com/features/physics_engine
  33262. */
  33263. physicsImpostor: Nullable<PhysicsImpostor>;
  33264. /**
  33265. * Gets the current physics impostor
  33266. * @see http://doc.babylonjs.com/features/physics_engine
  33267. * @returns a physics impostor or null
  33268. */
  33269. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  33270. /** Apply a physic impulse to the mesh
  33271. * @param force defines the force to apply
  33272. * @param contactPoint defines where to apply the force
  33273. * @returns the current mesh
  33274. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  33275. */
  33276. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  33277. /**
  33278. * Creates a physic joint between two meshes
  33279. * @param otherMesh defines the other mesh to use
  33280. * @param pivot1 defines the pivot to use on this mesh
  33281. * @param pivot2 defines the pivot to use on the other mesh
  33282. * @param options defines additional options (can be plugin dependent)
  33283. * @returns the current mesh
  33284. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  33285. */
  33286. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  33287. /** @hidden */
  33288. _disposePhysicsObserver: Nullable<Observer<Node>>;
  33289. }
  33290. /**
  33291. * Defines the physics engine scene component responsible to manage a physics engine
  33292. */
  33293. class PhysicsEngineSceneComponent implements ISceneComponent {
  33294. /**
  33295. * The component name helpful to identify the component in the list of scene components.
  33296. */
  33297. readonly name: string;
  33298. /**
  33299. * The scene the component belongs to.
  33300. */
  33301. scene: Scene;
  33302. /**
  33303. * Creates a new instance of the component for the given scene
  33304. * @param scene Defines the scene to register the component in
  33305. */
  33306. constructor(scene: Scene);
  33307. /**
  33308. * Registers the component in a given scene
  33309. */
  33310. register(): void;
  33311. /**
  33312. * Rebuilds the elements related to this component in case of
  33313. * context lost for instance.
  33314. */
  33315. rebuild(): void;
  33316. /**
  33317. * Disposes the component and the associated ressources
  33318. */
  33319. dispose(): void;
  33320. }
  33321. }
  33322. declare module BABYLON {
  33323. /**
  33324. * A helper for physics simulations
  33325. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33326. */
  33327. class PhysicsHelper {
  33328. private _scene;
  33329. private _physicsEngine;
  33330. /**
  33331. * Initializes the Physics helper
  33332. * @param scene Babylon.js scene
  33333. */
  33334. constructor(scene: Scene);
  33335. /**
  33336. * Applies a radial explosion impulse
  33337. * @param origin the origin of the explosion
  33338. * @param radius the explosion radius
  33339. * @param strength the explosion strength
  33340. * @param falloff possible options: Constant & Linear. Defaults to Constant
  33341. * @returns A physics radial explosion event, or null
  33342. */
  33343. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  33344. /**
  33345. * Applies a radial explosion force
  33346. * @param origin the origin of the explosion
  33347. * @param radius the explosion radius
  33348. * @param strength the explosion strength
  33349. * @param falloff possible options: Constant & Linear. Defaults to Constant
  33350. * @returns A physics radial explosion event, or null
  33351. */
  33352. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  33353. /**
  33354. * Creates a gravitational field
  33355. * @param origin the origin of the explosion
  33356. * @param radius the explosion radius
  33357. * @param strength the explosion strength
  33358. * @param falloff possible options: Constant & Linear. Defaults to Constant
  33359. * @returns A physics gravitational field event, or null
  33360. */
  33361. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  33362. /**
  33363. * Creates a physics updraft event
  33364. * @param origin the origin of the updraft
  33365. * @param radius the radius of the updraft
  33366. * @param strength the strength of the updraft
  33367. * @param height the height of the updraft
  33368. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  33369. * @returns A physics updraft event, or null
  33370. */
  33371. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  33372. /**
  33373. * Creates a physics vortex event
  33374. * @param origin the of the vortex
  33375. * @param radius the radius of the vortex
  33376. * @param strength the strength of the vortex
  33377. * @param height the height of the vortex
  33378. * @returns a Physics vortex event, or null
  33379. * A physics vortex event or null
  33380. */
  33381. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  33382. }
  33383. /**
  33384. * Represents a physics radial explosion event
  33385. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33386. */
  33387. class PhysicsRadialExplosionEvent {
  33388. private _scene;
  33389. private _sphere;
  33390. private _sphereOptions;
  33391. private _rays;
  33392. private _dataFetched;
  33393. /**
  33394. * Initializes a radial explosioin event
  33395. * @param scene BabylonJS scene
  33396. */
  33397. constructor(scene: Scene);
  33398. /**
  33399. * Returns the data related to the radial explosion event (sphere & rays).
  33400. * @returns The radial explosion event data
  33401. */
  33402. getData(): PhysicsRadialExplosionEventData;
  33403. /**
  33404. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  33405. * @param impostor A physics imposter
  33406. * @param origin the origin of the explosion
  33407. * @param radius the explosion radius
  33408. * @param strength the explosion strength
  33409. * @param falloff possible options: Constant & Linear
  33410. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  33411. */
  33412. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  33413. /**
  33414. * Disposes the sphere.
  33415. * @param force Specifies if the sphere should be disposed by force
  33416. */
  33417. dispose(force?: boolean): void;
  33418. /*** Helpers ***/
  33419. private _prepareSphere;
  33420. private _intersectsWithSphere;
  33421. }
  33422. /**
  33423. * Represents a gravitational field event
  33424. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33425. */
  33426. class PhysicsGravitationalFieldEvent {
  33427. private _physicsHelper;
  33428. private _scene;
  33429. private _origin;
  33430. private _radius;
  33431. private _strength;
  33432. private _falloff;
  33433. private _tickCallback;
  33434. private _sphere;
  33435. private _dataFetched;
  33436. /**
  33437. * Initializes the physics gravitational field event
  33438. * @param physicsHelper A physics helper
  33439. * @param scene BabylonJS scene
  33440. * @param origin The origin position of the gravitational field event
  33441. * @param radius The radius of the gravitational field event
  33442. * @param strength The strength of the gravitational field event
  33443. * @param falloff The falloff for the gravitational field event
  33444. */
  33445. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  33446. /**
  33447. * Returns the data related to the gravitational field event (sphere).
  33448. * @returns A gravitational field event
  33449. */
  33450. getData(): PhysicsGravitationalFieldEventData;
  33451. /**
  33452. * Enables the gravitational field.
  33453. */
  33454. enable(): void;
  33455. /**
  33456. * Disables the gravitational field.
  33457. */
  33458. disable(): void;
  33459. /**
  33460. * Disposes the sphere.
  33461. * @param force The force to dispose from the gravitational field event
  33462. */
  33463. dispose(force?: boolean): void;
  33464. private _tick;
  33465. }
  33466. /**
  33467. * Represents a physics updraft event
  33468. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33469. */
  33470. class PhysicsUpdraftEvent {
  33471. private _scene;
  33472. private _origin;
  33473. private _radius;
  33474. private _strength;
  33475. private _height;
  33476. private _updraftMode;
  33477. private _physicsEngine;
  33478. private _originTop;
  33479. private _originDirection;
  33480. private _tickCallback;
  33481. private _cylinder;
  33482. private _cylinderPosition;
  33483. private _dataFetched;
  33484. /**
  33485. * Initializes the physics updraft event
  33486. * @param _scene BabylonJS scene
  33487. * @param _origin The origin position of the updraft
  33488. * @param _radius The radius of the updraft
  33489. * @param _strength The strength of the updraft
  33490. * @param _height The height of the updraft
  33491. * @param _updraftMode The mode of the updraft
  33492. */
  33493. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  33494. /**
  33495. * Returns the data related to the updraft event (cylinder).
  33496. * @returns A physics updraft event
  33497. */
  33498. getData(): PhysicsUpdraftEventData;
  33499. /**
  33500. * Enables the updraft.
  33501. */
  33502. enable(): void;
  33503. /**
  33504. * Disables the cortex.
  33505. */
  33506. disable(): void;
  33507. /**
  33508. * Disposes the sphere.
  33509. * @param force Specifies if the updraft should be disposed by force
  33510. */
  33511. dispose(force?: boolean): void;
  33512. private getImpostorForceAndContactPoint;
  33513. private _tick;
  33514. /*** Helpers ***/
  33515. private _prepareCylinder;
  33516. private _intersectsWithCylinder;
  33517. }
  33518. /**
  33519. * Represents a physics vortex event
  33520. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33521. */
  33522. class PhysicsVortexEvent {
  33523. private _scene;
  33524. private _origin;
  33525. private _radius;
  33526. private _strength;
  33527. private _height;
  33528. private _physicsEngine;
  33529. private _originTop;
  33530. private _centripetalForceThreshold;
  33531. private _updraftMultiplier;
  33532. private _tickCallback;
  33533. private _cylinder;
  33534. private _cylinderPosition;
  33535. private _dataFetched;
  33536. /**
  33537. * Initializes the physics vortex event
  33538. * @param _scene The BabylonJS scene
  33539. * @param _origin The origin position of the vortex
  33540. * @param _radius The radius of the vortex
  33541. * @param _strength The strength of the vortex
  33542. * @param _height The height of the vortex
  33543. */
  33544. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  33545. /**
  33546. * Returns the data related to the vortex event (cylinder).
  33547. * @returns The physics vortex event data
  33548. */
  33549. getData(): PhysicsVortexEventData;
  33550. /**
  33551. * Enables the vortex.
  33552. */
  33553. enable(): void;
  33554. /**
  33555. * Disables the cortex.
  33556. */
  33557. disable(): void;
  33558. /**
  33559. * Disposes the sphere.
  33560. * @param force
  33561. */
  33562. dispose(force?: boolean): void;
  33563. private getImpostorForceAndContactPoint;
  33564. private _tick;
  33565. /*** Helpers ***/
  33566. private _prepareCylinder;
  33567. private _intersectsWithCylinder;
  33568. }
  33569. /**
  33570. * The strenght of the force in correspondence to the distance of the affected object
  33571. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33572. */
  33573. enum PhysicsRadialImpulseFalloff {
  33574. /** Defines that impulse is constant in strength across it's whole radius */
  33575. Constant = 0,
  33576. /** DEfines that impulse gets weaker if it's further from the origin */
  33577. Linear = 1
  33578. }
  33579. /**
  33580. * The strength of the force in correspondence to the distance of the affected object
  33581. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33582. */
  33583. enum PhysicsUpdraftMode {
  33584. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  33585. Center = 0,
  33586. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  33587. Perpendicular = 1
  33588. }
  33589. /**
  33590. * Interface for a physics force and contact point
  33591. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33592. */
  33593. interface PhysicsForceAndContactPoint {
  33594. /**
  33595. * The force applied at the contact point
  33596. */
  33597. force: Vector3;
  33598. /**
  33599. * The contact point
  33600. */
  33601. contactPoint: Vector3;
  33602. }
  33603. /**
  33604. * Interface for radial explosion event data
  33605. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33606. */
  33607. interface PhysicsRadialExplosionEventData {
  33608. /**
  33609. * A sphere used for the radial explosion event
  33610. */
  33611. sphere: Mesh;
  33612. /**
  33613. * An array of rays for the radial explosion event
  33614. */
  33615. rays: Array<Ray>;
  33616. }
  33617. /**
  33618. * Interface for gravitational field event data
  33619. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33620. */
  33621. interface PhysicsGravitationalFieldEventData {
  33622. /**
  33623. * A sphere mesh used for the gravitational field event
  33624. */
  33625. sphere: Mesh;
  33626. }
  33627. /**
  33628. * Interface for updraft event data
  33629. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33630. */
  33631. interface PhysicsUpdraftEventData {
  33632. /**
  33633. * A cylinder used for the updraft event
  33634. */
  33635. cylinder: Mesh;
  33636. }
  33637. /**
  33638. * Interface for vortex event data
  33639. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33640. */
  33641. interface PhysicsVortexEventData {
  33642. /**
  33643. * A cylinder used for the vortex event
  33644. */
  33645. cylinder: Mesh;
  33646. }
  33647. }
  33648. declare module BABYLON {
  33649. /**
  33650. * The interface for the physics imposter parameters
  33651. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33652. */
  33653. interface PhysicsImpostorParameters {
  33654. /**
  33655. * The mass of the physics imposter
  33656. */
  33657. mass: number;
  33658. /**
  33659. * The friction of the physics imposter
  33660. */
  33661. friction?: number;
  33662. /**
  33663. * The coefficient of restitution of the physics imposter
  33664. */
  33665. restitution?: number;
  33666. /**
  33667. * The native options of the physics imposter
  33668. */
  33669. nativeOptions?: any;
  33670. /**
  33671. * Specifies if the parent should be ignored
  33672. */
  33673. ignoreParent?: boolean;
  33674. /**
  33675. * Specifies if bi-directional transformations should be disabled
  33676. */
  33677. disableBidirectionalTransformation?: boolean;
  33678. }
  33679. /**
  33680. * Interface for a physics-enabled object
  33681. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33682. */
  33683. interface IPhysicsEnabledObject {
  33684. /**
  33685. * The position of the physics-enabled object
  33686. */
  33687. position: Vector3;
  33688. /**
  33689. * The rotation of the physics-enabled object
  33690. */
  33691. rotationQuaternion: Nullable<Quaternion>;
  33692. /**
  33693. * The scale of the physics-enabled object
  33694. */
  33695. scaling: Vector3;
  33696. /**
  33697. * The rotation of the physics-enabled object
  33698. */
  33699. rotation?: Vector3;
  33700. /**
  33701. * The parent of the physics-enabled object
  33702. */
  33703. parent?: any;
  33704. /**
  33705. * The bounding info of the physics-enabled object
  33706. * @returns The bounding info of the physics-enabled object
  33707. */
  33708. getBoundingInfo(): BoundingInfo;
  33709. /**
  33710. * Computes the world matrix
  33711. * @param force Specifies if the world matrix should be computed by force
  33712. * @returns A world matrix
  33713. */
  33714. computeWorldMatrix(force: boolean): Matrix;
  33715. /**
  33716. * Gets the world matrix
  33717. * @returns A world matrix
  33718. */
  33719. getWorldMatrix?(): Matrix;
  33720. /**
  33721. * Gets the child meshes
  33722. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  33723. * @returns An array of abstract meshes
  33724. */
  33725. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  33726. /**
  33727. * Gets the vertex data
  33728. * @param kind The type of vertex data
  33729. * @returns A nullable array of numbers, or a float32 array
  33730. */
  33731. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  33732. /**
  33733. * Gets the indices from the mesh
  33734. * @returns A nullable array of index arrays
  33735. */
  33736. getIndices?(): Nullable<IndicesArray>;
  33737. /**
  33738. * Gets the scene from the mesh
  33739. * @returns the indices array or null
  33740. */
  33741. getScene?(): Scene;
  33742. /**
  33743. * Gets the absolute position from the mesh
  33744. * @returns the absolute position
  33745. */
  33746. getAbsolutePosition(): Vector3;
  33747. /**
  33748. * Gets the absolute pivot point from the mesh
  33749. * @returns the absolute pivot point
  33750. */
  33751. getAbsolutePivotPoint(): Vector3;
  33752. /**
  33753. * Rotates the mesh
  33754. * @param axis The axis of rotation
  33755. * @param amount The amount of rotation
  33756. * @param space The space of the rotation
  33757. * @returns The rotation transform node
  33758. */
  33759. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  33760. /**
  33761. * Translates the mesh
  33762. * @param axis The axis of translation
  33763. * @param distance The distance of translation
  33764. * @param space The space of the translation
  33765. * @returns The transform node
  33766. */
  33767. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  33768. /**
  33769. * Sets the absolute position of the mesh
  33770. * @param absolutePosition The absolute position of the mesh
  33771. * @returns The transform node
  33772. */
  33773. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  33774. /**
  33775. * Gets the class name of the mesh
  33776. * @returns The class name
  33777. */
  33778. getClassName(): string;
  33779. }
  33780. /**
  33781. * Represents a physics imposter
  33782. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33783. */
  33784. class PhysicsImpostor {
  33785. /**
  33786. * The physics-enabled object used as the physics imposter
  33787. */
  33788. object: IPhysicsEnabledObject;
  33789. /**
  33790. * The type of the physics imposter
  33791. */
  33792. type: number;
  33793. private _options;
  33794. private _scene?;
  33795. /**
  33796. * The default object size of the imposter
  33797. */
  33798. static DEFAULT_OBJECT_SIZE: Vector3;
  33799. /**
  33800. * The identity quaternion of the imposter
  33801. */
  33802. static IDENTITY_QUATERNION: Quaternion;
  33803. /** @hidden */
  33804. _pluginData: any;
  33805. private _physicsEngine;
  33806. private _physicsBody;
  33807. private _bodyUpdateRequired;
  33808. private _onBeforePhysicsStepCallbacks;
  33809. private _onAfterPhysicsStepCallbacks;
  33810. /** @hidden */
  33811. _onPhysicsCollideCallbacks: Array<{
  33812. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  33813. otherImpostors: Array<PhysicsImpostor>;
  33814. }>;
  33815. private _deltaPosition;
  33816. private _deltaRotation;
  33817. private _deltaRotationConjugated;
  33818. private _parent;
  33819. private _isDisposed;
  33820. private static _tmpVecs;
  33821. private static _tmpQuat;
  33822. /**
  33823. * Specifies if the physics imposter is disposed
  33824. */
  33825. readonly isDisposed: boolean;
  33826. /**
  33827. * Gets the mass of the physics imposter
  33828. */
  33829. mass: number;
  33830. /**
  33831. * Gets the coefficient of friction
  33832. */
  33833. /**
  33834. * Sets the coefficient of friction
  33835. */
  33836. friction: number;
  33837. /**
  33838. * Gets the coefficient of restitution
  33839. */
  33840. /**
  33841. * Sets the coefficient of restitution
  33842. */
  33843. restitution: number;
  33844. /**
  33845. * The unique id of the physics imposter
  33846. * set by the physics engine when adding this impostor to the array
  33847. */
  33848. uniqueId: number;
  33849. private _joints;
  33850. /**
  33851. * Initializes the physics imposter
  33852. * @param object The physics-enabled object used as the physics imposter
  33853. * @param type The type of the physics imposter
  33854. * @param _options The options for the physics imposter
  33855. * @param _scene The Babylon scene
  33856. */
  33857. constructor(
  33858. /**
  33859. * The physics-enabled object used as the physics imposter
  33860. */
  33861. object: IPhysicsEnabledObject,
  33862. /**
  33863. * The type of the physics imposter
  33864. */
  33865. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  33866. /**
  33867. * This function will completly initialize this impostor.
  33868. * It will create a new body - but only if this mesh has no parent.
  33869. * If it has, this impostor will not be used other than to define the impostor
  33870. * of the child mesh.
  33871. * @hidden
  33872. */
  33873. _init(): void;
  33874. private _getPhysicsParent;
  33875. /**
  33876. * Should a new body be generated.
  33877. * @returns boolean specifying if body initialization is required
  33878. */
  33879. isBodyInitRequired(): boolean;
  33880. /**
  33881. * Sets the updated scaling
  33882. * @param updated Specifies if the scaling is updated
  33883. */
  33884. setScalingUpdated(updated: boolean): void;
  33885. /**
  33886. * Force a regeneration of this or the parent's impostor's body.
  33887. * Use under cautious - This will remove all joints already implemented.
  33888. */
  33889. forceUpdate(): void;
  33890. /**
  33891. * Gets the body that holds this impostor. Either its own, or its parent.
  33892. */
  33893. /**
  33894. * Set the physics body. Used mainly by the physics engine/plugin
  33895. */
  33896. physicsBody: any;
  33897. /**
  33898. * Get the parent of the physics imposter
  33899. * @returns Physics imposter or null
  33900. */
  33901. /**
  33902. * Sets the parent of the physics imposter
  33903. */
  33904. parent: Nullable<PhysicsImpostor>;
  33905. /**
  33906. * Resets the update flags
  33907. */
  33908. resetUpdateFlags(): void;
  33909. /**
  33910. * Gets the object extend size
  33911. * @returns the object extend size
  33912. */
  33913. getObjectExtendSize(): Vector3;
  33914. /**
  33915. * Gets the object center
  33916. * @returns The object center
  33917. */
  33918. getObjectCenter(): Vector3;
  33919. /**
  33920. * Get a specific parametes from the options parameter
  33921. * @param paramName The object parameter name
  33922. * @returns The object parameter
  33923. */
  33924. getParam(paramName: string): any;
  33925. /**
  33926. * Sets a specific parameter in the options given to the physics plugin
  33927. * @param paramName The parameter name
  33928. * @param value The value of the parameter
  33929. */
  33930. setParam(paramName: string, value: number): void;
  33931. /**
  33932. * Specifically change the body's mass option. Won't recreate the physics body object
  33933. * @param mass The mass of the physics imposter
  33934. */
  33935. setMass(mass: number): void;
  33936. /**
  33937. * Gets the linear velocity
  33938. * @returns linear velocity or null
  33939. */
  33940. getLinearVelocity(): Nullable<Vector3>;
  33941. /**
  33942. * Sets the linear velocity
  33943. * @param velocity linear velocity or null
  33944. */
  33945. setLinearVelocity(velocity: Nullable<Vector3>): void;
  33946. /**
  33947. * Gets the angular velocity
  33948. * @returns angular velocity or null
  33949. */
  33950. getAngularVelocity(): Nullable<Vector3>;
  33951. /**
  33952. * Sets the angular velocity
  33953. * @param velocity The velocity or null
  33954. */
  33955. setAngularVelocity(velocity: Nullable<Vector3>): void;
  33956. /**
  33957. * Execute a function with the physics plugin native code
  33958. * Provide a function the will have two variables - the world object and the physics body object
  33959. * @param func The function to execute with the physics plugin native code
  33960. */
  33961. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  33962. /**
  33963. * Register a function that will be executed before the physics world is stepping forward
  33964. * @param func The function to execute before the physics world is stepped forward
  33965. */
  33966. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33967. /**
  33968. * Unregister a function that will be executed before the physics world is stepping forward
  33969. * @param func The function to execute before the physics world is stepped forward
  33970. */
  33971. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33972. /**
  33973. * Register a function that will be executed after the physics step
  33974. * @param func The function to execute after physics step
  33975. */
  33976. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33977. /**
  33978. * Unregisters a function that will be executed after the physics step
  33979. * @param func The function to execute after physics step
  33980. */
  33981. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33982. /**
  33983. * register a function that will be executed when this impostor collides against a different body
  33984. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  33985. * @param func Callback that is executed on collision
  33986. */
  33987. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  33988. /**
  33989. * Unregisters the physics imposter on contact
  33990. * @param collideAgainst The physics object to collide against
  33991. * @param func Callback to execute on collision
  33992. */
  33993. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  33994. private _tmpQuat;
  33995. private _tmpQuat2;
  33996. /**
  33997. * Get the parent rotation
  33998. * @returns The parent rotation
  33999. */
  34000. getParentsRotation(): Quaternion;
  34001. /**
  34002. * this function is executed by the physics engine.
  34003. */
  34004. beforeStep: () => void;
  34005. /**
  34006. * this function is executed by the physics engine
  34007. */
  34008. afterStep: () => void;
  34009. /**
  34010. * Legacy collision detection event support
  34011. */
  34012. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  34013. /**
  34014. * event and body object due to cannon's event-based architecture.
  34015. */
  34016. onCollide: (e: {
  34017. body: any;
  34018. }) => void;
  34019. /**
  34020. * Apply a force
  34021. * @param force The force to apply
  34022. * @param contactPoint The contact point for the force
  34023. * @returns The physics imposter
  34024. */
  34025. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  34026. /**
  34027. * Apply an impulse
  34028. * @param force The impulse force
  34029. * @param contactPoint The contact point for the impulse force
  34030. * @returns The physics imposter
  34031. */
  34032. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  34033. /**
  34034. * A help function to create a joint
  34035. * @param otherImpostor A physics imposter used to create a joint
  34036. * @param jointType The type of joint
  34037. * @param jointData The data for the joint
  34038. * @returns The physics imposter
  34039. */
  34040. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  34041. /**
  34042. * Add a joint to this impostor with a different impostor
  34043. * @param otherImpostor A physics imposter used to add a joint
  34044. * @param joint The joint to add
  34045. * @returns The physics imposter
  34046. */
  34047. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  34048. /**
  34049. * Will keep this body still, in a sleep mode.
  34050. * @returns the physics imposter
  34051. */
  34052. sleep(): PhysicsImpostor;
  34053. /**
  34054. * Wake the body up.
  34055. * @returns The physics imposter
  34056. */
  34057. wakeUp(): PhysicsImpostor;
  34058. /**
  34059. * Clones the physics imposter
  34060. * @param newObject The physics imposter clones to this physics-enabled object
  34061. * @returns A nullable physics imposter
  34062. */
  34063. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  34064. /**
  34065. * Disposes the physics imposter
  34066. */
  34067. dispose(): void;
  34068. /**
  34069. * Sets the delta position
  34070. * @param position The delta position amount
  34071. */
  34072. setDeltaPosition(position: Vector3): void;
  34073. /**
  34074. * Sets the delta rotation
  34075. * @param rotation The delta rotation amount
  34076. */
  34077. setDeltaRotation(rotation: Quaternion): void;
  34078. /**
  34079. * Gets the box size of the physics imposter and stores the result in the input parameter
  34080. * @param result Stores the box size
  34081. * @returns The physics imposter
  34082. */
  34083. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  34084. /**
  34085. * Gets the radius of the physics imposter
  34086. * @returns Radius of the physics imposter
  34087. */
  34088. getRadius(): number;
  34089. /**
  34090. * Sync a bone with this impostor
  34091. * @param bone The bone to sync to the impostor.
  34092. * @param boneMesh The mesh that the bone is influencing.
  34093. * @param jointPivot The pivot of the joint / bone in local space.
  34094. * @param distToJoint Optional distance from the impostor to the joint.
  34095. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  34096. */
  34097. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  34098. /**
  34099. * Sync impostor to a bone
  34100. * @param bone The bone that the impostor will be synced to.
  34101. * @param boneMesh The mesh that the bone is influencing.
  34102. * @param jointPivot The pivot of the joint / bone in local space.
  34103. * @param distToJoint Optional distance from the impostor to the joint.
  34104. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  34105. * @param boneAxis Optional vector3 axis the bone is aligned with
  34106. */
  34107. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  34108. /**
  34109. * No-Imposter type
  34110. */
  34111. static NoImpostor: number;
  34112. /**
  34113. * Sphere-Imposter type
  34114. */
  34115. static SphereImpostor: number;
  34116. /**
  34117. * Box-Imposter type
  34118. */
  34119. static BoxImpostor: number;
  34120. /**
  34121. * Plane-Imposter type
  34122. */
  34123. static PlaneImpostor: number;
  34124. /**
  34125. * Mesh-imposter type
  34126. */
  34127. static MeshImpostor: number;
  34128. /**
  34129. * Cylinder-Imposter type
  34130. */
  34131. static CylinderImpostor: number;
  34132. /**
  34133. * Particle-Imposter type
  34134. */
  34135. static ParticleImpostor: number;
  34136. /**
  34137. * Heightmap-Imposter type
  34138. */
  34139. static HeightmapImpostor: number;
  34140. }
  34141. }
  34142. declare module BABYLON {
  34143. /**
  34144. * Interface for Physics-Joint data
  34145. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34146. */
  34147. interface PhysicsJointData {
  34148. /**
  34149. * The main pivot of the joint
  34150. */
  34151. mainPivot?: Vector3;
  34152. /**
  34153. * The connected pivot of the joint
  34154. */
  34155. connectedPivot?: Vector3;
  34156. /**
  34157. * The main axis of the joint
  34158. */
  34159. mainAxis?: Vector3;
  34160. /**
  34161. * The connected axis of the joint
  34162. */
  34163. connectedAxis?: Vector3;
  34164. /**
  34165. * The collision of the joint
  34166. */
  34167. collision?: boolean;
  34168. /**
  34169. * Native Oimo/Cannon/Energy data
  34170. */
  34171. nativeParams?: any;
  34172. }
  34173. /**
  34174. * This is a holder class for the physics joint created by the physics plugin
  34175. * It holds a set of functions to control the underlying joint
  34176. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34177. */
  34178. class PhysicsJoint {
  34179. /**
  34180. * The type of the physics joint
  34181. */
  34182. type: number;
  34183. /**
  34184. * The data for the physics joint
  34185. */
  34186. jointData: PhysicsJointData;
  34187. private _physicsJoint;
  34188. protected _physicsPlugin: IPhysicsEnginePlugin;
  34189. /**
  34190. * Initializes the physics joint
  34191. * @param type The type of the physics joint
  34192. * @param jointData The data for the physics joint
  34193. */
  34194. constructor(
  34195. /**
  34196. * The type of the physics joint
  34197. */
  34198. type: number,
  34199. /**
  34200. * The data for the physics joint
  34201. */
  34202. jointData: PhysicsJointData);
  34203. /**
  34204. * Gets the physics joint
  34205. */
  34206. /**
  34207. * Sets the physics joint
  34208. */
  34209. physicsJoint: any;
  34210. /**
  34211. * Sets the physics plugin
  34212. */
  34213. physicsPlugin: IPhysicsEnginePlugin;
  34214. /**
  34215. * Execute a function that is physics-plugin specific.
  34216. * @param {Function} func the function that will be executed.
  34217. * It accepts two parameters: the physics world and the physics joint
  34218. */
  34219. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  34220. /**
  34221. * Distance-Joint type
  34222. */
  34223. static DistanceJoint: number;
  34224. /**
  34225. * Hinge-Joint type
  34226. */
  34227. static HingeJoint: number;
  34228. /**
  34229. * Ball-and-Socket joint type
  34230. */
  34231. static BallAndSocketJoint: number;
  34232. /**
  34233. * Wheel-Joint type
  34234. */
  34235. static WheelJoint: number;
  34236. /**
  34237. * Slider-Joint type
  34238. */
  34239. static SliderJoint: number;
  34240. /**
  34241. * Prismatic-Joint type
  34242. */
  34243. static PrismaticJoint: number;
  34244. /**
  34245. * Universal-Joint type
  34246. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  34247. */
  34248. static UniversalJoint: number;
  34249. /**
  34250. * Hinge-Joint 2 type
  34251. */
  34252. static Hinge2Joint: number;
  34253. /**
  34254. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  34255. */
  34256. static PointToPointJoint: number;
  34257. /**
  34258. * Spring-Joint type
  34259. */
  34260. static SpringJoint: number;
  34261. /**
  34262. * Lock-Joint type
  34263. */
  34264. static LockJoint: number;
  34265. }
  34266. /**
  34267. * A class representing a physics distance joint
  34268. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34269. */
  34270. class DistanceJoint extends PhysicsJoint {
  34271. /**
  34272. *
  34273. * @param jointData The data for the Distance-Joint
  34274. */
  34275. constructor(jointData: DistanceJointData);
  34276. /**
  34277. * Update the predefined distance.
  34278. * @param maxDistance The maximum preferred distance
  34279. * @param minDistance The minimum preferred distance
  34280. */
  34281. updateDistance(maxDistance: number, minDistance?: number): void;
  34282. }
  34283. /**
  34284. * Represents a Motor-Enabled Joint
  34285. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34286. */
  34287. class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  34288. /**
  34289. * Initializes the Motor-Enabled Joint
  34290. * @param type The type of the joint
  34291. * @param jointData The physica joint data for the joint
  34292. */
  34293. constructor(type: number, jointData: PhysicsJointData);
  34294. /**
  34295. * Set the motor values.
  34296. * Attention, this function is plugin specific. Engines won't react 100% the same.
  34297. * @param force the force to apply
  34298. * @param maxForce max force for this motor.
  34299. */
  34300. setMotor(force?: number, maxForce?: number): void;
  34301. /**
  34302. * Set the motor's limits.
  34303. * Attention, this function is plugin specific. Engines won't react 100% the same.
  34304. * @param upperLimit The upper limit of the motor
  34305. * @param lowerLimit The lower limit of the motor
  34306. */
  34307. setLimit(upperLimit: number, lowerLimit?: number): void;
  34308. }
  34309. /**
  34310. * This class represents a single physics Hinge-Joint
  34311. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34312. */
  34313. class HingeJoint extends MotorEnabledJoint {
  34314. /**
  34315. * Initializes the Hinge-Joint
  34316. * @param jointData The joint data for the Hinge-Joint
  34317. */
  34318. constructor(jointData: PhysicsJointData);
  34319. /**
  34320. * Set the motor values.
  34321. * Attention, this function is plugin specific. Engines won't react 100% the same.
  34322. * @param {number} force the force to apply
  34323. * @param {number} maxForce max force for this motor.
  34324. */
  34325. setMotor(force?: number, maxForce?: number): void;
  34326. /**
  34327. * Set the motor's limits.
  34328. * Attention, this function is plugin specific. Engines won't react 100% the same.
  34329. * @param upperLimit The upper limit of the motor
  34330. * @param lowerLimit The lower limit of the motor
  34331. */
  34332. setLimit(upperLimit: number, lowerLimit?: number): void;
  34333. }
  34334. /**
  34335. * This class represents a dual hinge physics joint (same as wheel joint)
  34336. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34337. */
  34338. class Hinge2Joint extends MotorEnabledJoint {
  34339. /**
  34340. * Initializes the Hinge2-Joint
  34341. * @param jointData The joint data for the Hinge2-Joint
  34342. */
  34343. constructor(jointData: PhysicsJointData);
  34344. /**
  34345. * Set the motor values.
  34346. * Attention, this function is plugin specific. Engines won't react 100% the same.
  34347. * @param {number} force the force to apply
  34348. * @param {number} maxForce max force for this motor.
  34349. * @param {motorIndex} the motor's index, 0 or 1.
  34350. */
  34351. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  34352. /**
  34353. * Set the motor limits.
  34354. * Attention, this function is plugin specific. Engines won't react 100% the same.
  34355. * @param {number} upperLimit the upper limit
  34356. * @param {number} lowerLimit lower limit
  34357. * @param {motorIndex} the motor's index, 0 or 1.
  34358. */
  34359. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  34360. }
  34361. /**
  34362. * Interface for a motor enabled joint
  34363. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34364. */
  34365. interface IMotorEnabledJoint {
  34366. /**
  34367. * Physics joint
  34368. */
  34369. physicsJoint: any;
  34370. /**
  34371. * Sets the motor of the motor-enabled joint
  34372. * @param force The force of the motor
  34373. * @param maxForce The maximum force of the motor
  34374. * @param motorIndex The index of the motor
  34375. */
  34376. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  34377. /**
  34378. * Sets the limit of the motor
  34379. * @param upperLimit The upper limit of the motor
  34380. * @param lowerLimit The lower limit of the motor
  34381. * @param motorIndex The index of the motor
  34382. */
  34383. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  34384. }
  34385. /**
  34386. * Joint data for a Distance-Joint
  34387. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34388. */
  34389. interface DistanceJointData extends PhysicsJointData {
  34390. /**
  34391. * Max distance the 2 joint objects can be apart
  34392. */
  34393. maxDistance: number;
  34394. }
  34395. /**
  34396. * Joint data from a spring joint
  34397. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34398. */
  34399. interface SpringJointData extends PhysicsJointData {
  34400. /**
  34401. * Length of the spring
  34402. */
  34403. length: number;
  34404. /**
  34405. * Stiffness of the spring
  34406. */
  34407. stiffness: number;
  34408. /**
  34409. * Damping of the spring
  34410. */
  34411. damping: number;
  34412. /** this callback will be called when applying the force to the impostors. */
  34413. forceApplicationCallback: () => void;
  34414. }
  34415. }
  34416. declare module BABYLON {
  34417. interface AbstractScene {
  34418. /**
  34419. * The list of reflection probes added to the scene
  34420. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  34421. */
  34422. reflectionProbes: Array<ReflectionProbe>;
  34423. /**
  34424. * Removes the given reflection probe from this scene.
  34425. * @param toRemove The reflection probe to remove
  34426. * @returns The index of the removed reflection probe
  34427. */
  34428. removeReflectionProbe(toRemove: ReflectionProbe): number;
  34429. /**
  34430. * Adds the given reflection probe to this scene.
  34431. * @param newReflectionProbe The reflection probe to add
  34432. */
  34433. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  34434. }
  34435. /**
  34436. * Class used to generate realtime reflection / refraction cube textures
  34437. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  34438. */
  34439. class ReflectionProbe {
  34440. /** defines the name of the probe */
  34441. name: string;
  34442. private _scene;
  34443. private _renderTargetTexture;
  34444. private _projectionMatrix;
  34445. private _viewMatrix;
  34446. private _target;
  34447. private _add;
  34448. private _attachedMesh;
  34449. private _invertYAxis;
  34450. /** Gets or sets probe position (center of the cube map) */
  34451. position: Vector3;
  34452. /**
  34453. * Creates a new reflection probe
  34454. * @param name defines the name of the probe
  34455. * @param size defines the texture resolution (for each face)
  34456. * @param scene defines the hosting scene
  34457. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  34458. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  34459. */
  34460. constructor(
  34461. /** defines the name of the probe */
  34462. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  34463. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  34464. samples: number;
  34465. /** Gets or sets the refresh rate to use (on every frame by default) */
  34466. refreshRate: number;
  34467. /**
  34468. * Gets the hosting scene
  34469. * @returns a Scene
  34470. */
  34471. getScene(): Scene;
  34472. /** Gets the internal CubeTexture used to render to */
  34473. readonly cubeTexture: RenderTargetTexture;
  34474. /** Gets the list of meshes to render */
  34475. readonly renderList: Nullable<AbstractMesh[]>;
  34476. /**
  34477. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  34478. * @param mesh defines the mesh to attach to
  34479. */
  34480. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  34481. /**
  34482. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  34483. * @param renderingGroupId The rendering group id corresponding to its index
  34484. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34485. */
  34486. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  34487. /**
  34488. * Clean all associated resources
  34489. */
  34490. dispose(): void;
  34491. /**
  34492. * Converts the reflection probe information to a readable string for debug purpose.
  34493. * @param fullDetails Supports for multiple levels of logging within scene loading
  34494. * @returns the human readable reflection probe info
  34495. */
  34496. toString(fullDetails?: boolean): string;
  34497. /**
  34498. * Get the class name of the relfection probe.
  34499. * @returns "ReflectionProbe"
  34500. */
  34501. getClassName(): string;
  34502. /**
  34503. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  34504. * @returns The JSON representation of the texture
  34505. */
  34506. serialize(): any;
  34507. /**
  34508. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  34509. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  34510. * @param scene Define the scene the parsed reflection probe should be instantiated in
  34511. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  34512. * @returns The parsed reflection probe if successful
  34513. */
  34514. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  34515. }
  34516. }
  34517. declare module BABYLON {
  34518. /**
  34519. * Postprocess used to generate anaglyphic rendering
  34520. */
  34521. class AnaglyphPostProcess extends PostProcess {
  34522. private _passedProcess;
  34523. /**
  34524. * Creates a new AnaglyphPostProcess
  34525. * @param name defines postprocess name
  34526. * @param options defines creation options or target ratio scale
  34527. * @param rigCameras defines cameras using this postprocess
  34528. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  34529. * @param engine defines hosting engine
  34530. * @param reusable defines if the postprocess will be reused multiple times per frame
  34531. */
  34532. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  34533. }
  34534. }
  34535. declare module BABYLON {
  34536. /**
  34537. * Post process used to render in black and white
  34538. */
  34539. class BlackAndWhitePostProcess extends PostProcess {
  34540. /**
  34541. * Linear about to convert he result to black and white (default: 1)
  34542. */
  34543. degree: number;
  34544. /**
  34545. * Creates a black and white post process
  34546. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  34547. * @param name The name of the effect.
  34548. * @param options The required width/height ratio to downsize to before computing the render pass.
  34549. * @param camera The camera to apply the render pass to.
  34550. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34551. * @param engine The engine which the post process will be applied. (default: current engine)
  34552. * @param reusable If the post process can be reused on the same frame. (default: false)
  34553. */
  34554. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  34555. }
  34556. }
  34557. declare module BABYLON {
  34558. /**
  34559. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  34560. */
  34561. class BloomEffect extends PostProcessRenderEffect {
  34562. private bloomScale;
  34563. /**
  34564. * @hidden Internal
  34565. */
  34566. _effects: Array<PostProcess>;
  34567. /**
  34568. * @hidden Internal
  34569. */
  34570. _downscale: ExtractHighlightsPostProcess;
  34571. private _blurX;
  34572. private _blurY;
  34573. private _merge;
  34574. /**
  34575. * The luminance threshold to find bright areas of the image to bloom.
  34576. */
  34577. threshold: number;
  34578. /**
  34579. * The strength of the bloom.
  34580. */
  34581. weight: number;
  34582. /**
  34583. * Specifies the size of the bloom blur kernel, relative to the final output size
  34584. */
  34585. kernel: number;
  34586. /**
  34587. * Creates a new instance of @see BloomEffect
  34588. * @param scene The scene the effect belongs to.
  34589. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  34590. * @param bloomKernel The size of the kernel to be used when applying the blur.
  34591. * @param bloomWeight The the strength of bloom.
  34592. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  34593. * @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)
  34594. */
  34595. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  34596. /**
  34597. * Disposes each of the internal effects for a given camera.
  34598. * @param camera The camera to dispose the effect on.
  34599. */
  34600. disposeEffects(camera: Camera): void;
  34601. /**
  34602. * @hidden Internal
  34603. */
  34604. _updateEffects(): void;
  34605. /**
  34606. * Internal
  34607. * @returns if all the contained post processes are ready.
  34608. * @hidden
  34609. */
  34610. _isReady(): boolean;
  34611. }
  34612. }
  34613. declare module BABYLON {
  34614. /**
  34615. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  34616. */
  34617. class BloomMergePostProcess extends PostProcess {
  34618. /** Weight of the bloom to be added to the original input. */
  34619. weight: number;
  34620. /**
  34621. * Creates a new instance of @see BloomMergePostProcess
  34622. * @param name The name of the effect.
  34623. * @param originalFromInput Post process which's input will be used for the merge.
  34624. * @param blurred Blurred highlights post process which's output will be used.
  34625. * @param weight Weight of the bloom to be added to the original input.
  34626. * @param options The required width/height ratio to downsize to before computing the render pass.
  34627. * @param camera The camera to apply the render pass to.
  34628. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34629. * @param engine The engine which the post process will be applied. (default: current engine)
  34630. * @param reusable If the post process can be reused on the same frame. (default: false)
  34631. * @param textureType Type of textures used when performing the post process. (default: 0)
  34632. * @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)
  34633. */
  34634. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  34635. /** Weight of the bloom to be added to the original input. */
  34636. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  34637. }
  34638. }
  34639. declare module BABYLON {
  34640. /**
  34641. * The Blur Post Process which blurs an image based on a kernel and direction.
  34642. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  34643. */
  34644. class BlurPostProcess extends PostProcess {
  34645. /** The direction in which to blur the image. */
  34646. direction: Vector2;
  34647. private blockCompilation;
  34648. protected _kernel: number;
  34649. protected _idealKernel: number;
  34650. protected _packedFloat: boolean;
  34651. private _staticDefines;
  34652. /**
  34653. * Sets the length in pixels of the blur sample region
  34654. */
  34655. /**
  34656. * Gets the length in pixels of the blur sample region
  34657. */
  34658. kernel: number;
  34659. /**
  34660. * Sets wether or not the blur needs to unpack/repack floats
  34661. */
  34662. /**
  34663. * Gets wether or not the blur is unpacking/repacking floats
  34664. */
  34665. packedFloat: boolean;
  34666. /**
  34667. * Creates a new instance BlurPostProcess
  34668. * @param name The name of the effect.
  34669. * @param direction The direction in which to blur the image.
  34670. * @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.
  34671. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  34672. * @param camera The camera to apply the render pass to.
  34673. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34674. * @param engine The engine which the post process will be applied. (default: current engine)
  34675. * @param reusable If the post process can be reused on the same frame. (default: false)
  34676. * @param textureType Type of textures used when performing the post process. (default: 0)
  34677. * @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)
  34678. */
  34679. constructor(name: string,
  34680. /** The direction in which to blur the image. */
  34681. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  34682. /**
  34683. * Updates the effect with the current post process compile time values and recompiles the shader.
  34684. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  34685. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  34686. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  34687. * @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
  34688. * @param onCompiled Called when the shader has been compiled.
  34689. * @param onError Called if there is an error when compiling a shader.
  34690. */
  34691. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  34692. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  34693. /**
  34694. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  34695. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  34696. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  34697. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  34698. * The gaps between physical kernels are compensated for in the weighting of the samples
  34699. * @param idealKernel Ideal blur kernel.
  34700. * @return Nearest best kernel.
  34701. */
  34702. protected _nearestBestKernel(idealKernel: number): number;
  34703. /**
  34704. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  34705. * @param x The point on the Gaussian distribution to sample.
  34706. * @return the value of the Gaussian function at x.
  34707. */
  34708. protected _gaussianWeight(x: number): number;
  34709. /**
  34710. * Generates a string that can be used as a floating point number in GLSL.
  34711. * @param x Value to print.
  34712. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  34713. * @return GLSL float string.
  34714. */
  34715. protected _glslFloat(x: number, decimalFigures?: number): string;
  34716. }
  34717. }
  34718. declare module BABYLON {
  34719. /**
  34720. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  34721. */
  34722. class ChromaticAberrationPostProcess extends PostProcess {
  34723. /**
  34724. * The amount of seperation of rgb channels (default: 30)
  34725. */
  34726. aberrationAmount: number;
  34727. /**
  34728. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  34729. */
  34730. radialIntensity: number;
  34731. /**
  34732. * 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))
  34733. */
  34734. direction: Vector2;
  34735. /**
  34736. * 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))
  34737. */
  34738. centerPosition: Vector2;
  34739. /**
  34740. * Creates a new instance ChromaticAberrationPostProcess
  34741. * @param name The name of the effect.
  34742. * @param screenWidth The width of the screen to apply the effect on.
  34743. * @param screenHeight The height of the screen to apply the effect on.
  34744. * @param options The required width/height ratio to downsize to before computing the render pass.
  34745. * @param camera The camera to apply the render pass to.
  34746. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34747. * @param engine The engine which the post process will be applied. (default: current engine)
  34748. * @param reusable If the post process can be reused on the same frame. (default: false)
  34749. * @param textureType Type of textures used when performing the post process. (default: 0)
  34750. * @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)
  34751. */
  34752. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  34753. }
  34754. }
  34755. declare module BABYLON {
  34756. /**
  34757. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  34758. */
  34759. class CircleOfConfusionPostProcess extends PostProcess {
  34760. /**
  34761. * 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.
  34762. */
  34763. lensSize: number;
  34764. /**
  34765. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  34766. */
  34767. fStop: number;
  34768. /**
  34769. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  34770. */
  34771. focusDistance: number;
  34772. /**
  34773. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  34774. */
  34775. focalLength: number;
  34776. private _depthTexture;
  34777. /**
  34778. * Creates a new instance CircleOfConfusionPostProcess
  34779. * @param name The name of the effect.
  34780. * @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.
  34781. * @param options The required width/height ratio to downsize to before computing the render pass.
  34782. * @param camera The camera to apply the render pass to.
  34783. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34784. * @param engine The engine which the post process will be applied. (default: current engine)
  34785. * @param reusable If the post process can be reused on the same frame. (default: false)
  34786. * @param textureType Type of textures used when performing the post process. (default: 0)
  34787. * @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)
  34788. */
  34789. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  34790. /**
  34791. * 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.
  34792. */
  34793. depthTexture: RenderTargetTexture;
  34794. }
  34795. }
  34796. declare module BABYLON {
  34797. /**
  34798. *
  34799. * This post-process allows the modification of rendered colors by using
  34800. * a 'look-up table' (LUT). This effect is also called Color Grading.
  34801. *
  34802. * The object needs to be provided an url to a texture containing the color
  34803. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  34804. * Use an image editing software to tweak the LUT to match your needs.
  34805. *
  34806. * For an example of a color LUT, see here:
  34807. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  34808. * For explanations on color grading, see here:
  34809. * @see http://udn.epicgames.com/Three/ColorGrading.html
  34810. *
  34811. */
  34812. class ColorCorrectionPostProcess extends PostProcess {
  34813. private _colorTableTexture;
  34814. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  34815. }
  34816. }
  34817. declare module BABYLON {
  34818. /**
  34819. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  34820. * input texture to perform effects such as edge detection or sharpening
  34821. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  34822. */
  34823. class ConvolutionPostProcess extends PostProcess {
  34824. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  34825. kernel: number[];
  34826. /**
  34827. * Creates a new instance ConvolutionPostProcess
  34828. * @param name The name of the effect.
  34829. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  34830. * @param options The required width/height ratio to downsize to before computing the render pass.
  34831. * @param camera The camera to apply the render pass to.
  34832. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34833. * @param engine The engine which the post process will be applied. (default: current engine)
  34834. * @param reusable If the post process can be reused on the same frame. (default: false)
  34835. * @param textureType Type of textures used when performing the post process. (default: 0)
  34836. */
  34837. constructor(name: string,
  34838. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  34839. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  34840. /**
  34841. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34842. */
  34843. static EdgeDetect0Kernel: number[];
  34844. /**
  34845. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34846. */
  34847. static EdgeDetect1Kernel: number[];
  34848. /**
  34849. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34850. */
  34851. static EdgeDetect2Kernel: number[];
  34852. /**
  34853. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34854. */
  34855. static SharpenKernel: number[];
  34856. /**
  34857. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34858. */
  34859. static EmbossKernel: number[];
  34860. /**
  34861. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34862. */
  34863. static GaussianKernel: number[];
  34864. }
  34865. }
  34866. declare module BABYLON {
  34867. /**
  34868. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  34869. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  34870. * based on samples that have a large difference in distance than the center pixel.
  34871. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  34872. */
  34873. class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  34874. direction: Vector2;
  34875. /**
  34876. * Creates a new instance CircleOfConfusionPostProcess
  34877. * @param name The name of the effect.
  34878. * @param scene The scene the effect belongs to.
  34879. * @param direction The direction the blur should be applied.
  34880. * @param kernel The size of the kernel used to blur.
  34881. * @param options The required width/height ratio to downsize to before computing the render pass.
  34882. * @param camera The camera to apply the render pass to.
  34883. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  34884. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  34885. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34886. * @param engine The engine which the post process will be applied. (default: current engine)
  34887. * @param reusable If the post process can be reused on the same frame. (default: false)
  34888. * @param textureType Type of textures used when performing the post process. (default: 0)
  34889. * @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)
  34890. */
  34891. 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);
  34892. }
  34893. }
  34894. declare module BABYLON {
  34895. /**
  34896. * Specifies the level of max blur that should be applied when using the depth of field effect
  34897. */
  34898. enum DepthOfFieldEffectBlurLevel {
  34899. /**
  34900. * Subtle blur
  34901. */
  34902. Low = 0,
  34903. /**
  34904. * Medium blur
  34905. */
  34906. Medium = 1,
  34907. /**
  34908. * Large blur
  34909. */
  34910. High = 2
  34911. }
  34912. /**
  34913. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  34914. */
  34915. class DepthOfFieldEffect extends PostProcessRenderEffect {
  34916. private _circleOfConfusion;
  34917. /**
  34918. * @hidden Internal, blurs from high to low
  34919. */
  34920. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  34921. private _depthOfFieldBlurY;
  34922. private _dofMerge;
  34923. /**
  34924. * @hidden Internal post processes in depth of field effect
  34925. */
  34926. _effects: Array<PostProcess>;
  34927. /**
  34928. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  34929. */
  34930. focalLength: number;
  34931. /**
  34932. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  34933. */
  34934. fStop: number;
  34935. /**
  34936. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  34937. */
  34938. focusDistance: number;
  34939. /**
  34940. * 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.
  34941. */
  34942. lensSize: number;
  34943. /**
  34944. * Creates a new instance DepthOfFieldEffect
  34945. * @param scene The scene the effect belongs to.
  34946. * @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.
  34947. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  34948. * @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)
  34949. */
  34950. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  34951. /**
  34952. * 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.
  34953. */
  34954. depthTexture: RenderTargetTexture;
  34955. /**
  34956. * Disposes each of the internal effects for a given camera.
  34957. * @param camera The camera to dispose the effect on.
  34958. */
  34959. disposeEffects(camera: Camera): void;
  34960. /**
  34961. * @hidden Internal
  34962. */
  34963. _updateEffects(): void;
  34964. /**
  34965. * Internal
  34966. * @returns if all the contained post processes are ready.
  34967. * @hidden
  34968. */
  34969. _isReady(): boolean;
  34970. }
  34971. }
  34972. declare module BABYLON {
  34973. /**
  34974. * Options to be set when merging outputs from the default pipeline.
  34975. */
  34976. class DepthOfFieldMergePostProcessOptions {
  34977. /**
  34978. * The original image to merge on top of
  34979. */
  34980. originalFromInput: PostProcess;
  34981. /**
  34982. * Parameters to perform the merge of the depth of field effect
  34983. */
  34984. depthOfField?: {
  34985. circleOfConfusion: PostProcess;
  34986. blurSteps: Array<PostProcess>;
  34987. };
  34988. /**
  34989. * Parameters to perform the merge of bloom effect
  34990. */
  34991. bloom?: {
  34992. blurred: PostProcess;
  34993. weight: number;
  34994. };
  34995. }
  34996. /**
  34997. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  34998. */
  34999. class DepthOfFieldMergePostProcess extends PostProcess {
  35000. private blurSteps;
  35001. /**
  35002. * Creates a new instance of DepthOfFieldMergePostProcess
  35003. * @param name The name of the effect.
  35004. * @param originalFromInput Post process which's input will be used for the merge.
  35005. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  35006. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  35007. * @param options The required width/height ratio to downsize to before computing the render pass.
  35008. * @param camera The camera to apply the render pass to.
  35009. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35010. * @param engine The engine which the post process will be applied. (default: current engine)
  35011. * @param reusable If the post process can be reused on the same frame. (default: false)
  35012. * @param textureType Type of textures used when performing the post process. (default: 0)
  35013. * @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)
  35014. */
  35015. 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);
  35016. /**
  35017. * Updates the effect with the current post process compile time values and recompiles the shader.
  35018. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  35019. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  35020. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  35021. * @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
  35022. * @param onCompiled Called when the shader has been compiled.
  35023. * @param onError Called if there is an error when compiling a shader.
  35024. */
  35025. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  35026. }
  35027. }
  35028. declare module BABYLON {
  35029. /**
  35030. * DisplayPassPostProcess which produces an output the same as it's input
  35031. */
  35032. class DisplayPassPostProcess extends PostProcess {
  35033. /**
  35034. * Creates the DisplayPassPostProcess
  35035. * @param name The name of the effect.
  35036. * @param options The required width/height ratio to downsize to before computing the render pass.
  35037. * @param camera The camera to apply the render pass to.
  35038. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35039. * @param engine The engine which the post process will be applied. (default: current engine)
  35040. * @param reusable If the post process can be reused on the same frame. (default: false)
  35041. */
  35042. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  35043. }
  35044. }
  35045. declare module BABYLON {
  35046. /**
  35047. * 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.
  35048. */
  35049. class ExtractHighlightsPostProcess extends PostProcess {
  35050. /**
  35051. * The luminance threshold, pixels below this value will be set to black.
  35052. */
  35053. threshold: number;
  35054. /** @hidden */
  35055. _exposure: number;
  35056. /**
  35057. * Post process which has the input texture to be used when performing highlight extraction
  35058. * @hidden
  35059. */
  35060. _inputPostProcess: Nullable<PostProcess>;
  35061. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35062. }
  35063. }
  35064. declare module BABYLON {
  35065. /**
  35066. * Applies a kernel filter to the image
  35067. */
  35068. class FilterPostProcess extends PostProcess {
  35069. /** The matrix to be applied to the image */
  35070. kernelMatrix: Matrix;
  35071. /**
  35072. *
  35073. * @param name The name of the effect.
  35074. * @param kernelMatrix The matrix to be applied to the image
  35075. * @param options The required width/height ratio to downsize to before computing the render pass.
  35076. * @param camera The camera to apply the render pass to.
  35077. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35078. * @param engine The engine which the post process will be applied. (default: current engine)
  35079. * @param reusable If the post process can be reused on the same frame. (default: false)
  35080. */
  35081. constructor(name: string,
  35082. /** The matrix to be applied to the image */
  35083. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  35084. }
  35085. }
  35086. declare module BABYLON {
  35087. /**
  35088. * Fxaa post process
  35089. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  35090. */
  35091. class FxaaPostProcess extends PostProcess {
  35092. /** @hidden */
  35093. texelWidth: number;
  35094. /** @hidden */
  35095. texelHeight: number;
  35096. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  35097. private _getDefines;
  35098. }
  35099. }
  35100. declare module BABYLON {
  35101. /**
  35102. * The GrainPostProcess adds noise to the image at mid luminance levels
  35103. */
  35104. class GrainPostProcess extends PostProcess {
  35105. /**
  35106. * The intensity of the grain added (default: 30)
  35107. */
  35108. intensity: number;
  35109. /**
  35110. * If the grain should be randomized on every frame
  35111. */
  35112. animated: boolean;
  35113. /**
  35114. * Creates a new instance of @see GrainPostProcess
  35115. * @param name The name of the effect.
  35116. * @param options The required width/height ratio to downsize to before computing the render pass.
  35117. * @param camera The camera to apply the render pass to.
  35118. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35119. * @param engine The engine which the post process will be applied. (default: current engine)
  35120. * @param reusable If the post process can be reused on the same frame. (default: false)
  35121. * @param textureType Type of textures used when performing the post process. (default: 0)
  35122. * @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)
  35123. */
  35124. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35125. }
  35126. }
  35127. declare module BABYLON {
  35128. /**
  35129. * Extracts highlights from the image
  35130. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  35131. */
  35132. class HighlightsPostProcess extends PostProcess {
  35133. /**
  35134. * Extracts highlights from the image
  35135. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  35136. * @param name The name of the effect.
  35137. * @param options The required width/height ratio to downsize to before computing the render pass.
  35138. * @param camera The camera to apply the render pass to.
  35139. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35140. * @param engine The engine which the post process will be applied. (default: current engine)
  35141. * @param reusable If the post process can be reused on the same frame. (default: false)
  35142. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  35143. */
  35144. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  35145. }
  35146. }
  35147. declare module BABYLON {
  35148. /**
  35149. * ImageProcessingPostProcess
  35150. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  35151. */
  35152. class ImageProcessingPostProcess extends PostProcess {
  35153. /**
  35154. * Default configuration related to image processing available in the PBR Material.
  35155. */
  35156. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  35157. /**
  35158. * Gets the image processing configuration used either in this material.
  35159. */
  35160. /**
  35161. * Sets the Default image processing configuration used either in the this material.
  35162. *
  35163. * If sets to null, the scene one is in use.
  35164. */
  35165. imageProcessingConfiguration: ImageProcessingConfiguration;
  35166. /**
  35167. * Keep track of the image processing observer to allow dispose and replace.
  35168. */
  35169. private _imageProcessingObserver;
  35170. /**
  35171. * Attaches a new image processing configuration to the PBR Material.
  35172. * @param configuration
  35173. */
  35174. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  35175. /**
  35176. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  35177. */
  35178. /**
  35179. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  35180. */
  35181. colorCurves: Nullable<ColorCurves>;
  35182. /**
  35183. * Gets wether the color curves effect is enabled.
  35184. */
  35185. /**
  35186. * Sets wether the color curves effect is enabled.
  35187. */
  35188. colorCurvesEnabled: boolean;
  35189. /**
  35190. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  35191. */
  35192. /**
  35193. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  35194. */
  35195. colorGradingTexture: Nullable<BaseTexture>;
  35196. /**
  35197. * Gets wether the color grading effect is enabled.
  35198. */
  35199. /**
  35200. * Gets wether the color grading effect is enabled.
  35201. */
  35202. colorGradingEnabled: boolean;
  35203. /**
  35204. * Gets exposure used in the effect.
  35205. */
  35206. /**
  35207. * Sets exposure used in the effect.
  35208. */
  35209. exposure: number;
  35210. /**
  35211. * Gets wether tonemapping is enabled or not.
  35212. */
  35213. /**
  35214. * Sets wether tonemapping is enabled or not
  35215. */
  35216. toneMappingEnabled: boolean;
  35217. /**
  35218. * Gets contrast used in the effect.
  35219. */
  35220. /**
  35221. * Sets contrast used in the effect.
  35222. */
  35223. contrast: number;
  35224. /**
  35225. * Gets Vignette stretch size.
  35226. */
  35227. /**
  35228. * Sets Vignette stretch size.
  35229. */
  35230. vignetteStretch: number;
  35231. /**
  35232. * Gets Vignette centre X Offset.
  35233. */
  35234. /**
  35235. * Sets Vignette centre X Offset.
  35236. */
  35237. vignetteCentreX: number;
  35238. /**
  35239. * Gets Vignette centre Y Offset.
  35240. */
  35241. /**
  35242. * Sets Vignette centre Y Offset.
  35243. */
  35244. vignetteCentreY: number;
  35245. /**
  35246. * Gets Vignette weight or intensity of the vignette effect.
  35247. */
  35248. /**
  35249. * Sets Vignette weight or intensity of the vignette effect.
  35250. */
  35251. vignetteWeight: number;
  35252. /**
  35253. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  35254. * if vignetteEnabled is set to true.
  35255. */
  35256. /**
  35257. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  35258. * if vignetteEnabled is set to true.
  35259. */
  35260. vignetteColor: Color4;
  35261. /**
  35262. * Gets Camera field of view used by the Vignette effect.
  35263. */
  35264. /**
  35265. * Sets Camera field of view used by the Vignette effect.
  35266. */
  35267. vignetteCameraFov: number;
  35268. /**
  35269. * Gets the vignette blend mode allowing different kind of effect.
  35270. */
  35271. /**
  35272. * Sets the vignette blend mode allowing different kind of effect.
  35273. */
  35274. vignetteBlendMode: number;
  35275. /**
  35276. * Gets wether the vignette effect is enabled.
  35277. */
  35278. /**
  35279. * Sets wether the vignette effect is enabled.
  35280. */
  35281. vignetteEnabled: boolean;
  35282. private _fromLinearSpace;
  35283. /**
  35284. * Gets wether the input of the processing is in Gamma or Linear Space.
  35285. */
  35286. /**
  35287. * Sets wether the input of the processing is in Gamma or Linear Space.
  35288. */
  35289. fromLinearSpace: boolean;
  35290. /**
  35291. * Defines cache preventing GC.
  35292. */
  35293. private _defines;
  35294. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  35295. /**
  35296. * "ImageProcessingPostProcess"
  35297. * @returns "ImageProcessingPostProcess"
  35298. */
  35299. getClassName(): string;
  35300. protected _updateParameters(): void;
  35301. dispose(camera?: Camera): void;
  35302. }
  35303. }
  35304. declare module BABYLON {
  35305. /**
  35306. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  35307. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  35308. * As an example, all you have to do is to create the post-process:
  35309. * var mb = new BABYLON.MotionBlurPostProcess(
  35310. * 'mb', // The name of the effect.
  35311. * scene, // The scene containing the objects to blur according to their velocity.
  35312. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  35313. * camera // The camera to apply the render pass to.
  35314. * );
  35315. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  35316. */
  35317. class MotionBlurPostProcess extends PostProcess {
  35318. /**
  35319. * Defines how much the image is blurred by the movement. Default value is equal to 1
  35320. */
  35321. motionStrength: number;
  35322. /**
  35323. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  35324. */
  35325. /**
  35326. * Sets the number of iterations to be used for motion blur quality
  35327. */
  35328. motionBlurSamples: number;
  35329. private _motionBlurSamples;
  35330. private _geometryBufferRenderer;
  35331. /**
  35332. * Creates a new instance MotionBlurPostProcess
  35333. * @param name The name of the effect.
  35334. * @param scene The scene containing the objects to blur according to their velocity.
  35335. * @param options The required width/height ratio to downsize to before computing the render pass.
  35336. * @param camera The camera to apply the render pass to.
  35337. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35338. * @param engine The engine which the post process will be applied. (default: current engine)
  35339. * @param reusable If the post process can be reused on the same frame. (default: false)
  35340. * @param textureType Type of textures used when performing the post process. (default: 0)
  35341. * @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)
  35342. */
  35343. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35344. /**
  35345. * Disposes the post process.
  35346. * @param camera The camera to dispose the post process on.
  35347. */
  35348. dispose(camera?: Camera): void;
  35349. }
  35350. }
  35351. declare module BABYLON {
  35352. /**
  35353. * PassPostProcess which produces an output the same as it's input
  35354. */
  35355. class PassPostProcess extends PostProcess {
  35356. /**
  35357. * Creates the PassPostProcess
  35358. * @param name The name of the effect.
  35359. * @param options The required width/height ratio to downsize to before computing the render pass.
  35360. * @param camera The camera to apply the render pass to.
  35361. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35362. * @param engine The engine which the post process will be applied. (default: current engine)
  35363. * @param reusable If the post process can be reused on the same frame. (default: false)
  35364. * @param textureType The type of texture to be used when performing the post processing.
  35365. * @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)
  35366. */
  35367. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35368. }
  35369. /**
  35370. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  35371. */
  35372. class PassCubePostProcess extends PostProcess {
  35373. private _face;
  35374. /**
  35375. * Gets or sets the cube face to display.
  35376. * * 0 is +X
  35377. * * 1 is -X
  35378. * * 2 is +Y
  35379. * * 3 is -Y
  35380. * * 4 is +Z
  35381. * * 5 is -Z
  35382. */
  35383. face: number;
  35384. /**
  35385. * Creates the PassCubePostProcess
  35386. * @param name The name of the effect.
  35387. * @param options The required width/height ratio to downsize to before computing the render pass.
  35388. * @param camera The camera to apply the render pass to.
  35389. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35390. * @param engine The engine which the post process will be applied. (default: current engine)
  35391. * @param reusable If the post process can be reused on the same frame. (default: false)
  35392. * @param textureType The type of texture to be used when performing the post processing.
  35393. * @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)
  35394. */
  35395. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35396. }
  35397. }
  35398. declare module BABYLON {
  35399. /**
  35400. * Size options for a post process
  35401. */
  35402. type PostProcessOptions = {
  35403. width: number;
  35404. height: number;
  35405. };
  35406. /**
  35407. * PostProcess can be used to apply a shader to a texture after it has been rendered
  35408. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  35409. */
  35410. class PostProcess {
  35411. /** Name of the PostProcess. */
  35412. name: string;
  35413. /**
  35414. * Width of the texture to apply the post process on
  35415. */
  35416. width: number;
  35417. /**
  35418. * Height of the texture to apply the post process on
  35419. */
  35420. height: number;
  35421. /**
  35422. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  35423. * @hidden
  35424. */
  35425. _outputTexture: Nullable<InternalTexture>;
  35426. /**
  35427. * Sampling mode used by the shader
  35428. * See https://doc.babylonjs.com/classes/3.1/texture
  35429. */
  35430. renderTargetSamplingMode: number;
  35431. /**
  35432. * Clear color to use when screen clearing
  35433. */
  35434. clearColor: Color4;
  35435. /**
  35436. * If the buffer needs to be cleared before applying the post process. (default: true)
  35437. * Should be set to false if shader will overwrite all previous pixels.
  35438. */
  35439. autoClear: boolean;
  35440. /**
  35441. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  35442. */
  35443. alphaMode: number;
  35444. /**
  35445. * Sets the setAlphaBlendConstants of the babylon engine
  35446. */
  35447. alphaConstants: Color4;
  35448. /**
  35449. * Animations to be used for the post processing
  35450. */
  35451. animations: Animation[];
  35452. /**
  35453. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  35454. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  35455. */
  35456. enablePixelPerfectMode: boolean;
  35457. /**
  35458. * Force the postprocess to be applied without taking in account viewport
  35459. */
  35460. forceFullscreenViewport: boolean;
  35461. /**
  35462. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  35463. *
  35464. * | Value | Type | Description |
  35465. * | ----- | ----------------------------------- | ----------- |
  35466. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  35467. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  35468. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  35469. *
  35470. */
  35471. scaleMode: number;
  35472. /**
  35473. * Force textures to be a power of two (default: false)
  35474. */
  35475. alwaysForcePOT: boolean;
  35476. private _samples;
  35477. /**
  35478. * Number of sample textures (default: 1)
  35479. */
  35480. samples: number;
  35481. /**
  35482. * Modify the scale of the post process to be the same as the viewport (default: false)
  35483. */
  35484. adaptScaleToCurrentViewport: boolean;
  35485. private _camera;
  35486. private _scene;
  35487. private _engine;
  35488. private _options;
  35489. private _reusable;
  35490. private _textureType;
  35491. /**
  35492. * Smart array of input and output textures for the post process.
  35493. * @hidden
  35494. */
  35495. _textures: SmartArray<InternalTexture>;
  35496. /**
  35497. * The index in _textures that corresponds to the output texture.
  35498. * @hidden
  35499. */
  35500. _currentRenderTextureInd: number;
  35501. private _effect;
  35502. private _samplers;
  35503. private _fragmentUrl;
  35504. private _vertexUrl;
  35505. private _parameters;
  35506. private _scaleRatio;
  35507. protected _indexParameters: any;
  35508. private _shareOutputWithPostProcess;
  35509. private _texelSize;
  35510. private _forcedOutputTexture;
  35511. /**
  35512. * An event triggered when the postprocess is activated.
  35513. */
  35514. onActivateObservable: Observable<Camera>;
  35515. private _onActivateObserver;
  35516. /**
  35517. * A function that is added to the onActivateObservable
  35518. */
  35519. onActivate: Nullable<(camera: Camera) => void>;
  35520. /**
  35521. * An event triggered when the postprocess changes its size.
  35522. */
  35523. onSizeChangedObservable: Observable<PostProcess>;
  35524. private _onSizeChangedObserver;
  35525. /**
  35526. * A function that is added to the onSizeChangedObservable
  35527. */
  35528. onSizeChanged: (postProcess: PostProcess) => void;
  35529. /**
  35530. * An event triggered when the postprocess applies its effect.
  35531. */
  35532. onApplyObservable: Observable<Effect>;
  35533. private _onApplyObserver;
  35534. /**
  35535. * A function that is added to the onApplyObservable
  35536. */
  35537. onApply: (effect: Effect) => void;
  35538. /**
  35539. * An event triggered before rendering the postprocess
  35540. */
  35541. onBeforeRenderObservable: Observable<Effect>;
  35542. private _onBeforeRenderObserver;
  35543. /**
  35544. * A function that is added to the onBeforeRenderObservable
  35545. */
  35546. onBeforeRender: (effect: Effect) => void;
  35547. /**
  35548. * An event triggered after rendering the postprocess
  35549. */
  35550. onAfterRenderObservable: Observable<Effect>;
  35551. private _onAfterRenderObserver;
  35552. /**
  35553. * A function that is added to the onAfterRenderObservable
  35554. */
  35555. onAfterRender: (efect: Effect) => void;
  35556. /**
  35557. * 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
  35558. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  35559. */
  35560. inputTexture: InternalTexture;
  35561. /**
  35562. * Gets the camera which post process is applied to.
  35563. * @returns The camera the post process is applied to.
  35564. */
  35565. getCamera(): Camera;
  35566. /**
  35567. * Gets the texel size of the postprocess.
  35568. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  35569. */
  35570. readonly texelSize: Vector2;
  35571. /**
  35572. * Creates a new instance PostProcess
  35573. * @param name The name of the PostProcess.
  35574. * @param fragmentUrl The url of the fragment shader to be used.
  35575. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  35576. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  35577. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  35578. * @param camera The camera to apply the render pass to.
  35579. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35580. * @param engine The engine which the post process will be applied. (default: current engine)
  35581. * @param reusable If the post process can be reused on the same frame. (default: false)
  35582. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  35583. * @param textureType Type of textures used when performing the post process. (default: 0)
  35584. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  35585. * @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
  35586. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  35587. */
  35588. constructor(
  35589. /** Name of the PostProcess. */
  35590. 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);
  35591. /**
  35592. * Gets the engine which this post process belongs to.
  35593. * @returns The engine the post process was enabled with.
  35594. */
  35595. getEngine(): Engine;
  35596. /**
  35597. * The effect that is created when initializing the post process.
  35598. * @returns The created effect corrisponding the the postprocess.
  35599. */
  35600. getEffect(): Effect;
  35601. /**
  35602. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  35603. * @param postProcess The post process to share the output with.
  35604. * @returns This post process.
  35605. */
  35606. shareOutputWith(postProcess: PostProcess): PostProcess;
  35607. /**
  35608. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  35609. * This should be called if the post process that shares output with this post process is disabled/disposed.
  35610. */
  35611. useOwnOutput(): void;
  35612. /**
  35613. * Updates the effect with the current post process compile time values and recompiles the shader.
  35614. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  35615. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  35616. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  35617. * @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
  35618. * @param onCompiled Called when the shader has been compiled.
  35619. * @param onError Called if there is an error when compiling a shader.
  35620. */
  35621. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  35622. /**
  35623. * The post process is reusable if it can be used multiple times within one frame.
  35624. * @returns If the post process is reusable
  35625. */
  35626. isReusable(): boolean;
  35627. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  35628. markTextureDirty(): void;
  35629. /**
  35630. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  35631. * 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.
  35632. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  35633. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  35634. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  35635. * @returns The target texture that was bound to be written to.
  35636. */
  35637. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  35638. /**
  35639. * If the post process is supported.
  35640. */
  35641. readonly isSupported: boolean;
  35642. /**
  35643. * The aspect ratio of the output texture.
  35644. */
  35645. readonly aspectRatio: number;
  35646. /**
  35647. * Get a value indicating if the post-process is ready to be used
  35648. * @returns true if the post-process is ready (shader is compiled)
  35649. */
  35650. isReady(): boolean;
  35651. /**
  35652. * Binds all textures and uniforms to the shader, this will be run on every pass.
  35653. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  35654. */
  35655. apply(): Nullable<Effect>;
  35656. private _disposeTextures;
  35657. /**
  35658. * Disposes the post process.
  35659. * @param camera The camera to dispose the post process on.
  35660. */
  35661. dispose(camera?: Camera): void;
  35662. }
  35663. }
  35664. declare module BABYLON {
  35665. /**
  35666. * PostProcessManager is used to manage one or more post processes or post process pipelines
  35667. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  35668. */
  35669. class PostProcessManager {
  35670. private _scene;
  35671. private _indexBuffer;
  35672. private _vertexBuffers;
  35673. /**
  35674. * Creates a new instance PostProcess
  35675. * @param scene The scene that the post process is associated with.
  35676. */
  35677. constructor(scene: Scene);
  35678. private _prepareBuffers;
  35679. private _buildIndexBuffer;
  35680. /**
  35681. * Rebuilds the vertex buffers of the manager.
  35682. * @hidden
  35683. */
  35684. _rebuild(): void;
  35685. /**
  35686. * Prepares a frame to be run through a post process.
  35687. * @param sourceTexture The input texture to the post procesess. (default: null)
  35688. * @param postProcesses An array of post processes to be run. (default: null)
  35689. * @returns True if the post processes were able to be run.
  35690. * @hidden
  35691. */
  35692. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  35693. /**
  35694. * Manually render a set of post processes to a texture.
  35695. * @param postProcesses An array of post processes to be run.
  35696. * @param targetTexture The target texture to render to.
  35697. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  35698. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  35699. * @param lodLevel defines which lod of the texture to render to
  35700. */
  35701. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  35702. /**
  35703. * Finalize the result of the output of the postprocesses.
  35704. * @param doNotPresent If true the result will not be displayed to the screen.
  35705. * @param targetTexture The target texture to render to.
  35706. * @param faceIndex The index of the face to bind the target texture to.
  35707. * @param postProcesses The array of post processes to render.
  35708. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  35709. * @hidden
  35710. */
  35711. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  35712. /**
  35713. * Disposes of the post process manager.
  35714. */
  35715. dispose(): void;
  35716. }
  35717. }
  35718. declare module BABYLON {
  35719. /**
  35720. * Post process which applies a refractin texture
  35721. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  35722. */
  35723. class RefractionPostProcess extends PostProcess {
  35724. /** the base color of the refraction (used to taint the rendering) */
  35725. color: Color3;
  35726. /** simulated refraction depth */
  35727. depth: number;
  35728. /** the coefficient of the base color (0 to remove base color tainting) */
  35729. colorLevel: number;
  35730. private _refTexture;
  35731. private _ownRefractionTexture;
  35732. /**
  35733. * Gets or sets the refraction texture
  35734. * Please note that you are responsible for disposing the texture if you set it manually
  35735. */
  35736. refractionTexture: Texture;
  35737. /**
  35738. * Initializes the RefractionPostProcess
  35739. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  35740. * @param name The name of the effect.
  35741. * @param refractionTextureUrl Url of the refraction texture to use
  35742. * @param color the base color of the refraction (used to taint the rendering)
  35743. * @param depth simulated refraction depth
  35744. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  35745. * @param camera The camera to apply the render pass to.
  35746. * @param options The required width/height ratio to downsize to before computing the render pass.
  35747. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35748. * @param engine The engine which the post process will be applied. (default: current engine)
  35749. * @param reusable If the post process can be reused on the same frame. (default: false)
  35750. */
  35751. constructor(name: string, refractionTextureUrl: string,
  35752. /** the base color of the refraction (used to taint the rendering) */
  35753. color: Color3,
  35754. /** simulated refraction depth */
  35755. depth: number,
  35756. /** the coefficient of the base color (0 to remove base color tainting) */
  35757. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  35758. /**
  35759. * Disposes of the post process
  35760. * @param camera Camera to dispose post process on
  35761. */
  35762. dispose(camera: Camera): void;
  35763. }
  35764. }
  35765. declare module BABYLON {
  35766. /**
  35767. * The SharpenPostProcess applies a sharpen kernel to every pixel
  35768. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  35769. */
  35770. class SharpenPostProcess extends PostProcess {
  35771. /**
  35772. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  35773. */
  35774. colorAmount: number;
  35775. /**
  35776. * How much sharpness should be applied (default: 0.3)
  35777. */
  35778. edgeAmount: number;
  35779. /**
  35780. * Creates a new instance ConvolutionPostProcess
  35781. * @param name The name of the effect.
  35782. * @param options The required width/height ratio to downsize to before computing the render pass.
  35783. * @param camera The camera to apply the render pass to.
  35784. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35785. * @param engine The engine which the post process will be applied. (default: current engine)
  35786. * @param reusable If the post process can be reused on the same frame. (default: false)
  35787. * @param textureType Type of textures used when performing the post process. (default: 0)
  35788. * @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)
  35789. */
  35790. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35791. }
  35792. }
  35793. declare module BABYLON {
  35794. /**
  35795. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  35796. */
  35797. class StereoscopicInterlacePostProcess extends PostProcess {
  35798. private _stepSize;
  35799. private _passedProcess;
  35800. /**
  35801. * Initializes a StereoscopicInterlacePostProcess
  35802. * @param name The name of the effect.
  35803. * @param rigCameras The rig cameras to be appled to the post process
  35804. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  35805. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35806. * @param engine The engine which the post process will be applied. (default: current engine)
  35807. * @param reusable If the post process can be reused on the same frame. (default: false)
  35808. */
  35809. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  35810. }
  35811. }
  35812. declare module BABYLON {
  35813. /** Defines operator used for tonemapping */
  35814. enum TonemappingOperator {
  35815. /** Hable */
  35816. Hable = 0,
  35817. /** Reinhard */
  35818. Reinhard = 1,
  35819. /** HejiDawson */
  35820. HejiDawson = 2,
  35821. /** Photographic */
  35822. Photographic = 3
  35823. }
  35824. /**
  35825. * Defines a post process to apply tone mapping
  35826. */
  35827. class TonemapPostProcess extends PostProcess {
  35828. private _operator;
  35829. /** Defines the required exposure adjustement */
  35830. exposureAdjustment: number;
  35831. /**
  35832. * Creates a new TonemapPostProcess
  35833. * @param name defines the name of the postprocess
  35834. * @param _operator defines the operator to use
  35835. * @param exposureAdjustment defines the required exposure adjustement
  35836. * @param camera defines the camera to use (can be null)
  35837. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  35838. * @param engine defines the hosting engine (can be ignore if camera is set)
  35839. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  35840. */
  35841. constructor(name: string, _operator: TonemappingOperator,
  35842. /** Defines the required exposure adjustement */
  35843. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  35844. }
  35845. }
  35846. declare module BABYLON {
  35847. /**
  35848. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  35849. */
  35850. class VolumetricLightScatteringPostProcess extends PostProcess {
  35851. private _volumetricLightScatteringPass;
  35852. private _volumetricLightScatteringRTT;
  35853. private _viewPort;
  35854. private _screenCoordinates;
  35855. private _cachedDefines;
  35856. /**
  35857. * If not undefined, the mesh position is computed from the attached node position
  35858. */
  35859. attachedNode: {
  35860. position: Vector3;
  35861. };
  35862. /**
  35863. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  35864. */
  35865. customMeshPosition: Vector3;
  35866. /**
  35867. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  35868. */
  35869. useCustomMeshPosition: boolean;
  35870. /**
  35871. * If the post-process should inverse the light scattering direction
  35872. */
  35873. invert: boolean;
  35874. /**
  35875. * The internal mesh used by the post-process
  35876. */
  35877. mesh: Mesh;
  35878. /**
  35879. * @hidden
  35880. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  35881. */
  35882. useDiffuseColor: boolean;
  35883. /**
  35884. * Array containing the excluded meshes not rendered in the internal pass
  35885. */
  35886. excludedMeshes: AbstractMesh[];
  35887. /**
  35888. * Controls the overall intensity of the post-process
  35889. */
  35890. exposure: number;
  35891. /**
  35892. * Dissipates each sample's contribution in range [0, 1]
  35893. */
  35894. decay: number;
  35895. /**
  35896. * Controls the overall intensity of each sample
  35897. */
  35898. weight: number;
  35899. /**
  35900. * Controls the density of each sample
  35901. */
  35902. density: number;
  35903. /**
  35904. * @constructor
  35905. * @param name The post-process name
  35906. * @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)
  35907. * @param camera The camera that the post-process will be attached to
  35908. * @param mesh The mesh used to create the light scattering
  35909. * @param samples The post-process quality, default 100
  35910. * @param samplingModeThe post-process filtering mode
  35911. * @param engine The babylon engine
  35912. * @param reusable If the post-process is reusable
  35913. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  35914. */
  35915. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  35916. /**
  35917. * Returns the string "VolumetricLightScatteringPostProcess"
  35918. * @returns "VolumetricLightScatteringPostProcess"
  35919. */
  35920. getClassName(): string;
  35921. private _isReady;
  35922. /**
  35923. * Sets the new light position for light scattering effect
  35924. * @param position The new custom light position
  35925. */
  35926. setCustomMeshPosition(position: Vector3): void;
  35927. /**
  35928. * Returns the light position for light scattering effect
  35929. * @return Vector3 The custom light position
  35930. */
  35931. getCustomMeshPosition(): Vector3;
  35932. /**
  35933. * Disposes the internal assets and detaches the post-process from the camera
  35934. */
  35935. dispose(camera: Camera): void;
  35936. /**
  35937. * Returns the render target texture used by the post-process
  35938. * @return the render target texture used by the post-process
  35939. */
  35940. getPass(): RenderTargetTexture;
  35941. private _meshExcluded;
  35942. private _createPass;
  35943. private _updateMeshScreenCoordinates;
  35944. /**
  35945. * Creates a default mesh for the Volumeric Light Scattering post-process
  35946. * @param name The mesh name
  35947. * @param scene The scene where to create the mesh
  35948. * @return the default mesh
  35949. */
  35950. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  35951. }
  35952. }
  35953. declare module BABYLON {
  35954. /**
  35955. * VRDistortionCorrectionPostProcess used for mobile VR
  35956. */
  35957. class VRDistortionCorrectionPostProcess extends PostProcess {
  35958. private _isRightEye;
  35959. private _distortionFactors;
  35960. private _postProcessScaleFactor;
  35961. private _lensCenterOffset;
  35962. private _scaleIn;
  35963. private _scaleFactor;
  35964. private _lensCenter;
  35965. /**
  35966. * Initializes the VRDistortionCorrectionPostProcess
  35967. * @param name The name of the effect.
  35968. * @param camera The camera to apply the render pass to.
  35969. * @param isRightEye If this is for the right eye distortion
  35970. * @param vrMetrics All the required metrics for the VR camera
  35971. */
  35972. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  35973. }
  35974. }
  35975. declare module BABYLON {
  35976. interface Scene {
  35977. /** @hidden (Backing field) */
  35978. _boundingBoxRenderer: BoundingBoxRenderer;
  35979. /** @hidden (Backing field) */
  35980. _forceShowBoundingBoxes: boolean;
  35981. /**
  35982. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  35983. */
  35984. forceShowBoundingBoxes: boolean;
  35985. /**
  35986. * Gets the bounding box renderer associated with the scene
  35987. * @returns a BoundingBoxRenderer
  35988. */
  35989. getBoundingBoxRenderer(): BoundingBoxRenderer;
  35990. }
  35991. interface AbstractMesh {
  35992. /** @hidden (Backing field) */
  35993. _showBoundingBox: boolean;
  35994. /**
  35995. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  35996. */
  35997. showBoundingBox: boolean;
  35998. }
  35999. /**
  36000. * Component responsible of rendering the bounding box of the meshes in a scene.
  36001. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  36002. */
  36003. class BoundingBoxRenderer implements ISceneComponent {
  36004. /**
  36005. * The component name helpfull to identify the component in the list of scene components.
  36006. */
  36007. readonly name: string;
  36008. /**
  36009. * The scene the component belongs to.
  36010. */
  36011. scene: Scene;
  36012. /**
  36013. * Color of the bounding box lines placed in front of an object
  36014. */
  36015. frontColor: Color3;
  36016. /**
  36017. * Color of the bounding box lines placed behind an object
  36018. */
  36019. backColor: Color3;
  36020. /**
  36021. * Defines if the renderer should show the back lines or not
  36022. */
  36023. showBackLines: boolean;
  36024. /**
  36025. * @hidden
  36026. */
  36027. renderList: SmartArray<BoundingBox>;
  36028. private _colorShader;
  36029. private _vertexBuffers;
  36030. private _indexBuffer;
  36031. /**
  36032. * Instantiates a new bounding box renderer in a scene.
  36033. * @param scene the scene the renderer renders in
  36034. */
  36035. constructor(scene: Scene);
  36036. /**
  36037. * Registers the component in a given scene
  36038. */
  36039. register(): void;
  36040. private _evaluateSubMesh;
  36041. private _activeMesh;
  36042. private _prepareRessources;
  36043. private _createIndexBuffer;
  36044. /**
  36045. * Rebuilds the elements related to this component in case of
  36046. * context lost for instance.
  36047. */
  36048. rebuild(): void;
  36049. /**
  36050. * @hidden
  36051. */
  36052. reset(): void;
  36053. /**
  36054. * Render the bounding boxes of a specific rendering group
  36055. * @param renderingGroupId defines the rendering group to render
  36056. */
  36057. render(renderingGroupId: number): void;
  36058. /**
  36059. * In case of occlusion queries, we can render the occlusion bounding box through this method
  36060. * @param mesh Define the mesh to render the occlusion bounding box for
  36061. */
  36062. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  36063. /**
  36064. * Dispose and release the resources attached to this renderer.
  36065. */
  36066. dispose(): void;
  36067. }
  36068. }
  36069. declare module BABYLON {
  36070. /**
  36071. * This represents a depth renderer in Babylon.
  36072. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  36073. */
  36074. class DepthRenderer {
  36075. private _scene;
  36076. private _depthMap;
  36077. private _effect;
  36078. private _cachedDefines;
  36079. private _camera;
  36080. /**
  36081. * Specifiess that the depth renderer will only be used within
  36082. * the camera it is created for.
  36083. * This can help forcing its rendering during the camera processing.
  36084. */
  36085. useOnlyInActiveCamera: boolean;
  36086. /**
  36087. * Instantiates a depth renderer
  36088. * @param scene The scene the renderer belongs to
  36089. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  36090. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  36091. */
  36092. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  36093. /**
  36094. * Creates the depth rendering effect and checks if the effect is ready.
  36095. * @param subMesh The submesh to be used to render the depth map of
  36096. * @param useInstances If multiple world instances should be used
  36097. * @returns if the depth renderer is ready to render the depth map
  36098. */
  36099. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  36100. /**
  36101. * Gets the texture which the depth map will be written to.
  36102. * @returns The depth map texture
  36103. */
  36104. getDepthMap(): RenderTargetTexture;
  36105. /**
  36106. * Disposes of the depth renderer.
  36107. */
  36108. dispose(): void;
  36109. }
  36110. }
  36111. declare module BABYLON {
  36112. interface Scene {
  36113. /** @hidden (Backing field) */
  36114. _depthRenderer: {
  36115. [id: string]: DepthRenderer;
  36116. };
  36117. /**
  36118. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  36119. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  36120. * @returns the created depth renderer
  36121. */
  36122. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  36123. /**
  36124. * Disables a depth renderer for a given camera
  36125. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  36126. */
  36127. disableDepthRenderer(camera?: Nullable<Camera>): void;
  36128. }
  36129. /**
  36130. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  36131. * in several rendering techniques.
  36132. */
  36133. class DepthRendererSceneComponent implements ISceneComponent {
  36134. /**
  36135. * The component name helpfull to identify the component in the list of scene components.
  36136. */
  36137. readonly name: string;
  36138. /**
  36139. * The scene the component belongs to.
  36140. */
  36141. scene: Scene;
  36142. /**
  36143. * Creates a new instance of the component for the given scene
  36144. * @param scene Defines the scene to register the component in
  36145. */
  36146. constructor(scene: Scene);
  36147. /**
  36148. * Registers the component in a given scene
  36149. */
  36150. register(): void;
  36151. /**
  36152. * Rebuilds the elements related to this component in case of
  36153. * context lost for instance.
  36154. */
  36155. rebuild(): void;
  36156. /**
  36157. * Disposes the component and the associated ressources
  36158. */
  36159. dispose(): void;
  36160. private _gatherRenderTargets;
  36161. private _gatherActiveCameraRenderTargets;
  36162. }
  36163. }
  36164. declare module BABYLON {
  36165. interface AbstractMesh {
  36166. /**
  36167. * Disables the mesh edge rendering mode
  36168. * @returns the currentAbstractMesh
  36169. */
  36170. disableEdgesRendering(): AbstractMesh;
  36171. /**
  36172. * Enables the edge rendering mode on the mesh.
  36173. * This mode makes the mesh edges visible
  36174. * @param epsilon defines the maximal distance between two angles to detect a face
  36175. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  36176. * @returns the currentAbstractMesh
  36177. * @see https://www.babylonjs-playground.com/#19O9TU#0
  36178. */
  36179. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  36180. /**
  36181. * Gets the edgesRenderer associated with the mesh
  36182. */
  36183. edgesRenderer: Nullable<EdgesRenderer>;
  36184. }
  36185. interface LinesMesh {
  36186. /**
  36187. * Enables the edge rendering mode on the mesh.
  36188. * This mode makes the mesh edges visible
  36189. * @param epsilon defines the maximal distance between two angles to detect a face
  36190. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  36191. * @returns the currentAbstractMesh
  36192. * @see https://www.babylonjs-playground.com/#19O9TU#0
  36193. */
  36194. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  36195. }
  36196. interface InstancedLinesMesh {
  36197. /**
  36198. * Enables the edge rendering mode on the mesh.
  36199. * This mode makes the mesh edges visible
  36200. * @param epsilon defines the maximal distance between two angles to detect a face
  36201. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  36202. * @returns the current InstancedLinesMesh
  36203. * @see https://www.babylonjs-playground.com/#19O9TU#0
  36204. */
  36205. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  36206. }
  36207. /**
  36208. * Defines the minimum contract an Edges renderer should follow.
  36209. */
  36210. interface IEdgesRenderer extends IDisposable {
  36211. /**
  36212. * Gets or sets a boolean indicating if the edgesRenderer is active
  36213. */
  36214. isEnabled: boolean;
  36215. /**
  36216. * Renders the edges of the attached mesh,
  36217. */
  36218. render(): void;
  36219. /**
  36220. * Checks wether or not the edges renderer is ready to render.
  36221. * @return true if ready, otherwise false.
  36222. */
  36223. isReady(): boolean;
  36224. }
  36225. /**
  36226. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  36227. */
  36228. class EdgesRenderer implements IEdgesRenderer {
  36229. /**
  36230. * Define the size of the edges with an orthographic camera
  36231. */
  36232. edgesWidthScalerForOrthographic: number;
  36233. /**
  36234. * Define the size of the edges with a perspective camera
  36235. */
  36236. edgesWidthScalerForPerspective: number;
  36237. protected _source: AbstractMesh;
  36238. protected _linesPositions: number[];
  36239. protected _linesNormals: number[];
  36240. protected _linesIndices: number[];
  36241. protected _epsilon: number;
  36242. protected _indicesCount: number;
  36243. protected _lineShader: ShaderMaterial;
  36244. protected _ib: WebGLBuffer;
  36245. protected _buffers: {
  36246. [key: string]: Nullable<VertexBuffer>;
  36247. };
  36248. protected _checkVerticesInsteadOfIndices: boolean;
  36249. private _meshRebuildObserver;
  36250. private _meshDisposeObserver;
  36251. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  36252. isEnabled: boolean;
  36253. /**
  36254. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  36255. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  36256. * @param source Mesh used to create edges
  36257. * @param epsilon sum of angles in adjacency to check for edge
  36258. * @param checkVerticesInsteadOfIndices
  36259. * @param generateEdgesLines - should generate Lines or only prepare resources.
  36260. */
  36261. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  36262. protected _prepareRessources(): void;
  36263. /** @hidden */
  36264. _rebuild(): void;
  36265. /**
  36266. * Releases the required resources for the edges renderer
  36267. */
  36268. dispose(): void;
  36269. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  36270. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  36271. /**
  36272. * Checks if the pair of p0 and p1 is en edge
  36273. * @param faceIndex
  36274. * @param edge
  36275. * @param faceNormals
  36276. * @param p0
  36277. * @param p1
  36278. * @private
  36279. */
  36280. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  36281. /**
  36282. * push line into the position, normal and index buffer
  36283. * @protected
  36284. */
  36285. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  36286. /**
  36287. * Generates lines edges from adjacencjes
  36288. * @private
  36289. */
  36290. _generateEdgesLines(): void;
  36291. /**
  36292. * Checks wether or not the edges renderer is ready to render.
  36293. * @return true if ready, otherwise false.
  36294. */
  36295. isReady(): boolean;
  36296. /**
  36297. * Renders the edges of the attached mesh,
  36298. */
  36299. render(): void;
  36300. }
  36301. }
  36302. declare module BABYLON {
  36303. /**
  36304. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  36305. */
  36306. class GeometryBufferRenderer {
  36307. /**
  36308. * Constant used to retrieve the position texture index in the G-Buffer textures array
  36309. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  36310. */
  36311. static readonly POSITION_TEXTURE_TYPE: number;
  36312. /**
  36313. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  36314. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  36315. */
  36316. static readonly VELOCITY_TEXTURE_TYPE: number;
  36317. /**
  36318. * Dictionary used to store the previous transformation matrices of each rendered mesh
  36319. * in order to compute objects velocities when enableVelocity is set to "true"
  36320. * @hidden
  36321. */
  36322. _previousTransformationMatrices: {
  36323. [index: number]: Matrix;
  36324. };
  36325. private _scene;
  36326. private _multiRenderTarget;
  36327. private _ratio;
  36328. private _enablePosition;
  36329. private _enableVelocity;
  36330. private _positionIndex;
  36331. private _velocityIndex;
  36332. protected _effect: Effect;
  36333. protected _cachedDefines: string;
  36334. /**
  36335. * Set the render list (meshes to be rendered) used in the G buffer.
  36336. */
  36337. renderList: Mesh[];
  36338. /**
  36339. * Gets wether or not G buffer are supported by the running hardware.
  36340. * This requires draw buffer supports
  36341. */
  36342. readonly isSupported: boolean;
  36343. /**
  36344. * Returns the index of the given texture type in the G-Buffer textures array
  36345. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  36346. * @returns the index of the given texture type in the G-Buffer textures array
  36347. */
  36348. getTextureIndex(textureType: number): number;
  36349. /**
  36350. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  36351. */
  36352. /**
  36353. * Sets whether or not objects positions are enabled for the G buffer.
  36354. */
  36355. enablePosition: boolean;
  36356. /**
  36357. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  36358. */
  36359. /**
  36360. * Sets wether or not objects velocities are enabled for the G buffer.
  36361. */
  36362. enableVelocity: boolean;
  36363. /**
  36364. * Gets the scene associated with the buffer.
  36365. */
  36366. readonly scene: Scene;
  36367. /**
  36368. * Gets the ratio used by the buffer during its creation.
  36369. * How big is the buffer related to the main canvas.
  36370. */
  36371. readonly ratio: number;
  36372. /**
  36373. * Creates a new G Buffer for the scene
  36374. * @param scene The scene the buffer belongs to
  36375. * @param ratio How big is the buffer related to the main canvas.
  36376. */
  36377. constructor(scene: Scene, ratio?: number);
  36378. /**
  36379. * Checks wether everything is ready to render a submesh to the G buffer.
  36380. * @param subMesh the submesh to check readiness for
  36381. * @param useInstances is the mesh drawn using instance or not
  36382. * @returns true if ready otherwise false
  36383. */
  36384. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  36385. /**
  36386. * Gets the current underlying G Buffer.
  36387. * @returns the buffer
  36388. */
  36389. getGBuffer(): MultiRenderTarget;
  36390. /**
  36391. * Gets the number of samples used to render the buffer (anti aliasing).
  36392. */
  36393. /**
  36394. * Sets the number of samples used to render the buffer (anti aliasing).
  36395. */
  36396. samples: number;
  36397. /**
  36398. * Disposes the renderer and frees up associated resources.
  36399. */
  36400. dispose(): void;
  36401. protected _createRenderTargets(): void;
  36402. }
  36403. }
  36404. declare module BABYLON {
  36405. interface Scene {
  36406. /** @hidden (Backing field) */
  36407. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  36408. /**
  36409. * Gets or Sets the current geometry buffer associated to the scene.
  36410. */
  36411. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  36412. /**
  36413. * Enables a GeometryBufferRender and associates it with the scene
  36414. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  36415. * @returns the GeometryBufferRenderer
  36416. */
  36417. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  36418. /**
  36419. * Disables the GeometryBufferRender associated with the scene
  36420. */
  36421. disableGeometryBufferRenderer(): void;
  36422. }
  36423. /**
  36424. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  36425. * in several rendering techniques.
  36426. */
  36427. class GeometryBufferRendererSceneComponent implements ISceneComponent {
  36428. /**
  36429. * The component name helpful to identify the component in the list of scene components.
  36430. */
  36431. readonly name: string;
  36432. /**
  36433. * The scene the component belongs to.
  36434. */
  36435. scene: Scene;
  36436. /**
  36437. * Creates a new instance of the component for the given scene
  36438. * @param scene Defines the scene to register the component in
  36439. */
  36440. constructor(scene: Scene);
  36441. /**
  36442. * Registers the component in a given scene
  36443. */
  36444. register(): void;
  36445. /**
  36446. * Rebuilds the elements related to this component in case of
  36447. * context lost for instance.
  36448. */
  36449. rebuild(): void;
  36450. /**
  36451. * Disposes the component and the associated ressources
  36452. */
  36453. dispose(): void;
  36454. private _gatherRenderTargets;
  36455. }
  36456. }
  36457. declare module BABYLON {
  36458. /**
  36459. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  36460. */
  36461. class LineEdgesRenderer extends EdgesRenderer {
  36462. /**
  36463. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  36464. * @param source LineMesh used to generate edges
  36465. * @param epsilon not important (specified angle for edge detection)
  36466. * @param checkVerticesInsteadOfIndices not important for LineMesh
  36467. */
  36468. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  36469. /**
  36470. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  36471. */
  36472. _generateEdgesLines(): void;
  36473. }
  36474. }
  36475. declare module BABYLON {
  36476. interface Scene {
  36477. /** @hidden */
  36478. _outlineRenderer: OutlineRenderer;
  36479. /**
  36480. * Gets the outline renderer associated with the scene
  36481. * @returns a OutlineRenderer
  36482. */
  36483. getOutlineRenderer(): OutlineRenderer;
  36484. }
  36485. interface AbstractMesh {
  36486. /** @hidden (Backing field) */
  36487. _renderOutline: boolean;
  36488. /**
  36489. * Gets or sets a boolean indicating if the outline must be rendered as well
  36490. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  36491. */
  36492. renderOutline: boolean;
  36493. /** @hidden (Backing field) */
  36494. _renderOverlay: boolean;
  36495. /**
  36496. * Gets or sets a boolean indicating if the overlay must be rendered as well
  36497. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  36498. */
  36499. renderOverlay: boolean;
  36500. }
  36501. /**
  36502. * This class is responsible to draw bothe outline/overlay of meshes.
  36503. * It should not be used directly but through the available method on mesh.
  36504. */
  36505. class OutlineRenderer implements ISceneComponent {
  36506. /**
  36507. * The name of the component. Each component must have a unique name.
  36508. */
  36509. name: string;
  36510. /**
  36511. * The scene the component belongs to.
  36512. */
  36513. scene: Scene;
  36514. /**
  36515. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  36516. */
  36517. zOffset: number;
  36518. private _engine;
  36519. private _effect;
  36520. private _cachedDefines;
  36521. private _savedDepthWrite;
  36522. /**
  36523. * Instantiates a new outline renderer. (There could be only one per scene).
  36524. * @param scene Defines the scene it belongs to
  36525. */
  36526. constructor(scene: Scene);
  36527. /**
  36528. * Register the component to one instance of a scene.
  36529. */
  36530. register(): void;
  36531. /**
  36532. * Rebuilds the elements related to this component in case of
  36533. * context lost for instance.
  36534. */
  36535. rebuild(): void;
  36536. /**
  36537. * Disposes the component and the associated ressources.
  36538. */
  36539. dispose(): void;
  36540. /**
  36541. * Renders the outline in the canvas.
  36542. * @param subMesh Defines the sumesh to render
  36543. * @param batch Defines the batch of meshes in case of instances
  36544. * @param useOverlay Defines if the rendering is for the overlay or the outline
  36545. */
  36546. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  36547. /**
  36548. * Returns whether or not the outline renderer is ready for a given submesh.
  36549. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  36550. * @param subMesh Defines the submesh to check readyness for
  36551. * @param useInstances Defines wheter wee are trying to render instances or not
  36552. * @returns true if ready otherwise false
  36553. */
  36554. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  36555. private _beforeRenderingMesh;
  36556. private _afterRenderingMesh;
  36557. }
  36558. }
  36559. declare module BABYLON {
  36560. /**
  36561. * This represents the object necessary to create a rendering group.
  36562. * This is exclusively used and created by the rendering manager.
  36563. * To modify the behavior, you use the available helpers in your scene or meshes.
  36564. * @hidden
  36565. */
  36566. class RenderingGroup {
  36567. index: number;
  36568. private _scene;
  36569. private _opaqueSubMeshes;
  36570. private _transparentSubMeshes;
  36571. private _alphaTestSubMeshes;
  36572. private _depthOnlySubMeshes;
  36573. private _particleSystems;
  36574. private _spriteManagers;
  36575. private _opaqueSortCompareFn;
  36576. private _alphaTestSortCompareFn;
  36577. private _transparentSortCompareFn;
  36578. private _renderOpaque;
  36579. private _renderAlphaTest;
  36580. private _renderTransparent;
  36581. private _edgesRenderers;
  36582. onBeforeTransparentRendering: () => void;
  36583. /**
  36584. * Set the opaque sort comparison function.
  36585. * If null the sub meshes will be render in the order they were created
  36586. */
  36587. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  36588. /**
  36589. * Set the alpha test sort comparison function.
  36590. * If null the sub meshes will be render in the order they were created
  36591. */
  36592. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  36593. /**
  36594. * Set the transparent sort comparison function.
  36595. * If null the sub meshes will be render in the order they were created
  36596. */
  36597. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  36598. /**
  36599. * Creates a new rendering group.
  36600. * @param index The rendering group index
  36601. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  36602. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  36603. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  36604. */
  36605. 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>);
  36606. /**
  36607. * Render all the sub meshes contained in the group.
  36608. * @param customRenderFunction Used to override the default render behaviour of the group.
  36609. * @returns true if rendered some submeshes.
  36610. */
  36611. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  36612. /**
  36613. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  36614. * @param subMeshes The submeshes to render
  36615. */
  36616. private renderOpaqueSorted;
  36617. /**
  36618. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  36619. * @param subMeshes The submeshes to render
  36620. */
  36621. private renderAlphaTestSorted;
  36622. /**
  36623. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  36624. * @param subMeshes The submeshes to render
  36625. */
  36626. private renderTransparentSorted;
  36627. /**
  36628. * Renders the submeshes in a specified order.
  36629. * @param subMeshes The submeshes to sort before render
  36630. * @param sortCompareFn The comparison function use to sort
  36631. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  36632. * @param transparent Specifies to activate blending if true
  36633. */
  36634. private static renderSorted;
  36635. /**
  36636. * Renders the submeshes in the order they were dispatched (no sort applied).
  36637. * @param subMeshes The submeshes to render
  36638. */
  36639. private static renderUnsorted;
  36640. /**
  36641. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  36642. * are rendered back to front if in the same alpha index.
  36643. *
  36644. * @param a The first submesh
  36645. * @param b The second submesh
  36646. * @returns The result of the comparison
  36647. */
  36648. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  36649. /**
  36650. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  36651. * are rendered back to front.
  36652. *
  36653. * @param a The first submesh
  36654. * @param b The second submesh
  36655. * @returns The result of the comparison
  36656. */
  36657. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  36658. /**
  36659. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  36660. * are rendered front to back (prevent overdraw).
  36661. *
  36662. * @param a The first submesh
  36663. * @param b The second submesh
  36664. * @returns The result of the comparison
  36665. */
  36666. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  36667. /**
  36668. * Resets the different lists of submeshes to prepare a new frame.
  36669. */
  36670. prepare(): void;
  36671. dispose(): void;
  36672. /**
  36673. * Inserts the submesh in its correct queue depending on its material.
  36674. * @param subMesh The submesh to dispatch
  36675. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  36676. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  36677. */
  36678. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  36679. dispatchSprites(spriteManager: ISpriteManager): void;
  36680. dispatchParticles(particleSystem: IParticleSystem): void;
  36681. private _renderParticles;
  36682. private _renderSprites;
  36683. }
  36684. }
  36685. declare module BABYLON {
  36686. /**
  36687. * Interface describing the different options available in the rendering manager
  36688. * regarding Auto Clear between groups.
  36689. */
  36690. interface IRenderingManagerAutoClearSetup {
  36691. /**
  36692. * Defines whether or not autoclear is enable.
  36693. */
  36694. autoClear: boolean;
  36695. /**
  36696. * Defines whether or not to autoclear the depth buffer.
  36697. */
  36698. depth: boolean;
  36699. /**
  36700. * Defines whether or not to autoclear the stencil buffer.
  36701. */
  36702. stencil: boolean;
  36703. }
  36704. /**
  36705. * This is the manager responsible of all the rendering for meshes sprites and particles.
  36706. * It is enable to manage the different groups as well as the different necessary sort functions.
  36707. * This should not be used directly aside of the few static configurations
  36708. */
  36709. class RenderingManager {
  36710. /**
  36711. * The max id used for rendering groups (not included)
  36712. */
  36713. static MAX_RENDERINGGROUPS: number;
  36714. /**
  36715. * The min id used for rendering groups (included)
  36716. */
  36717. static MIN_RENDERINGGROUPS: number;
  36718. /**
  36719. * Used to globally prevent autoclearing scenes.
  36720. */
  36721. static AUTOCLEAR: boolean;
  36722. /**
  36723. * @hidden
  36724. */
  36725. _useSceneAutoClearSetup: boolean;
  36726. private _scene;
  36727. private _renderingGroups;
  36728. private _depthStencilBufferAlreadyCleaned;
  36729. private _autoClearDepthStencil;
  36730. private _customOpaqueSortCompareFn;
  36731. private _customAlphaTestSortCompareFn;
  36732. private _customTransparentSortCompareFn;
  36733. private _renderingGroupInfo;
  36734. /**
  36735. * Instantiates a new rendering group for a particular scene
  36736. * @param scene Defines the scene the groups belongs to
  36737. */
  36738. constructor(scene: Scene);
  36739. private _clearDepthStencilBuffer;
  36740. /**
  36741. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  36742. * @hidden
  36743. */
  36744. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  36745. /**
  36746. * Resets the different information of the group to prepare a new frame
  36747. * @hidden
  36748. */
  36749. reset(): void;
  36750. /**
  36751. * Dispose and release the group and its associated resources.
  36752. * @hidden
  36753. */
  36754. dispose(): void;
  36755. /**
  36756. * Clear the info related to rendering groups preventing retention points during dispose.
  36757. */
  36758. freeRenderingGroups(): void;
  36759. private _prepareRenderingGroup;
  36760. /**
  36761. * Add a sprite manager to the rendering manager in order to render it this frame.
  36762. * @param spriteManager Define the sprite manager to render
  36763. */
  36764. dispatchSprites(spriteManager: ISpriteManager): void;
  36765. /**
  36766. * Add a particle system to the rendering manager in order to render it this frame.
  36767. * @param particleSystem Define the particle system to render
  36768. */
  36769. dispatchParticles(particleSystem: IParticleSystem): void;
  36770. /**
  36771. * Add a submesh to the manager in order to render it this frame
  36772. * @param subMesh The submesh to dispatch
  36773. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  36774. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  36775. */
  36776. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  36777. /**
  36778. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  36779. * This allowed control for front to back rendering or reversly depending of the special needs.
  36780. *
  36781. * @param renderingGroupId The rendering group id corresponding to its index
  36782. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  36783. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  36784. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  36785. */
  36786. 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;
  36787. /**
  36788. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  36789. *
  36790. * @param renderingGroupId The rendering group id corresponding to its index
  36791. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  36792. * @param depth Automatically clears depth between groups if true and autoClear is true.
  36793. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  36794. */
  36795. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  36796. /**
  36797. * Gets the current auto clear configuration for one rendering group of the rendering
  36798. * manager.
  36799. * @param index the rendering group index to get the information for
  36800. * @returns The auto clear setup for the requested rendering group
  36801. */
  36802. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  36803. }
  36804. }
  36805. declare module BABYLON {
  36806. /**
  36807. * Renders a layer on top of an existing scene
  36808. */
  36809. class UtilityLayerRenderer implements IDisposable {
  36810. /** the original scene that will be rendered on top of */
  36811. originalScene: Scene;
  36812. private _pointerCaptures;
  36813. private _lastPointerEvents;
  36814. private static _DefaultUtilityLayer;
  36815. private static _DefaultKeepDepthUtilityLayer;
  36816. /**
  36817. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  36818. */
  36819. pickUtilitySceneFirst: boolean;
  36820. /**
  36821. * 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)
  36822. */
  36823. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  36824. /**
  36825. * 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)
  36826. */
  36827. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  36828. /**
  36829. * The scene that is rendered on top of the original scene
  36830. */
  36831. utilityLayerScene: Scene;
  36832. /**
  36833. * If the utility layer should automatically be rendered on top of existing scene
  36834. */
  36835. shouldRender: boolean;
  36836. /**
  36837. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  36838. */
  36839. onlyCheckPointerDownEvents: boolean;
  36840. /**
  36841. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  36842. */
  36843. processAllEvents: boolean;
  36844. /**
  36845. * Observable raised when the pointer move from the utility layer scene to the main scene
  36846. */
  36847. onPointerOutObservable: Observable<number>;
  36848. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  36849. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  36850. private _afterRenderObserver;
  36851. private _sceneDisposeObserver;
  36852. private _originalPointerObserver;
  36853. /**
  36854. * Instantiates a UtilityLayerRenderer
  36855. * @param originalScene the original scene that will be rendered on top of
  36856. * @param handleEvents boolean indicating if the utility layer should handle events
  36857. */
  36858. constructor(
  36859. /** the original scene that will be rendered on top of */
  36860. originalScene: Scene, handleEvents?: boolean);
  36861. private _notifyObservers;
  36862. /**
  36863. * Renders the utility layers scene on top of the original scene
  36864. */
  36865. render(): void;
  36866. /**
  36867. * Disposes of the renderer
  36868. */
  36869. dispose(): void;
  36870. private _updateCamera;
  36871. }
  36872. }
  36873. declare module BABYLON {
  36874. /**
  36875. * Class used to represent a sprite
  36876. * @see http://doc.babylonjs.com/babylon101/sprites
  36877. */
  36878. class Sprite {
  36879. /** defines the name */
  36880. name: string;
  36881. /** Gets or sets the current world position */
  36882. position: Vector3;
  36883. /** Gets or sets the main color */
  36884. color: Color4;
  36885. /** Gets or sets the width */
  36886. width: number;
  36887. /** Gets or sets the height */
  36888. height: number;
  36889. /** Gets or sets rotation angle */
  36890. angle: number;
  36891. /** Gets or sets the cell index in the sprite sheet */
  36892. cellIndex: number;
  36893. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  36894. invertU: number;
  36895. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  36896. invertV: number;
  36897. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  36898. disposeWhenFinishedAnimating: boolean;
  36899. /** Gets the list of attached animations */
  36900. animations: Animation[];
  36901. /** Gets or sets a boolean indicating if the sprite can be picked */
  36902. isPickable: boolean;
  36903. /**
  36904. * Gets or sets the associated action manager
  36905. */
  36906. actionManager: Nullable<ActionManager>;
  36907. private _animationStarted;
  36908. private _loopAnimation;
  36909. private _fromIndex;
  36910. private _toIndex;
  36911. private _delay;
  36912. private _direction;
  36913. private _manager;
  36914. private _time;
  36915. private _onAnimationEnd;
  36916. /**
  36917. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  36918. */
  36919. isVisible: boolean;
  36920. /**
  36921. * Gets or sets the sprite size
  36922. */
  36923. size: number;
  36924. /**
  36925. * Creates a new Sprite
  36926. * @param name defines the name
  36927. * @param manager defines the manager
  36928. */
  36929. constructor(
  36930. /** defines the name */
  36931. name: string, manager: ISpriteManager);
  36932. /**
  36933. * Starts an animation
  36934. * @param from defines the initial key
  36935. * @param to defines the end key
  36936. * @param loop defines if the animation must loop
  36937. * @param delay defines the start delay (in ms)
  36938. * @param onAnimationEnd defines a callback to call when animation ends
  36939. */
  36940. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  36941. /** Stops current animation (if any) */
  36942. stopAnimation(): void;
  36943. /** @hidden */
  36944. _animate(deltaTime: number): void;
  36945. /** Release associated resources */
  36946. dispose(): void;
  36947. }
  36948. }
  36949. declare module BABYLON {
  36950. /**
  36951. * Defines the minimum interface to fullfil in order to be a sprite manager.
  36952. */
  36953. interface ISpriteManager extends IDisposable {
  36954. /**
  36955. * Restricts the camera to viewing objects with the same layerMask.
  36956. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  36957. */
  36958. layerMask: number;
  36959. /**
  36960. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  36961. */
  36962. isPickable: boolean;
  36963. /**
  36964. * Specifies the rendering group id for this mesh (0 by default)
  36965. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  36966. */
  36967. renderingGroupId: number;
  36968. /**
  36969. * Defines the list of sprites managed by the manager.
  36970. */
  36971. sprites: Array<Sprite>;
  36972. /**
  36973. * Tests the intersection of a sprite with a specific ray.
  36974. * @param ray The ray we are sending to test the collision
  36975. * @param camera The camera space we are sending rays in
  36976. * @param predicate A predicate allowing excluding sprites from the list of object to test
  36977. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  36978. * @returns picking info or null.
  36979. */
  36980. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  36981. /**
  36982. * Renders the list of sprites on screen.
  36983. */
  36984. render(): void;
  36985. }
  36986. /**
  36987. * Class used to manage multiple sprites on the same spritesheet
  36988. * @see http://doc.babylonjs.com/babylon101/sprites
  36989. */
  36990. class SpriteManager implements ISpriteManager {
  36991. /** defines the manager's name */
  36992. name: string;
  36993. /** Gets the list of sprites */
  36994. sprites: Sprite[];
  36995. /** Gets or sets the rendering group id (0 by default) */
  36996. renderingGroupId: number;
  36997. /** Gets or sets camera layer mask */
  36998. layerMask: number;
  36999. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  37000. fogEnabled: boolean;
  37001. /** Gets or sets a boolean indicating if the sprites are pickable */
  37002. isPickable: boolean;
  37003. /** Defines the default width of a cell in the spritesheet */
  37004. cellWidth: number;
  37005. /** Defines the default height of a cell in the spritesheet */
  37006. cellHeight: number;
  37007. /**
  37008. * An event triggered when the manager is disposed.
  37009. */
  37010. onDisposeObservable: Observable<SpriteManager>;
  37011. private _onDisposeObserver;
  37012. /**
  37013. * Callback called when the manager is disposed
  37014. */
  37015. onDispose: () => void;
  37016. private _capacity;
  37017. private _spriteTexture;
  37018. private _epsilon;
  37019. private _scene;
  37020. private _vertexData;
  37021. private _buffer;
  37022. private _vertexBuffers;
  37023. private _indexBuffer;
  37024. private _effectBase;
  37025. private _effectFog;
  37026. /**
  37027. * Gets or sets the spritesheet texture
  37028. */
  37029. texture: Texture;
  37030. /**
  37031. * Creates a new sprite manager
  37032. * @param name defines the manager's name
  37033. * @param imgUrl defines the sprite sheet url
  37034. * @param capacity defines the maximum allowed number of sprites
  37035. * @param cellSize defines the size of a sprite cell
  37036. * @param scene defines the hosting scene
  37037. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  37038. * @param samplingMode defines the smapling mode to use with spritesheet
  37039. */
  37040. constructor(
  37041. /** defines the manager's name */
  37042. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  37043. private _appendSpriteVertex;
  37044. /**
  37045. * Intersects the sprites with a ray
  37046. * @param ray defines the ray to intersect with
  37047. * @param camera defines the current active camera
  37048. * @param predicate defines a predicate used to select candidate sprites
  37049. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  37050. * @returns null if no hit or a PickingInfo
  37051. */
  37052. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  37053. /**
  37054. * Render all child sprites
  37055. */
  37056. render(): void;
  37057. /**
  37058. * Release associated resources
  37059. */
  37060. dispose(): void;
  37061. }
  37062. }
  37063. declare module BABYLON {
  37064. interface Scene {
  37065. /** @hidden */
  37066. _pointerOverSprite: Nullable<Sprite>;
  37067. /** @hidden */
  37068. _pickedDownSprite: Nullable<Sprite>;
  37069. /** @hidden */
  37070. _tempSpritePickingRay: Nullable<Ray>;
  37071. /**
  37072. * All of the sprite managers added to this scene
  37073. * @see http://doc.babylonjs.com/babylon101/sprites
  37074. */
  37075. spriteManagers: Array<ISpriteManager>;
  37076. /**
  37077. * An event triggered when sprites rendering is about to start
  37078. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  37079. */
  37080. onBeforeSpritesRenderingObservable: Observable<Scene>;
  37081. /**
  37082. * An event triggered when sprites rendering is done
  37083. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  37084. */
  37085. onAfterSpritesRenderingObservable: Observable<Scene>;
  37086. /** @hidden */
  37087. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  37088. /** Launch a ray to try to pick a sprite in the scene
  37089. * @param x position on screen
  37090. * @param y position on screen
  37091. * @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
  37092. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  37093. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37094. * @returns a PickingInfo
  37095. */
  37096. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  37097. /** Use the given ray to pick a sprite in the scene
  37098. * @param ray The ray (in world space) to use to pick meshes
  37099. * @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
  37100. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  37101. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  37102. * @returns a PickingInfo
  37103. */
  37104. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  37105. /**
  37106. * Force the sprite under the pointer
  37107. * @param sprite defines the sprite to use
  37108. */
  37109. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  37110. /**
  37111. * Gets the sprite under the pointer
  37112. * @returns a Sprite or null if no sprite is under the pointer
  37113. */
  37114. getPointerOverSprite(): Nullable<Sprite>;
  37115. }
  37116. /**
  37117. * Defines the sprite scene component responsible to manage sprites
  37118. * in a given scene.
  37119. */
  37120. class SpriteSceneComponent implements ISceneComponent {
  37121. /**
  37122. * The component name helpfull to identify the component in the list of scene components.
  37123. */
  37124. readonly name: string;
  37125. /**
  37126. * The scene the component belongs to.
  37127. */
  37128. scene: Scene;
  37129. /** @hidden */
  37130. private _spritePredicate;
  37131. /**
  37132. * Creates a new instance of the component for the given scene
  37133. * @param scene Defines the scene to register the component in
  37134. */
  37135. constructor(scene: Scene);
  37136. /**
  37137. * Registers the component in a given scene
  37138. */
  37139. register(): void;
  37140. /**
  37141. * Rebuilds the elements related to this component in case of
  37142. * context lost for instance.
  37143. */
  37144. rebuild(): void;
  37145. /**
  37146. * Disposes the component and the associated ressources.
  37147. */
  37148. dispose(): void;
  37149. private _pickSpriteButKeepRay;
  37150. private _pointerMove;
  37151. private _pointerDown;
  37152. private _pointerUp;
  37153. }
  37154. }
  37155. declare module BABYLON {
  37156. /**
  37157. * @hidden
  37158. **/
  37159. class _AlphaState {
  37160. private _isAlphaBlendDirty;
  37161. private _isBlendFunctionParametersDirty;
  37162. private _isBlendEquationParametersDirty;
  37163. private _isBlendConstantsDirty;
  37164. private _alphaBlend;
  37165. private _blendFunctionParameters;
  37166. private _blendEquationParameters;
  37167. private _blendConstants;
  37168. /**
  37169. * Initializes the state.
  37170. */
  37171. constructor();
  37172. readonly isDirty: boolean;
  37173. alphaBlend: boolean;
  37174. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  37175. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  37176. setAlphaEquationParameters(rgb: number, alpha: number): void;
  37177. reset(): void;
  37178. apply(gl: WebGLRenderingContext): void;
  37179. }
  37180. }
  37181. declare module BABYLON {
  37182. /**
  37183. * @hidden
  37184. **/
  37185. class _DepthCullingState {
  37186. private _isDepthTestDirty;
  37187. private _isDepthMaskDirty;
  37188. private _isDepthFuncDirty;
  37189. private _isCullFaceDirty;
  37190. private _isCullDirty;
  37191. private _isZOffsetDirty;
  37192. private _isFrontFaceDirty;
  37193. private _depthTest;
  37194. private _depthMask;
  37195. private _depthFunc;
  37196. private _cull;
  37197. private _cullFace;
  37198. private _zOffset;
  37199. private _frontFace;
  37200. /**
  37201. * Initializes the state.
  37202. */
  37203. constructor();
  37204. readonly isDirty: boolean;
  37205. zOffset: number;
  37206. cullFace: Nullable<number>;
  37207. cull: Nullable<boolean>;
  37208. depthFunc: Nullable<number>;
  37209. depthMask: boolean;
  37210. depthTest: boolean;
  37211. frontFace: Nullable<number>;
  37212. reset(): void;
  37213. apply(gl: WebGLRenderingContext): void;
  37214. }
  37215. }
  37216. declare module BABYLON {
  37217. /**
  37218. * @hidden
  37219. **/
  37220. class _StencilState {
  37221. private _isStencilTestDirty;
  37222. private _isStencilMaskDirty;
  37223. private _isStencilFuncDirty;
  37224. private _isStencilOpDirty;
  37225. private _stencilTest;
  37226. private _stencilMask;
  37227. private _stencilFunc;
  37228. private _stencilFuncRef;
  37229. private _stencilFuncMask;
  37230. private _stencilOpStencilFail;
  37231. private _stencilOpDepthFail;
  37232. private _stencilOpStencilDepthPass;
  37233. readonly isDirty: boolean;
  37234. stencilFunc: number;
  37235. stencilFuncRef: number;
  37236. stencilFuncMask: number;
  37237. stencilOpStencilFail: number;
  37238. stencilOpDepthFail: number;
  37239. stencilOpStencilDepthPass: number;
  37240. stencilMask: number;
  37241. stencilTest: boolean;
  37242. constructor();
  37243. reset(): void;
  37244. apply(gl: WebGLRenderingContext): void;
  37245. }
  37246. }
  37247. declare module BABYLON {
  37248. /**
  37249. * Class used to evalaute queries containing `and` and `or` operators
  37250. */
  37251. class AndOrNotEvaluator {
  37252. /**
  37253. * Evaluate a query
  37254. * @param query defines the query to evaluate
  37255. * @param evaluateCallback defines the callback used to filter result
  37256. * @returns true if the query matches
  37257. */
  37258. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  37259. private static _HandleParenthesisContent;
  37260. private static _SimplifyNegation;
  37261. }
  37262. }
  37263. declare module BABYLON {
  37264. /**
  37265. * Defines the list of states available for a task inside a AssetsManager
  37266. */
  37267. enum AssetTaskState {
  37268. /**
  37269. * Initialization
  37270. */
  37271. INIT = 0,
  37272. /**
  37273. * Running
  37274. */
  37275. RUNNING = 1,
  37276. /**
  37277. * Done
  37278. */
  37279. DONE = 2,
  37280. /**
  37281. * Error
  37282. */
  37283. ERROR = 3
  37284. }
  37285. /**
  37286. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  37287. */
  37288. abstract class AbstractAssetTask {
  37289. /**
  37290. * Task name
  37291. */ name: string;
  37292. /**
  37293. * Callback called when the task is successful
  37294. */
  37295. onSuccess: (task: any) => void;
  37296. /**
  37297. * Callback called when the task is not successful
  37298. */
  37299. onError: (task: any, message?: string, exception?: any) => void;
  37300. /**
  37301. * Creates a new AssetsManager
  37302. * @param name defines the name of the task
  37303. */
  37304. constructor(
  37305. /**
  37306. * Task name
  37307. */ name: string);
  37308. private _isCompleted;
  37309. private _taskState;
  37310. private _errorObject;
  37311. /**
  37312. * Get if the task is completed
  37313. */
  37314. readonly isCompleted: boolean;
  37315. /**
  37316. * Gets the current state of the task
  37317. */
  37318. readonly taskState: AssetTaskState;
  37319. /**
  37320. * Gets the current error object (if task is in error)
  37321. */
  37322. readonly errorObject: {
  37323. message?: string;
  37324. exception?: any;
  37325. };
  37326. /**
  37327. * Internal only
  37328. * @hidden
  37329. */
  37330. _setErrorObject(message?: string, exception?: any): void;
  37331. /**
  37332. * Execute the current task
  37333. * @param scene defines the scene where you want your assets to be loaded
  37334. * @param onSuccess is a callback called when the task is successfully executed
  37335. * @param onError is a callback called if an error occurs
  37336. */
  37337. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37338. /**
  37339. * Execute the current task
  37340. * @param scene defines the scene where you want your assets to be loaded
  37341. * @param onSuccess is a callback called when the task is successfully executed
  37342. * @param onError is a callback called if an error occurs
  37343. */
  37344. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37345. /**
  37346. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  37347. * This can be used with failed tasks that have the reason for failure fixed.
  37348. */
  37349. reset(): void;
  37350. private onErrorCallback;
  37351. private onDoneCallback;
  37352. }
  37353. /**
  37354. * Define the interface used by progress events raised during assets loading
  37355. */
  37356. interface IAssetsProgressEvent {
  37357. /**
  37358. * Defines the number of remaining tasks to process
  37359. */
  37360. remainingCount: number;
  37361. /**
  37362. * Defines the total number of tasks
  37363. */
  37364. totalCount: number;
  37365. /**
  37366. * Defines the task that was just processed
  37367. */
  37368. task: AbstractAssetTask;
  37369. }
  37370. /**
  37371. * Class used to share progress information about assets loading
  37372. */
  37373. class AssetsProgressEvent implements IAssetsProgressEvent {
  37374. /**
  37375. * Defines the number of remaining tasks to process
  37376. */
  37377. remainingCount: number;
  37378. /**
  37379. * Defines the total number of tasks
  37380. */
  37381. totalCount: number;
  37382. /**
  37383. * Defines the task that was just processed
  37384. */
  37385. task: AbstractAssetTask;
  37386. /**
  37387. * Creates a AssetsProgressEvent
  37388. * @param remainingCount defines the number of remaining tasks to process
  37389. * @param totalCount defines the total number of tasks
  37390. * @param task defines the task that was just processed
  37391. */
  37392. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  37393. }
  37394. /**
  37395. * Define a task used by AssetsManager to load meshes
  37396. */
  37397. class MeshAssetTask extends AbstractAssetTask {
  37398. /**
  37399. * Defines the name of the task
  37400. */
  37401. name: string;
  37402. /**
  37403. * Defines the list of mesh's names you want to load
  37404. */
  37405. meshesNames: any;
  37406. /**
  37407. * Defines the root url to use as a base to load your meshes and associated resources
  37408. */
  37409. rootUrl: string;
  37410. /**
  37411. * Defines the filename of the scene to load from
  37412. */
  37413. sceneFilename: string;
  37414. /**
  37415. * Gets the list of loaded meshes
  37416. */
  37417. loadedMeshes: Array<AbstractMesh>;
  37418. /**
  37419. * Gets the list of loaded particle systems
  37420. */
  37421. loadedParticleSystems: Array<IParticleSystem>;
  37422. /**
  37423. * Gets the list of loaded skeletons
  37424. */
  37425. loadedSkeletons: Array<Skeleton>;
  37426. /**
  37427. * Callback called when the task is successful
  37428. */
  37429. onSuccess: (task: MeshAssetTask) => void;
  37430. /**
  37431. * Callback called when the task is successful
  37432. */
  37433. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  37434. /**
  37435. * Creates a new MeshAssetTask
  37436. * @param name defines the name of the task
  37437. * @param meshesNames defines the list of mesh's names you want to load
  37438. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  37439. * @param sceneFilename defines the filename of the scene to load from
  37440. */
  37441. constructor(
  37442. /**
  37443. * Defines the name of the task
  37444. */
  37445. name: string,
  37446. /**
  37447. * Defines the list of mesh's names you want to load
  37448. */
  37449. meshesNames: any,
  37450. /**
  37451. * Defines the root url to use as a base to load your meshes and associated resources
  37452. */
  37453. rootUrl: string,
  37454. /**
  37455. * Defines the filename of the scene to load from
  37456. */
  37457. sceneFilename: string);
  37458. /**
  37459. * Execute the current task
  37460. * @param scene defines the scene where you want your assets to be loaded
  37461. * @param onSuccess is a callback called when the task is successfully executed
  37462. * @param onError is a callback called if an error occurs
  37463. */
  37464. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37465. }
  37466. /**
  37467. * Define a task used by AssetsManager to load text content
  37468. */
  37469. class TextFileAssetTask extends AbstractAssetTask {
  37470. /**
  37471. * Defines the name of the task
  37472. */
  37473. name: string;
  37474. /**
  37475. * Defines the location of the file to load
  37476. */
  37477. url: string;
  37478. /**
  37479. * Gets the loaded text string
  37480. */
  37481. text: string;
  37482. /**
  37483. * Callback called when the task is successful
  37484. */
  37485. onSuccess: (task: TextFileAssetTask) => void;
  37486. /**
  37487. * Callback called when the task is successful
  37488. */
  37489. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  37490. /**
  37491. * Creates a new TextFileAssetTask object
  37492. * @param name defines the name of the task
  37493. * @param url defines the location of the file to load
  37494. */
  37495. constructor(
  37496. /**
  37497. * Defines the name of the task
  37498. */
  37499. name: string,
  37500. /**
  37501. * Defines the location of the file to load
  37502. */
  37503. url: string);
  37504. /**
  37505. * Execute the current task
  37506. * @param scene defines the scene where you want your assets to be loaded
  37507. * @param onSuccess is a callback called when the task is successfully executed
  37508. * @param onError is a callback called if an error occurs
  37509. */
  37510. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37511. }
  37512. /**
  37513. * Define a task used by AssetsManager to load binary data
  37514. */
  37515. class BinaryFileAssetTask extends AbstractAssetTask {
  37516. /**
  37517. * Defines the name of the task
  37518. */
  37519. name: string;
  37520. /**
  37521. * Defines the location of the file to load
  37522. */
  37523. url: string;
  37524. /**
  37525. * Gets the lodaded data (as an array buffer)
  37526. */
  37527. data: ArrayBuffer;
  37528. /**
  37529. * Callback called when the task is successful
  37530. */
  37531. onSuccess: (task: BinaryFileAssetTask) => void;
  37532. /**
  37533. * Callback called when the task is successful
  37534. */
  37535. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  37536. /**
  37537. * Creates a new BinaryFileAssetTask object
  37538. * @param name defines the name of the new task
  37539. * @param url defines the location of the file to load
  37540. */
  37541. constructor(
  37542. /**
  37543. * Defines the name of the task
  37544. */
  37545. name: string,
  37546. /**
  37547. * Defines the location of the file to load
  37548. */
  37549. url: string);
  37550. /**
  37551. * Execute the current task
  37552. * @param scene defines the scene where you want your assets to be loaded
  37553. * @param onSuccess is a callback called when the task is successfully executed
  37554. * @param onError is a callback called if an error occurs
  37555. */
  37556. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37557. }
  37558. /**
  37559. * Define a task used by AssetsManager to load images
  37560. */
  37561. class ImageAssetTask extends AbstractAssetTask {
  37562. /**
  37563. * Defines the name of the task
  37564. */
  37565. name: string;
  37566. /**
  37567. * Defines the location of the image to load
  37568. */
  37569. url: string;
  37570. /**
  37571. * Gets the loaded images
  37572. */
  37573. image: HTMLImageElement;
  37574. /**
  37575. * Callback called when the task is successful
  37576. */
  37577. onSuccess: (task: ImageAssetTask) => void;
  37578. /**
  37579. * Callback called when the task is successful
  37580. */
  37581. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  37582. /**
  37583. * Creates a new ImageAssetTask
  37584. * @param name defines the name of the task
  37585. * @param url defines the location of the image to load
  37586. */
  37587. constructor(
  37588. /**
  37589. * Defines the name of the task
  37590. */
  37591. name: string,
  37592. /**
  37593. * Defines the location of the image to load
  37594. */
  37595. url: string);
  37596. /**
  37597. * Execute the current task
  37598. * @param scene defines the scene where you want your assets to be loaded
  37599. * @param onSuccess is a callback called when the task is successfully executed
  37600. * @param onError is a callback called if an error occurs
  37601. */
  37602. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37603. }
  37604. /**
  37605. * Defines the interface used by texture loading tasks
  37606. */
  37607. interface ITextureAssetTask<TEX extends BaseTexture> {
  37608. /**
  37609. * Gets the loaded texture
  37610. */
  37611. texture: TEX;
  37612. }
  37613. /**
  37614. * Define a task used by AssetsManager to load 2D textures
  37615. */
  37616. class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  37617. /**
  37618. * Defines the name of the task
  37619. */
  37620. name: string;
  37621. /**
  37622. * Defines the location of the file to load
  37623. */
  37624. url: string;
  37625. /**
  37626. * Defines if mipmap should not be generated (default is false)
  37627. */
  37628. noMipmap?: boolean | undefined;
  37629. /**
  37630. * Defines if texture must be inverted on Y axis (default is false)
  37631. */
  37632. invertY?: boolean | undefined;
  37633. /**
  37634. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  37635. */
  37636. samplingMode: number;
  37637. /**
  37638. * Gets the loaded texture
  37639. */
  37640. texture: Texture;
  37641. /**
  37642. * Callback called when the task is successful
  37643. */
  37644. onSuccess: (task: TextureAssetTask) => void;
  37645. /**
  37646. * Callback called when the task is successful
  37647. */
  37648. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  37649. /**
  37650. * Creates a new TextureAssetTask object
  37651. * @param name defines the name of the task
  37652. * @param url defines the location of the file to load
  37653. * @param noMipmap defines if mipmap should not be generated (default is false)
  37654. * @param invertY defines if texture must be inverted on Y axis (default is false)
  37655. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  37656. */
  37657. constructor(
  37658. /**
  37659. * Defines the name of the task
  37660. */
  37661. name: string,
  37662. /**
  37663. * Defines the location of the file to load
  37664. */
  37665. url: string,
  37666. /**
  37667. * Defines if mipmap should not be generated (default is false)
  37668. */
  37669. noMipmap?: boolean | undefined,
  37670. /**
  37671. * Defines if texture must be inverted on Y axis (default is false)
  37672. */
  37673. invertY?: boolean | undefined,
  37674. /**
  37675. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  37676. */
  37677. samplingMode?: number);
  37678. /**
  37679. * Execute the current task
  37680. * @param scene defines the scene where you want your assets to be loaded
  37681. * @param onSuccess is a callback called when the task is successfully executed
  37682. * @param onError is a callback called if an error occurs
  37683. */
  37684. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37685. }
  37686. /**
  37687. * Define a task used by AssetsManager to load cube textures
  37688. */
  37689. class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  37690. /**
  37691. * Defines the name of the task
  37692. */
  37693. name: string;
  37694. /**
  37695. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  37696. */
  37697. url: string;
  37698. /**
  37699. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  37700. */
  37701. extensions?: string[] | undefined;
  37702. /**
  37703. * Defines if mipmaps should not be generated (default is false)
  37704. */
  37705. noMipmap?: boolean | undefined;
  37706. /**
  37707. * Defines the explicit list of files (undefined by default)
  37708. */
  37709. files?: string[] | undefined;
  37710. /**
  37711. * Gets the loaded texture
  37712. */
  37713. texture: CubeTexture;
  37714. /**
  37715. * Callback called when the task is successful
  37716. */
  37717. onSuccess: (task: CubeTextureAssetTask) => void;
  37718. /**
  37719. * Callback called when the task is successful
  37720. */
  37721. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  37722. /**
  37723. * Creates a new CubeTextureAssetTask
  37724. * @param name defines the name of the task
  37725. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  37726. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  37727. * @param noMipmap defines if mipmaps should not be generated (default is false)
  37728. * @param files defines the explicit list of files (undefined by default)
  37729. */
  37730. constructor(
  37731. /**
  37732. * Defines the name of the task
  37733. */
  37734. name: string,
  37735. /**
  37736. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  37737. */
  37738. url: string,
  37739. /**
  37740. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  37741. */
  37742. extensions?: string[] | undefined,
  37743. /**
  37744. * Defines if mipmaps should not be generated (default is false)
  37745. */
  37746. noMipmap?: boolean | undefined,
  37747. /**
  37748. * Defines the explicit list of files (undefined by default)
  37749. */
  37750. files?: string[] | undefined);
  37751. /**
  37752. * Execute the current task
  37753. * @param scene defines the scene where you want your assets to be loaded
  37754. * @param onSuccess is a callback called when the task is successfully executed
  37755. * @param onError is a callback called if an error occurs
  37756. */
  37757. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37758. }
  37759. /**
  37760. * Define a task used by AssetsManager to load HDR cube textures
  37761. */
  37762. class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  37763. /**
  37764. * Defines the name of the task
  37765. */
  37766. name: string;
  37767. /**
  37768. * Defines the location of the file to load
  37769. */
  37770. url: string;
  37771. /**
  37772. * Defines the desired size (the more it increases the longer the generation will be)
  37773. */
  37774. size: number;
  37775. /**
  37776. * Defines if mipmaps should not be generated (default is false)
  37777. */
  37778. noMipmap: boolean;
  37779. /**
  37780. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  37781. */
  37782. generateHarmonics: boolean;
  37783. /**
  37784. * 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)
  37785. */
  37786. gammaSpace: boolean;
  37787. /**
  37788. * Internal Use Only
  37789. */
  37790. reserved: boolean;
  37791. /**
  37792. * Gets the loaded texture
  37793. */
  37794. texture: HDRCubeTexture;
  37795. /**
  37796. * Callback called when the task is successful
  37797. */
  37798. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  37799. /**
  37800. * Callback called when the task is successful
  37801. */
  37802. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  37803. /**
  37804. * Creates a new HDRCubeTextureAssetTask object
  37805. * @param name defines the name of the task
  37806. * @param url defines the location of the file to load
  37807. * @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.
  37808. * @param noMipmap defines if mipmaps should not be generated (default is false)
  37809. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  37810. * @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)
  37811. * @param reserved Internal use only
  37812. */
  37813. constructor(
  37814. /**
  37815. * Defines the name of the task
  37816. */
  37817. name: string,
  37818. /**
  37819. * Defines the location of the file to load
  37820. */
  37821. url: string,
  37822. /**
  37823. * Defines the desired size (the more it increases the longer the generation will be)
  37824. */
  37825. size: number,
  37826. /**
  37827. * Defines if mipmaps should not be generated (default is false)
  37828. */
  37829. noMipmap?: boolean,
  37830. /**
  37831. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  37832. */
  37833. generateHarmonics?: boolean,
  37834. /**
  37835. * 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)
  37836. */
  37837. gammaSpace?: boolean,
  37838. /**
  37839. * Internal Use Only
  37840. */
  37841. reserved?: boolean);
  37842. /**
  37843. * Execute the current task
  37844. * @param scene defines the scene where you want your assets to be loaded
  37845. * @param onSuccess is a callback called when the task is successfully executed
  37846. * @param onError is a callback called if an error occurs
  37847. */
  37848. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37849. }
  37850. /**
  37851. * This class can be used to easily import assets into a scene
  37852. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  37853. */
  37854. class AssetsManager {
  37855. private _scene;
  37856. private _isLoading;
  37857. protected _tasks: AbstractAssetTask[];
  37858. protected _waitingTasksCount: number;
  37859. protected _totalTasksCount: number;
  37860. /**
  37861. * Callback called when all tasks are processed
  37862. */
  37863. onFinish: (tasks: AbstractAssetTask[]) => void;
  37864. /**
  37865. * Callback called when a task is successful
  37866. */
  37867. onTaskSuccess: (task: AbstractAssetTask) => void;
  37868. /**
  37869. * Callback called when a task had an error
  37870. */
  37871. onTaskError: (task: AbstractAssetTask) => void;
  37872. /**
  37873. * Callback called when a task is done (whatever the result is)
  37874. */
  37875. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  37876. /**
  37877. * Observable called when all tasks are processed
  37878. */
  37879. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  37880. /**
  37881. * Observable called when a task had an error
  37882. */
  37883. onTaskErrorObservable: Observable<AbstractAssetTask>;
  37884. /**
  37885. * Observable called when a task is successful
  37886. */
  37887. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  37888. /**
  37889. * Observable called when a task is done (whatever the result is)
  37890. */
  37891. onProgressObservable: Observable<IAssetsProgressEvent>;
  37892. /**
  37893. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  37894. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37895. */
  37896. useDefaultLoadingScreen: boolean;
  37897. /**
  37898. * Creates a new AssetsManager
  37899. * @param scene defines the scene to work on
  37900. */
  37901. constructor(scene: Scene);
  37902. /**
  37903. * Add a MeshAssetTask to the list of active tasks
  37904. * @param taskName defines the name of the new task
  37905. * @param meshesNames defines the name of meshes to load
  37906. * @param rootUrl defines the root url to use to locate files
  37907. * @param sceneFilename defines the filename of the scene file
  37908. * @returns a new MeshAssetTask object
  37909. */
  37910. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  37911. /**
  37912. * Add a TextFileAssetTask to the list of active tasks
  37913. * @param taskName defines the name of the new task
  37914. * @param url defines the url of the file to load
  37915. * @returns a new TextFileAssetTask object
  37916. */
  37917. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  37918. /**
  37919. * Add a BinaryFileAssetTask to the list of active tasks
  37920. * @param taskName defines the name of the new task
  37921. * @param url defines the url of the file to load
  37922. * @returns a new BinaryFileAssetTask object
  37923. */
  37924. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  37925. /**
  37926. * Add a ImageAssetTask to the list of active tasks
  37927. * @param taskName defines the name of the new task
  37928. * @param url defines the url of the file to load
  37929. * @returns a new ImageAssetTask object
  37930. */
  37931. addImageTask(taskName: string, url: string): ImageAssetTask;
  37932. /**
  37933. * Add a TextureAssetTask to the list of active tasks
  37934. * @param taskName defines the name of the new task
  37935. * @param url defines the url of the file to load
  37936. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  37937. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  37938. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  37939. * @returns a new TextureAssetTask object
  37940. */
  37941. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  37942. /**
  37943. * Add a CubeTextureAssetTask to the list of active tasks
  37944. * @param taskName defines the name of the new task
  37945. * @param url defines the url of the file to load
  37946. * @param extensions defines the extension to use to load the cube map (can be null)
  37947. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  37948. * @param files defines the list of files to load (can be null)
  37949. * @returns a new CubeTextureAssetTask object
  37950. */
  37951. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  37952. /**
  37953. *
  37954. * Add a HDRCubeTextureAssetTask to the list of active tasks
  37955. * @param taskName defines the name of the new task
  37956. * @param url defines the url of the file to load
  37957. * @param size defines the size you want for the cubemap (can be null)
  37958. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  37959. * @param generateHarmonics defines if you want to automatically generate (true by default)
  37960. * @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)
  37961. * @param reserved Internal use only
  37962. * @returns a new HDRCubeTextureAssetTask object
  37963. */
  37964. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  37965. /**
  37966. * Remove a task from the assets manager.
  37967. * @param task the task to remove
  37968. */
  37969. removeTask(task: AbstractAssetTask): void;
  37970. private _decreaseWaitingTasksCount;
  37971. private _runTask;
  37972. /**
  37973. * Reset the AssetsManager and remove all tasks
  37974. * @return the current instance of the AssetsManager
  37975. */
  37976. reset(): AssetsManager;
  37977. /**
  37978. * Start the loading process
  37979. * @return the current instance of the AssetsManager
  37980. */
  37981. load(): AssetsManager;
  37982. }
  37983. }
  37984. declare module BABYLON {
  37985. /**
  37986. * Direct draw surface info
  37987. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  37988. */
  37989. interface DDSInfo {
  37990. /**
  37991. * Width of the texture
  37992. */
  37993. width: number;
  37994. /**
  37995. * Width of the texture
  37996. */
  37997. height: number;
  37998. /**
  37999. * Number of Mipmaps for the texture
  38000. * @see https://en.wikipedia.org/wiki/Mipmap
  38001. */
  38002. mipmapCount: number;
  38003. /**
  38004. * If the textures format is a known fourCC format
  38005. * @see https://www.fourcc.org/
  38006. */
  38007. isFourCC: boolean;
  38008. /**
  38009. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  38010. */
  38011. isRGB: boolean;
  38012. /**
  38013. * If the texture is a lumincance format
  38014. */
  38015. isLuminance: boolean;
  38016. /**
  38017. * If this is a cube texture
  38018. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  38019. */
  38020. isCube: boolean;
  38021. /**
  38022. * If the texture is a compressed format eg. FOURCC_DXT1
  38023. */
  38024. isCompressed: boolean;
  38025. /**
  38026. * The dxgiFormat of the texture
  38027. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  38028. */
  38029. dxgiFormat: number;
  38030. /**
  38031. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  38032. */
  38033. textureType: number;
  38034. /**
  38035. * Sphericle polynomial created for the dds texture
  38036. */
  38037. sphericalPolynomial?: SphericalPolynomial;
  38038. }
  38039. /**
  38040. * Class used to provide DDS decompression tools
  38041. */
  38042. class DDSTools {
  38043. /**
  38044. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  38045. */
  38046. static StoreLODInAlphaChannel: boolean;
  38047. /**
  38048. * Gets DDS information from an array buffer
  38049. * @param arrayBuffer defines the array buffer to read data from
  38050. * @returns the DDS information
  38051. */
  38052. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  38053. private static _FloatView;
  38054. private static _Int32View;
  38055. private static _ToHalfFloat;
  38056. private static _FromHalfFloat;
  38057. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  38058. private static _GetHalfFloatRGBAArrayBuffer;
  38059. private static _GetFloatRGBAArrayBuffer;
  38060. private static _GetFloatAsUIntRGBAArrayBuffer;
  38061. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  38062. private static _GetRGBAArrayBuffer;
  38063. private static _ExtractLongWordOrder;
  38064. private static _GetRGBArrayBuffer;
  38065. private static _GetLuminanceArrayBuffer;
  38066. /**
  38067. * Uploads DDS Levels to a Babylon Texture
  38068. * @hidden
  38069. */
  38070. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  38071. }
  38072. }
  38073. declare module BABYLON {
  38074. function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  38075. function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38076. function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38077. function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38078. function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38079. function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38080. function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38081. function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38082. function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38083. function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38084. function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38085. function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38086. /**
  38087. * Decorator used to define property that can be serialized as reference to a camera
  38088. * @param sourceName defines the name of the property to decorate
  38089. */
  38090. function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38091. /**
  38092. * Class used to help serialization objects
  38093. */
  38094. class SerializationHelper {
  38095. /**
  38096. * Static function used to serialized a specific entity
  38097. * @param entity defines the entity to serialize
  38098. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  38099. * @returns a JSON compatible object representing the serialization of the entity
  38100. */
  38101. static Serialize<T>(entity: T, serializationObject?: any): any;
  38102. /**
  38103. * Creates a new entity from a serialization data object
  38104. * @param creationFunction defines a function used to instanciated the new entity
  38105. * @param source defines the source serialization data
  38106. * @param scene defines the hosting scene
  38107. * @param rootUrl defines the root url for resources
  38108. * @returns a new entity
  38109. */
  38110. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  38111. /**
  38112. * Clones an object
  38113. * @param creationFunction defines the function used to instanciate the new object
  38114. * @param source defines the source object
  38115. * @returns the cloned object
  38116. */
  38117. static Clone<T>(creationFunction: () => T, source: T): T;
  38118. /**
  38119. * Instanciates a new object based on a source one (some data will be shared between both object)
  38120. * @param creationFunction defines the function used to instanciate the new object
  38121. * @param source defines the source object
  38122. * @returns the new object
  38123. */
  38124. static Instanciate<T>(creationFunction: () => T, source: T): T;
  38125. }
  38126. }
  38127. declare module BABYLON {
  38128. /**
  38129. * Wrapper class for promise with external resolve and reject.
  38130. */
  38131. class Deferred<T> {
  38132. /**
  38133. * The promise associated with this deferred object.
  38134. */
  38135. readonly promise: Promise<T>;
  38136. private _resolve;
  38137. private _reject;
  38138. /**
  38139. * The resolve method of the promise associated with this deferred object.
  38140. */
  38141. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  38142. /**
  38143. * The reject method of the promise associated with this deferred object.
  38144. */
  38145. readonly reject: (reason?: any) => void;
  38146. /**
  38147. * Constructor for this deferred object.
  38148. */
  38149. constructor();
  38150. }
  38151. }
  38152. declare module BABYLON {
  38153. /**
  38154. * Raw texture data and descriptor sufficient for WebGL texture upload
  38155. */
  38156. interface EnvironmentTextureInfo {
  38157. /**
  38158. * Version of the environment map
  38159. */
  38160. version: number;
  38161. /**
  38162. * Width of image
  38163. */
  38164. width: number;
  38165. /**
  38166. * Irradiance information stored in the file.
  38167. */
  38168. irradiance: any;
  38169. /**
  38170. * Specular information stored in the file.
  38171. */
  38172. specular: any;
  38173. }
  38174. /**
  38175. * Sets of helpers addressing the serialization and deserialization of environment texture
  38176. * stored in a BabylonJS env file.
  38177. * Those files are usually stored as .env files.
  38178. */
  38179. class EnvironmentTextureTools {
  38180. /**
  38181. * Magic number identifying the env file.
  38182. */
  38183. private static _MagicBytes;
  38184. /**
  38185. * Gets the environment info from an env file.
  38186. * @param data The array buffer containing the .env bytes.
  38187. * @returns the environment file info (the json header) if successfully parsed.
  38188. */
  38189. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  38190. /**
  38191. * Creates an environment texture from a loaded cube texture.
  38192. * @param texture defines the cube texture to convert in env file
  38193. * @return a promise containing the environment data if succesfull.
  38194. */
  38195. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  38196. /**
  38197. * Creates a JSON representation of the spherical data.
  38198. * @param texture defines the texture containing the polynomials
  38199. * @return the JSON representation of the spherical info
  38200. */
  38201. private static _CreateEnvTextureIrradiance;
  38202. /**
  38203. * Uploads the texture info contained in the env file to the GPU.
  38204. * @param texture defines the internal texture to upload to
  38205. * @param arrayBuffer defines the buffer cotaining the data to load
  38206. * @param info defines the texture info retrieved through the GetEnvInfo method
  38207. * @returns a promise
  38208. */
  38209. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  38210. /**
  38211. * Uploads the levels of image data to the GPU.
  38212. * @param texture defines the internal texture to upload to
  38213. * @param imageData defines the array buffer views of image data [mipmap][face]
  38214. * @returns a promise
  38215. */
  38216. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  38217. /**
  38218. * Uploads spherical polynomials information to the texture.
  38219. * @param texture defines the texture we are trying to upload the information to
  38220. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  38221. */
  38222. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  38223. }
  38224. }
  38225. declare module BABYLON {
  38226. /**
  38227. * Class used to help managing file picking and drag'n'drop
  38228. */
  38229. class FilesInput {
  38230. /**
  38231. * List of files ready to be loaded
  38232. */
  38233. static FilesToLoad: {
  38234. [key: string]: File;
  38235. };
  38236. /**
  38237. * Callback called when a file is processed
  38238. */
  38239. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  38240. private _engine;
  38241. private _currentScene;
  38242. private _sceneLoadedCallback;
  38243. private _progressCallback;
  38244. private _additionalRenderLoopLogicCallback;
  38245. private _textureLoadingCallback;
  38246. private _startingProcessingFilesCallback;
  38247. private _onReloadCallback;
  38248. private _errorCallback;
  38249. private _elementToMonitor;
  38250. private _sceneFileToLoad;
  38251. private _filesToLoad;
  38252. /**
  38253. * Creates a new FilesInput
  38254. * @param engine defines the rendering engine
  38255. * @param scene defines the hosting scene
  38256. * @param sceneLoadedCallback callback called when scene is loaded
  38257. * @param progressCallback callback called to track progress
  38258. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  38259. * @param textureLoadingCallback callback called when a texture is loading
  38260. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  38261. * @param onReloadCallback callback called when a reload is requested
  38262. * @param errorCallback callback call if an error occurs
  38263. */
  38264. 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);
  38265. private _dragEnterHandler;
  38266. private _dragOverHandler;
  38267. private _dropHandler;
  38268. /**
  38269. * Calls this function to listen to drag'n'drop events on a specific DOM element
  38270. * @param elementToMonitor defines the DOM element to track
  38271. */
  38272. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  38273. /**
  38274. * Release all associated resources
  38275. */
  38276. dispose(): void;
  38277. private renderFunction;
  38278. private drag;
  38279. private drop;
  38280. private _traverseFolder;
  38281. private _processFiles;
  38282. /**
  38283. * Load files from a drop event
  38284. * @param event defines the drop event to use as source
  38285. */
  38286. loadFiles(event: any): void;
  38287. private _processReload;
  38288. /**
  38289. * Reload the current scene from the loaded files
  38290. */
  38291. reload(): void;
  38292. }
  38293. }
  38294. declare module BABYLON {
  38295. /**
  38296. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  38297. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  38298. */
  38299. class KhronosTextureContainer {
  38300. /** contents of the KTX container file */
  38301. arrayBuffer: any;
  38302. private static HEADER_LEN;
  38303. private static COMPRESSED_2D;
  38304. private static COMPRESSED_3D;
  38305. private static TEX_2D;
  38306. private static TEX_3D;
  38307. /**
  38308. * Gets the openGL type
  38309. */
  38310. glType: number;
  38311. /**
  38312. * Gets the openGL type size
  38313. */
  38314. glTypeSize: number;
  38315. /**
  38316. * Gets the openGL format
  38317. */
  38318. glFormat: number;
  38319. /**
  38320. * Gets the openGL internal format
  38321. */
  38322. glInternalFormat: number;
  38323. /**
  38324. * Gets the base internal format
  38325. */
  38326. glBaseInternalFormat: number;
  38327. /**
  38328. * Gets image width in pixel
  38329. */
  38330. pixelWidth: number;
  38331. /**
  38332. * Gets image height in pixel
  38333. */
  38334. pixelHeight: number;
  38335. /**
  38336. * Gets image depth in pixels
  38337. */
  38338. pixelDepth: number;
  38339. /**
  38340. * Gets the number of array elements
  38341. */
  38342. numberOfArrayElements: number;
  38343. /**
  38344. * Gets the number of faces
  38345. */
  38346. numberOfFaces: number;
  38347. /**
  38348. * Gets the number of mipmap levels
  38349. */
  38350. numberOfMipmapLevels: number;
  38351. /**
  38352. * Gets the bytes of key value data
  38353. */
  38354. bytesOfKeyValueData: number;
  38355. /**
  38356. * Gets the load type
  38357. */
  38358. loadType: number;
  38359. /**
  38360. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  38361. */
  38362. isInvalid: boolean;
  38363. /**
  38364. * Creates a new KhronosTextureContainer
  38365. * @param arrayBuffer contents of the KTX container file
  38366. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  38367. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  38368. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  38369. */
  38370. constructor(
  38371. /** contents of the KTX container file */
  38372. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  38373. /**
  38374. * Revert the endianness of a value.
  38375. * Not as fast hardware based, but will probably never need to use
  38376. * @param val defines the value to convert
  38377. * @returns the new value
  38378. */
  38379. switchEndianness(val: number): number;
  38380. /**
  38381. * Uploads KTX content to a Babylon Texture.
  38382. * It is assumed that the texture has already been created & is currently bound
  38383. * @hidden
  38384. */
  38385. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  38386. private _upload2DCompressedLevels;
  38387. }
  38388. }
  38389. declare module BABYLON {
  38390. /**
  38391. * A class serves as a medium between the observable and its observers
  38392. */
  38393. class EventState {
  38394. /**
  38395. * Create a new EventState
  38396. * @param mask defines the mask associated with this state
  38397. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  38398. * @param target defines the original target of the state
  38399. * @param currentTarget defines the current target of the state
  38400. */
  38401. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  38402. /**
  38403. * Initialize the current event state
  38404. * @param mask defines the mask associated with this state
  38405. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  38406. * @param target defines the original target of the state
  38407. * @param currentTarget defines the current target of the state
  38408. * @returns the current event state
  38409. */
  38410. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  38411. /**
  38412. * An Observer can set this property to true to prevent subsequent observers of being notified
  38413. */
  38414. skipNextObservers: boolean;
  38415. /**
  38416. * Get the mask value that were used to trigger the event corresponding to this EventState object
  38417. */
  38418. mask: number;
  38419. /**
  38420. * The object that originally notified the event
  38421. */
  38422. target?: any;
  38423. /**
  38424. * The current object in the bubbling phase
  38425. */
  38426. currentTarget?: any;
  38427. /**
  38428. * This will be populated with the return value of the last function that was executed.
  38429. * If it is the first function in the callback chain it will be the event data.
  38430. */
  38431. lastReturnValue?: any;
  38432. }
  38433. /**
  38434. * Represent an Observer registered to a given Observable object.
  38435. */
  38436. class Observer<T> {
  38437. /**
  38438. * Defines the callback to call when the observer is notified
  38439. */
  38440. callback: (eventData: T, eventState: EventState) => void;
  38441. /**
  38442. * Defines the mask of the observer (used to filter notifications)
  38443. */
  38444. mask: number;
  38445. /**
  38446. * Defines the current scope used to restore the JS context
  38447. */
  38448. scope: any;
  38449. /** @hidden */
  38450. _willBeUnregistered: boolean;
  38451. /**
  38452. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  38453. */
  38454. unregisterOnNextCall: boolean;
  38455. /**
  38456. * Creates a new observer
  38457. * @param callback defines the callback to call when the observer is notified
  38458. * @param mask defines the mask of the observer (used to filter notifications)
  38459. * @param scope defines the current scope used to restore the JS context
  38460. */
  38461. constructor(
  38462. /**
  38463. * Defines the callback to call when the observer is notified
  38464. */
  38465. callback: (eventData: T, eventState: EventState) => void,
  38466. /**
  38467. * Defines the mask of the observer (used to filter notifications)
  38468. */
  38469. mask: number,
  38470. /**
  38471. * Defines the current scope used to restore the JS context
  38472. */
  38473. scope?: any);
  38474. }
  38475. /**
  38476. * Represent a list of observers registered to multiple Observables object.
  38477. */
  38478. class MultiObserver<T> {
  38479. private _observers;
  38480. private _observables;
  38481. /**
  38482. * Release associated resources
  38483. */
  38484. dispose(): void;
  38485. /**
  38486. * Raise a callback when one of the observable will notify
  38487. * @param observables defines a list of observables to watch
  38488. * @param callback defines the callback to call on notification
  38489. * @param mask defines the mask used to filter notifications
  38490. * @param scope defines the current scope used to restore the JS context
  38491. * @returns the new MultiObserver
  38492. */
  38493. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  38494. }
  38495. /**
  38496. * The Observable class is a simple implementation of the Observable pattern.
  38497. *
  38498. * 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.
  38499. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  38500. * 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).
  38501. * 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.
  38502. */
  38503. class Observable<T> {
  38504. private _observers;
  38505. private _eventState;
  38506. private _onObserverAdded;
  38507. /**
  38508. * Creates a new observable
  38509. * @param onObserverAdded defines a callback to call when a new observer is added
  38510. */
  38511. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  38512. /**
  38513. * Create a new Observer with the specified callback
  38514. * @param callback the callback that will be executed for that Observer
  38515. * @param mask the mask used to filter observers
  38516. * @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.
  38517. * @param scope optional scope for the callback to be called from
  38518. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  38519. * @returns the new observer created for the callback
  38520. */
  38521. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  38522. /**
  38523. * Create a new Observer with the specified callback and unregisters after the next notification
  38524. * @param callback the callback that will be executed for that Observer
  38525. * @returns the new observer created for the callback
  38526. */
  38527. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  38528. /**
  38529. * Remove an Observer from the Observable object
  38530. * @param observer the instance of the Observer to remove
  38531. * @returns false if it doesn't belong to this Observable
  38532. */
  38533. remove(observer: Nullable<Observer<T>>): boolean;
  38534. /**
  38535. * Remove a callback from the Observable object
  38536. * @param callback the callback to remove
  38537. * @param scope optional scope. If used only the callbacks with this scope will be removed
  38538. * @returns false if it doesn't belong to this Observable
  38539. */
  38540. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  38541. private _deferUnregister;
  38542. private _remove;
  38543. /**
  38544. * Notify all Observers by calling their respective callback with the given data
  38545. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  38546. * @param eventData defines the data to send to all observers
  38547. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  38548. * @param target defines the original target of the state
  38549. * @param currentTarget defines the current target of the state
  38550. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  38551. */
  38552. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  38553. /**
  38554. * Calling this will execute each callback, expecting it to be a promise or return a value.
  38555. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  38556. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  38557. * and it is crucial that all callbacks will be executed.
  38558. * The order of the callbacks is kept, callbacks are not executed parallel.
  38559. *
  38560. * @param eventData The data to be sent to each callback
  38561. * @param mask is used to filter observers defaults to -1
  38562. * @param target defines the callback target (see EventState)
  38563. * @param currentTarget defines he current object in the bubbling phase
  38564. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  38565. */
  38566. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  38567. /**
  38568. * Notify a specific observer
  38569. * @param observer defines the observer to notify
  38570. * @param eventData defines the data to be sent to each callback
  38571. * @param mask is used to filter observers defaults to -1
  38572. */
  38573. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  38574. /**
  38575. * Gets a boolean indicating if the observable has at least one observer
  38576. * @returns true is the Observable has at least one Observer registered
  38577. */
  38578. hasObservers(): boolean;
  38579. /**
  38580. * Clear the list of observers
  38581. */
  38582. clear(): void;
  38583. /**
  38584. * Clone the current observable
  38585. * @returns a new observable
  38586. */
  38587. clone(): Observable<T>;
  38588. /**
  38589. * Does this observable handles observer registered with a given mask
  38590. * @param mask defines the mask to be tested
  38591. * @return whether or not one observer registered with the given mask is handeled
  38592. **/
  38593. hasSpecificMask(mask?: number): boolean;
  38594. }
  38595. }
  38596. declare module BABYLON {
  38597. /**
  38598. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  38599. */
  38600. class PerformanceMonitor {
  38601. private _enabled;
  38602. private _rollingFrameTime;
  38603. private _lastFrameTimeMs;
  38604. /**
  38605. * constructor
  38606. * @param frameSampleSize The number of samples required to saturate the sliding window
  38607. */
  38608. constructor(frameSampleSize?: number);
  38609. /**
  38610. * Samples current frame
  38611. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  38612. */
  38613. sampleFrame(timeMs?: number): void;
  38614. /**
  38615. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38616. */
  38617. readonly averageFrameTime: number;
  38618. /**
  38619. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38620. */
  38621. readonly averageFrameTimeVariance: number;
  38622. /**
  38623. * Returns the frame time of the most recent frame
  38624. */
  38625. readonly instantaneousFrameTime: number;
  38626. /**
  38627. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  38628. */
  38629. readonly averageFPS: number;
  38630. /**
  38631. * Returns the average framerate in frames per second using the most recent frame time
  38632. */
  38633. readonly instantaneousFPS: number;
  38634. /**
  38635. * Returns true if enough samples have been taken to completely fill the sliding window
  38636. */
  38637. readonly isSaturated: boolean;
  38638. /**
  38639. * Enables contributions to the sliding window sample set
  38640. */
  38641. enable(): void;
  38642. /**
  38643. * Disables contributions to the sliding window sample set
  38644. * Samples will not be interpolated over the disabled period
  38645. */
  38646. disable(): void;
  38647. /**
  38648. * Returns true if sampling is enabled
  38649. */
  38650. readonly isEnabled: boolean;
  38651. /**
  38652. * Resets performance monitor
  38653. */
  38654. reset(): void;
  38655. }
  38656. /**
  38657. * RollingAverage
  38658. *
  38659. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  38660. */
  38661. class RollingAverage {
  38662. /**
  38663. * Current average
  38664. */
  38665. average: number;
  38666. /**
  38667. * Current variance
  38668. */
  38669. variance: number;
  38670. protected _samples: Array<number>;
  38671. protected _sampleCount: number;
  38672. protected _pos: number;
  38673. protected _m2: number;
  38674. /**
  38675. * constructor
  38676. * @param length The number of samples required to saturate the sliding window
  38677. */
  38678. constructor(length: number);
  38679. /**
  38680. * Adds a sample to the sample set
  38681. * @param v The sample value
  38682. */
  38683. add(v: number): void;
  38684. /**
  38685. * Returns previously added values or null if outside of history or outside the sliding window domain
  38686. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  38687. * @return Value previously recorded with add() or null if outside of range
  38688. */
  38689. history(i: number): number;
  38690. /**
  38691. * Returns true if enough samples have been taken to completely fill the sliding window
  38692. * @return true if sample-set saturated
  38693. */
  38694. isSaturated(): boolean;
  38695. /**
  38696. * Resets the rolling average (equivalent to 0 samples taken so far)
  38697. */
  38698. reset(): void;
  38699. /**
  38700. * Wraps a value around the sample range boundaries
  38701. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  38702. * @return Wrapped position in sample range
  38703. */
  38704. protected _wrapPosition(i: number): number;
  38705. }
  38706. }
  38707. declare module BABYLON {
  38708. /**
  38709. * Helper class that provides a small promise polyfill
  38710. */
  38711. class PromisePolyfill {
  38712. /**
  38713. * Static function used to check if the polyfill is required
  38714. * If this is the case then the function will inject the polyfill to window.Promise
  38715. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  38716. */
  38717. static Apply(force?: boolean): void;
  38718. }
  38719. }
  38720. declare module BABYLON {
  38721. /**
  38722. * Defines the root class used to create scene optimization to use with SceneOptimizer
  38723. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38724. */
  38725. class SceneOptimization {
  38726. /**
  38727. * Defines the priority of this optimization (0 by default which means first in the list)
  38728. */
  38729. priority: number;
  38730. /**
  38731. * Gets a string describing the action executed by the current optimization
  38732. * @returns description string
  38733. */
  38734. getDescription(): string;
  38735. /**
  38736. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38737. * @param scene defines the current scene where to apply this optimization
  38738. * @param optimizer defines the current optimizer
  38739. * @returns true if everything that can be done was applied
  38740. */
  38741. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38742. /**
  38743. * Creates the SceneOptimization object
  38744. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  38745. * @param desc defines the description associated with the optimization
  38746. */
  38747. constructor(
  38748. /**
  38749. * Defines the priority of this optimization (0 by default which means first in the list)
  38750. */
  38751. priority?: number);
  38752. }
  38753. /**
  38754. * Defines an optimization used to reduce the size of render target textures
  38755. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38756. */
  38757. class TextureOptimization extends SceneOptimization {
  38758. /**
  38759. * Defines the priority of this optimization (0 by default which means first in the list)
  38760. */
  38761. priority: number;
  38762. /**
  38763. * 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
  38764. */
  38765. maximumSize: number;
  38766. /**
  38767. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  38768. */
  38769. step: number;
  38770. /**
  38771. * Gets a string describing the action executed by the current optimization
  38772. * @returns description string
  38773. */
  38774. getDescription(): string;
  38775. /**
  38776. * Creates the TextureOptimization object
  38777. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  38778. * @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
  38779. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  38780. */
  38781. constructor(
  38782. /**
  38783. * Defines the priority of this optimization (0 by default which means first in the list)
  38784. */
  38785. priority?: number,
  38786. /**
  38787. * 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
  38788. */
  38789. maximumSize?: number,
  38790. /**
  38791. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  38792. */
  38793. step?: number);
  38794. /**
  38795. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38796. * @param scene defines the current scene where to apply this optimization
  38797. * @param optimizer defines the current optimizer
  38798. * @returns true if everything that can be done was applied
  38799. */
  38800. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38801. }
  38802. /**
  38803. * Defines an optimization used to increase or decrease the rendering resolution
  38804. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38805. */
  38806. class HardwareScalingOptimization extends SceneOptimization {
  38807. /**
  38808. * Defines the priority of this optimization (0 by default which means first in the list)
  38809. */
  38810. priority: number;
  38811. /**
  38812. * Defines the maximum scale to use (2 by default)
  38813. */
  38814. maximumScale: number;
  38815. /**
  38816. * Defines the step to use between two passes (0.5 by default)
  38817. */
  38818. step: number;
  38819. private _currentScale;
  38820. private _directionOffset;
  38821. /**
  38822. * Gets a string describing the action executed by the current optimization
  38823. * @return description string
  38824. */
  38825. getDescription(): string;
  38826. /**
  38827. * Creates the HardwareScalingOptimization object
  38828. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  38829. * @param maximumScale defines the maximum scale to use (2 by default)
  38830. * @param step defines the step to use between two passes (0.5 by default)
  38831. */
  38832. constructor(
  38833. /**
  38834. * Defines the priority of this optimization (0 by default which means first in the list)
  38835. */
  38836. priority?: number,
  38837. /**
  38838. * Defines the maximum scale to use (2 by default)
  38839. */
  38840. maximumScale?: number,
  38841. /**
  38842. * Defines the step to use between two passes (0.5 by default)
  38843. */
  38844. step?: number);
  38845. /**
  38846. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38847. * @param scene defines the current scene where to apply this optimization
  38848. * @param optimizer defines the current optimizer
  38849. * @returns true if everything that can be done was applied
  38850. */
  38851. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38852. }
  38853. /**
  38854. * Defines an optimization used to remove shadows
  38855. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38856. */
  38857. class ShadowsOptimization extends SceneOptimization {
  38858. /**
  38859. * Gets a string describing the action executed by the current optimization
  38860. * @return description string
  38861. */
  38862. getDescription(): string;
  38863. /**
  38864. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38865. * @param scene defines the current scene where to apply this optimization
  38866. * @param optimizer defines the current optimizer
  38867. * @returns true if everything that can be done was applied
  38868. */
  38869. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38870. }
  38871. /**
  38872. * Defines an optimization used to turn post-processes off
  38873. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38874. */
  38875. class PostProcessesOptimization extends SceneOptimization {
  38876. /**
  38877. * Gets a string describing the action executed by the current optimization
  38878. * @return description string
  38879. */
  38880. getDescription(): string;
  38881. /**
  38882. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38883. * @param scene defines the current scene where to apply this optimization
  38884. * @param optimizer defines the current optimizer
  38885. * @returns true if everything that can be done was applied
  38886. */
  38887. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38888. }
  38889. /**
  38890. * Defines an optimization used to turn lens flares off
  38891. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38892. */
  38893. class LensFlaresOptimization extends SceneOptimization {
  38894. /**
  38895. * Gets a string describing the action executed by the current optimization
  38896. * @return description string
  38897. */
  38898. getDescription(): string;
  38899. /**
  38900. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38901. * @param scene defines the current scene where to apply this optimization
  38902. * @param optimizer defines the current optimizer
  38903. * @returns true if everything that can be done was applied
  38904. */
  38905. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38906. }
  38907. /**
  38908. * Defines an optimization based on user defined callback.
  38909. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38910. */
  38911. class CustomOptimization extends SceneOptimization {
  38912. /**
  38913. * Callback called to apply the custom optimization.
  38914. */
  38915. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  38916. /**
  38917. * Callback called to get custom description
  38918. */
  38919. onGetDescription: () => string;
  38920. /**
  38921. * Gets a string describing the action executed by the current optimization
  38922. * @returns description string
  38923. */
  38924. getDescription(): string;
  38925. /**
  38926. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38927. * @param scene defines the current scene where to apply this optimization
  38928. * @param optimizer defines the current optimizer
  38929. * @returns true if everything that can be done was applied
  38930. */
  38931. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38932. }
  38933. /**
  38934. * Defines an optimization used to turn particles off
  38935. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38936. */
  38937. class ParticlesOptimization extends SceneOptimization {
  38938. /**
  38939. * Gets a string describing the action executed by the current optimization
  38940. * @return description string
  38941. */
  38942. getDescription(): string;
  38943. /**
  38944. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38945. * @param scene defines the current scene where to apply this optimization
  38946. * @param optimizer defines the current optimizer
  38947. * @returns true if everything that can be done was applied
  38948. */
  38949. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38950. }
  38951. /**
  38952. * Defines an optimization used to turn render targets off
  38953. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38954. */
  38955. class RenderTargetsOptimization extends SceneOptimization {
  38956. /**
  38957. * Gets a string describing the action executed by the current optimization
  38958. * @return description string
  38959. */
  38960. getDescription(): string;
  38961. /**
  38962. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38963. * @param scene defines the current scene where to apply this optimization
  38964. * @param optimizer defines the current optimizer
  38965. * @returns true if everything that can be done was applied
  38966. */
  38967. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38968. }
  38969. /**
  38970. * Defines an optimization used to merge meshes with compatible materials
  38971. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38972. */
  38973. class MergeMeshesOptimization extends SceneOptimization {
  38974. private static _UpdateSelectionTree;
  38975. /**
  38976. * Gets or sets a boolean which defines if optimization octree has to be updated
  38977. */
  38978. /**
  38979. * Gets or sets a boolean which defines if optimization octree has to be updated
  38980. */
  38981. static UpdateSelectionTree: boolean;
  38982. /**
  38983. * Gets a string describing the action executed by the current optimization
  38984. * @return description string
  38985. */
  38986. getDescription(): string;
  38987. private _canBeMerged;
  38988. /**
  38989. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38990. * @param scene defines the current scene where to apply this optimization
  38991. * @param optimizer defines the current optimizer
  38992. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  38993. * @returns true if everything that can be done was applied
  38994. */
  38995. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  38996. }
  38997. /**
  38998. * Defines a list of options used by SceneOptimizer
  38999. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  39000. */
  39001. class SceneOptimizerOptions {
  39002. /**
  39003. * Defines the target frame rate to reach (60 by default)
  39004. */
  39005. targetFrameRate: number;
  39006. /**
  39007. * Defines the interval between two checkes (2000ms by default)
  39008. */
  39009. trackerDuration: number;
  39010. /**
  39011. * Gets the list of optimizations to apply
  39012. */
  39013. optimizations: SceneOptimization[];
  39014. /**
  39015. * Creates a new list of options used by SceneOptimizer
  39016. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  39017. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  39018. */
  39019. constructor(
  39020. /**
  39021. * Defines the target frame rate to reach (60 by default)
  39022. */
  39023. targetFrameRate?: number,
  39024. /**
  39025. * Defines the interval between two checkes (2000ms by default)
  39026. */
  39027. trackerDuration?: number);
  39028. /**
  39029. * Add a new optimization
  39030. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  39031. * @returns the current SceneOptimizerOptions
  39032. */
  39033. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  39034. /**
  39035. * Add a new custom optimization
  39036. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  39037. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  39038. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  39039. * @returns the current SceneOptimizerOptions
  39040. */
  39041. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  39042. /**
  39043. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  39044. * @param targetFrameRate defines the target frame rate (60 by default)
  39045. * @returns a SceneOptimizerOptions object
  39046. */
  39047. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  39048. /**
  39049. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  39050. * @param targetFrameRate defines the target frame rate (60 by default)
  39051. * @returns a SceneOptimizerOptions object
  39052. */
  39053. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  39054. /**
  39055. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  39056. * @param targetFrameRate defines the target frame rate (60 by default)
  39057. * @returns a SceneOptimizerOptions object
  39058. */
  39059. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  39060. }
  39061. /**
  39062. * Class used to run optimizations in order to reach a target frame rate
  39063. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  39064. */
  39065. class SceneOptimizer implements IDisposable {
  39066. private _isRunning;
  39067. private _options;
  39068. private _scene;
  39069. private _currentPriorityLevel;
  39070. private _targetFrameRate;
  39071. private _trackerDuration;
  39072. private _currentFrameRate;
  39073. private _sceneDisposeObserver;
  39074. private _improvementMode;
  39075. /**
  39076. * Defines an observable called when the optimizer reaches the target frame rate
  39077. */
  39078. onSuccessObservable: Observable<SceneOptimizer>;
  39079. /**
  39080. * Defines an observable called when the optimizer enables an optimization
  39081. */
  39082. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  39083. /**
  39084. * Defines an observable called when the optimizer is not able to reach the target frame rate
  39085. */
  39086. onFailureObservable: Observable<SceneOptimizer>;
  39087. /**
  39088. * Gets a boolean indicating if the optimizer is in improvement mode
  39089. */
  39090. readonly isInImprovementMode: boolean;
  39091. /**
  39092. * Gets the current priority level (0 at start)
  39093. */
  39094. readonly currentPriorityLevel: number;
  39095. /**
  39096. * Gets the current frame rate checked by the SceneOptimizer
  39097. */
  39098. readonly currentFrameRate: number;
  39099. /**
  39100. * Gets or sets the current target frame rate (60 by default)
  39101. */
  39102. /**
  39103. * Gets or sets the current target frame rate (60 by default)
  39104. */
  39105. targetFrameRate: number;
  39106. /**
  39107. * Gets or sets the current interval between two checks (every 2000ms by default)
  39108. */
  39109. /**
  39110. * Gets or sets the current interval between two checks (every 2000ms by default)
  39111. */
  39112. trackerDuration: number;
  39113. /**
  39114. * Gets the list of active optimizations
  39115. */
  39116. readonly optimizations: SceneOptimization[];
  39117. /**
  39118. * Creates a new SceneOptimizer
  39119. * @param scene defines the scene to work on
  39120. * @param options defines the options to use with the SceneOptimizer
  39121. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  39122. * @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)
  39123. */
  39124. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  39125. /**
  39126. * Stops the current optimizer
  39127. */
  39128. stop(): void;
  39129. /**
  39130. * Reset the optimizer to initial step (current priority level = 0)
  39131. */
  39132. reset(): void;
  39133. /**
  39134. * Start the optimizer. By default it will try to reach a specific framerate
  39135. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  39136. */
  39137. start(): void;
  39138. private _checkCurrentState;
  39139. /**
  39140. * Release all resources
  39141. */
  39142. dispose(): void;
  39143. /**
  39144. * Helper function to create a SceneOptimizer with one single line of code
  39145. * @param scene defines the scene to work on
  39146. * @param options defines the options to use with the SceneOptimizer
  39147. * @param onSuccess defines a callback to call on success
  39148. * @param onFailure defines a callback to call on failure
  39149. * @returns the new SceneOptimizer object
  39150. */
  39151. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  39152. }
  39153. }
  39154. declare module BABYLON {
  39155. /**
  39156. * Class used to serialize a scene into a string
  39157. */
  39158. class SceneSerializer {
  39159. /**
  39160. * Clear cache used by a previous serialization
  39161. */
  39162. static ClearCache(): void;
  39163. /**
  39164. * Serialize a scene into a JSON compatible object
  39165. * @param scene defines the scene to serialize
  39166. * @returns a JSON compatible object
  39167. */
  39168. static Serialize(scene: Scene): any;
  39169. /**
  39170. * Serialize a mesh into a JSON compatible object
  39171. * @param toSerialize defines the mesh to serialize
  39172. * @param withParents defines if parents must be serialized as well
  39173. * @param withChildren defines if children must be serialized as well
  39174. * @returns a JSON compatible object
  39175. */
  39176. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  39177. }
  39178. }
  39179. declare module BABYLON {
  39180. /**
  39181. * Defines an array and its length.
  39182. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  39183. */
  39184. interface ISmartArrayLike<T> {
  39185. /**
  39186. * The data of the array.
  39187. */
  39188. data: Array<T>;
  39189. /**
  39190. * The active length of the array.
  39191. */
  39192. length: number;
  39193. }
  39194. /**
  39195. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  39196. */
  39197. class SmartArray<T> implements ISmartArrayLike<T> {
  39198. /**
  39199. * The full set of data from the array.
  39200. */
  39201. data: Array<T>;
  39202. /**
  39203. * The active length of the array.
  39204. */
  39205. length: number;
  39206. protected _id: number;
  39207. /**
  39208. * Instantiates a Smart Array.
  39209. * @param capacity defines the default capacity of the array.
  39210. */
  39211. constructor(capacity: number);
  39212. /**
  39213. * Pushes a value at the end of the active data.
  39214. * @param value defines the object to push in the array.
  39215. */
  39216. push(value: T): void;
  39217. /**
  39218. * Iterates over the active data and apply the lambda to them.
  39219. * @param func defines the action to apply on each value.
  39220. */
  39221. forEach(func: (content: T) => void): void;
  39222. /**
  39223. * Sorts the full sets of data.
  39224. * @param compareFn defines the comparison function to apply.
  39225. */
  39226. sort(compareFn: (a: T, b: T) => number): void;
  39227. /**
  39228. * Resets the active data to an empty array.
  39229. */
  39230. reset(): void;
  39231. /**
  39232. * Releases all the data from the array as well as the array.
  39233. */
  39234. dispose(): void;
  39235. /**
  39236. * Concats the active data with a given array.
  39237. * @param array defines the data to concatenate with.
  39238. */
  39239. concat(array: any): void;
  39240. /**
  39241. * Returns the position of a value in the active data.
  39242. * @param value defines the value to find the index for
  39243. * @returns the index if found in the active data otherwise -1
  39244. */
  39245. indexOf(value: T): number;
  39246. /**
  39247. * Returns whether an element is part of the active data.
  39248. * @param value defines the value to look for
  39249. * @returns true if found in the active data otherwise false
  39250. */
  39251. contains(value: T): boolean;
  39252. private static _GlobalId;
  39253. }
  39254. /**
  39255. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  39256. * The data in this array can only be present once
  39257. */
  39258. class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  39259. private _duplicateId;
  39260. /**
  39261. * Pushes a value at the end of the active data.
  39262. * THIS DOES NOT PREVENT DUPPLICATE DATA
  39263. * @param value defines the object to push in the array.
  39264. */
  39265. push(value: T): void;
  39266. /**
  39267. * Pushes a value at the end of the active data.
  39268. * If the data is already present, it won t be added again
  39269. * @param value defines the object to push in the array.
  39270. * @returns true if added false if it was already present
  39271. */
  39272. pushNoDuplicate(value: T): boolean;
  39273. /**
  39274. * Resets the active data to an empty array.
  39275. */
  39276. reset(): void;
  39277. /**
  39278. * Concats the active data with a given array.
  39279. * This ensures no dupplicate will be present in the result.
  39280. * @param array defines the data to concatenate with.
  39281. */
  39282. concatWithNoDuplicate(array: any): void;
  39283. }
  39284. }
  39285. declare module BABYLON {
  39286. /**
  39287. * This class implement a typical dictionary using a string as key and the generic type T as value.
  39288. * The underlying implementation relies on an associative array to ensure the best performances.
  39289. * The value can be anything including 'null' but except 'undefined'
  39290. */
  39291. class StringDictionary<T> {
  39292. /**
  39293. * This will clear this dictionary and copy the content from the 'source' one.
  39294. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  39295. * @param source the dictionary to take the content from and copy to this dictionary
  39296. */
  39297. copyFrom(source: StringDictionary<T>): void;
  39298. /**
  39299. * Get a value based from its key
  39300. * @param key the given key to get the matching value from
  39301. * @return the value if found, otherwise undefined is returned
  39302. */
  39303. get(key: string): T | undefined;
  39304. /**
  39305. * Get a value from its key or add it if it doesn't exist.
  39306. * This method will ensure you that a given key/data will be present in the dictionary.
  39307. * @param key the given key to get the matching value from
  39308. * @param factory the factory that will create the value if the key is not present in the dictionary.
  39309. * The factory will only be invoked if there's no data for the given key.
  39310. * @return the value corresponding to the key.
  39311. */
  39312. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  39313. /**
  39314. * Get a value from its key if present in the dictionary otherwise add it
  39315. * @param key the key to get the value from
  39316. * @param val if there's no such key/value pair in the dictionary add it with this value
  39317. * @return the value corresponding to the key
  39318. */
  39319. getOrAdd(key: string, val: T): T;
  39320. /**
  39321. * Check if there's a given key in the dictionary
  39322. * @param key the key to check for
  39323. * @return true if the key is present, false otherwise
  39324. */
  39325. contains(key: string): boolean;
  39326. /**
  39327. * Add a new key and its corresponding value
  39328. * @param key the key to add
  39329. * @param value the value corresponding to the key
  39330. * @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
  39331. */
  39332. add(key: string, value: T): boolean;
  39333. /**
  39334. * Update a specific value associated to a key
  39335. * @param key defines the key to use
  39336. * @param value defines the value to store
  39337. * @returns true if the value was updated (or false if the key was not found)
  39338. */
  39339. set(key: string, value: T): boolean;
  39340. /**
  39341. * Get the element of the given key and remove it from the dictionary
  39342. * @param key defines the key to search
  39343. * @returns the value associated with the key or null if not found
  39344. */
  39345. getAndRemove(key: string): Nullable<T>;
  39346. /**
  39347. * Remove a key/value from the dictionary.
  39348. * @param key the key to remove
  39349. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  39350. */
  39351. remove(key: string): boolean;
  39352. /**
  39353. * Clear the whole content of the dictionary
  39354. */
  39355. clear(): void;
  39356. /**
  39357. * Gets the current count
  39358. */
  39359. readonly count: number;
  39360. /**
  39361. * Execute a callback on each key/val of the dictionary.
  39362. * Note that you can remove any element in this dictionary in the callback implementation
  39363. * @param callback the callback to execute on a given key/value pair
  39364. */
  39365. forEach(callback: (key: string, val: T) => void): void;
  39366. /**
  39367. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  39368. * If the callback returns null or undefined the method will iterate to the next key/value pair
  39369. * Note that you can remove any element in this dictionary in the callback implementation
  39370. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  39371. * @returns the first item
  39372. */
  39373. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  39374. private _count;
  39375. private _data;
  39376. }
  39377. }
  39378. declare module BABYLON {
  39379. /**
  39380. * Class used to store custom tags
  39381. */
  39382. class Tags {
  39383. /**
  39384. * Adds support for tags on the given object
  39385. * @param obj defines the object to use
  39386. */
  39387. static EnableFor(obj: any): void;
  39388. /**
  39389. * Removes tags support
  39390. * @param obj defines the object to use
  39391. */
  39392. static DisableFor(obj: any): void;
  39393. /**
  39394. * Gets a boolean indicating if the given object has tags
  39395. * @param obj defines the object to use
  39396. * @returns a boolean
  39397. */
  39398. static HasTags(obj: any): boolean;
  39399. /**
  39400. * Gets the tags available on a given object
  39401. * @param obj defines the object to use
  39402. * @param asString defines if the tags must be returned as a string instead of an array of strings
  39403. * @returns the tags
  39404. */
  39405. static GetTags(obj: any, asString?: boolean): any;
  39406. /**
  39407. * Adds tags to an object
  39408. * @param obj defines the object to use
  39409. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  39410. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  39411. */
  39412. static AddTagsTo(obj: any, tagsString: string): void;
  39413. /**
  39414. * @hidden
  39415. */
  39416. static _AddTagTo(obj: any, tag: string): void;
  39417. /**
  39418. * Removes specific tags from a specific object
  39419. * @param obj defines the object to use
  39420. * @param tagsString defines the tags to remove
  39421. */
  39422. static RemoveTagsFrom(obj: any, tagsString: string): void;
  39423. /**
  39424. * @hidden
  39425. */
  39426. static _RemoveTagFrom(obj: any, tag: string): void;
  39427. /**
  39428. * Defines if tags hosted on an object match a given query
  39429. * @param obj defines the object to use
  39430. * @param tagsQuery defines the tag query
  39431. * @returns a boolean
  39432. */
  39433. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  39434. }
  39435. }
  39436. declare module BABYLON {
  39437. /**
  39438. * Class used to host texture specific utilities
  39439. */
  39440. class TextureTools {
  39441. /**
  39442. * Uses the GPU to create a copy texture rescaled at a given size
  39443. * @param texture Texture to copy from
  39444. * @param width defines the desired width
  39445. * @param height defines the desired height
  39446. * @param useBilinearMode defines if bilinear mode has to be used
  39447. * @return the generated texture
  39448. */
  39449. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  39450. /**
  39451. * Gets an environment BRDF texture for a given scene
  39452. * @param scene defines the hosting scene
  39453. * @returns the environment BRDF texture
  39454. */
  39455. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  39456. private static _environmentBRDFBase64Texture;
  39457. }
  39458. }
  39459. declare module BABYLON {
  39460. /**
  39461. * Based on jsTGALoader - Javascript loader for TGA file
  39462. * By Vincent Thibault
  39463. * @see http://blog.robrowser.com/javascript-tga-loader.html
  39464. */
  39465. class TGATools {
  39466. private static _TYPE_INDEXED;
  39467. private static _TYPE_RGB;
  39468. private static _TYPE_GREY;
  39469. private static _TYPE_RLE_INDEXED;
  39470. private static _TYPE_RLE_RGB;
  39471. private static _TYPE_RLE_GREY;
  39472. private static _ORIGIN_MASK;
  39473. private static _ORIGIN_SHIFT;
  39474. private static _ORIGIN_BL;
  39475. private static _ORIGIN_BR;
  39476. private static _ORIGIN_UL;
  39477. private static _ORIGIN_UR;
  39478. /**
  39479. * Gets the header of a TGA file
  39480. * @param data defines the TGA data
  39481. * @returns the header
  39482. */
  39483. static GetTGAHeader(data: Uint8Array): any;
  39484. /**
  39485. * Uploads TGA content to a Babylon Texture
  39486. * @hidden
  39487. */
  39488. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  39489. /** @hidden */
  39490. 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;
  39491. /** @hidden */
  39492. 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;
  39493. /** @hidden */
  39494. 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;
  39495. /** @hidden */
  39496. 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;
  39497. /** @hidden */
  39498. 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;
  39499. /** @hidden */
  39500. 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;
  39501. }
  39502. }
  39503. declare module BABYLON {
  39504. /**
  39505. * Interface for any object that can request an animation frame
  39506. */
  39507. interface ICustomAnimationFrameRequester {
  39508. /**
  39509. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  39510. */
  39511. renderFunction?: Function;
  39512. /**
  39513. * Called to request the next frame to render to
  39514. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  39515. */
  39516. requestAnimationFrame: Function;
  39517. /**
  39518. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  39519. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  39520. */
  39521. requestID?: number;
  39522. }
  39523. /**
  39524. * Interface containing an array of animations
  39525. */
  39526. interface IAnimatable {
  39527. /**
  39528. * Array of animations
  39529. */
  39530. animations: Array<Animation>;
  39531. }
  39532. /** Interface used by value gradients (color, factor, ...) */
  39533. interface IValueGradient {
  39534. /**
  39535. * Gets or sets the gradient value (between 0 and 1)
  39536. */
  39537. gradient: number;
  39538. }
  39539. /** Class used to store color4 gradient */
  39540. class ColorGradient implements IValueGradient {
  39541. /**
  39542. * Gets or sets the gradient value (between 0 and 1)
  39543. */
  39544. gradient: number;
  39545. /**
  39546. * Gets or sets first associated color
  39547. */
  39548. color1: Color4;
  39549. /**
  39550. * Gets or sets second associated color
  39551. */
  39552. color2?: Color4;
  39553. /**
  39554. * Will get a color picked randomly between color1 and color2.
  39555. * If color2 is undefined then color1 will be used
  39556. * @param result defines the target Color4 to store the result in
  39557. */
  39558. getColorToRef(result: Color4): void;
  39559. }
  39560. /** Class used to store color 3 gradient */
  39561. class Color3Gradient implements IValueGradient {
  39562. /**
  39563. * Gets or sets the gradient value (between 0 and 1)
  39564. */
  39565. gradient: number;
  39566. /**
  39567. * Gets or sets the associated color
  39568. */
  39569. color: Color3;
  39570. }
  39571. /** Class used to store factor gradient */
  39572. class FactorGradient implements IValueGradient {
  39573. /**
  39574. * Gets or sets the gradient value (between 0 and 1)
  39575. */
  39576. gradient: number;
  39577. /**
  39578. * Gets or sets first associated factor
  39579. */
  39580. factor1: number;
  39581. /**
  39582. * Gets or sets second associated factor
  39583. */
  39584. factor2?: number;
  39585. /**
  39586. * Will get a number picked randomly between factor1 and factor2.
  39587. * If factor2 is undefined then factor1 will be used
  39588. * @returns the picked number
  39589. */
  39590. getFactor(): number;
  39591. }
  39592. /**
  39593. * @ignore
  39594. * Application error to support additional information when loading a file
  39595. */
  39596. class LoadFileError extends Error {
  39597. /** defines the optional XHR request */
  39598. request?: XMLHttpRequest | undefined;
  39599. private static _setPrototypeOf;
  39600. /**
  39601. * Creates a new LoadFileError
  39602. * @param message defines the message of the error
  39603. * @param request defines the optional XHR request
  39604. */
  39605. constructor(message: string,
  39606. /** defines the optional XHR request */
  39607. request?: XMLHttpRequest | undefined);
  39608. }
  39609. /**
  39610. * Class used to define a retry strategy when error happens while loading assets
  39611. */
  39612. class RetryStrategy {
  39613. /**
  39614. * Function used to defines an exponential back off strategy
  39615. * @param maxRetries defines the maximum number of retries (3 by default)
  39616. * @param baseInterval defines the interval between retries
  39617. * @returns the strategy function to use
  39618. */
  39619. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  39620. }
  39621. /**
  39622. * File request interface
  39623. */
  39624. interface IFileRequest {
  39625. /**
  39626. * Raised when the request is complete (success or error).
  39627. */
  39628. onCompleteObservable: Observable<IFileRequest>;
  39629. /**
  39630. * Aborts the request for a file.
  39631. */
  39632. abort: () => void;
  39633. }
  39634. /**
  39635. * Class containing a set of static utilities functions
  39636. */
  39637. class Tools {
  39638. /**
  39639. * Gets or sets the base URL to use to load assets
  39640. */
  39641. static BaseUrl: string;
  39642. /**
  39643. * Enable/Disable Custom HTTP Request Headers globally.
  39644. * default = false
  39645. * @see CustomRequestHeaders
  39646. */
  39647. static UseCustomRequestHeaders: boolean;
  39648. /**
  39649. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  39650. * i.e. when loading files, where the server/service expects an Authorization header.
  39651. * @see InjectCustomRequestHeaders injects them to an XMLHttpRequest
  39652. */
  39653. static CustomRequestHeaders: {
  39654. [key: string]: string;
  39655. };
  39656. /**
  39657. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  39658. */
  39659. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  39660. /**
  39661. * Default behaviour for cors in the application.
  39662. * It can be a string if the expected behavior is identical in the entire app.
  39663. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  39664. */
  39665. static CorsBehavior: string | ((url: string | string[]) => string);
  39666. /**
  39667. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  39668. * @ignorenaming
  39669. */
  39670. static UseFallbackTexture: boolean;
  39671. /**
  39672. * Use this object to register external classes like custom textures or material
  39673. * to allow the laoders to instantiate them
  39674. */
  39675. static RegisteredExternalClasses: {
  39676. [key: string]: Object;
  39677. };
  39678. /**
  39679. * Texture content used if a texture cannot loaded
  39680. * @ignorenaming
  39681. */
  39682. static fallbackTexture: string;
  39683. /**
  39684. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  39685. * @param u defines the coordinate on X axis
  39686. * @param v defines the coordinate on Y axis
  39687. * @param width defines the width of the source data
  39688. * @param height defines the height of the source data
  39689. * @param pixels defines the source byte array
  39690. * @param color defines the output color
  39691. */
  39692. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  39693. /**
  39694. * Interpolates between a and b via alpha
  39695. * @param a The lower value (returned when alpha = 0)
  39696. * @param b The upper value (returned when alpha = 1)
  39697. * @param alpha The interpolation-factor
  39698. * @return The mixed value
  39699. */
  39700. static Mix(a: number, b: number, alpha: number): number;
  39701. /**
  39702. * Tries to instantiate a new object from a given class name
  39703. * @param className defines the class name to instantiate
  39704. * @returns the new object or null if the system was not able to do the instantiation
  39705. */
  39706. static Instantiate(className: string): any;
  39707. /**
  39708. * Provides a slice function that will work even on IE
  39709. * @param data defines the array to slice
  39710. * @param start defines the start of the data (optional)
  39711. * @param end defines the end of the data (optional)
  39712. * @returns the new sliced array
  39713. */
  39714. static Slice<T>(data: T, start?: number, end?: number): T;
  39715. /**
  39716. * Polyfill for setImmediate
  39717. * @param action defines the action to execute after the current execution block
  39718. */
  39719. static SetImmediate(action: () => void): void;
  39720. /**
  39721. * Function indicating if a number is an exponent of 2
  39722. * @param value defines the value to test
  39723. * @returns true if the value is an exponent of 2
  39724. */
  39725. static IsExponentOfTwo(value: number): boolean;
  39726. private static _tmpFloatArray;
  39727. /**
  39728. * Returns the nearest 32-bit single precision float representation of a Number
  39729. * @param value A Number. If the parameter is of a different type, it will get converted
  39730. * to a number or to NaN if it cannot be converted
  39731. * @returns number
  39732. */
  39733. static FloatRound(value: number): number;
  39734. /**
  39735. * Find the next highest power of two.
  39736. * @param x Number to start search from.
  39737. * @return Next highest power of two.
  39738. */
  39739. static CeilingPOT(x: number): number;
  39740. /**
  39741. * Find the next lowest power of two.
  39742. * @param x Number to start search from.
  39743. * @return Next lowest power of two.
  39744. */
  39745. static FloorPOT(x: number): number;
  39746. /**
  39747. * Find the nearest power of two.
  39748. * @param x Number to start search from.
  39749. * @return Next nearest power of two.
  39750. */
  39751. static NearestPOT(x: number): number;
  39752. /**
  39753. * Get the closest exponent of two
  39754. * @param value defines the value to approximate
  39755. * @param max defines the maximum value to return
  39756. * @param mode defines how to define the closest value
  39757. * @returns closest exponent of two of the given value
  39758. */
  39759. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  39760. /**
  39761. * Extracts the filename from a path
  39762. * @param path defines the path to use
  39763. * @returns the filename
  39764. */
  39765. static GetFilename(path: string): string;
  39766. /**
  39767. * Extracts the "folder" part of a path (everything before the filename).
  39768. * @param uri The URI to extract the info from
  39769. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  39770. * @returns The "folder" part of the path
  39771. */
  39772. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  39773. /**
  39774. * Extracts text content from a DOM element hierarchy
  39775. * @param element defines the root element
  39776. * @returns a string
  39777. */
  39778. static GetDOMTextContent(element: HTMLElement): string;
  39779. /**
  39780. * Convert an angle in radians to degrees
  39781. * @param angle defines the angle to convert
  39782. * @returns the angle in degrees
  39783. */
  39784. static ToDegrees(angle: number): number;
  39785. /**
  39786. * Convert an angle in degrees to radians
  39787. * @param angle defines the angle to convert
  39788. * @returns the angle in radians
  39789. */
  39790. static ToRadians(angle: number): number;
  39791. /**
  39792. * Encode a buffer to a base64 string
  39793. * @param buffer defines the buffer to encode
  39794. * @returns the encoded string
  39795. */
  39796. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  39797. /**
  39798. * Extracts minimum and maximum values from a list of indexed positions
  39799. * @param positions defines the positions to use
  39800. * @param indices defines the indices to the positions
  39801. * @param indexStart defines the start index
  39802. * @param indexCount defines the end index
  39803. * @param bias defines bias value to add to the result
  39804. * @return minimum and maximum values
  39805. */
  39806. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  39807. minimum: Vector3;
  39808. maximum: Vector3;
  39809. };
  39810. /**
  39811. * Extracts minimum and maximum values from a list of positions
  39812. * @param positions defines the positions to use
  39813. * @param start defines the start index in the positions array
  39814. * @param count defines the number of positions to handle
  39815. * @param bias defines bias value to add to the result
  39816. * @param stride defines the stride size to use (distance between two positions in the positions array)
  39817. * @return minimum and maximum values
  39818. */
  39819. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  39820. minimum: Vector3;
  39821. maximum: Vector3;
  39822. };
  39823. /**
  39824. * Returns an array if obj is not an array
  39825. * @param obj defines the object to evaluate as an array
  39826. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  39827. * @returns either obj directly if obj is an array or a new array containing obj
  39828. */
  39829. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  39830. /**
  39831. * Returns an array of the given size filled with element built from the given constructor and the paramters
  39832. * @param size the number of element to construct and put in the array
  39833. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  39834. * @returns a new array filled with new objects
  39835. */
  39836. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  39837. /**
  39838. * Gets the pointer prefix to use
  39839. * @returns "pointer" if touch is enabled. Else returns "mouse"
  39840. */
  39841. static GetPointerPrefix(): string;
  39842. /**
  39843. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  39844. * @param func - the function to be called
  39845. * @param requester - the object that will request the next frame. Falls back to window.
  39846. * @returns frame number
  39847. */
  39848. static QueueNewFrame(func: () => void, requester?: any): number;
  39849. /**
  39850. * Ask the browser to promote the current element to fullscreen rendering mode
  39851. * @param element defines the DOM element to promote
  39852. */
  39853. static RequestFullscreen(element: HTMLElement): void;
  39854. /**
  39855. * Asks the browser to exit fullscreen mode
  39856. */
  39857. static ExitFullscreen(): void;
  39858. /**
  39859. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  39860. * @param url define the url we are trying
  39861. * @param element define the dom element where to configure the cors policy
  39862. */
  39863. static SetCorsBehavior(url: string | string[], element: {
  39864. crossOrigin: string | null;
  39865. }): void;
  39866. /**
  39867. * Removes unwanted characters from an url
  39868. * @param url defines the url to clean
  39869. * @returns the cleaned url
  39870. */
  39871. static CleanUrl(url: string): string;
  39872. /**
  39873. * Gets or sets a function used to pre-process url before using them to load assets
  39874. */
  39875. static PreprocessUrl: (url: string) => string;
  39876. /**
  39877. * Loads an image as an HTMLImageElement.
  39878. * @param input url string, ArrayBuffer, or Blob to load
  39879. * @param onLoad callback called when the image successfully loads
  39880. * @param onError callback called when the image fails to load
  39881. * @param offlineProvider offline provider for caching
  39882. * @returns the HTMLImageElement of the loaded image
  39883. */
  39884. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  39885. /**
  39886. * Loads a file
  39887. * @param url url string, ArrayBuffer, or Blob to load
  39888. * @param onSuccess callback called when the file successfully loads
  39889. * @param onProgress callback called while file is loading (if the server supports this mode)
  39890. * @param offlineProvider defines the offline provider for caching
  39891. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  39892. * @param onError callback called when the file fails to load
  39893. * @returns a file request object
  39894. */
  39895. 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;
  39896. /**
  39897. * Load a script (identified by an url). When the url returns, the
  39898. * content of this file is added into a new script element, attached to the DOM (body element)
  39899. * @param scriptUrl defines the url of the script to laod
  39900. * @param onSuccess defines the callback called when the script is loaded
  39901. * @param onError defines the callback to call if an error occurs
  39902. */
  39903. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  39904. /**
  39905. * Loads a file from a blob
  39906. * @param fileToLoad defines the blob to use
  39907. * @param callback defines the callback to call when data is loaded
  39908. * @param progressCallback defines the callback to call during loading process
  39909. * @returns a file request object
  39910. */
  39911. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  39912. /**
  39913. * Loads a file
  39914. * @param fileToLoad defines the file to load
  39915. * @param callback defines the callback to call when data is loaded
  39916. * @param progressCallBack defines the callback to call during loading process
  39917. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  39918. * @returns a file request object
  39919. */
  39920. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  39921. /**
  39922. * Creates a data url from a given string content
  39923. * @param content defines the content to convert
  39924. * @returns the new data url link
  39925. */
  39926. static FileAsURL(content: string): string;
  39927. /**
  39928. * Format the given number to a specific decimal format
  39929. * @param value defines the number to format
  39930. * @param decimals defines the number of decimals to use
  39931. * @returns the formatted string
  39932. */
  39933. static Format(value: number, decimals?: number): string;
  39934. /**
  39935. * Checks if a given vector is inside a specific range
  39936. * @param v defines the vector to test
  39937. * @param min defines the minimum range
  39938. * @param max defines the maximum range
  39939. */
  39940. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  39941. /**
  39942. * Tries to copy an object by duplicating every property
  39943. * @param source defines the source object
  39944. * @param destination defines the target object
  39945. * @param doNotCopyList defines a list of properties to avoid
  39946. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  39947. */
  39948. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  39949. /**
  39950. * Gets a boolean indicating if the given object has no own property
  39951. * @param obj defines the object to test
  39952. * @returns true if object has no own property
  39953. */
  39954. static IsEmpty(obj: any): boolean;
  39955. /**
  39956. * Function used to register events at window level
  39957. * @param events defines the events to register
  39958. */
  39959. static RegisterTopRootEvents(events: {
  39960. name: string;
  39961. handler: Nullable<(e: FocusEvent) => any>;
  39962. }[]): void;
  39963. /**
  39964. * Function used to unregister events from window level
  39965. * @param events defines the events to unregister
  39966. */
  39967. static UnregisterTopRootEvents(events: {
  39968. name: string;
  39969. handler: Nullable<(e: FocusEvent) => any>;
  39970. }[]): void;
  39971. /**
  39972. * Dumps the current bound framebuffer
  39973. * @param width defines the rendering width
  39974. * @param height defines the rendering height
  39975. * @param engine defines the hosting engine
  39976. * @param successCallback defines the callback triggered once the data are available
  39977. * @param mimeType defines the mime type of the result
  39978. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  39979. */
  39980. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  39981. /**
  39982. * Converts the canvas data to blob.
  39983. * This acts as a polyfill for browsers not supporting the to blob function.
  39984. * @param canvas Defines the canvas to extract the data from
  39985. * @param successCallback Defines the callback triggered once the data are available
  39986. * @param mimeType Defines the mime type of the result
  39987. */
  39988. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  39989. /**
  39990. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  39991. * @param successCallback defines the callback triggered once the data are available
  39992. * @param mimeType defines the mime type of the result
  39993. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  39994. */
  39995. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  39996. /**
  39997. * Downloads a blob in the browser
  39998. * @param blob defines the blob to download
  39999. * @param fileName defines the name of the downloaded file
  40000. */
  40001. static Download(blob: Blob, fileName: string): void;
  40002. /**
  40003. * Captures a screenshot of the current rendering
  40004. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  40005. * @param engine defines the rendering engine
  40006. * @param camera defines the source camera
  40007. * @param size This parameter can be set to a single number or to an object with the
  40008. * following (optional) properties: precision, width, height. If a single number is passed,
  40009. * it will be used for both width and height. If an object is passed, the screenshot size
  40010. * will be derived from the parameters. The precision property is a multiplier allowing
  40011. * rendering at a higher or lower resolution
  40012. * @param successCallback defines the callback receives a single parameter which contains the
  40013. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  40014. * src parameter of an <img> to display it
  40015. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  40016. * Check your browser for supported MIME types
  40017. */
  40018. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  40019. /**
  40020. * Generates an image screenshot from the specified camera.
  40021. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  40022. * @param engine The engine to use for rendering
  40023. * @param camera The camera to use for rendering
  40024. * @param size This parameter can be set to a single number or to an object with the
  40025. * following (optional) properties: precision, width, height. If a single number is passed,
  40026. * it will be used for both width and height. If an object is passed, the screenshot size
  40027. * will be derived from the parameters. The precision property is a multiplier allowing
  40028. * rendering at a higher or lower resolution
  40029. * @param successCallback The callback receives a single parameter which contains the
  40030. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  40031. * src parameter of an <img> to display it
  40032. * @param mimeType The MIME type of the screenshot image (default: image/png).
  40033. * Check your browser for supported MIME types
  40034. * @param samples Texture samples (default: 1)
  40035. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  40036. * @param fileName A name for for the downloaded file.
  40037. */
  40038. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  40039. /**
  40040. * Validates if xhr data is correct
  40041. * @param xhr defines the request to validate
  40042. * @param dataType defines the expected data type
  40043. * @returns true if data is correct
  40044. */
  40045. static ValidateXHRData(xhr: XMLHttpRequest, dataType?: number): boolean;
  40046. /**
  40047. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  40048. * Be aware Math.random() could cause collisions, but:
  40049. * "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"
  40050. * @returns a pseudo random id
  40051. */
  40052. static RandomId(): string;
  40053. /**
  40054. * Test if the given uri is a base64 string
  40055. * @param uri The uri to test
  40056. * @return True if the uri is a base64 string or false otherwise
  40057. */
  40058. static IsBase64(uri: string): boolean;
  40059. /**
  40060. * Decode the given base64 uri.
  40061. * @param uri The uri to decode
  40062. * @return The decoded base64 data.
  40063. */
  40064. static DecodeBase64(uri: string): ArrayBuffer;
  40065. /**
  40066. * No log
  40067. */
  40068. static readonly NoneLogLevel: number;
  40069. /**
  40070. * Only message logs
  40071. */
  40072. static readonly MessageLogLevel: number;
  40073. /**
  40074. * Only warning logs
  40075. */
  40076. static readonly WarningLogLevel: number;
  40077. /**
  40078. * Only error logs
  40079. */
  40080. static readonly ErrorLogLevel: number;
  40081. /**
  40082. * All logs
  40083. */
  40084. static readonly AllLogLevel: number;
  40085. private static _LogCache;
  40086. /**
  40087. * Gets a value indicating the number of loading errors
  40088. * @ignorenaming
  40089. */
  40090. static errorsCount: number;
  40091. /**
  40092. * Callback called when a new log is added
  40093. */
  40094. static OnNewCacheEntry: (entry: string) => void;
  40095. private static _AddLogEntry;
  40096. private static _FormatMessage;
  40097. private static _LogDisabled;
  40098. private static _LogEnabled;
  40099. private static _WarnDisabled;
  40100. private static _WarnEnabled;
  40101. private static _ErrorDisabled;
  40102. private static _ErrorEnabled;
  40103. /**
  40104. * Log a message to the console
  40105. */
  40106. static Log: (message: string) => void;
  40107. /**
  40108. * Write a warning message to the console
  40109. */
  40110. static Warn: (message: string) => void;
  40111. /**
  40112. * Write an error message to the console
  40113. */
  40114. static Error: (message: string) => void;
  40115. /**
  40116. * Gets current log cache (list of logs)
  40117. */
  40118. static readonly LogCache: string;
  40119. /**
  40120. * Clears the log cache
  40121. */
  40122. static ClearLogCache(): void;
  40123. /**
  40124. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  40125. */
  40126. static LogLevels: number;
  40127. /**
  40128. * Checks if the loaded document was accessed via `file:`-Protocol.
  40129. * @returns boolean
  40130. */
  40131. static IsFileURL(): boolean;
  40132. /**
  40133. * Checks if the window object exists
  40134. * @returns true if the window object exists
  40135. */
  40136. static IsWindowObjectExist(): boolean;
  40137. /**
  40138. * No performance log
  40139. */
  40140. static readonly PerformanceNoneLogLevel: number;
  40141. /**
  40142. * Use user marks to log performance
  40143. */
  40144. static readonly PerformanceUserMarkLogLevel: number;
  40145. /**
  40146. * Log performance to the console
  40147. */
  40148. static readonly PerformanceConsoleLogLevel: number;
  40149. private static _performance;
  40150. /**
  40151. * Sets the current performance log level
  40152. */
  40153. static PerformanceLogLevel: number;
  40154. private static _StartPerformanceCounterDisabled;
  40155. private static _EndPerformanceCounterDisabled;
  40156. private static _StartUserMark;
  40157. private static _EndUserMark;
  40158. private static _StartPerformanceConsole;
  40159. private static _EndPerformanceConsole;
  40160. /**
  40161. * Injects the @see CustomRequestHeaders into the given request
  40162. * @param request the request that should be used for injection
  40163. */
  40164. static InjectCustomRequestHeaders(request: XMLHttpRequest): void;
  40165. /**
  40166. * Starts a performance counter
  40167. */
  40168. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  40169. /**
  40170. * Ends a specific performance coutner
  40171. */
  40172. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  40173. /**
  40174. * Gets either window.performance.now() if supported or Date.now() else
  40175. */
  40176. static readonly Now: number;
  40177. /**
  40178. * This method will return the name of the class used to create the instance of the given object.
  40179. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  40180. * @param object the object to get the class name from
  40181. * @param isType defines if the object is actually a type
  40182. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  40183. */
  40184. static GetClassName(object: any, isType?: boolean): string;
  40185. /**
  40186. * Gets the first element of an array satisfying a given predicate
  40187. * @param array defines the array to browse
  40188. * @param predicate defines the predicate to use
  40189. * @returns null if not found or the element
  40190. */
  40191. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  40192. /**
  40193. * This method will return the name of the full name of the class, including its owning module (if any).
  40194. * 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).
  40195. * @param object the object to get the class name from
  40196. * @param isType defines if the object is actually a type
  40197. * @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.
  40198. * @ignorenaming
  40199. */
  40200. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  40201. /**
  40202. * Returns a promise that resolves after the given amount of time.
  40203. * @param delay Number of milliseconds to delay
  40204. * @returns Promise that resolves after the given amount of time
  40205. */
  40206. static DelayAsync(delay: number): Promise<void>;
  40207. /**
  40208. * Gets the current gradient from an array of IValueGradient
  40209. * @param ratio defines the current ratio to get
  40210. * @param gradients defines the array of IValueGradient
  40211. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  40212. */
  40213. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  40214. }
  40215. /**
  40216. * This class is used to track a performance counter which is number based.
  40217. * The user has access to many properties which give statistics of different nature.
  40218. *
  40219. * The implementer can track two kinds of Performance Counter: time and count.
  40220. * 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.
  40221. * 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.
  40222. */
  40223. class PerfCounter {
  40224. /**
  40225. * Gets or sets a global boolean to turn on and off all the counters
  40226. */
  40227. static Enabled: boolean;
  40228. /**
  40229. * Returns the smallest value ever
  40230. */
  40231. readonly min: number;
  40232. /**
  40233. * Returns the biggest value ever
  40234. */
  40235. readonly max: number;
  40236. /**
  40237. * Returns the average value since the performance counter is running
  40238. */
  40239. readonly average: number;
  40240. /**
  40241. * Returns the average value of the last second the counter was monitored
  40242. */
  40243. readonly lastSecAverage: number;
  40244. /**
  40245. * Returns the current value
  40246. */
  40247. readonly current: number;
  40248. /**
  40249. * Gets the accumulated total
  40250. */
  40251. readonly total: number;
  40252. /**
  40253. * Gets the total value count
  40254. */
  40255. readonly count: number;
  40256. /**
  40257. * Creates a new counter
  40258. */
  40259. constructor();
  40260. /**
  40261. * Call this method to start monitoring a new frame.
  40262. * 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.
  40263. */
  40264. fetchNewFrame(): void;
  40265. /**
  40266. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  40267. * @param newCount the count value to add to the monitored count
  40268. * @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.
  40269. */
  40270. addCount(newCount: number, fetchResult: boolean): void;
  40271. /**
  40272. * Start monitoring this performance counter
  40273. */
  40274. beginMonitoring(): void;
  40275. /**
  40276. * Compute the time lapsed since the previous beginMonitoring() call.
  40277. * @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
  40278. */
  40279. endMonitoring(newFrame?: boolean): void;
  40280. private _fetchResult;
  40281. private _startMonitoringTime;
  40282. private _min;
  40283. private _max;
  40284. private _average;
  40285. private _current;
  40286. private _totalValueCount;
  40287. private _totalAccumulated;
  40288. private _lastSecAverage;
  40289. private _lastSecAccumulated;
  40290. private _lastSecTime;
  40291. private _lastSecValueCount;
  40292. }
  40293. /**
  40294. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  40295. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  40296. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  40297. * @param name The name of the class, case should be preserved
  40298. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  40299. */
  40300. function className(name: string, module?: string): (target: Object) => void;
  40301. /**
  40302. * An implementation of a loop for asynchronous functions.
  40303. */
  40304. class AsyncLoop {
  40305. /**
  40306. * Defines the number of iterations for the loop
  40307. */
  40308. iterations: number;
  40309. /**
  40310. * Defines the current index of the loop.
  40311. */
  40312. index: number;
  40313. private _done;
  40314. private _fn;
  40315. private _successCallback;
  40316. /**
  40317. * Constructor.
  40318. * @param iterations the number of iterations.
  40319. * @param func the function to run each iteration
  40320. * @param successCallback the callback that will be called upon succesful execution
  40321. * @param offset starting offset.
  40322. */
  40323. constructor(
  40324. /**
  40325. * Defines the number of iterations for the loop
  40326. */
  40327. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  40328. /**
  40329. * Execute the next iteration. Must be called after the last iteration was finished.
  40330. */
  40331. executeNext(): void;
  40332. /**
  40333. * Break the loop and run the success callback.
  40334. */
  40335. breakLoop(): void;
  40336. /**
  40337. * Create and run an async loop.
  40338. * @param iterations the number of iterations.
  40339. * @param fn the function to run each iteration
  40340. * @param successCallback the callback that will be called upon succesful execution
  40341. * @param offset starting offset.
  40342. * @returns the created async loop object
  40343. */
  40344. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  40345. /**
  40346. * A for-loop that will run a given number of iterations synchronous and the rest async.
  40347. * @param iterations total number of iterations
  40348. * @param syncedIterations number of synchronous iterations in each async iteration.
  40349. * @param fn the function to call each iteration.
  40350. * @param callback a success call back that will be called when iterating stops.
  40351. * @param breakFunction a break condition (optional)
  40352. * @param timeout timeout settings for the setTimeout function. default - 0.
  40353. * @returns the created async loop object
  40354. */
  40355. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  40356. }
  40357. }
  40358. interface HTMLCanvasElement {
  40359. /** Track wether a record is in progress */
  40360. isRecording: boolean;
  40361. /** Capture Stream method defined by some browsers */
  40362. captureStream(fps?: number): MediaStream;
  40363. }
  40364. interface MediaRecorder {
  40365. /** Starts recording */
  40366. start(timeSlice: number): void;
  40367. /** Stops recording */
  40368. stop(): void;
  40369. /** Event raised when an error arised. */
  40370. onerror: (event: ErrorEvent) => void;
  40371. /** Event raised when the recording stops. */
  40372. onstop: (event: Event) => void;
  40373. /** Event raised when a new chunk of data is available and should be tracked. */
  40374. ondataavailable: (event: Event) => void;
  40375. }
  40376. interface MediaRecorderOptions {
  40377. /** The mime type you want to use as the recording container for the new MediaRecorder */
  40378. mimeType?: string;
  40379. /** The chosen bitrate for the audio component of the media. */
  40380. audioBitsPerSecond?: number;
  40381. /** The chosen bitrate for the video component of the media. */
  40382. videoBitsPerSecond?: number;
  40383. /** 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. */
  40384. bitsPerSecond?: number;
  40385. }
  40386. interface MediaRecorderConstructor {
  40387. /**
  40388. * A reference to the prototype.
  40389. */
  40390. readonly prototype: MediaRecorder;
  40391. /**
  40392. * Creates a new MediaRecorder.
  40393. * @param stream Defines the stream to record.
  40394. * @param options Defines the options for the recorder available in the type MediaRecorderOptions.
  40395. */
  40396. new (stream: MediaStream, options?: MediaRecorderOptions): MediaRecorder;
  40397. }
  40398. /**
  40399. * MediaRecoreder object available in some browsers.
  40400. */
  40401. declare var MediaRecorder: MediaRecorderConstructor;
  40402. declare module BABYLON {
  40403. /**
  40404. * This represents the different options avilable for the video capture.
  40405. */
  40406. interface VideoRecorderOptions {
  40407. /** Defines the mime type of the video */
  40408. mimeType: string;
  40409. /** Defines the video the video should be recorded at */
  40410. fps: number;
  40411. /** Defines the chunk size for the recording data */
  40412. recordChunckSize: number;
  40413. }
  40414. /**
  40415. * This can helps recording videos from BabylonJS.
  40416. * This is based on the available WebRTC functionalities of the browser.
  40417. *
  40418. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  40419. */
  40420. class VideoRecorder {
  40421. private static readonly _defaultOptions;
  40422. /**
  40423. * Returns wehther or not the VideoRecorder is available in your browser.
  40424. * @param engine Defines the Babylon Engine to check the support for
  40425. * @returns true if supported otherwise false
  40426. */
  40427. static IsSupported(engine: Engine): boolean;
  40428. private readonly _options;
  40429. private _canvas;
  40430. private _mediaRecorder;
  40431. private _recordedChunks;
  40432. private _fileName;
  40433. private _resolve;
  40434. private _reject;
  40435. /**
  40436. * True wether a recording is already in progress.
  40437. */
  40438. readonly isRecording: boolean;
  40439. /**
  40440. * Create a new VideoCapture object which can help converting what you see in Babylon to
  40441. * a video file.
  40442. * @param engine Defines the BabylonJS Engine you wish to record
  40443. * @param options Defines options that can be used to customized the capture
  40444. */
  40445. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  40446. /**
  40447. * Stops the current recording before the default capture timeout passed in the startRecording
  40448. * functions.
  40449. */
  40450. stopRecording(): void;
  40451. /**
  40452. * Starts recording the canvas for a max duration specified in parameters.
  40453. * @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.
  40454. * @param maxDuration Defines the maximum recording time in seconds.
  40455. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  40456. * @return a promise callback at the end of the recording with the video data in Blob.
  40457. */
  40458. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  40459. /**
  40460. * Releases internal resources used during the recording.
  40461. */
  40462. dispose(): void;
  40463. private _handleDataAvailable;
  40464. private _handleError;
  40465. private _handleStop;
  40466. }
  40467. }
  40468. declare module BABYLON {
  40469. /**
  40470. * Defines the potential axis of a Joystick
  40471. */
  40472. enum JoystickAxis {
  40473. /** X axis */
  40474. X = 0,
  40475. /** Y axis */
  40476. Y = 1,
  40477. /** Z axis */
  40478. Z = 2
  40479. }
  40480. /**
  40481. * Class used to define virtual joystick (used in touch mode)
  40482. */
  40483. class VirtualJoystick {
  40484. /**
  40485. * Gets or sets a boolean indicating that left and right values must be inverted
  40486. */
  40487. reverseLeftRight: boolean;
  40488. /**
  40489. * Gets or sets a boolean indicating that up and down values must be inverted
  40490. */
  40491. reverseUpDown: boolean;
  40492. /**
  40493. * Gets the offset value for the position (ie. the change of the position value)
  40494. */
  40495. deltaPosition: Vector3;
  40496. /**
  40497. * Gets a boolean indicating if the virtual joystick was pressed
  40498. */
  40499. pressed: boolean;
  40500. /**
  40501. * Canvas the virtual joystick will render onto, default z-index of this is 5
  40502. */
  40503. static Canvas: Nullable<HTMLCanvasElement>;
  40504. private static _globalJoystickIndex;
  40505. private static vjCanvasContext;
  40506. private static vjCanvasWidth;
  40507. private static vjCanvasHeight;
  40508. private static halfWidth;
  40509. private _action;
  40510. private _axisTargetedByLeftAndRight;
  40511. private _axisTargetedByUpAndDown;
  40512. private _joystickSensibility;
  40513. private _inversedSensibility;
  40514. private _joystickPointerID;
  40515. private _joystickColor;
  40516. private _joystickPointerPos;
  40517. private _joystickPreviousPointerPos;
  40518. private _joystickPointerStartPos;
  40519. private _deltaJoystickVector;
  40520. private _leftJoystick;
  40521. private _touches;
  40522. private _onPointerDownHandlerRef;
  40523. private _onPointerMoveHandlerRef;
  40524. private _onPointerUpHandlerRef;
  40525. private _onResize;
  40526. /**
  40527. * Creates a new virtual joystick
  40528. * @param leftJoystick defines that the joystick is for left hand (false by default)
  40529. */
  40530. constructor(leftJoystick?: boolean);
  40531. /**
  40532. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  40533. * @param newJoystickSensibility defines the new sensibility
  40534. */
  40535. setJoystickSensibility(newJoystickSensibility: number): void;
  40536. private _onPointerDown;
  40537. private _onPointerMove;
  40538. private _onPointerUp;
  40539. /**
  40540. * Change the color of the virtual joystick
  40541. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  40542. */
  40543. setJoystickColor(newColor: string): void;
  40544. /**
  40545. * Defines a callback to call when the joystick is touched
  40546. * @param action defines the callback
  40547. */
  40548. setActionOnTouch(action: () => any): void;
  40549. /**
  40550. * Defines which axis you'd like to control for left & right
  40551. * @param axis defines the axis to use
  40552. */
  40553. setAxisForLeftRight(axis: JoystickAxis): void;
  40554. /**
  40555. * Defines which axis you'd like to control for up & down
  40556. * @param axis defines the axis to use
  40557. */
  40558. setAxisForUpDown(axis: JoystickAxis): void;
  40559. private _drawVirtualJoystick;
  40560. /**
  40561. * Release internal HTML canvas
  40562. */
  40563. releaseCanvas(): void;
  40564. }
  40565. }
  40566. declare module BABYLON {
  40567. /**
  40568. * Helper class to push actions to a pool of workers.
  40569. */
  40570. class WorkerPool implements IDisposable {
  40571. private _workerInfos;
  40572. private _pendingActions;
  40573. /**
  40574. * Constructor
  40575. * @param workers Array of workers to use for actions
  40576. */
  40577. constructor(workers: Array<Worker>);
  40578. /**
  40579. * Terminates all workers and clears any pending actions.
  40580. */
  40581. dispose(): void;
  40582. /**
  40583. * Pushes an action to the worker pool. If all the workers are active, the action will be
  40584. * pended until a worker has completed its action.
  40585. * @param action The action to perform. Call onComplete when the action is complete.
  40586. */
  40587. push(action: (worker: Worker, onComplete: () => void) => void): void;
  40588. private _execute;
  40589. }
  40590. }
  40591. declare module BABYLON {
  40592. /**
  40593. * The autoRotation behavior (BABYLON.AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  40594. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40595. */
  40596. class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  40597. /**
  40598. * Gets the name of the behavior.
  40599. */
  40600. readonly name: string;
  40601. private _zoomStopsAnimation;
  40602. private _idleRotationSpeed;
  40603. private _idleRotationWaitTime;
  40604. private _idleRotationSpinupTime;
  40605. /**
  40606. * Sets the flag that indicates if user zooming should stop animation.
  40607. */
  40608. /**
  40609. * Gets the flag that indicates if user zooming should stop animation.
  40610. */
  40611. zoomStopsAnimation: boolean;
  40612. /**
  40613. * Sets the default speed at which the camera rotates around the model.
  40614. */
  40615. /**
  40616. * Gets the default speed at which the camera rotates around the model.
  40617. */
  40618. idleRotationSpeed: number;
  40619. /**
  40620. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  40621. */
  40622. /**
  40623. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  40624. */
  40625. idleRotationWaitTime: number;
  40626. /**
  40627. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40628. */
  40629. /**
  40630. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40631. */
  40632. idleRotationSpinupTime: number;
  40633. /**
  40634. * Gets a value indicating if the camera is currently rotating because of this behavior
  40635. */
  40636. readonly rotationInProgress: boolean;
  40637. private _onPrePointerObservableObserver;
  40638. private _onAfterCheckInputsObserver;
  40639. private _attachedCamera;
  40640. private _isPointerDown;
  40641. private _lastFrameTime;
  40642. private _lastInteractionTime;
  40643. private _cameraRotationSpeed;
  40644. /**
  40645. * Initializes the behavior.
  40646. */
  40647. init(): void;
  40648. /**
  40649. * Attaches the behavior to its arc rotate camera.
  40650. * @param camera Defines the camera to attach the behavior to
  40651. */
  40652. attach(camera: ArcRotateCamera): void;
  40653. /**
  40654. * Detaches the behavior from its current arc rotate camera.
  40655. */
  40656. detach(): void;
  40657. /**
  40658. * Returns true if user is scrolling.
  40659. * @return true if user is scrolling.
  40660. */
  40661. private _userIsZooming;
  40662. private _lastFrameRadius;
  40663. private _shouldAnimationStopForInteraction;
  40664. /**
  40665. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  40666. */
  40667. private _applyUserInteraction;
  40668. private _userIsMoving;
  40669. }
  40670. }
  40671. declare module BABYLON {
  40672. /**
  40673. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  40674. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  40675. */
  40676. class BouncingBehavior implements Behavior<ArcRotateCamera> {
  40677. /**
  40678. * Gets the name of the behavior.
  40679. */
  40680. readonly name: string;
  40681. /**
  40682. * The easing function used by animations
  40683. */
  40684. static EasingFunction: BackEase;
  40685. /**
  40686. * The easing mode used by animations
  40687. */
  40688. static EasingMode: number;
  40689. /**
  40690. * The duration of the animation, in milliseconds
  40691. */
  40692. transitionDuration: number;
  40693. /**
  40694. * Length of the distance animated by the transition when lower radius is reached
  40695. */
  40696. lowerRadiusTransitionRange: number;
  40697. /**
  40698. * Length of the distance animated by the transition when upper radius is reached
  40699. */
  40700. upperRadiusTransitionRange: number;
  40701. private _autoTransitionRange;
  40702. /**
  40703. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  40704. */
  40705. /**
  40706. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  40707. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  40708. */
  40709. autoTransitionRange: boolean;
  40710. private _attachedCamera;
  40711. private _onAfterCheckInputsObserver;
  40712. private _onMeshTargetChangedObserver;
  40713. /**
  40714. * Initializes the behavior.
  40715. */
  40716. init(): void;
  40717. /**
  40718. * Attaches the behavior to its arc rotate camera.
  40719. * @param camera Defines the camera to attach the behavior to
  40720. */
  40721. attach(camera: ArcRotateCamera): void;
  40722. /**
  40723. * Detaches the behavior from its current arc rotate camera.
  40724. */
  40725. detach(): void;
  40726. private _radiusIsAnimating;
  40727. private _radiusBounceTransition;
  40728. private _animatables;
  40729. private _cachedWheelPrecision;
  40730. /**
  40731. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  40732. * @param radiusLimit The limit to check against.
  40733. * @return Bool to indicate if at limit.
  40734. */
  40735. private _isRadiusAtLimit;
  40736. /**
  40737. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  40738. * @param radiusDelta The delta by which to animate to. Can be negative.
  40739. */
  40740. private _applyBoundRadiusAnimation;
  40741. /**
  40742. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  40743. */
  40744. protected _clearAnimationLocks(): void;
  40745. /**
  40746. * Stops and removes all animations that have been applied to the camera
  40747. */
  40748. stopAllAnimations(): void;
  40749. }
  40750. }
  40751. declare module BABYLON {
  40752. /**
  40753. * 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.
  40754. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  40755. */
  40756. class FramingBehavior implements Behavior<ArcRotateCamera> {
  40757. /**
  40758. * Gets the name of the behavior.
  40759. */
  40760. readonly name: string;
  40761. private _mode;
  40762. private _radiusScale;
  40763. private _positionScale;
  40764. private _defaultElevation;
  40765. private _elevationReturnTime;
  40766. private _elevationReturnWaitTime;
  40767. private _zoomStopsAnimation;
  40768. private _framingTime;
  40769. /**
  40770. * The easing function used by animations
  40771. */
  40772. static EasingFunction: ExponentialEase;
  40773. /**
  40774. * The easing mode used by animations
  40775. */
  40776. static EasingMode: number;
  40777. /**
  40778. * Sets the current mode used by the behavior
  40779. */
  40780. /**
  40781. * Gets current mode used by the behavior.
  40782. */
  40783. mode: number;
  40784. /**
  40785. * Sets the scale applied to the radius (1 by default)
  40786. */
  40787. /**
  40788. * Gets the scale applied to the radius
  40789. */
  40790. radiusScale: number;
  40791. /**
  40792. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  40793. */
  40794. /**
  40795. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  40796. */
  40797. positionScale: number;
  40798. /**
  40799. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  40800. * behaviour is triggered, in radians.
  40801. */
  40802. /**
  40803. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  40804. * behaviour is triggered, in radians.
  40805. */
  40806. defaultElevation: number;
  40807. /**
  40808. * Sets the time (in milliseconds) taken to return to the default beta position.
  40809. * Negative value indicates camera should not return to default.
  40810. */
  40811. /**
  40812. * Gets the time (in milliseconds) taken to return to the default beta position.
  40813. * Negative value indicates camera should not return to default.
  40814. */
  40815. elevationReturnTime: number;
  40816. /**
  40817. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  40818. */
  40819. /**
  40820. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  40821. */
  40822. elevationReturnWaitTime: number;
  40823. /**
  40824. * Sets the flag that indicates if user zooming should stop animation.
  40825. */
  40826. /**
  40827. * Gets the flag that indicates if user zooming should stop animation.
  40828. */
  40829. zoomStopsAnimation: boolean;
  40830. /**
  40831. * Sets the transition time when framing the mesh, in milliseconds
  40832. */
  40833. /**
  40834. * Gets the transition time when framing the mesh, in milliseconds
  40835. */
  40836. framingTime: number;
  40837. /**
  40838. * Define if the behavior should automatically change the configured
  40839. * camera limits and sensibilities.
  40840. */
  40841. autoCorrectCameraLimitsAndSensibility: boolean;
  40842. private _onPrePointerObservableObserver;
  40843. private _onAfterCheckInputsObserver;
  40844. private _onMeshTargetChangedObserver;
  40845. private _attachedCamera;
  40846. private _isPointerDown;
  40847. private _lastInteractionTime;
  40848. /**
  40849. * Initializes the behavior.
  40850. */
  40851. init(): void;
  40852. /**
  40853. * Attaches the behavior to its arc rotate camera.
  40854. * @param camera Defines the camera to attach the behavior to
  40855. */
  40856. attach(camera: ArcRotateCamera): void;
  40857. /**
  40858. * Detaches the behavior from its current arc rotate camera.
  40859. */
  40860. detach(): void;
  40861. private _animatables;
  40862. private _betaIsAnimating;
  40863. private _betaTransition;
  40864. private _radiusTransition;
  40865. private _vectorTransition;
  40866. /**
  40867. * Targets the given mesh and updates zoom level accordingly.
  40868. * @param mesh The mesh to target.
  40869. * @param radius Optional. If a cached radius position already exists, overrides default.
  40870. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  40871. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40872. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40873. */
  40874. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40875. /**
  40876. * Targets the given mesh with its children and updates zoom level accordingly.
  40877. * @param mesh The mesh to target.
  40878. * @param radius Optional. If a cached radius position already exists, overrides default.
  40879. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  40880. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40881. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40882. */
  40883. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40884. /**
  40885. * Targets the given meshes with their children and updates zoom level accordingly.
  40886. * @param meshes The mesh to target.
  40887. * @param radius Optional. If a cached radius position already exists, overrides default.
  40888. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  40889. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40890. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40891. */
  40892. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40893. /**
  40894. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  40895. * @param minimumWorld Determines the smaller position of the bounding box extend
  40896. * @param maximumWorld Determines the bigger position of the bounding box extend
  40897. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40898. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40899. */
  40900. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40901. /**
  40902. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  40903. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  40904. * frustum width.
  40905. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  40906. * to fully enclose the mesh in the viewing frustum.
  40907. */
  40908. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  40909. /**
  40910. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  40911. * is automatically returned to its default position (expected to be above ground plane).
  40912. */
  40913. private _maintainCameraAboveGround;
  40914. /**
  40915. * Returns the frustum slope based on the canvas ratio and camera FOV
  40916. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  40917. */
  40918. private _getFrustumSlope;
  40919. /**
  40920. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  40921. */
  40922. private _clearAnimationLocks;
  40923. /**
  40924. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  40925. */
  40926. private _applyUserInteraction;
  40927. /**
  40928. * Stops and removes all animations that have been applied to the camera
  40929. */
  40930. stopAllAnimations(): void;
  40931. /**
  40932. * Gets a value indicating if the user is moving the camera
  40933. */
  40934. readonly isUserIsMoving: boolean;
  40935. /**
  40936. * The camera can move all the way towards the mesh.
  40937. */
  40938. static IgnoreBoundsSizeMode: number;
  40939. /**
  40940. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  40941. */
  40942. static FitFrustumSidesMode: number;
  40943. }
  40944. }
  40945. declare module BABYLON {
  40946. /**
  40947. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  40948. */
  40949. class AttachToBoxBehavior implements BABYLON.Behavior<BABYLON.Mesh> {
  40950. private ui;
  40951. /**
  40952. * The name of the behavior
  40953. */
  40954. name: string;
  40955. /**
  40956. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  40957. */
  40958. distanceAwayFromFace: number;
  40959. /**
  40960. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  40961. */
  40962. distanceAwayFromBottomOfFace: number;
  40963. private _faceVectors;
  40964. private _target;
  40965. private _scene;
  40966. private _onRenderObserver;
  40967. private _tmpMatrix;
  40968. private _tmpVector;
  40969. /**
  40970. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  40971. * @param ui The transform node that should be attched to the mesh
  40972. */
  40973. constructor(ui: BABYLON.TransformNode);
  40974. /**
  40975. * Initializes the behavior
  40976. */
  40977. init(): void;
  40978. private _closestFace;
  40979. private _zeroVector;
  40980. private _lookAtTmpMatrix;
  40981. private _lookAtToRef;
  40982. /**
  40983. * Attaches the AttachToBoxBehavior to the passed in mesh
  40984. * @param target The mesh that the specified node will be attached to
  40985. */
  40986. attach(target: BABYLON.Mesh): void;
  40987. /**
  40988. * Detaches the behavior from the mesh
  40989. */
  40990. detach(): void;
  40991. }
  40992. }
  40993. declare module BABYLON {
  40994. /**
  40995. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  40996. */
  40997. class FadeInOutBehavior implements Behavior<Mesh> {
  40998. /**
  40999. * Time in milliseconds to delay before fading in (Default: 0)
  41000. */
  41001. delay: number;
  41002. /**
  41003. * Time in milliseconds for the mesh to fade in (Default: 300)
  41004. */
  41005. fadeInTime: number;
  41006. private _millisecondsPerFrame;
  41007. private _hovered;
  41008. private _hoverValue;
  41009. private _ownerNode;
  41010. /**
  41011. * Instatiates the FadeInOutBehavior
  41012. */
  41013. constructor();
  41014. /**
  41015. * The name of the behavior
  41016. */
  41017. readonly name: string;
  41018. /**
  41019. * Initializes the behavior
  41020. */
  41021. init(): void;
  41022. /**
  41023. * Attaches the fade behavior on the passed in mesh
  41024. * @param ownerNode The mesh that will be faded in/out once attached
  41025. */
  41026. attach(ownerNode: Mesh): void;
  41027. /**
  41028. * Detaches the behavior from the mesh
  41029. */
  41030. detach(): void;
  41031. /**
  41032. * Triggers the mesh to begin fading in or out
  41033. * @param value if the object should fade in or out (true to fade in)
  41034. */
  41035. fadeIn(value: boolean): void;
  41036. private _update;
  41037. private _setAllVisibility;
  41038. }
  41039. }
  41040. declare module BABYLON {
  41041. /**
  41042. * A behavior that when attached to a mesh will allow the mesh to be scaled
  41043. */
  41044. class MultiPointerScaleBehavior implements Behavior<Mesh> {
  41045. private _dragBehaviorA;
  41046. private _dragBehaviorB;
  41047. private _startDistance;
  41048. private _initialScale;
  41049. private _targetScale;
  41050. private _ownerNode;
  41051. private _sceneRenderObserver;
  41052. /**
  41053. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  41054. */
  41055. constructor();
  41056. /**
  41057. * The name of the behavior
  41058. */
  41059. readonly name: string;
  41060. /**
  41061. * Initializes the behavior
  41062. */
  41063. init(): void;
  41064. private _getCurrentDistance;
  41065. /**
  41066. * Attaches the scale behavior the passed in mesh
  41067. * @param ownerNode The mesh that will be scaled around once attached
  41068. */
  41069. attach(ownerNode: Mesh): void;
  41070. /**
  41071. * Detaches the behavior from the mesh
  41072. */
  41073. detach(): void;
  41074. }
  41075. }
  41076. declare module BABYLON {
  41077. /**
  41078. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  41079. */
  41080. class PointerDragBehavior implements Behavior<AbstractMesh> {
  41081. private static _AnyMouseID;
  41082. private _attachedNode;
  41083. private _dragPlane;
  41084. private _scene;
  41085. private _pointerObserver;
  41086. private _beforeRenderObserver;
  41087. private static _planeScene;
  41088. /**
  41089. * 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)
  41090. */
  41091. maxDragAngle: number;
  41092. /**
  41093. * @hidden
  41094. */
  41095. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  41096. /**
  41097. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  41098. */
  41099. currentDraggingPointerID: number;
  41100. /**
  41101. * The last position where the pointer hit the drag plane in world space
  41102. */
  41103. lastDragPosition: Vector3;
  41104. /**
  41105. * If the behavior is currently in a dragging state
  41106. */
  41107. dragging: boolean;
  41108. /**
  41109. * 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)
  41110. */
  41111. dragDeltaRatio: number;
  41112. /**
  41113. * If the drag plane orientation should be updated during the dragging (Default: true)
  41114. */
  41115. updateDragPlane: boolean;
  41116. private _debugMode;
  41117. private _moving;
  41118. /**
  41119. * Fires each time the attached mesh is dragged with the pointer
  41120. * * delta between last drag position and current drag position in world space
  41121. * * dragDistance along the drag axis
  41122. * * dragPlaneNormal normal of the current drag plane used during the drag
  41123. * * dragPlanePoint in world space where the drag intersects the drag plane
  41124. */
  41125. onDragObservable: Observable<{
  41126. delta: Vector3;
  41127. dragPlanePoint: Vector3;
  41128. dragPlaneNormal: Vector3;
  41129. dragDistance: number;
  41130. pointerId: number;
  41131. }>;
  41132. /**
  41133. * Fires each time a drag begins (eg. mouse down on mesh)
  41134. */
  41135. onDragStartObservable: Observable<{
  41136. dragPlanePoint: Vector3;
  41137. pointerId: number;
  41138. }>;
  41139. /**
  41140. * Fires each time a drag ends (eg. mouse release after drag)
  41141. */
  41142. onDragEndObservable: Observable<{
  41143. dragPlanePoint: Vector3;
  41144. pointerId: number;
  41145. }>;
  41146. /**
  41147. * If the attached mesh should be moved when dragged
  41148. */
  41149. moveAttached: boolean;
  41150. /**
  41151. * If the drag behavior will react to drag events (Default: true)
  41152. */
  41153. enabled: boolean;
  41154. /**
  41155. * If camera controls should be detached during the drag
  41156. */
  41157. detachCameraControls: boolean;
  41158. /**
  41159. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  41160. */
  41161. useObjectOrienationForDragging: boolean;
  41162. private _options;
  41163. /**
  41164. * Creates a pointer drag behavior that can be attached to a mesh
  41165. * @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)
  41166. */
  41167. constructor(options?: {
  41168. dragAxis?: Vector3;
  41169. dragPlaneNormal?: Vector3;
  41170. });
  41171. /**
  41172. * The name of the behavior
  41173. */
  41174. readonly name: string;
  41175. /**
  41176. * Initializes the behavior
  41177. */
  41178. init(): void;
  41179. private _tmpVector;
  41180. private _alternatePickedPoint;
  41181. private _worldDragAxis;
  41182. private _targetPosition;
  41183. private _attachedElement;
  41184. /**
  41185. * Attaches the drag behavior the passed in mesh
  41186. * @param ownerNode The mesh that will be dragged around once attached
  41187. */
  41188. attach(ownerNode: AbstractMesh): void;
  41189. /**
  41190. * Force relase the drag action by code.
  41191. */
  41192. releaseDrag(): void;
  41193. private _startDragRay;
  41194. private _lastPointerRay;
  41195. /**
  41196. * Simulates the start of a pointer drag event on the behavior
  41197. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  41198. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  41199. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  41200. */
  41201. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  41202. private _startDrag;
  41203. private _dragDelta;
  41204. private _moveDrag;
  41205. private _pickWithRayOnDragPlane;
  41206. private _pointA;
  41207. private _pointB;
  41208. private _pointC;
  41209. private _lineA;
  41210. private _lineB;
  41211. private _localAxis;
  41212. private _lookAt;
  41213. private _updateDragPlanePosition;
  41214. /**
  41215. * Detaches the behavior from the mesh
  41216. */
  41217. detach(): void;
  41218. }
  41219. }
  41220. declare module BABYLON {
  41221. /**
  41222. * 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
  41223. */
  41224. class SixDofDragBehavior implements Behavior<Mesh> {
  41225. private static _virtualScene;
  41226. private _ownerNode;
  41227. private _sceneRenderObserver;
  41228. private _scene;
  41229. private _targetPosition;
  41230. private _virtualOriginMesh;
  41231. private _virtualDragMesh;
  41232. private _pointerObserver;
  41233. private _moving;
  41234. private _startingOrientation;
  41235. /**
  41236. * 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)
  41237. */
  41238. private zDragFactor;
  41239. /**
  41240. * If the object should rotate to face the drag origin
  41241. */
  41242. rotateDraggedObject: boolean;
  41243. /**
  41244. * If the behavior is currently in a dragging state
  41245. */
  41246. dragging: boolean;
  41247. /**
  41248. * 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)
  41249. */
  41250. dragDeltaRatio: number;
  41251. /**
  41252. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  41253. */
  41254. currentDraggingPointerID: number;
  41255. /**
  41256. * If camera controls should be detached during the drag
  41257. */
  41258. detachCameraControls: boolean;
  41259. /**
  41260. * Fires each time a drag starts
  41261. */
  41262. onDragStartObservable: Observable<{}>;
  41263. /**
  41264. * Fires each time a drag ends (eg. mouse release after drag)
  41265. */
  41266. onDragEndObservable: Observable<{}>;
  41267. /**
  41268. * 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
  41269. */
  41270. constructor();
  41271. /**
  41272. * The name of the behavior
  41273. */
  41274. readonly name: string;
  41275. /**
  41276. * Initializes the behavior
  41277. */
  41278. init(): void;
  41279. /**
  41280. * Attaches the scale behavior the passed in mesh
  41281. * @param ownerNode The mesh that will be scaled around once attached
  41282. */
  41283. attach(ownerNode: Mesh): void;
  41284. /**
  41285. * Detaches the behavior from the mesh
  41286. */
  41287. detach(): void;
  41288. }
  41289. }
  41290. declare module BABYLON {
  41291. /**
  41292. * Contains an array of blocks representing the octree
  41293. */
  41294. interface IOctreeContainer<T> {
  41295. /**
  41296. * Blocks within the octree
  41297. */
  41298. blocks: Array<OctreeBlock<T>>;
  41299. }
  41300. /**
  41301. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  41302. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41303. */
  41304. class Octree<T> {
  41305. /** 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.) */
  41306. maxDepth: number;
  41307. /**
  41308. * Blocks within the octree containing objects
  41309. */
  41310. blocks: Array<OctreeBlock<T>>;
  41311. /**
  41312. * Content stored in the octree
  41313. */
  41314. dynamicContent: T[];
  41315. private _maxBlockCapacity;
  41316. private _selectionContent;
  41317. private _creationFunc;
  41318. /**
  41319. * Creates a octree
  41320. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41321. * @param creationFunc function to be used to instatiate the octree
  41322. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  41323. * @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.)
  41324. */
  41325. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  41326. /** 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.) */
  41327. maxDepth?: number);
  41328. /**
  41329. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  41330. * @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);
  41331. * @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);
  41332. * @param entries meshes to be added to the octree blocks
  41333. */
  41334. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  41335. /**
  41336. * Adds a mesh to the octree
  41337. * @param entry Mesh to add to the octree
  41338. */
  41339. addMesh(entry: T): void;
  41340. /**
  41341. * Selects an array of meshes within the frustum
  41342. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  41343. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  41344. * @returns array of meshes within the frustum
  41345. */
  41346. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  41347. /**
  41348. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  41349. * @param sphereCenter defines the bounding sphere center
  41350. * @param sphereRadius defines the bounding sphere radius
  41351. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41352. * @returns an array of objects that intersect the sphere
  41353. */
  41354. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  41355. /**
  41356. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  41357. * @param ray defines the ray to test with
  41358. * @returns array of intersected objects
  41359. */
  41360. intersectsRay(ray: Ray): SmartArray<T>;
  41361. /**
  41362. * @hidden
  41363. */
  41364. 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;
  41365. /**
  41366. * Adds a mesh into the octree block if it intersects the block
  41367. */
  41368. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  41369. /**
  41370. * Adds a submesh into the octree block if it intersects the block
  41371. */
  41372. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  41373. }
  41374. }
  41375. declare module BABYLON {
  41376. /**
  41377. * Class used to store a cell in an octree
  41378. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41379. */
  41380. class OctreeBlock<T> {
  41381. /**
  41382. * Gets the content of the current block
  41383. */
  41384. entries: T[];
  41385. /**
  41386. * Gets the list of block children
  41387. */
  41388. blocks: Array<OctreeBlock<T>>;
  41389. private _depth;
  41390. private _maxDepth;
  41391. private _capacity;
  41392. private _minPoint;
  41393. private _maxPoint;
  41394. private _boundingVectors;
  41395. private _creationFunc;
  41396. /**
  41397. * Creates a new block
  41398. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  41399. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  41400. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41401. * @param depth defines the current depth of this block in the octree
  41402. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  41403. * @param creationFunc defines a callback to call when an element is added to the block
  41404. */
  41405. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  41406. /**
  41407. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41408. */
  41409. readonly capacity: number;
  41410. /**
  41411. * Gets the minimum vector (in world space) of the block's bounding box
  41412. */
  41413. readonly minPoint: Vector3;
  41414. /**
  41415. * Gets the maximum vector (in world space) of the block's bounding box
  41416. */
  41417. readonly maxPoint: Vector3;
  41418. /**
  41419. * Add a new element to this block
  41420. * @param entry defines the element to add
  41421. */
  41422. addEntry(entry: T): void;
  41423. /**
  41424. * Add an array of elements to this block
  41425. * @param entries defines the array of elements to add
  41426. */
  41427. addEntries(entries: T[]): void;
  41428. /**
  41429. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  41430. * @param frustumPlanes defines the frustum planes to test
  41431. * @param selection defines the array to store current content if selection is positive
  41432. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41433. */
  41434. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41435. /**
  41436. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  41437. * @param sphereCenter defines the bounding sphere center
  41438. * @param sphereRadius defines the bounding sphere radius
  41439. * @param selection defines the array to store current content if selection is positive
  41440. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41441. */
  41442. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41443. /**
  41444. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  41445. * @param ray defines the ray to test with
  41446. * @param selection defines the array to store current content if selection is positive
  41447. */
  41448. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  41449. /**
  41450. * Subdivide the content into child blocks (this block will then be empty)
  41451. */
  41452. createInnerBlocks(): void;
  41453. }
  41454. }
  41455. declare module BABYLON {
  41456. interface Scene {
  41457. /**
  41458. * @hidden
  41459. * Backing Filed
  41460. */
  41461. _selectionOctree: Octree<AbstractMesh>;
  41462. /**
  41463. * Gets the octree used to boost mesh selection (picking)
  41464. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41465. */
  41466. selectionOctree: Octree<AbstractMesh>;
  41467. /**
  41468. * Creates or updates the octree used to boost selection (picking)
  41469. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41470. * @param maxCapacity defines the maximum capacity per leaf
  41471. * @param maxDepth defines the maximum depth of the octree
  41472. * @returns an octree of AbstractMesh
  41473. */
  41474. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  41475. }
  41476. interface AbstractMesh {
  41477. /**
  41478. * @hidden
  41479. * Backing Field
  41480. */
  41481. _submeshesOctree: Octree<SubMesh>;
  41482. /**
  41483. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  41484. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  41485. * @param maxCapacity defines the maximum size of each block (64 by default)
  41486. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  41487. * @returns the new octree
  41488. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  41489. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41490. */
  41491. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  41492. }
  41493. /**
  41494. * Defines the octree scene component responsible to manage any octrees
  41495. * in a given scene.
  41496. */
  41497. class OctreeSceneComponent {
  41498. /**
  41499. * The component name helpfull to identify the component in the list of scene components.
  41500. */
  41501. readonly name: string;
  41502. /**
  41503. * The scene the component belongs to.
  41504. */
  41505. scene: Scene;
  41506. /**
  41507. * Indicates if the meshes have been checked to make sure they are isEnabled()
  41508. */
  41509. readonly checksIsEnabled: boolean;
  41510. /**
  41511. * Creates a new instance of the component for the given scene
  41512. * @param scene Defines the scene to register the component in
  41513. */
  41514. constructor(scene: Scene);
  41515. /**
  41516. * Registers the component in a given scene
  41517. */
  41518. register(): void;
  41519. /**
  41520. * Return the list of active meshes
  41521. * @returns the list of active meshes
  41522. */
  41523. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  41524. /**
  41525. * Return the list of active sub meshes
  41526. * @param mesh The mesh to get the candidates sub meshes from
  41527. * @returns the list of active sub meshes
  41528. */
  41529. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  41530. private _tempRay;
  41531. /**
  41532. * Return the list of sub meshes intersecting with a given local ray
  41533. * @param mesh defines the mesh to find the submesh for
  41534. * @param localRay defines the ray in local space
  41535. * @returns the list of intersecting sub meshes
  41536. */
  41537. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  41538. /**
  41539. * Return the list of sub meshes colliding with a collider
  41540. * @param mesh defines the mesh to find the submesh for
  41541. * @param collider defines the collider to evaluate the collision against
  41542. * @returns the list of colliding sub meshes
  41543. */
  41544. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  41545. /**
  41546. * Rebuilds the elements related to this component in case of
  41547. * context lost for instance.
  41548. */
  41549. rebuild(): void;
  41550. /**
  41551. * Disposes the component and the associated ressources.
  41552. */
  41553. dispose(): void;
  41554. }
  41555. }
  41556. declare module BABYLON {
  41557. /**
  41558. * Manage the gamepad inputs to control an arc rotate camera.
  41559. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41560. */
  41561. class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  41562. /**
  41563. * Defines the camera the input is attached to.
  41564. */
  41565. camera: ArcRotateCamera;
  41566. /**
  41567. * Defines the gamepad the input is gathering event from.
  41568. */
  41569. gamepad: Nullable<Gamepad>;
  41570. /**
  41571. * Defines the gamepad rotation sensiblity.
  41572. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41573. */
  41574. gamepadRotationSensibility: number;
  41575. /**
  41576. * Defines the gamepad move sensiblity.
  41577. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41578. */
  41579. gamepadMoveSensibility: number;
  41580. private _onGamepadConnectedObserver;
  41581. private _onGamepadDisconnectedObserver;
  41582. /**
  41583. * Attach the input controls to a specific dom element to get the input from.
  41584. * @param element Defines the element the controls should be listened from
  41585. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41586. */
  41587. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41588. /**
  41589. * Detach the current controls from the specified dom element.
  41590. * @param element Defines the element to stop listening the inputs from
  41591. */
  41592. detachControl(element: Nullable<HTMLElement>): void;
  41593. /**
  41594. * Update the current camera state depending on the inputs that have been used this frame.
  41595. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41596. */
  41597. checkInputs(): void;
  41598. /**
  41599. * Gets the class name of the current intput.
  41600. * @returns the class name
  41601. */
  41602. getClassName(): string;
  41603. /**
  41604. * Get the friendly name associated with the input class.
  41605. * @returns the input friendly name
  41606. */
  41607. getSimpleName(): string;
  41608. }
  41609. }
  41610. declare module BABYLON {
  41611. /**
  41612. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  41613. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41614. */
  41615. class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  41616. /**
  41617. * Defines the camera the input is attached to.
  41618. */
  41619. camera: ArcRotateCamera;
  41620. /**
  41621. * Defines the list of key codes associated with the up action (increase alpha)
  41622. */
  41623. keysUp: number[];
  41624. /**
  41625. * Defines the list of key codes associated with the down action (decrease alpha)
  41626. */
  41627. keysDown: number[];
  41628. /**
  41629. * Defines the list of key codes associated with the left action (increase beta)
  41630. */
  41631. keysLeft: number[];
  41632. /**
  41633. * Defines the list of key codes associated with the right action (decrease beta)
  41634. */
  41635. keysRight: number[];
  41636. /**
  41637. * Defines the list of key codes associated with the reset action.
  41638. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  41639. */
  41640. keysReset: number[];
  41641. /**
  41642. * Defines the panning sensibility of the inputs.
  41643. * (How fast is the camera paning)
  41644. */
  41645. panningSensibility: number;
  41646. /**
  41647. * Defines the zooming sensibility of the inputs.
  41648. * (How fast is the camera zooming)
  41649. */
  41650. zoomingSensibility: number;
  41651. /**
  41652. * Defines wether maintaining the alt key down switch the movement mode from
  41653. * orientation to zoom.
  41654. */
  41655. useAltToZoom: boolean;
  41656. /**
  41657. * Rotation speed of the camera
  41658. */
  41659. angularSpeed: number;
  41660. private _keys;
  41661. private _ctrlPressed;
  41662. private _altPressed;
  41663. private _onCanvasBlurObserver;
  41664. private _onKeyboardObserver;
  41665. private _engine;
  41666. private _scene;
  41667. /**
  41668. * Attach the input controls to a specific dom element to get the input from.
  41669. * @param element Defines the element the controls should be listened from
  41670. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41671. */
  41672. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41673. /**
  41674. * Detach the current controls from the specified dom element.
  41675. * @param element Defines the element to stop listening the inputs from
  41676. */
  41677. detachControl(element: Nullable<HTMLElement>): void;
  41678. /**
  41679. * Update the current camera state depending on the inputs that have been used this frame.
  41680. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41681. */
  41682. checkInputs(): void;
  41683. /**
  41684. * Gets the class name of the current intput.
  41685. * @returns the class name
  41686. */
  41687. getClassName(): string;
  41688. /**
  41689. * Get the friendly name associated with the input class.
  41690. * @returns the input friendly name
  41691. */
  41692. getSimpleName(): string;
  41693. }
  41694. }
  41695. declare module BABYLON {
  41696. /**
  41697. * Manage the mouse wheel inputs to control an arc rotate camera.
  41698. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41699. */
  41700. class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  41701. /**
  41702. * Defines the camera the input is attached to.
  41703. */
  41704. camera: ArcRotateCamera;
  41705. /**
  41706. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  41707. */
  41708. wheelPrecision: number;
  41709. /**
  41710. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  41711. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  41712. */
  41713. wheelDeltaPercentage: number;
  41714. private _wheel;
  41715. private _observer;
  41716. /**
  41717. * Attach the input controls to a specific dom element to get the input from.
  41718. * @param element Defines the element the controls should be listened from
  41719. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41720. */
  41721. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41722. /**
  41723. * Detach the current controls from the specified dom element.
  41724. * @param element Defines the element to stop listening the inputs from
  41725. */
  41726. detachControl(element: Nullable<HTMLElement>): void;
  41727. /**
  41728. * Gets the class name of the current intput.
  41729. * @returns the class name
  41730. */
  41731. getClassName(): string;
  41732. /**
  41733. * Get the friendly name associated with the input class.
  41734. * @returns the input friendly name
  41735. */
  41736. getSimpleName(): string;
  41737. }
  41738. }
  41739. declare module BABYLON {
  41740. /**
  41741. * Manage the pointers inputs to control an arc rotate camera.
  41742. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41743. */
  41744. class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  41745. /**
  41746. * Defines the camera the input is attached to.
  41747. */
  41748. camera: ArcRotateCamera;
  41749. /**
  41750. * Defines the buttons associated with the input to handle camera move.
  41751. */
  41752. buttons: number[];
  41753. /**
  41754. * Defines the pointer angular sensibility along the X axis or how fast is the camera rotating.
  41755. */
  41756. angularSensibilityX: number;
  41757. /**
  41758. * Defines the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  41759. */
  41760. angularSensibilityY: number;
  41761. /**
  41762. * Defines the pointer pinch precision or how fast is the camera zooming.
  41763. */
  41764. pinchPrecision: number;
  41765. /**
  41766. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  41767. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  41768. */
  41769. pinchDeltaPercentage: number;
  41770. /**
  41771. * Defines the pointer panning sensibility or how fast is the camera moving.
  41772. */
  41773. panningSensibility: number;
  41774. /**
  41775. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  41776. */
  41777. multiTouchPanning: boolean;
  41778. /**
  41779. * Defines whether panning is enabled for both pan (2 fingers swipe) and zoom (pinch) through multitouch.
  41780. */
  41781. multiTouchPanAndZoom: boolean;
  41782. /**
  41783. * Revers pinch action direction.
  41784. */
  41785. pinchInwards: boolean;
  41786. private _isPanClick;
  41787. private _pointerInput;
  41788. private _observer;
  41789. private _onMouseMove;
  41790. private _onGestureStart;
  41791. private _onGesture;
  41792. private _MSGestureHandler;
  41793. private _onLostFocus;
  41794. private _onContextMenu;
  41795. /**
  41796. * Attach the input controls to a specific dom element to get the input from.
  41797. * @param element Defines the element the controls should be listened from
  41798. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41799. */
  41800. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41801. /**
  41802. * Detach the current controls from the specified dom element.
  41803. * @param element Defines the element to stop listening the inputs from
  41804. */
  41805. detachControl(element: Nullable<HTMLElement>): void;
  41806. /**
  41807. * Gets the class name of the current intput.
  41808. * @returns the class name
  41809. */
  41810. getClassName(): string;
  41811. /**
  41812. * Get the friendly name associated with the input class.
  41813. * @returns the input friendly name
  41814. */
  41815. getSimpleName(): string;
  41816. }
  41817. }
  41818. declare module BABYLON {
  41819. /**
  41820. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  41821. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41822. */
  41823. class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  41824. /**
  41825. * Defines the camera the input is attached to.
  41826. */
  41827. camera: ArcRotateCamera;
  41828. /**
  41829. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  41830. */
  41831. alphaCorrection: number;
  41832. /**
  41833. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  41834. */
  41835. gammaCorrection: number;
  41836. private _alpha;
  41837. private _gamma;
  41838. private _dirty;
  41839. private _deviceOrientationHandler;
  41840. /**
  41841. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  41842. */
  41843. constructor();
  41844. /**
  41845. * Attach the input controls to a specific dom element to get the input from.
  41846. * @param element Defines the element the controls should be listened from
  41847. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41848. */
  41849. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41850. /** @hidden */
  41851. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  41852. /**
  41853. * Update the current camera state depending on the inputs that have been used this frame.
  41854. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41855. */
  41856. checkInputs(): void;
  41857. /**
  41858. * Detach the current controls from the specified dom element.
  41859. * @param element Defines the element to stop listening the inputs from
  41860. */
  41861. detachControl(element: Nullable<HTMLElement>): void;
  41862. /**
  41863. * Gets the class name of the current intput.
  41864. * @returns the class name
  41865. */
  41866. getClassName(): string;
  41867. /**
  41868. * Get the friendly name associated with the input class.
  41869. * @returns the input friendly name
  41870. */
  41871. getSimpleName(): string;
  41872. }
  41873. }
  41874. declare module BABYLON {
  41875. /**
  41876. * Listen to keyboard events to control the camera.
  41877. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41878. */
  41879. class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  41880. /**
  41881. * Defines the camera the input is attached to.
  41882. */
  41883. camera: FlyCamera;
  41884. /**
  41885. * The list of keyboard keys used to control the forward move of the camera.
  41886. */
  41887. keysForward: number[];
  41888. /**
  41889. * The list of keyboard keys used to control the backward move of the camera.
  41890. */
  41891. keysBackward: number[];
  41892. /**
  41893. * The list of keyboard keys used to control the forward move of the camera.
  41894. */
  41895. keysUp: number[];
  41896. /**
  41897. * The list of keyboard keys used to control the backward move of the camera.
  41898. */
  41899. keysDown: number[];
  41900. /**
  41901. * The list of keyboard keys used to control the right strafe move of the camera.
  41902. */
  41903. keysRight: number[];
  41904. /**
  41905. * The list of keyboard keys used to control the left strafe move of the camera.
  41906. */
  41907. keysLeft: number[];
  41908. private _keys;
  41909. private _onCanvasBlurObserver;
  41910. private _onKeyboardObserver;
  41911. private _engine;
  41912. private _scene;
  41913. /**
  41914. * Attach the input controls to a specific dom element to get the input from.
  41915. * @param element Defines the element the controls should be listened from
  41916. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41917. */
  41918. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41919. /**
  41920. * Detach the current controls from the specified dom element.
  41921. * @param element Defines the element to stop listening the inputs from
  41922. */
  41923. detachControl(element: Nullable<HTMLElement>): void;
  41924. /**
  41925. * Gets the class name of the current intput.
  41926. * @returns the class name
  41927. */
  41928. getClassName(): string;
  41929. /** @hidden */
  41930. _onLostFocus(e: FocusEvent): void;
  41931. /**
  41932. * Get the friendly name associated with the input class.
  41933. * @returns the input friendly name
  41934. */
  41935. getSimpleName(): string;
  41936. /**
  41937. * Update the current camera state depending on the inputs that have been used this frame.
  41938. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41939. */
  41940. checkInputs(): void;
  41941. }
  41942. }
  41943. declare module BABYLON {
  41944. /**
  41945. * Listen to mouse events to control the camera.
  41946. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41947. */
  41948. class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  41949. /**
  41950. * Defines the camera the input is attached to.
  41951. */
  41952. camera: FlyCamera;
  41953. /**
  41954. * Defines if touch is enabled. (Default is true.)
  41955. */
  41956. touchEnabled: boolean;
  41957. /**
  41958. * Defines the buttons associated with the input to handle camera rotation.
  41959. */
  41960. buttons: number[];
  41961. /**
  41962. * Assign buttons for Yaw control.
  41963. */
  41964. buttonsYaw: number[];
  41965. /**
  41966. * Assign buttons for Pitch control.
  41967. */
  41968. buttonsPitch: number[];
  41969. /**
  41970. * Assign buttons for Roll control.
  41971. */
  41972. buttonsRoll: number[];
  41973. /**
  41974. * Detect if any button is being pressed while mouse is moved.
  41975. * -1 = Mouse locked.
  41976. * 0 = Left button.
  41977. * 1 = Middle Button.
  41978. * 2 = Right Button.
  41979. */
  41980. activeButton: number;
  41981. /**
  41982. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  41983. * Higher values reduce its sensitivity.
  41984. */
  41985. angularSensibility: number;
  41986. private _mousemoveCallback;
  41987. private _observer;
  41988. private _rollObserver;
  41989. private previousPosition;
  41990. private noPreventDefault;
  41991. private element;
  41992. /**
  41993. * Listen to mouse events to control the camera.
  41994. * @param touchEnabled Define if touch is enabled. (Default is true.)
  41995. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41996. */
  41997. constructor(touchEnabled?: boolean);
  41998. /**
  41999. * Attach the mouse control to the HTML DOM element.
  42000. * @param element Defines the element that listens to the input events.
  42001. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  42002. */
  42003. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42004. /**
  42005. * Detach the current controls from the specified dom element.
  42006. * @param element Defines the element to stop listening the inputs from
  42007. */
  42008. detachControl(element: Nullable<HTMLElement>): void;
  42009. /**
  42010. * Gets the class name of the current input.
  42011. * @returns the class name.
  42012. */
  42013. getClassName(): string;
  42014. /**
  42015. * Get the friendly name associated with the input class.
  42016. * @returns the input's friendly name.
  42017. */
  42018. getSimpleName(): string;
  42019. private _pointerInput;
  42020. private _onMouseMove;
  42021. /**
  42022. * Rotate camera by mouse offset.
  42023. */
  42024. private rotateCamera;
  42025. }
  42026. }
  42027. declare module BABYLON {
  42028. /**
  42029. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  42030. * Screen rotation is taken into account.
  42031. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42032. */
  42033. class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  42034. private _camera;
  42035. private _screenOrientationAngle;
  42036. private _constantTranform;
  42037. private _screenQuaternion;
  42038. private _alpha;
  42039. private _beta;
  42040. private _gamma;
  42041. /**
  42042. * Instantiates a new input
  42043. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42044. */
  42045. constructor();
  42046. /**
  42047. * Define the camera controlled by the input.
  42048. */
  42049. camera: FreeCamera;
  42050. /**
  42051. * Attach the input controls to a specific dom element to get the input from.
  42052. * @param element Defines the element the controls should be listened from
  42053. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42054. */
  42055. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42056. private _orientationChanged;
  42057. private _deviceOrientation;
  42058. /**
  42059. * Detach the current controls from the specified dom element.
  42060. * @param element Defines the element to stop listening the inputs from
  42061. */
  42062. detachControl(element: Nullable<HTMLElement>): void;
  42063. /**
  42064. * Update the current camera state depending on the inputs that have been used this frame.
  42065. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42066. */
  42067. checkInputs(): void;
  42068. /**
  42069. * Gets the class name of the current intput.
  42070. * @returns the class name
  42071. */
  42072. getClassName(): string;
  42073. /**
  42074. * Get the friendly name associated with the input class.
  42075. * @returns the input friendly name
  42076. */
  42077. getSimpleName(): string;
  42078. }
  42079. }
  42080. declare module BABYLON {
  42081. /**
  42082. * Manage the gamepad inputs to control a free camera.
  42083. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42084. */
  42085. class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  42086. /**
  42087. * Define the camera the input is attached to.
  42088. */
  42089. camera: FreeCamera;
  42090. /**
  42091. * Define the Gamepad controlling the input
  42092. */
  42093. gamepad: Nullable<Gamepad>;
  42094. /**
  42095. * Defines the gamepad rotation sensiblity.
  42096. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42097. */
  42098. gamepadAngularSensibility: number;
  42099. /**
  42100. * Defines the gamepad move sensiblity.
  42101. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42102. */
  42103. gamepadMoveSensibility: number;
  42104. private _onGamepadConnectedObserver;
  42105. private _onGamepadDisconnectedObserver;
  42106. private _cameraTransform;
  42107. private _deltaTransform;
  42108. private _vector3;
  42109. private _vector2;
  42110. /**
  42111. * Attach the input controls to a specific dom element to get the input from.
  42112. * @param element Defines the element the controls should be listened from
  42113. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42114. */
  42115. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42116. /**
  42117. * Detach the current controls from the specified dom element.
  42118. * @param element Defines the element to stop listening the inputs from
  42119. */
  42120. detachControl(element: Nullable<HTMLElement>): void;
  42121. /**
  42122. * Update the current camera state depending on the inputs that have been used this frame.
  42123. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42124. */
  42125. checkInputs(): void;
  42126. /**
  42127. * Gets the class name of the current intput.
  42128. * @returns the class name
  42129. */
  42130. getClassName(): string;
  42131. /**
  42132. * Get the friendly name associated with the input class.
  42133. * @returns the input friendly name
  42134. */
  42135. getSimpleName(): string;
  42136. }
  42137. }
  42138. declare module BABYLON {
  42139. /**
  42140. * Manage the keyboard inputs to control the movement of a free camera.
  42141. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42142. */
  42143. class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  42144. /**
  42145. * Defines the camera the input is attached to.
  42146. */
  42147. camera: FreeCamera;
  42148. /**
  42149. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  42150. */
  42151. keysUp: number[];
  42152. /**
  42153. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  42154. */
  42155. keysDown: number[];
  42156. /**
  42157. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  42158. */
  42159. keysLeft: number[];
  42160. /**
  42161. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  42162. */
  42163. keysRight: number[];
  42164. private _keys;
  42165. private _onCanvasBlurObserver;
  42166. private _onKeyboardObserver;
  42167. private _engine;
  42168. private _scene;
  42169. /**
  42170. * Attach the input controls to a specific dom element to get the input from.
  42171. * @param element Defines the element the controls should be listened from
  42172. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42173. */
  42174. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42175. /**
  42176. * Detach the current controls from the specified dom element.
  42177. * @param element Defines the element to stop listening the inputs from
  42178. */
  42179. detachControl(element: Nullable<HTMLElement>): void;
  42180. /**
  42181. * Update the current camera state depending on the inputs that have been used this frame.
  42182. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42183. */
  42184. checkInputs(): void;
  42185. /**
  42186. * Gets the class name of the current intput.
  42187. * @returns the class name
  42188. */
  42189. getClassName(): string;
  42190. /** @hidden */
  42191. _onLostFocus(e: FocusEvent): void;
  42192. /**
  42193. * Get the friendly name associated with the input class.
  42194. * @returns the input friendly name
  42195. */
  42196. getSimpleName(): string;
  42197. }
  42198. }
  42199. declare module BABYLON {
  42200. /**
  42201. * Manage the mouse inputs to control the movement of a free camera.
  42202. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42203. */
  42204. class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  42205. /**
  42206. * Define if touch is enabled in the mouse input
  42207. */
  42208. touchEnabled: boolean;
  42209. /**
  42210. * Defines the camera the input is attached to.
  42211. */
  42212. camera: FreeCamera;
  42213. /**
  42214. * Defines the buttons associated with the input to handle camera move.
  42215. */
  42216. buttons: number[];
  42217. /**
  42218. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  42219. */
  42220. angularSensibility: number;
  42221. private _pointerInput;
  42222. private _onMouseMove;
  42223. private _observer;
  42224. private previousPosition;
  42225. /**
  42226. * Manage the mouse inputs to control the movement of a free camera.
  42227. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42228. * @param touchEnabled Defines if touch is enabled or not
  42229. */
  42230. constructor(
  42231. /**
  42232. * Define if touch is enabled in the mouse input
  42233. */
  42234. touchEnabled?: boolean);
  42235. /**
  42236. * Attach the input controls to a specific dom element to get the input from.
  42237. * @param element Defines the element the controls should be listened from
  42238. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42239. */
  42240. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42241. /**
  42242. * Detach the current controls from the specified dom element.
  42243. * @param element Defines the element to stop listening the inputs from
  42244. */
  42245. detachControl(element: Nullable<HTMLElement>): void;
  42246. /**
  42247. * Gets the class name of the current intput.
  42248. * @returns the class name
  42249. */
  42250. getClassName(): string;
  42251. /**
  42252. * Get the friendly name associated with the input class.
  42253. * @returns the input friendly name
  42254. */
  42255. getSimpleName(): string;
  42256. }
  42257. }
  42258. declare module BABYLON {
  42259. /**
  42260. * Manage the touch inputs to control the movement of a free camera.
  42261. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42262. */
  42263. class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  42264. /**
  42265. * Defines the camera the input is attached to.
  42266. */
  42267. camera: FreeCamera;
  42268. /**
  42269. * Defines the touch sensibility for rotation.
  42270. * The higher the faster.
  42271. */
  42272. touchAngularSensibility: number;
  42273. /**
  42274. * Defines the touch sensibility for move.
  42275. * The higher the faster.
  42276. */
  42277. touchMoveSensibility: number;
  42278. private _offsetX;
  42279. private _offsetY;
  42280. private _pointerPressed;
  42281. private _pointerInput;
  42282. private _observer;
  42283. private _onLostFocus;
  42284. /**
  42285. * Attach the input controls to a specific dom element to get the input from.
  42286. * @param element Defines the element the controls should be listened from
  42287. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42288. */
  42289. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42290. /**
  42291. * Detach the current controls from the specified dom element.
  42292. * @param element Defines the element to stop listening the inputs from
  42293. */
  42294. detachControl(element: Nullable<HTMLElement>): void;
  42295. /**
  42296. * Update the current camera state depending on the inputs that have been used this frame.
  42297. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42298. */
  42299. checkInputs(): void;
  42300. /**
  42301. * Gets the class name of the current intput.
  42302. * @returns the class name
  42303. */
  42304. getClassName(): string;
  42305. /**
  42306. * Get the friendly name associated with the input class.
  42307. * @returns the input friendly name
  42308. */
  42309. getSimpleName(): string;
  42310. }
  42311. }
  42312. declare module BABYLON {
  42313. /**
  42314. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  42315. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42316. */
  42317. class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  42318. /**
  42319. * Defines the camera the input is attached to.
  42320. */
  42321. camera: FreeCamera;
  42322. private _leftjoystick;
  42323. private _rightjoystick;
  42324. /**
  42325. * Gets the left stick of the virtual joystick.
  42326. * @returns The virtual Joystick
  42327. */
  42328. getLeftJoystick(): VirtualJoystick;
  42329. /**
  42330. * Gets the right stick of the virtual joystick.
  42331. * @returns The virtual Joystick
  42332. */
  42333. getRightJoystick(): VirtualJoystick;
  42334. /**
  42335. * Update the current camera state depending on the inputs that have been used this frame.
  42336. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42337. */
  42338. checkInputs(): void;
  42339. /**
  42340. * Attach the input controls to a specific dom element to get the input from.
  42341. * @param element Defines the element the controls should be listened from
  42342. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42343. */
  42344. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42345. /**
  42346. * Detach the current controls from the specified dom element.
  42347. * @param element Defines the element to stop listening the inputs from
  42348. */
  42349. detachControl(element: Nullable<HTMLElement>): void;
  42350. /**
  42351. * Gets the class name of the current intput.
  42352. * @returns the class name
  42353. */
  42354. getClassName(): string;
  42355. /**
  42356. * Get the friendly name associated with the input class.
  42357. * @returns the input friendly name
  42358. */
  42359. getSimpleName(): string;
  42360. }
  42361. }
  42362. declare module BABYLON {
  42363. /**
  42364. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  42365. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42366. */
  42367. class AnaglyphArcRotateCamera extends ArcRotateCamera {
  42368. /**
  42369. * Creates a new AnaglyphArcRotateCamera
  42370. * @param name defines camera name
  42371. * @param alpha defines alpha angle (in radians)
  42372. * @param beta defines beta angle (in radians)
  42373. * @param radius defines radius
  42374. * @param target defines camera target
  42375. * @param interaxialDistance defines distance between each color axis
  42376. * @param scene defines the hosting scene
  42377. */
  42378. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  42379. /**
  42380. * Gets camera class name
  42381. * @returns AnaglyphArcRotateCamera
  42382. */
  42383. getClassName(): string;
  42384. }
  42385. }
  42386. declare module BABYLON {
  42387. /**
  42388. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  42389. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42390. */
  42391. class AnaglyphFreeCamera extends FreeCamera {
  42392. /**
  42393. * Creates a new AnaglyphFreeCamera
  42394. * @param name defines camera name
  42395. * @param position defines initial position
  42396. * @param interaxialDistance defines distance between each color axis
  42397. * @param scene defines the hosting scene
  42398. */
  42399. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42400. /**
  42401. * Gets camera class name
  42402. * @returns AnaglyphFreeCamera
  42403. */
  42404. getClassName(): string;
  42405. }
  42406. }
  42407. declare module BABYLON {
  42408. /**
  42409. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  42410. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42411. */
  42412. class AnaglyphGamepadCamera extends GamepadCamera {
  42413. /**
  42414. * Creates a new AnaglyphGamepadCamera
  42415. * @param name defines camera name
  42416. * @param position defines initial position
  42417. * @param interaxialDistance defines distance between each color axis
  42418. * @param scene defines the hosting scene
  42419. */
  42420. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42421. /**
  42422. * Gets camera class name
  42423. * @returns AnaglyphGamepadCamera
  42424. */
  42425. getClassName(): string;
  42426. }
  42427. }
  42428. declare module BABYLON {
  42429. /**
  42430. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  42431. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42432. */
  42433. class AnaglyphUniversalCamera extends UniversalCamera {
  42434. /**
  42435. * Creates a new AnaglyphUniversalCamera
  42436. * @param name defines camera name
  42437. * @param position defines initial position
  42438. * @param interaxialDistance defines distance between each color axis
  42439. * @param scene defines the hosting scene
  42440. */
  42441. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42442. /**
  42443. * Gets camera class name
  42444. * @returns AnaglyphUniversalCamera
  42445. */
  42446. getClassName(): string;
  42447. }
  42448. }
  42449. declare module BABYLON {
  42450. /**
  42451. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  42452. * @see http://doc.babylonjs.com/features/cameras
  42453. */
  42454. class StereoscopicArcRotateCamera extends ArcRotateCamera {
  42455. /**
  42456. * Creates a new StereoscopicArcRotateCamera
  42457. * @param name defines camera name
  42458. * @param alpha defines alpha angle (in radians)
  42459. * @param beta defines beta angle (in radians)
  42460. * @param radius defines radius
  42461. * @param target defines camera target
  42462. * @param interaxialDistance defines distance between each color axis
  42463. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42464. * @param scene defines the hosting scene
  42465. */
  42466. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42467. /**
  42468. * Gets camera class name
  42469. * @returns StereoscopicArcRotateCamera
  42470. */
  42471. getClassName(): string;
  42472. }
  42473. }
  42474. declare module BABYLON {
  42475. /**
  42476. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  42477. * @see http://doc.babylonjs.com/features/cameras
  42478. */
  42479. class StereoscopicFreeCamera extends FreeCamera {
  42480. /**
  42481. * Creates a new StereoscopicFreeCamera
  42482. * @param name defines camera name
  42483. * @param position defines initial position
  42484. * @param interaxialDistance defines distance between each color axis
  42485. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42486. * @param scene defines the hosting scene
  42487. */
  42488. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42489. /**
  42490. * Gets camera class name
  42491. * @returns StereoscopicFreeCamera
  42492. */
  42493. getClassName(): string;
  42494. }
  42495. }
  42496. declare module BABYLON {
  42497. /**
  42498. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  42499. * @see http://doc.babylonjs.com/features/cameras
  42500. */
  42501. class StereoscopicGamepadCamera extends GamepadCamera {
  42502. /**
  42503. * Creates a new StereoscopicGamepadCamera
  42504. * @param name defines camera name
  42505. * @param position defines initial position
  42506. * @param interaxialDistance defines distance between each color axis
  42507. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42508. * @param scene defines the hosting scene
  42509. */
  42510. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42511. /**
  42512. * Gets camera class name
  42513. * @returns StereoscopicGamepadCamera
  42514. */
  42515. getClassName(): string;
  42516. }
  42517. }
  42518. declare module BABYLON {
  42519. /**
  42520. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  42521. * @see http://doc.babylonjs.com/features/cameras
  42522. */
  42523. class StereoscopicUniversalCamera extends UniversalCamera {
  42524. /**
  42525. * Creates a new StereoscopicUniversalCamera
  42526. * @param name defines camera name
  42527. * @param position defines initial position
  42528. * @param interaxialDistance defines distance between each color axis
  42529. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42530. * @param scene defines the hosting scene
  42531. */
  42532. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42533. /**
  42534. * Gets camera class name
  42535. * @returns StereoscopicUniversalCamera
  42536. */
  42537. getClassName(): string;
  42538. }
  42539. }
  42540. declare module BABYLON {
  42541. /**
  42542. * This represents all the required metrics to create a VR camera.
  42543. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  42544. */
  42545. class VRCameraMetrics {
  42546. /**
  42547. * Define the horizontal resolution off the screen.
  42548. */
  42549. hResolution: number;
  42550. /**
  42551. * Define the vertical resolution off the screen.
  42552. */
  42553. vResolution: number;
  42554. /**
  42555. * Define the horizontal screen size.
  42556. */
  42557. hScreenSize: number;
  42558. /**
  42559. * Define the vertical screen size.
  42560. */
  42561. vScreenSize: number;
  42562. /**
  42563. * Define the vertical screen center position.
  42564. */
  42565. vScreenCenter: number;
  42566. /**
  42567. * Define the distance of the eyes to the screen.
  42568. */
  42569. eyeToScreenDistance: number;
  42570. /**
  42571. * Define the distance between both lenses
  42572. */
  42573. lensSeparationDistance: number;
  42574. /**
  42575. * Define the distance between both viewer's eyes.
  42576. */
  42577. interpupillaryDistance: number;
  42578. /**
  42579. * Define the distortion factor of the VR postprocess.
  42580. * Please, touch with care.
  42581. */
  42582. distortionK: number[];
  42583. /**
  42584. * Define the chromatic aberration correction factors for the VR post process.
  42585. */
  42586. chromaAbCorrection: number[];
  42587. /**
  42588. * Define the scale factor of the post process.
  42589. * The smaller the better but the slower.
  42590. */
  42591. postProcessScaleFactor: number;
  42592. /**
  42593. * Define an offset for the lens center.
  42594. */
  42595. lensCenterOffset: number;
  42596. /**
  42597. * Define if the current vr camera should compensate the distortion of the lense or not.
  42598. */
  42599. compensateDistortion: boolean;
  42600. /**
  42601. * Gets the rendering aspect ratio based on the provided resolutions.
  42602. */
  42603. readonly aspectRatio: number;
  42604. /**
  42605. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  42606. */
  42607. readonly aspectRatioFov: number;
  42608. /**
  42609. * @hidden
  42610. */
  42611. readonly leftHMatrix: Matrix;
  42612. /**
  42613. * @hidden
  42614. */
  42615. readonly rightHMatrix: Matrix;
  42616. /**
  42617. * @hidden
  42618. */
  42619. readonly leftPreViewMatrix: Matrix;
  42620. /**
  42621. * @hidden
  42622. */
  42623. readonly rightPreViewMatrix: Matrix;
  42624. /**
  42625. * Get the default VRMetrics based on the most generic setup.
  42626. * @returns the default vr metrics
  42627. */
  42628. static GetDefault(): VRCameraMetrics;
  42629. }
  42630. }
  42631. declare module BABYLON {
  42632. /**
  42633. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  42634. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42635. */
  42636. class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  42637. /**
  42638. * Creates a new VRDeviceOrientationArcRotateCamera
  42639. * @param name defines camera name
  42640. * @param alpha defines the camera rotation along the logitudinal axis
  42641. * @param beta defines the camera rotation along the latitudinal axis
  42642. * @param radius defines the camera distance from its target
  42643. * @param target defines the camera target
  42644. * @param scene defines the scene the camera belongs to
  42645. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42646. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42647. */
  42648. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42649. /**
  42650. * Gets camera class name
  42651. * @returns VRDeviceOrientationArcRotateCamera
  42652. */
  42653. getClassName(): string;
  42654. }
  42655. }
  42656. declare module BABYLON {
  42657. /**
  42658. * Camera used to simulate VR rendering (based on FreeCamera)
  42659. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42660. */
  42661. class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  42662. /**
  42663. * Creates a new VRDeviceOrientationFreeCamera
  42664. * @param name defines camera name
  42665. * @param position defines the start position of the camera
  42666. * @param scene defines the scene the camera belongs to
  42667. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42668. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42669. */
  42670. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42671. /**
  42672. * Gets camera class name
  42673. * @returns VRDeviceOrientationFreeCamera
  42674. */
  42675. getClassName(): string;
  42676. }
  42677. }
  42678. declare module BABYLON {
  42679. /**
  42680. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  42681. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42682. */
  42683. class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  42684. /**
  42685. * Creates a new VRDeviceOrientationGamepadCamera
  42686. * @param name defines camera name
  42687. * @param position defines the start position of the camera
  42688. * @param scene defines the scene the camera belongs to
  42689. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42690. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42691. */
  42692. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42693. /**
  42694. * Gets camera class name
  42695. * @returns VRDeviceOrientationGamepadCamera
  42696. */
  42697. getClassName(): string;
  42698. }
  42699. }
  42700. declare module BABYLON {
  42701. /**
  42702. * Options to modify the vr teleportation behavior.
  42703. */
  42704. interface VRTeleportationOptions {
  42705. /**
  42706. * The name of the mesh which should be used as the teleportation floor. (default: null)
  42707. */
  42708. floorMeshName?: string;
  42709. /**
  42710. * A list of meshes to be used as the teleportation floor. (default: empty)
  42711. */
  42712. floorMeshes?: Mesh[];
  42713. }
  42714. /**
  42715. * Options to modify the vr experience helper's behavior.
  42716. */
  42717. interface VRExperienceHelperOptions extends WebVROptions {
  42718. /**
  42719. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  42720. */
  42721. createDeviceOrientationCamera?: boolean;
  42722. /**
  42723. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  42724. */
  42725. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  42726. /**
  42727. * Uses the main button on the controller to toggle the laser casted. (default: true)
  42728. */
  42729. laserToggle?: boolean;
  42730. /**
  42731. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  42732. */
  42733. floorMeshes?: Mesh[];
  42734. }
  42735. /**
  42736. * Helps to quickly add VR support to an existing scene.
  42737. * See http://doc.babylonjs.com/how_to/webvr_helper
  42738. */
  42739. class VRExperienceHelper {
  42740. /** Options to modify the vr experience helper's behavior. */
  42741. webVROptions: VRExperienceHelperOptions;
  42742. private _scene;
  42743. private _position;
  42744. private _btnVR;
  42745. private _btnVRDisplayed;
  42746. private _webVRsupported;
  42747. private _webVRready;
  42748. private _webVRrequesting;
  42749. private _webVRpresenting;
  42750. private _hasEnteredVR;
  42751. private _fullscreenVRpresenting;
  42752. private _canvas;
  42753. private _webVRCamera;
  42754. private _vrDeviceOrientationCamera;
  42755. private _deviceOrientationCamera;
  42756. private _existingCamera;
  42757. private _onKeyDown;
  42758. private _onVrDisplayPresentChange;
  42759. private _onVRDisplayChanged;
  42760. private _onVRRequestPresentStart;
  42761. private _onVRRequestPresentComplete;
  42762. /**
  42763. * Observable raised when entering VR.
  42764. */
  42765. onEnteringVRObservable: Observable<VRExperienceHelper>;
  42766. /**
  42767. * Observable raised when exiting VR.
  42768. */
  42769. onExitingVRObservable: Observable<VRExperienceHelper>;
  42770. /**
  42771. * Observable raised when controller mesh is loaded.
  42772. */
  42773. onControllerMeshLoadedObservable: Observable<WebVRController>;
  42774. /** Return this.onEnteringVRObservable
  42775. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  42776. */
  42777. readonly onEnteringVR: Observable<VRExperienceHelper>;
  42778. /** Return this.onExitingVRObservable
  42779. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  42780. */
  42781. readonly onExitingVR: Observable<VRExperienceHelper>;
  42782. /** Return this.onControllerMeshLoadedObservable
  42783. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  42784. */
  42785. readonly onControllerMeshLoaded: Observable<WebVRController>;
  42786. private _rayLength;
  42787. private _useCustomVRButton;
  42788. private _teleportationRequested;
  42789. private _teleportActive;
  42790. private _floorMeshName;
  42791. private _floorMeshesCollection;
  42792. private _rotationAllowed;
  42793. private _teleportBackwardsVector;
  42794. private _teleportationTarget;
  42795. private _isDefaultTeleportationTarget;
  42796. private _postProcessMove;
  42797. private _teleportationFillColor;
  42798. private _teleportationBorderColor;
  42799. private _rotationAngle;
  42800. private _haloCenter;
  42801. private _cameraGazer;
  42802. private _padSensibilityUp;
  42803. private _padSensibilityDown;
  42804. private _leftController;
  42805. private _rightController;
  42806. /**
  42807. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  42808. */
  42809. onNewMeshSelected: Observable<AbstractMesh>;
  42810. /**
  42811. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  42812. */
  42813. onNewMeshPicked: Observable<PickingInfo>;
  42814. private _circleEase;
  42815. /**
  42816. * Observable raised before camera teleportation
  42817. */
  42818. onBeforeCameraTeleport: Observable<Vector3>;
  42819. /**
  42820. * Observable raised after camera teleportation
  42821. */
  42822. onAfterCameraTeleport: Observable<Vector3>;
  42823. /**
  42824. * Observable raised when current selected mesh gets unselected
  42825. */
  42826. onSelectedMeshUnselected: Observable<AbstractMesh>;
  42827. private _raySelectionPredicate;
  42828. /**
  42829. * To be optionaly changed by user to define custom ray selection
  42830. */
  42831. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  42832. /**
  42833. * To be optionaly changed by user to define custom selection logic (after ray selection)
  42834. */
  42835. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  42836. /**
  42837. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  42838. */
  42839. teleportationEnabled: boolean;
  42840. private _defaultHeight;
  42841. private _teleportationInitialized;
  42842. private _interactionsEnabled;
  42843. private _interactionsRequested;
  42844. private _displayGaze;
  42845. private _displayLaserPointer;
  42846. /**
  42847. * The mesh used to display where the user is going to teleport.
  42848. */
  42849. /**
  42850. * Sets the mesh to be used to display where the user is going to teleport.
  42851. */
  42852. teleportationTarget: Mesh;
  42853. /**
  42854. * 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
  42855. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  42856. * See http://doc.babylonjs.com/resources/baking_transformations
  42857. */
  42858. gazeTrackerMesh: Mesh;
  42859. /**
  42860. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  42861. */
  42862. updateGazeTrackerScale: boolean;
  42863. /**
  42864. * The gaze tracking mesh corresponding to the left controller
  42865. */
  42866. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  42867. /**
  42868. * The gaze tracking mesh corresponding to the right controller
  42869. */
  42870. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  42871. /**
  42872. * If the ray of the gaze should be displayed.
  42873. */
  42874. /**
  42875. * Sets if the ray of the gaze should be displayed.
  42876. */
  42877. displayGaze: boolean;
  42878. /**
  42879. * If the ray of the LaserPointer should be displayed.
  42880. */
  42881. /**
  42882. * Sets if the ray of the LaserPointer should be displayed.
  42883. */
  42884. displayLaserPointer: boolean;
  42885. /**
  42886. * The deviceOrientationCamera used as the camera when not in VR.
  42887. */
  42888. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  42889. /**
  42890. * Based on the current WebVR support, returns the current VR camera used.
  42891. */
  42892. readonly currentVRCamera: Nullable<Camera>;
  42893. /**
  42894. * The webVRCamera which is used when in VR.
  42895. */
  42896. readonly webVRCamera: WebVRFreeCamera;
  42897. /**
  42898. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  42899. */
  42900. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  42901. private readonly _teleportationRequestInitiated;
  42902. /**
  42903. * Instantiates a VRExperienceHelper.
  42904. * Helps to quickly add VR support to an existing scene.
  42905. * @param scene The scene the VRExperienceHelper belongs to.
  42906. * @param webVROptions Options to modify the vr experience helper's behavior.
  42907. */
  42908. constructor(scene: Scene,
  42909. /** Options to modify the vr experience helper's behavior. */
  42910. webVROptions?: VRExperienceHelperOptions);
  42911. private _onDefaultMeshLoaded;
  42912. private _onResize;
  42913. private _onFullscreenChange;
  42914. /**
  42915. * Gets a value indicating if we are currently in VR mode.
  42916. */
  42917. readonly isInVRMode: boolean;
  42918. private onVrDisplayPresentChange;
  42919. private onVRDisplayChanged;
  42920. private moveButtonToBottomRight;
  42921. private displayVRButton;
  42922. private updateButtonVisibility;
  42923. private _cachedAngularSensibility;
  42924. /**
  42925. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  42926. * Otherwise, will use the fullscreen API.
  42927. */
  42928. enterVR(): void;
  42929. /**
  42930. * Attempt to exit VR, or fullscreen.
  42931. */
  42932. exitVR(): void;
  42933. /**
  42934. * The position of the vr experience helper.
  42935. */
  42936. /**
  42937. * Sets the position of the vr experience helper.
  42938. */
  42939. position: Vector3;
  42940. /**
  42941. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  42942. */
  42943. enableInteractions(): void;
  42944. private readonly _noControllerIsActive;
  42945. private beforeRender;
  42946. private _isTeleportationFloor;
  42947. /**
  42948. * Adds a floor mesh to be used for teleportation.
  42949. * @param floorMesh the mesh to be used for teleportation.
  42950. */
  42951. addFloorMesh(floorMesh: Mesh): void;
  42952. /**
  42953. * Removes a floor mesh from being used for teleportation.
  42954. * @param floorMesh the mesh to be removed.
  42955. */
  42956. removeFloorMesh(floorMesh: Mesh): void;
  42957. /**
  42958. * Enables interactions and teleportation using the VR controllers and gaze.
  42959. * @param vrTeleportationOptions options to modify teleportation behavior.
  42960. */
  42961. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  42962. private _onNewGamepadConnected;
  42963. private _tryEnableInteractionOnController;
  42964. private _onNewGamepadDisconnected;
  42965. private _enableInteractionOnController;
  42966. private _checkTeleportWithRay;
  42967. private _checkRotate;
  42968. private _checkTeleportBackwards;
  42969. private _enableTeleportationOnController;
  42970. private _createTeleportationCircles;
  42971. private _displayTeleportationTarget;
  42972. private _hideTeleportationTarget;
  42973. private _rotateCamera;
  42974. private _moveTeleportationSelectorTo;
  42975. private _workingVector;
  42976. private _workingQuaternion;
  42977. private _workingMatrix;
  42978. /**
  42979. * Teleports the users feet to the desired location
  42980. * @param location The location where the user's feet should be placed
  42981. */
  42982. teleportCamera(location: Vector3): void;
  42983. private _convertNormalToDirectionOfRay;
  42984. private _castRayAndSelectObject;
  42985. private _notifySelectedMeshUnselected;
  42986. /**
  42987. * Sets the color of the laser ray from the vr controllers.
  42988. * @param color new color for the ray.
  42989. */
  42990. changeLaserColor(color: Color3): void;
  42991. /**
  42992. * Sets the color of the ray from the vr headsets gaze.
  42993. * @param color new color for the ray.
  42994. */
  42995. changeGazeColor(color: Color3): void;
  42996. /**
  42997. * Exits VR and disposes of the vr experience helper
  42998. */
  42999. dispose(): void;
  43000. /**
  43001. * Gets the name of the VRExperienceHelper class
  43002. * @returns "VRExperienceHelper"
  43003. */
  43004. getClassName(): string;
  43005. }
  43006. }
  43007. declare module BABYLON {
  43008. /**
  43009. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  43010. * IMPORTANT!! The data is right-hand data.
  43011. * @export
  43012. * @interface DevicePose
  43013. */
  43014. interface DevicePose {
  43015. /**
  43016. * The position of the device, values in array are [x,y,z].
  43017. */
  43018. readonly position: Nullable<Float32Array>;
  43019. /**
  43020. * The linearVelocity of the device, values in array are [x,y,z].
  43021. */
  43022. readonly linearVelocity: Nullable<Float32Array>;
  43023. /**
  43024. * The linearAcceleration of the device, values in array are [x,y,z].
  43025. */
  43026. readonly linearAcceleration: Nullable<Float32Array>;
  43027. /**
  43028. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  43029. */
  43030. readonly orientation: Nullable<Float32Array>;
  43031. /**
  43032. * The angularVelocity of the device, values in array are [x,y,z].
  43033. */
  43034. readonly angularVelocity: Nullable<Float32Array>;
  43035. /**
  43036. * The angularAcceleration of the device, values in array are [x,y,z].
  43037. */
  43038. readonly angularAcceleration: Nullable<Float32Array>;
  43039. }
  43040. /**
  43041. * Interface representing a pose controlled object in Babylon.
  43042. * A pose controlled object has both regular pose values as well as pose values
  43043. * from an external device such as a VR head mounted display
  43044. */
  43045. interface PoseControlled {
  43046. /**
  43047. * The position of the object in babylon space.
  43048. */
  43049. position: Vector3;
  43050. /**
  43051. * The rotation quaternion of the object in babylon space.
  43052. */
  43053. rotationQuaternion: Quaternion;
  43054. /**
  43055. * The position of the device in babylon space.
  43056. */
  43057. devicePosition?: Vector3;
  43058. /**
  43059. * The rotation quaternion of the device in babylon space.
  43060. */
  43061. deviceRotationQuaternion: Quaternion;
  43062. /**
  43063. * The raw pose coming from the device.
  43064. */
  43065. rawPose: Nullable<DevicePose>;
  43066. /**
  43067. * The scale of the device to be used when translating from device space to babylon space.
  43068. */
  43069. deviceScaleFactor: number;
  43070. /**
  43071. * Updates the poseControlled values based on the input device pose.
  43072. * @param poseData the pose data to update the object with
  43073. */
  43074. updateFromDevice(poseData: DevicePose): void;
  43075. }
  43076. /**
  43077. * Set of options to customize the webVRCamera
  43078. */
  43079. interface WebVROptions {
  43080. /**
  43081. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  43082. */
  43083. trackPosition?: boolean;
  43084. /**
  43085. * Sets the scale of the vrDevice in babylon space. (default: 1)
  43086. */
  43087. positionScale?: number;
  43088. /**
  43089. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  43090. */
  43091. displayName?: string;
  43092. /**
  43093. * Should the native controller meshes be initialized. (default: true)
  43094. */
  43095. controllerMeshes?: boolean;
  43096. /**
  43097. * Creating a default HemiLight only on controllers. (default: true)
  43098. */
  43099. defaultLightingOnControllers?: boolean;
  43100. /**
  43101. * If you don't want to use the default VR button of the helper. (default: false)
  43102. */
  43103. useCustomVRButton?: boolean;
  43104. /**
  43105. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  43106. */
  43107. customVRButton?: HTMLButtonElement;
  43108. /**
  43109. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  43110. */
  43111. rayLength?: number;
  43112. /**
  43113. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  43114. */
  43115. defaultHeight?: number;
  43116. }
  43117. /**
  43118. * This represents a WebVR camera.
  43119. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  43120. * @example http://doc.babylonjs.com/how_to/webvr_camera
  43121. */
  43122. class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  43123. private webVROptions;
  43124. /**
  43125. * @hidden
  43126. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  43127. */
  43128. _vrDevice: any;
  43129. /**
  43130. * The rawPose of the vrDevice.
  43131. */
  43132. rawPose: Nullable<DevicePose>;
  43133. private _onVREnabled;
  43134. private _specsVersion;
  43135. private _attached;
  43136. private _frameData;
  43137. protected _descendants: Array<Node>;
  43138. private _deviceRoomPosition;
  43139. /** @hidden */
  43140. _deviceRoomRotationQuaternion: Quaternion;
  43141. private _standingMatrix;
  43142. /**
  43143. * Represents device position in babylon space.
  43144. */
  43145. devicePosition: Vector3;
  43146. /**
  43147. * Represents device rotation in babylon space.
  43148. */
  43149. deviceRotationQuaternion: Quaternion;
  43150. /**
  43151. * The scale of the device to be used when translating from device space to babylon space.
  43152. */
  43153. deviceScaleFactor: number;
  43154. private _deviceToWorld;
  43155. private _worldToDevice;
  43156. /**
  43157. * References to the webVR controllers for the vrDevice.
  43158. */
  43159. controllers: Array<WebVRController>;
  43160. /**
  43161. * Emits an event when a controller is attached.
  43162. */
  43163. onControllersAttachedObservable: Observable<WebVRController[]>;
  43164. /**
  43165. * Emits an event when a controller's mesh has been loaded;
  43166. */
  43167. onControllerMeshLoadedObservable: Observable<WebVRController>;
  43168. /**
  43169. * Emits an event when the HMD's pose has been updated.
  43170. */
  43171. onPoseUpdatedFromDeviceObservable: Observable<any>;
  43172. private _poseSet;
  43173. /**
  43174. * If the rig cameras be used as parent instead of this camera.
  43175. */
  43176. rigParenting: boolean;
  43177. private _lightOnControllers;
  43178. private _defaultHeight?;
  43179. /**
  43180. * Instantiates a WebVRFreeCamera.
  43181. * @param name The name of the WebVRFreeCamera
  43182. * @param position The starting anchor position for the camera
  43183. * @param scene The scene the camera belongs to
  43184. * @param webVROptions a set of customizable options for the webVRCamera
  43185. */
  43186. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  43187. /**
  43188. * Gets the device distance from the ground in meters.
  43189. * @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.
  43190. */
  43191. deviceDistanceToRoomGround(): number;
  43192. /**
  43193. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  43194. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  43195. */
  43196. useStandingMatrix(callback?: (bool: boolean) => void): void;
  43197. /**
  43198. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  43199. * @returns A promise with a boolean set to if the standing matrix is supported.
  43200. */
  43201. useStandingMatrixAsync(): Promise<boolean>;
  43202. /**
  43203. * Disposes the camera
  43204. */
  43205. dispose(): void;
  43206. /**
  43207. * Gets a vrController by name.
  43208. * @param name The name of the controller to retreive
  43209. * @returns the controller matching the name specified or null if not found
  43210. */
  43211. getControllerByName(name: string): Nullable<WebVRController>;
  43212. private _leftController;
  43213. /**
  43214. * The controller corrisponding to the users left hand.
  43215. */
  43216. readonly leftController: Nullable<WebVRController>;
  43217. private _rightController;
  43218. /**
  43219. * The controller corrisponding to the users right hand.
  43220. */
  43221. readonly rightController: Nullable<WebVRController>;
  43222. /**
  43223. * Casts a ray forward from the vrCamera's gaze.
  43224. * @param length Length of the ray (default: 100)
  43225. * @returns the ray corrisponding to the gaze
  43226. */
  43227. getForwardRay(length?: number): Ray;
  43228. /**
  43229. * @hidden
  43230. * Updates the camera based on device's frame data
  43231. */
  43232. _checkInputs(): void;
  43233. /**
  43234. * Updates the poseControlled values based on the input device pose.
  43235. * @param poseData Pose coming from the device
  43236. */
  43237. updateFromDevice(poseData: DevicePose): void;
  43238. private _htmlElementAttached;
  43239. private _detachIfAttached;
  43240. /**
  43241. * WebVR's attach control will start broadcasting frames to the device.
  43242. * Note that in certain browsers (chrome for example) this function must be called
  43243. * within a user-interaction callback. Example:
  43244. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  43245. *
  43246. * @param element html element to attach the vrDevice to
  43247. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  43248. */
  43249. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43250. /**
  43251. * Detaches the camera from the html element and disables VR
  43252. *
  43253. * @param element html element to detach from
  43254. */
  43255. detachControl(element: HTMLElement): void;
  43256. /**
  43257. * @returns the name of this class
  43258. */
  43259. getClassName(): string;
  43260. /**
  43261. * Calls resetPose on the vrDisplay
  43262. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  43263. */
  43264. resetToCurrentRotation(): void;
  43265. /**
  43266. * @hidden
  43267. * Updates the rig cameras (left and right eye)
  43268. */
  43269. _updateRigCameras(): void;
  43270. private _workingVector;
  43271. private _oneVector;
  43272. private _workingMatrix;
  43273. private updateCacheCalled;
  43274. private _correctPositionIfNotTrackPosition;
  43275. /**
  43276. * @hidden
  43277. * Updates the cached values of the camera
  43278. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  43279. */
  43280. _updateCache(ignoreParentClass?: boolean): void;
  43281. /**
  43282. * @hidden
  43283. * Get current device position in babylon world
  43284. */
  43285. _computeDevicePosition(): void;
  43286. /**
  43287. * Updates the current device position and rotation in the babylon world
  43288. */
  43289. update(): void;
  43290. /**
  43291. * @hidden
  43292. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  43293. * @returns an identity matrix
  43294. */
  43295. _getViewMatrix(): Matrix;
  43296. private _tmpMatrix;
  43297. /**
  43298. * This function is called by the two RIG cameras.
  43299. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  43300. */
  43301. protected _getWebVRViewMatrix(): Matrix;
  43302. protected _getWebVRProjectionMatrix(): Matrix;
  43303. private _onGamepadConnectedObserver;
  43304. private _onGamepadDisconnectedObserver;
  43305. private _updateCacheWhenTrackingDisabledObserver;
  43306. /**
  43307. * Initializes the controllers and their meshes
  43308. */
  43309. initControllers(): void;
  43310. }
  43311. }
  43312. declare module BABYLON {
  43313. /**
  43314. * WebXR Camera which holds the views for the xrSession
  43315. * @see https://doc.babylonjs.com/how_to/webxr
  43316. */
  43317. class WebXRCamera extends FreeCamera {
  43318. private static _TmpMatrix;
  43319. /**
  43320. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  43321. * @param name the name of the camera
  43322. * @param scene the scene to add the camera to
  43323. */
  43324. constructor(name: string, scene: BABYLON.Scene);
  43325. private _updateNumberOfRigCameras;
  43326. /** @hidden */
  43327. _updateForDualEyeDebugging(pupilDistance?: number): void;
  43328. /**
  43329. * Updates the cameras position from the current pose information of the XR session
  43330. * @param xrSessionManager the session containing pose information
  43331. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  43332. */
  43333. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  43334. }
  43335. }
  43336. declare module BABYLON {
  43337. /**
  43338. * Button which can be used to enter a different mode of XR
  43339. */
  43340. class WebXREnterExitUIButton {
  43341. /** button element */
  43342. element: HTMLElement;
  43343. /** XR initialization options for the button */
  43344. initializationOptions: XRSessionCreationOptions;
  43345. /**
  43346. * Creates a WebXREnterExitUIButton
  43347. * @param element button element
  43348. * @param initializationOptions XR initialization options for the button
  43349. */
  43350. constructor(
  43351. /** button element */
  43352. element: HTMLElement,
  43353. /** XR initialization options for the button */
  43354. initializationOptions: XRSessionCreationOptions);
  43355. /**
  43356. * Overwritable function which can be used to update the button's visuals when the state changes
  43357. * @param activeButton the current active button in the UI
  43358. */
  43359. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  43360. }
  43361. /**
  43362. * Options to create the webXR UI
  43363. */
  43364. class WebXREnterExitUIOptions {
  43365. /**
  43366. * Context to enter xr with
  43367. */
  43368. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  43369. /**
  43370. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  43371. */
  43372. customButtons?: Array<WebXREnterExitUIButton>;
  43373. }
  43374. /**
  43375. * UI to allow the user to enter/exit XR mode
  43376. */
  43377. class WebXREnterExitUI implements IDisposable {
  43378. private scene;
  43379. private _overlay;
  43380. private _buttons;
  43381. private _activeButton;
  43382. /**
  43383. * Fired every time the active button is changed.
  43384. *
  43385. * When xr is entered via a button that launches xr that button will be the callback parameter
  43386. *
  43387. * When exiting xr the callback parameter will be null)
  43388. */
  43389. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  43390. /**
  43391. * Creates UI to allow the user to enter/exit XR mode
  43392. * @param scene the scene to add the ui to
  43393. * @param helper the xr experience helper to enter/exit xr with
  43394. * @param options options to configure the UI
  43395. * @returns the created ui
  43396. */
  43397. static CreateAsync(scene: BABYLON.Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  43398. private constructor();
  43399. private _updateButtons;
  43400. /**
  43401. * Disposes of the object
  43402. */
  43403. dispose(): void;
  43404. }
  43405. }
  43406. declare module BABYLON {
  43407. /**
  43408. * States of the webXR experience
  43409. */
  43410. enum WebXRState {
  43411. /**
  43412. * Transitioning to being in XR mode
  43413. */
  43414. ENTERING_XR = 0,
  43415. /**
  43416. * Transitioning to non XR mode
  43417. */
  43418. EXITING_XR = 1,
  43419. /**
  43420. * In XR mode and presenting
  43421. */
  43422. IN_XR = 2,
  43423. /**
  43424. * Not entered XR mode
  43425. */
  43426. NOT_IN_XR = 3
  43427. }
  43428. /**
  43429. * Helper class used to enable XR
  43430. * @see https://doc.babylonjs.com/how_to/webxr
  43431. */
  43432. class WebXRExperienceHelper implements IDisposable {
  43433. private scene;
  43434. /**
  43435. * 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
  43436. */
  43437. container: AbstractMesh;
  43438. /**
  43439. * Camera used to render xr content
  43440. */
  43441. camera: WebXRCamera;
  43442. /**
  43443. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  43444. */
  43445. state: WebXRState;
  43446. private _setState;
  43447. private static _TmpVector;
  43448. /**
  43449. * Fires when the state of the experience helper has changed
  43450. */
  43451. onStateChangedObservable: Observable<WebXRState>;
  43452. /** @hidden */
  43453. _sessionManager: WebXRSessionManager;
  43454. private _nonVRCamera;
  43455. private _originalSceneAutoClear;
  43456. private _supported;
  43457. /**
  43458. * Creates the experience helper
  43459. * @param scene the scene to attach the experience helper to
  43460. * @returns a promise for the experience helper
  43461. */
  43462. static CreateAsync(scene: BABYLON.Scene): Promise<WebXRExperienceHelper>;
  43463. /**
  43464. * Creates a WebXRExperienceHelper
  43465. * @param scene The scene the helper should be created in
  43466. */
  43467. private constructor();
  43468. /**
  43469. * Exits XR mode and returns the scene to its original state
  43470. * @returns promise that resolves after xr mode has exited
  43471. */
  43472. exitXRAsync(): Promise<void>;
  43473. /**
  43474. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43475. * @param sessionCreationOptions options for the XR session
  43476. * @param frameOfReference frame of reference of the XR session
  43477. * @returns promise that resolves after xr mode has entered
  43478. */
  43479. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  43480. /**
  43481. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  43482. * @param ray ray to cast into the environment
  43483. * @returns Promise which resolves with a collision point in the environment if it exists
  43484. */
  43485. environmentPointHitTestAsync(ray: BABYLON.Ray): Promise<Nullable<Vector3>>;
  43486. /**
  43487. * Updates the global position of the camera by moving the camera's container
  43488. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  43489. * @param position The desired global position of the camera
  43490. */
  43491. setPositionOfCameraUsingContainer(position: Vector3): void;
  43492. /**
  43493. * Rotates the xr camera by rotating the camera's container around the camera's position
  43494. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  43495. * @param rotation the desired quaternion rotation to apply to the camera
  43496. */
  43497. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  43498. /**
  43499. * Checks if the creation options are supported by the xr session
  43500. * @param options creation options
  43501. * @returns true if supported
  43502. */
  43503. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  43504. /**
  43505. * Disposes of the experience helper
  43506. */
  43507. dispose(): void;
  43508. }
  43509. }
  43510. declare module BABYLON {
  43511. /**
  43512. * Represents an XR input
  43513. */
  43514. class WebXRController {
  43515. /**
  43516. * 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
  43517. */
  43518. grip?: BABYLON.AbstractMesh;
  43519. /**
  43520. * Pointer which can be used to select objects or attach a visible laser to
  43521. */
  43522. pointer: BABYLON.AbstractMesh;
  43523. /**
  43524. * Creates the controller
  43525. * @see https://doc.babylonjs.com/how_to/webxr
  43526. * @param scene the scene which the controller should be associated to
  43527. */
  43528. constructor(scene: BABYLON.Scene);
  43529. /**
  43530. * Disposes of the object
  43531. */
  43532. dispose(): void;
  43533. }
  43534. /**
  43535. * XR input used to track XR inputs such as controllers/rays
  43536. */
  43537. class WebXRInput implements IDisposable {
  43538. private helper;
  43539. /**
  43540. * XR controllers being tracked
  43541. */
  43542. controllers: Array<WebXRController>;
  43543. private _tmpMatrix;
  43544. private _frameObserver;
  43545. /**
  43546. * Initializes the WebXRInput
  43547. * @param helper experience helper which the input should be created for
  43548. */
  43549. constructor(helper: WebXRExperienceHelper);
  43550. /**
  43551. * Disposes of the object
  43552. */
  43553. dispose(): void;
  43554. }
  43555. }
  43556. declare module BABYLON {
  43557. /**
  43558. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  43559. */
  43560. class WebXRManagedOutputCanvas implements IDisposable {
  43561. private _canvas;
  43562. /**
  43563. * xrpresent context of the canvas which can be used to display/mirror xr content
  43564. */
  43565. canvasContext: Nullable<WebGLRenderingContext>;
  43566. /**
  43567. * Initializes the canvas to be added/removed upon entering/exiting xr
  43568. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  43569. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  43570. */
  43571. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  43572. /**
  43573. * Disposes of the object
  43574. */
  43575. dispose(): void;
  43576. private _setManagedOutputCanvas;
  43577. private _addCanvas;
  43578. private _removeCanvas;
  43579. }
  43580. }
  43581. declare module BABYLON {
  43582. /**
  43583. * Manages an XRSession
  43584. * @see https://doc.babylonjs.com/how_to/webxr
  43585. */
  43586. class WebXRSessionManager implements IDisposable {
  43587. private scene;
  43588. /**
  43589. * Fires every time a new xrFrame arrives which can be used to update the camera
  43590. */
  43591. onXRFrameObservable: Observable<any>;
  43592. /**
  43593. * Fires when the xr session is ended either by the device or manually done
  43594. */
  43595. onXRSessionEnded: Observable<any>;
  43596. /** @hidden */
  43597. _xrSession: XRSession;
  43598. /** @hidden */
  43599. _frameOfReference: XRFrameOfReference;
  43600. /** @hidden */
  43601. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  43602. /** @hidden */
  43603. _currentXRFrame: Nullable<XRFrame>;
  43604. private _xrNavigator;
  43605. private _xrDevice;
  43606. private _tmpMatrix;
  43607. /**
  43608. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  43609. * @param scene The scene which the session should be created for
  43610. */
  43611. constructor(scene: BABYLON.Scene);
  43612. /**
  43613. * Initializes the manager
  43614. * After initialization enterXR can be called to start an XR session
  43615. * @returns Promise which resolves after it is initialized
  43616. */
  43617. initializeAsync(): Promise<void>;
  43618. /**
  43619. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  43620. * @param sessionCreationOptions xr options to create the session with
  43621. * @param frameOfReferenceType option to configure how the xr pose is expressed
  43622. * @returns Promise which resolves after it enters XR
  43623. */
  43624. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  43625. /**
  43626. * Stops the xrSession and restores the renderloop
  43627. * @returns Promise which resolves after it exits XR
  43628. */
  43629. exitXRAsync(): Promise<void>;
  43630. /**
  43631. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  43632. * @param ray ray to cast into the environment
  43633. * @returns Promise which resolves with a collision point in the environment if it exists
  43634. */
  43635. environmentPointHitTestAsync(ray: BABYLON.Ray): Promise<Nullable<Vector3>>;
  43636. /**
  43637. * Checks if a session would be supported for the creation options specified
  43638. * @param options creation options to check if they are supported
  43639. * @returns true if supported
  43640. */
  43641. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  43642. /**
  43643. * @hidden
  43644. * Converts the render layer of xrSession to a render target
  43645. * @param session session to create render target for
  43646. * @param scene scene the new render target should be created for
  43647. */
  43648. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: BABYLON.Scene): RenderTargetTexture;
  43649. /**
  43650. * Disposes of the session manager
  43651. */
  43652. dispose(): void;
  43653. }
  43654. }
  43655. declare module BABYLON {
  43656. /** @hidden */
  43657. class _OcclusionDataStorage {
  43658. /** @hidden */
  43659. occlusionInternalRetryCounter: number;
  43660. /** @hidden */
  43661. isOcclusionQueryInProgress: boolean;
  43662. /** @hidden */
  43663. isOccluded: boolean;
  43664. /** @hidden */
  43665. occlusionRetryCount: number;
  43666. /** @hidden */
  43667. occlusionType: number;
  43668. /** @hidden */
  43669. occlusionQueryAlgorithmType: number;
  43670. }
  43671. interface Engine {
  43672. /**
  43673. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  43674. * @return the new query
  43675. */
  43676. createQuery(): WebGLQuery;
  43677. /**
  43678. * Delete and release a webGL query
  43679. * @param query defines the query to delete
  43680. * @return the current engine
  43681. */
  43682. deleteQuery(query: WebGLQuery): Engine;
  43683. /**
  43684. * Check if a given query has resolved and got its value
  43685. * @param query defines the query to check
  43686. * @returns true if the query got its value
  43687. */
  43688. isQueryResultAvailable(query: WebGLQuery): boolean;
  43689. /**
  43690. * Gets the value of a given query
  43691. * @param query defines the query to check
  43692. * @returns the value of the query
  43693. */
  43694. getQueryResult(query: WebGLQuery): number;
  43695. /**
  43696. * Initiates an occlusion query
  43697. * @param algorithmType defines the algorithm to use
  43698. * @param query defines the query to use
  43699. * @returns the current engine
  43700. * @see http://doc.babylonjs.com/features/occlusionquery
  43701. */
  43702. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  43703. /**
  43704. * Ends an occlusion query
  43705. * @see http://doc.babylonjs.com/features/occlusionquery
  43706. * @param algorithmType defines the algorithm to use
  43707. * @returns the current engine
  43708. */
  43709. endOcclusionQuery(algorithmType: number): Engine;
  43710. /**
  43711. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  43712. * Please note that only one query can be issued at a time
  43713. * @returns a time token used to track the time span
  43714. */
  43715. startTimeQuery(): Nullable<_TimeToken>;
  43716. /**
  43717. * Ends a time query
  43718. * @param token defines the token used to measure the time span
  43719. * @returns the time spent (in ns)
  43720. */
  43721. endTimeQuery(token: _TimeToken): int;
  43722. /** @hidden */
  43723. _currentNonTimestampToken: Nullable<_TimeToken>;
  43724. /** @hidden */
  43725. _createTimeQuery(): WebGLQuery;
  43726. /** @hidden */
  43727. _deleteTimeQuery(query: WebGLQuery): void;
  43728. /** @hidden */
  43729. _getGlAlgorithmType(algorithmType: number): number;
  43730. /** @hidden */
  43731. _getTimeQueryResult(query: WebGLQuery): any;
  43732. /** @hidden */
  43733. _getTimeQueryAvailability(query: WebGLQuery): any;
  43734. }
  43735. interface AbstractMesh {
  43736. /**
  43737. * Backing filed
  43738. * @hidden
  43739. */
  43740. __occlusionDataStorage: _OcclusionDataStorage;
  43741. /**
  43742. * Access property
  43743. * @hidden
  43744. */
  43745. _occlusionDataStorage: _OcclusionDataStorage;
  43746. /**
  43747. * 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.
  43748. * The default value is -1 which means don't break the query and wait till the result
  43749. * @see http://doc.babylonjs.com/features/occlusionquery
  43750. */
  43751. occlusionRetryCount: number;
  43752. /**
  43753. * 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:
  43754. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  43755. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  43756. * * 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.
  43757. * @see http://doc.babylonjs.com/features/occlusionquery
  43758. */
  43759. occlusionType: number;
  43760. /**
  43761. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  43762. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  43763. * * 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.
  43764. * @see http://doc.babylonjs.com/features/occlusionquery
  43765. */
  43766. occlusionQueryAlgorithmType: number;
  43767. /**
  43768. * 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
  43769. * @see http://doc.babylonjs.com/features/occlusionquery
  43770. */
  43771. isOccluded: boolean;
  43772. /**
  43773. * Flag to check the progress status of the query
  43774. * @see http://doc.babylonjs.com/features/occlusionquery
  43775. */
  43776. isOcclusionQueryInProgress: boolean;
  43777. }
  43778. }
  43779. declare module BABYLON {
  43780. interface Engine {
  43781. /**
  43782. * Creates a webGL transform feedback object
  43783. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  43784. * @returns the webGL transform feedback object
  43785. */
  43786. createTransformFeedback(): WebGLTransformFeedback;
  43787. /**
  43788. * Delete a webGL transform feedback object
  43789. * @param value defines the webGL transform feedback object to delete
  43790. */
  43791. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  43792. /**
  43793. * Bind a webGL transform feedback object to the webgl context
  43794. * @param value defines the webGL transform feedback object to bind
  43795. */
  43796. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  43797. /**
  43798. * Begins a transform feedback operation
  43799. * @param usePoints defines if points or triangles must be used
  43800. */
  43801. beginTransformFeedback(usePoints: boolean): void;
  43802. /**
  43803. * Ends a transform feedback operation
  43804. */
  43805. endTransformFeedback(): void;
  43806. /**
  43807. * Specify the varyings to use with transform feedback
  43808. * @param program defines the associated webGL program
  43809. * @param value defines the list of strings representing the varying names
  43810. */
  43811. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  43812. /**
  43813. * Bind a webGL buffer for a transform feedback operation
  43814. * @param value defines the webGL buffer to bind
  43815. */
  43816. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  43817. }
  43818. }
  43819. declare module BABYLON {
  43820. /**
  43821. * Google Daydream controller
  43822. */
  43823. class DaydreamController extends WebVRController {
  43824. /**
  43825. * Base Url for the controller model.
  43826. */
  43827. static MODEL_BASE_URL: string;
  43828. /**
  43829. * File name for the controller model.
  43830. */
  43831. static MODEL_FILENAME: string;
  43832. /**
  43833. * Gamepad Id prefix used to identify Daydream Controller.
  43834. */
  43835. static readonly GAMEPAD_ID_PREFIX: string;
  43836. /**
  43837. * Creates a new DaydreamController from a gamepad
  43838. * @param vrGamepad the gamepad that the controller should be created from
  43839. */
  43840. constructor(vrGamepad: any);
  43841. /**
  43842. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43843. * @param scene scene in which to add meshes
  43844. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43845. */
  43846. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43847. /**
  43848. * Called once for each button that changed state since the last frame
  43849. * @param buttonIdx Which button index changed
  43850. * @param state New state of the button
  43851. * @param changes Which properties on the state changed since last frame
  43852. */
  43853. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43854. }
  43855. }
  43856. declare module BABYLON {
  43857. /**
  43858. * Gear VR Controller
  43859. */
  43860. class GearVRController extends WebVRController {
  43861. /**
  43862. * Base Url for the controller model.
  43863. */
  43864. static MODEL_BASE_URL: string;
  43865. /**
  43866. * File name for the controller model.
  43867. */
  43868. static MODEL_FILENAME: string;
  43869. /**
  43870. * Gamepad Id prefix used to identify this controller.
  43871. */
  43872. static readonly GAMEPAD_ID_PREFIX: string;
  43873. private readonly _buttonIndexToObservableNameMap;
  43874. /**
  43875. * Creates a new GearVRController from a gamepad
  43876. * @param vrGamepad the gamepad that the controller should be created from
  43877. */
  43878. constructor(vrGamepad: any);
  43879. /**
  43880. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43881. * @param scene scene in which to add meshes
  43882. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43883. */
  43884. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43885. /**
  43886. * Called once for each button that changed state since the last frame
  43887. * @param buttonIdx Which button index changed
  43888. * @param state New state of the button
  43889. * @param changes Which properties on the state changed since last frame
  43890. */
  43891. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43892. }
  43893. }
  43894. declare module BABYLON {
  43895. /**
  43896. * Generic Controller
  43897. */
  43898. class GenericController extends WebVRController {
  43899. /**
  43900. * Base Url for the controller model.
  43901. */
  43902. static readonly MODEL_BASE_URL: string;
  43903. /**
  43904. * File name for the controller model.
  43905. */
  43906. static readonly MODEL_FILENAME: string;
  43907. /**
  43908. * Creates a new GenericController from a gamepad
  43909. * @param vrGamepad the gamepad that the controller should be created from
  43910. */
  43911. constructor(vrGamepad: any);
  43912. /**
  43913. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43914. * @param scene scene in which to add meshes
  43915. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43916. */
  43917. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43918. /**
  43919. * Called once for each button that changed state since the last frame
  43920. * @param buttonIdx Which button index changed
  43921. * @param state New state of the button
  43922. * @param changes Which properties on the state changed since last frame
  43923. */
  43924. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43925. }
  43926. }
  43927. declare module BABYLON {
  43928. /**
  43929. * Oculus Touch Controller
  43930. */
  43931. class OculusTouchController extends WebVRController {
  43932. /**
  43933. * Base Url for the controller model.
  43934. */
  43935. static MODEL_BASE_URL: string;
  43936. /**
  43937. * File name for the left controller model.
  43938. */
  43939. static MODEL_LEFT_FILENAME: string;
  43940. /**
  43941. * File name for the right controller model.
  43942. */
  43943. static MODEL_RIGHT_FILENAME: string;
  43944. /**
  43945. * Fired when the secondary trigger on this controller is modified
  43946. */
  43947. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43948. /**
  43949. * Fired when the thumb rest on this controller is modified
  43950. */
  43951. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43952. /**
  43953. * Creates a new OculusTouchController from a gamepad
  43954. * @param vrGamepad the gamepad that the controller should be created from
  43955. */
  43956. constructor(vrGamepad: any);
  43957. /**
  43958. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43959. * @param scene scene in which to add meshes
  43960. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43961. */
  43962. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43963. /**
  43964. * Fired when the A button on this controller is modified
  43965. */
  43966. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43967. /**
  43968. * Fired when the B button on this controller is modified
  43969. */
  43970. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43971. /**
  43972. * Fired when the X button on this controller is modified
  43973. */
  43974. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43975. /**
  43976. * Fired when the Y button on this controller is modified
  43977. */
  43978. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43979. /**
  43980. * Called once for each button that changed state since the last frame
  43981. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43982. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43983. * 2) secondary trigger (same)
  43984. * 3) A (right) X (left), touch, pressed = value
  43985. * 4) B / Y
  43986. * 5) thumb rest
  43987. * @param buttonIdx Which button index changed
  43988. * @param state New state of the button
  43989. * @param changes Which properties on the state changed since last frame
  43990. */
  43991. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43992. }
  43993. }
  43994. declare module BABYLON {
  43995. /**
  43996. * Defines the types of pose enabled controllers that are supported
  43997. */
  43998. enum PoseEnabledControllerType {
  43999. /**
  44000. * HTC Vive
  44001. */
  44002. VIVE = 0,
  44003. /**
  44004. * Oculus Rift
  44005. */
  44006. OCULUS = 1,
  44007. /**
  44008. * Windows mixed reality
  44009. */
  44010. WINDOWS = 2,
  44011. /**
  44012. * Samsung gear VR
  44013. */
  44014. GEAR_VR = 3,
  44015. /**
  44016. * Google Daydream
  44017. */
  44018. DAYDREAM = 4,
  44019. /**
  44020. * Generic
  44021. */
  44022. GENERIC = 5
  44023. }
  44024. /**
  44025. * Defines the MutableGamepadButton interface for the state of a gamepad button
  44026. */
  44027. interface MutableGamepadButton {
  44028. /**
  44029. * Value of the button/trigger
  44030. */
  44031. value: number;
  44032. /**
  44033. * If the button/trigger is currently touched
  44034. */
  44035. touched: boolean;
  44036. /**
  44037. * If the button/trigger is currently pressed
  44038. */
  44039. pressed: boolean;
  44040. }
  44041. /**
  44042. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  44043. * @hidden
  44044. */
  44045. interface ExtendedGamepadButton extends GamepadButton {
  44046. /**
  44047. * If the button/trigger is currently pressed
  44048. */
  44049. readonly pressed: boolean;
  44050. /**
  44051. * If the button/trigger is currently touched
  44052. */
  44053. readonly touched: boolean;
  44054. /**
  44055. * Value of the button/trigger
  44056. */
  44057. readonly value: number;
  44058. }
  44059. /**
  44060. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  44061. */
  44062. class PoseEnabledControllerHelper {
  44063. /**
  44064. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  44065. * @param vrGamepad the gamepad to initialized
  44066. * @returns a vr controller of the type the gamepad identified as
  44067. */
  44068. static InitiateController(vrGamepad: any): OculusTouchController | WindowsMotionController | ViveController | GearVRController | DaydreamController | GenericController;
  44069. }
  44070. /**
  44071. * Defines the PoseEnabledController object that contains state of a vr capable controller
  44072. */
  44073. class PoseEnabledController extends Gamepad implements PoseControlled {
  44074. private _deviceRoomPosition;
  44075. private _deviceRoomRotationQuaternion;
  44076. /**
  44077. * The device position in babylon space
  44078. */
  44079. devicePosition: Vector3;
  44080. /**
  44081. * The device rotation in babylon space
  44082. */
  44083. deviceRotationQuaternion: Quaternion;
  44084. /**
  44085. * The scale factor of the device in babylon space
  44086. */
  44087. deviceScaleFactor: number;
  44088. /**
  44089. * (Likely devicePosition should be used instead) The device position in its room space
  44090. */
  44091. position: Vector3;
  44092. /**
  44093. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  44094. */
  44095. rotationQuaternion: Quaternion;
  44096. /**
  44097. * The type of controller (Eg. Windows mixed reality)
  44098. */
  44099. controllerType: PoseEnabledControllerType;
  44100. protected _calculatedPosition: Vector3;
  44101. private _calculatedRotation;
  44102. /**
  44103. * The raw pose from the device
  44104. */
  44105. rawPose: DevicePose;
  44106. private _trackPosition;
  44107. private _maxRotationDistFromHeadset;
  44108. private _draggedRoomRotation;
  44109. /**
  44110. * @hidden
  44111. */
  44112. _disableTrackPosition(fixedPosition: Vector3): void;
  44113. /**
  44114. * Internal, the mesh attached to the controller
  44115. * @hidden
  44116. */
  44117. _mesh: Nullable<AbstractMesh>;
  44118. private _poseControlledCamera;
  44119. private _leftHandSystemQuaternion;
  44120. /**
  44121. * Internal, matrix used to convert room space to babylon space
  44122. * @hidden
  44123. */
  44124. _deviceToWorld: Matrix;
  44125. /**
  44126. * Node to be used when casting a ray from the controller
  44127. * @hidden
  44128. */
  44129. _pointingPoseNode: Nullable<TransformNode>;
  44130. /**
  44131. * Name of the child mesh that can be used to cast a ray from the controller
  44132. */
  44133. static readonly POINTING_POSE: string;
  44134. /**
  44135. * Creates a new PoseEnabledController from a gamepad
  44136. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  44137. */
  44138. constructor(browserGamepad: any);
  44139. private _workingMatrix;
  44140. /**
  44141. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  44142. */
  44143. update(): void;
  44144. /**
  44145. * Updates only the pose device and mesh without doing any button event checking
  44146. */
  44147. protected _updatePoseAndMesh(): void;
  44148. /**
  44149. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  44150. * @param poseData raw pose fromthe device
  44151. */
  44152. updateFromDevice(poseData: DevicePose): void;
  44153. /**
  44154. * @hidden
  44155. */
  44156. _meshAttachedObservable: Observable<AbstractMesh>;
  44157. /**
  44158. * Attaches a mesh to the controller
  44159. * @param mesh the mesh to be attached
  44160. */
  44161. attachToMesh(mesh: AbstractMesh): void;
  44162. /**
  44163. * Attaches the controllers mesh to a camera
  44164. * @param camera the camera the mesh should be attached to
  44165. */
  44166. attachToPoseControlledCamera(camera: TargetCamera): void;
  44167. /**
  44168. * Disposes of the controller
  44169. */
  44170. dispose(): void;
  44171. /**
  44172. * The mesh that is attached to the controller
  44173. */
  44174. readonly mesh: Nullable<AbstractMesh>;
  44175. /**
  44176. * Gets the ray of the controller in the direction the controller is pointing
  44177. * @param length the length the resulting ray should be
  44178. * @returns a ray in the direction the controller is pointing
  44179. */
  44180. getForwardRay(length?: number): Ray;
  44181. }
  44182. }
  44183. declare module BABYLON {
  44184. /**
  44185. * Vive Controller
  44186. */
  44187. class ViveController extends WebVRController {
  44188. /**
  44189. * Base Url for the controller model.
  44190. */
  44191. static MODEL_BASE_URL: string;
  44192. /**
  44193. * File name for the controller model.
  44194. */
  44195. static MODEL_FILENAME: string;
  44196. /**
  44197. * Creates a new ViveController from a gamepad
  44198. * @param vrGamepad the gamepad that the controller should be created from
  44199. */
  44200. constructor(vrGamepad: any);
  44201. /**
  44202. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44203. * @param scene scene in which to add meshes
  44204. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44205. */
  44206. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44207. /**
  44208. * Fired when the left button on this controller is modified
  44209. */
  44210. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44211. /**
  44212. * Fired when the right button on this controller is modified
  44213. */
  44214. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44215. /**
  44216. * Fired when the menu button on this controller is modified
  44217. */
  44218. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44219. /**
  44220. * Called once for each button that changed state since the last frame
  44221. * Vive mapping:
  44222. * 0: touchpad
  44223. * 1: trigger
  44224. * 2: left AND right buttons
  44225. * 3: menu button
  44226. * @param buttonIdx Which button index changed
  44227. * @param state New state of the button
  44228. * @param changes Which properties on the state changed since last frame
  44229. */
  44230. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44231. }
  44232. }
  44233. declare module BABYLON {
  44234. /**
  44235. * Defines the WebVRController object that represents controllers tracked in 3D space
  44236. */
  44237. abstract class WebVRController extends PoseEnabledController {
  44238. /**
  44239. * Internal, the default controller model for the controller
  44240. */
  44241. protected _defaultModel: AbstractMesh;
  44242. /**
  44243. * Fired when the trigger state has changed
  44244. */
  44245. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  44246. /**
  44247. * Fired when the main button state has changed
  44248. */
  44249. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44250. /**
  44251. * Fired when the secondary button state has changed
  44252. */
  44253. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44254. /**
  44255. * Fired when the pad state has changed
  44256. */
  44257. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  44258. /**
  44259. * Fired when controllers stick values have changed
  44260. */
  44261. onPadValuesChangedObservable: Observable<StickValues>;
  44262. /**
  44263. * Array of button availible on the controller
  44264. */
  44265. protected _buttons: Array<MutableGamepadButton>;
  44266. private _onButtonStateChange;
  44267. /**
  44268. * Fired when a controller button's state has changed
  44269. * @param callback the callback containing the button that was modified
  44270. */
  44271. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  44272. /**
  44273. * X and Y axis corrisponding to the controllers joystick
  44274. */
  44275. pad: StickValues;
  44276. /**
  44277. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  44278. */
  44279. hand: string;
  44280. /**
  44281. * The default controller model for the controller
  44282. */
  44283. readonly defaultModel: AbstractMesh;
  44284. /**
  44285. * Creates a new WebVRController from a gamepad
  44286. * @param vrGamepad the gamepad that the WebVRController should be created from
  44287. */
  44288. constructor(vrGamepad: any);
  44289. /**
  44290. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  44291. */
  44292. update(): void;
  44293. /**
  44294. * Function to be called when a button is modified
  44295. */
  44296. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44297. /**
  44298. * Loads a mesh and attaches it to the controller
  44299. * @param scene the scene the mesh should be added to
  44300. * @param meshLoaded callback for when the mesh has been loaded
  44301. */
  44302. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44303. private _setButtonValue;
  44304. private _changes;
  44305. private _checkChanges;
  44306. /**
  44307. * Disposes of th webVRCOntroller
  44308. */
  44309. dispose(): void;
  44310. }
  44311. }
  44312. declare module BABYLON {
  44313. /**
  44314. * Defines the WindowsMotionController object that the state of the windows motion controller
  44315. */
  44316. class WindowsMotionController extends WebVRController {
  44317. /**
  44318. * The base url used to load the left and right controller models
  44319. */
  44320. static MODEL_BASE_URL: string;
  44321. /**
  44322. * The name of the left controller model file
  44323. */
  44324. static MODEL_LEFT_FILENAME: string;
  44325. /**
  44326. * The name of the right controller model file
  44327. */
  44328. static MODEL_RIGHT_FILENAME: string;
  44329. /**
  44330. * The controller name prefix for this controller type
  44331. */
  44332. static readonly GAMEPAD_ID_PREFIX: string;
  44333. /**
  44334. * The controller id pattern for this controller type
  44335. */
  44336. private static readonly GAMEPAD_ID_PATTERN;
  44337. private _loadedMeshInfo;
  44338. private readonly _mapping;
  44339. /**
  44340. * Fired when the trackpad on this controller is clicked
  44341. */
  44342. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  44343. /**
  44344. * Fired when the trackpad on this controller is modified
  44345. */
  44346. onTrackpadValuesChangedObservable: Observable<StickValues>;
  44347. /**
  44348. * The current x and y values of this controller's trackpad
  44349. */
  44350. trackpad: StickValues;
  44351. /**
  44352. * Creates a new WindowsMotionController from a gamepad
  44353. * @param vrGamepad the gamepad that the controller should be created from
  44354. */
  44355. constructor(vrGamepad: any);
  44356. /**
  44357. * Fired when the trigger on this controller is modified
  44358. */
  44359. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44360. /**
  44361. * Fired when the menu button on this controller is modified
  44362. */
  44363. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44364. /**
  44365. * Fired when the grip button on this controller is modified
  44366. */
  44367. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44368. /**
  44369. * Fired when the thumbstick button on this controller is modified
  44370. */
  44371. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44372. /**
  44373. * Fired when the touchpad button on this controller is modified
  44374. */
  44375. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44376. /**
  44377. * Fired when the touchpad values on this controller are modified
  44378. */
  44379. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  44380. private _updateTrackpad;
  44381. /**
  44382. * Called once per frame by the engine.
  44383. */
  44384. update(): void;
  44385. /**
  44386. * Called once for each button that changed state since the last frame
  44387. * @param buttonIdx Which button index changed
  44388. * @param state New state of the button
  44389. * @param changes Which properties on the state changed since last frame
  44390. */
  44391. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44392. /**
  44393. * Moves the buttons on the controller mesh based on their current state
  44394. * @param buttonName the name of the button to move
  44395. * @param buttonValue the value of the button which determines the buttons new position
  44396. */
  44397. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  44398. /**
  44399. * Moves the axis on the controller mesh based on its current state
  44400. * @param axis the index of the axis
  44401. * @param axisValue the value of the axis which determines the meshes new position
  44402. * @hidden
  44403. */
  44404. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  44405. /**
  44406. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44407. * @param scene scene in which to add meshes
  44408. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44409. */
  44410. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  44411. /**
  44412. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  44413. * can be transformed by button presses and axes values, based on this._mapping.
  44414. *
  44415. * @param scene scene in which the meshes exist
  44416. * @param meshes list of meshes that make up the controller model to process
  44417. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  44418. */
  44419. private processModel;
  44420. private createMeshInfo;
  44421. /**
  44422. * Gets the ray of the controller in the direction the controller is pointing
  44423. * @param length the length the resulting ray should be
  44424. * @returns a ray in the direction the controller is pointing
  44425. */
  44426. getForwardRay(length?: number): Ray;
  44427. /**
  44428. * Disposes of the controller
  44429. */
  44430. dispose(): void;
  44431. }
  44432. }
  44433. declare module BABYLON {
  44434. /**
  44435. * Interface to implement to create a shadow generator compatible with BJS.
  44436. */
  44437. interface IShadowGenerator {
  44438. /**
  44439. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  44440. * @returns The render target texture if present otherwise, null
  44441. */
  44442. getShadowMap(): Nullable<RenderTargetTexture>;
  44443. /**
  44444. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  44445. * @returns The render target texture if the shadow map is present otherwise, null
  44446. */
  44447. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  44448. /**
  44449. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  44450. * @param subMesh The submesh we want to render in the shadow map
  44451. * @param useInstances Defines wether will draw in the map using instances
  44452. * @returns true if ready otherwise, false
  44453. */
  44454. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  44455. /**
  44456. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  44457. * @param defines Defines of the material we want to update
  44458. * @param lightIndex Index of the light in the enabled light list of the material
  44459. */
  44460. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  44461. /**
  44462. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  44463. * defined in the generator but impacting the effect).
  44464. * It implies the unifroms available on the materials are the standard BJS ones.
  44465. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  44466. * @param effect The effect we are binfing the information for
  44467. */
  44468. bindShadowLight(lightIndex: string, effect: Effect): void;
  44469. /**
  44470. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  44471. * (eq to shadow prjection matrix * light transform matrix)
  44472. * @returns The transform matrix used to create the shadow map
  44473. */
  44474. getTransformMatrix(): Matrix;
  44475. /**
  44476. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  44477. * Cube and 2D textures for instance.
  44478. */
  44479. recreateShadowMap(): void;
  44480. /**
  44481. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  44482. * @param onCompiled Callback triggered at the and of the effects compilation
  44483. * @param options Sets of optional options forcing the compilation with different modes
  44484. */
  44485. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  44486. useInstances: boolean;
  44487. }>): void;
  44488. /**
  44489. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  44490. * @param options Sets of optional options forcing the compilation with different modes
  44491. * @returns A promise that resolves when the compilation completes
  44492. */
  44493. forceCompilationAsync(options?: Partial<{
  44494. useInstances: boolean;
  44495. }>): Promise<void>;
  44496. /**
  44497. * Serializes the shadow generator setup to a json object.
  44498. * @returns The serialized JSON object
  44499. */
  44500. serialize(): any;
  44501. /**
  44502. * Disposes the Shadow map and related Textures and effects.
  44503. */
  44504. dispose(): void;
  44505. }
  44506. /**
  44507. * Default implementation IShadowGenerator.
  44508. * This is the main object responsible of generating shadows in the framework.
  44509. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  44510. */
  44511. class ShadowGenerator implements IShadowGenerator {
  44512. /**
  44513. * Shadow generator mode None: no filtering applied.
  44514. */
  44515. static readonly FILTER_NONE: number;
  44516. /**
  44517. * Shadow generator mode ESM: Exponential Shadow Mapping.
  44518. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  44519. */
  44520. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  44521. /**
  44522. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  44523. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  44524. */
  44525. static readonly FILTER_POISSONSAMPLING: number;
  44526. /**
  44527. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  44528. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  44529. */
  44530. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  44531. /**
  44532. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  44533. * edge artifacts on steep falloff.
  44534. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  44535. */
  44536. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  44537. /**
  44538. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  44539. * edge artifacts on steep falloff.
  44540. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  44541. */
  44542. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  44543. /**
  44544. * Shadow generator mode PCF: Percentage Closer Filtering
  44545. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  44546. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  44547. */
  44548. static readonly FILTER_PCF: number;
  44549. /**
  44550. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  44551. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  44552. * Contact Hardening
  44553. */
  44554. static readonly FILTER_PCSS: number;
  44555. /**
  44556. * Reserved for PCF and PCSS
  44557. * Highest Quality.
  44558. *
  44559. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  44560. *
  44561. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  44562. */
  44563. static readonly QUALITY_HIGH: number;
  44564. /**
  44565. * Reserved for PCF and PCSS
  44566. * Good tradeoff for quality/perf cross devices
  44567. *
  44568. * Execute PCF on a 3*3 kernel.
  44569. *
  44570. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  44571. */
  44572. static readonly QUALITY_MEDIUM: number;
  44573. /**
  44574. * Reserved for PCF and PCSS
  44575. * The lowest quality but the fastest.
  44576. *
  44577. * Execute PCF on a 1*1 kernel.
  44578. *
  44579. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  44580. */
  44581. static readonly QUALITY_LOW: number;
  44582. private _bias;
  44583. /**
  44584. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  44585. */
  44586. /**
  44587. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  44588. */
  44589. bias: number;
  44590. private _normalBias;
  44591. /**
  44592. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  44593. */
  44594. /**
  44595. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  44596. */
  44597. normalBias: number;
  44598. private _blurBoxOffset;
  44599. /**
  44600. * Gets the blur box offset: offset applied during the blur pass.
  44601. * Only useful if useKernelBlur = false
  44602. */
  44603. /**
  44604. * Sets the blur box offset: offset applied during the blur pass.
  44605. * Only useful if useKernelBlur = false
  44606. */
  44607. blurBoxOffset: number;
  44608. private _blurScale;
  44609. /**
  44610. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  44611. * 2 means half of the size.
  44612. */
  44613. /**
  44614. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  44615. * 2 means half of the size.
  44616. */
  44617. blurScale: number;
  44618. private _blurKernel;
  44619. /**
  44620. * Gets the blur kernel: kernel size of the blur pass.
  44621. * Only useful if useKernelBlur = true
  44622. */
  44623. /**
  44624. * Sets the blur kernel: kernel size of the blur pass.
  44625. * Only useful if useKernelBlur = true
  44626. */
  44627. blurKernel: number;
  44628. private _useKernelBlur;
  44629. /**
  44630. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  44631. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  44632. */
  44633. /**
  44634. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  44635. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  44636. */
  44637. useKernelBlur: boolean;
  44638. private _depthScale;
  44639. /**
  44640. * Gets the depth scale used in ESM mode.
  44641. */
  44642. /**
  44643. * Sets the depth scale used in ESM mode.
  44644. * This can override the scale stored on the light.
  44645. */
  44646. depthScale: number;
  44647. private _filter;
  44648. /**
  44649. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  44650. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  44651. */
  44652. /**
  44653. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  44654. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  44655. */
  44656. filter: number;
  44657. /**
  44658. * Gets if the current filter is set to Poisson Sampling.
  44659. */
  44660. /**
  44661. * Sets the current filter to Poisson Sampling.
  44662. */
  44663. usePoissonSampling: boolean;
  44664. /**
  44665. * Gets if the current filter is set to ESM.
  44666. */
  44667. /**
  44668. * Sets the current filter is to ESM.
  44669. */
  44670. useExponentialShadowMap: boolean;
  44671. /**
  44672. * Gets if the current filter is set to filtered ESM.
  44673. */
  44674. /**
  44675. * Gets if the current filter is set to filtered ESM.
  44676. */
  44677. useBlurExponentialShadowMap: boolean;
  44678. /**
  44679. * Gets if the current filter is set to "close ESM" (using the inverse of the
  44680. * exponential to prevent steep falloff artifacts).
  44681. */
  44682. /**
  44683. * Sets the current filter to "close ESM" (using the inverse of the
  44684. * exponential to prevent steep falloff artifacts).
  44685. */
  44686. useCloseExponentialShadowMap: boolean;
  44687. /**
  44688. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  44689. * exponential to prevent steep falloff artifacts).
  44690. */
  44691. /**
  44692. * Sets the current filter to filtered "close ESM" (using the inverse of the
  44693. * exponential to prevent steep falloff artifacts).
  44694. */
  44695. useBlurCloseExponentialShadowMap: boolean;
  44696. /**
  44697. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  44698. */
  44699. /**
  44700. * Sets the current filter to "PCF" (percentage closer filtering).
  44701. */
  44702. usePercentageCloserFiltering: boolean;
  44703. private _filteringQuality;
  44704. /**
  44705. * Gets the PCF or PCSS Quality.
  44706. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  44707. */
  44708. /**
  44709. * Sets the PCF or PCSS Quality.
  44710. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  44711. */
  44712. filteringQuality: number;
  44713. /**
  44714. * Gets if the current filter is set to "PCSS" (contact hardening).
  44715. */
  44716. /**
  44717. * Sets the current filter to "PCSS" (contact hardening).
  44718. */
  44719. useContactHardeningShadow: boolean;
  44720. private _contactHardeningLightSizeUVRatio;
  44721. /**
  44722. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  44723. * Using a ratio helps keeping shape stability independently of the map size.
  44724. *
  44725. * It does not account for the light projection as it was having too much
  44726. * instability during the light setup or during light position changes.
  44727. *
  44728. * Only valid if useContactHardeningShadow is true.
  44729. */
  44730. /**
  44731. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  44732. * Using a ratio helps keeping shape stability independently of the map size.
  44733. *
  44734. * It does not account for the light projection as it was having too much
  44735. * instability during the light setup or during light position changes.
  44736. *
  44737. * Only valid if useContactHardeningShadow is true.
  44738. */
  44739. contactHardeningLightSizeUVRatio: number;
  44740. private _darkness;
  44741. /**
  44742. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  44743. * 0 means strongest and 1 would means no shadow.
  44744. * @returns the darkness.
  44745. */
  44746. getDarkness(): number;
  44747. /**
  44748. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  44749. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  44750. * @returns the shadow generator allowing fluent coding.
  44751. */
  44752. setDarkness(darkness: number): ShadowGenerator;
  44753. private _transparencyShadow;
  44754. /**
  44755. * Sets the ability to have transparent shadow (boolean).
  44756. * @param transparent True if transparent else False
  44757. * @returns the shadow generator allowing fluent coding
  44758. */
  44759. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  44760. private _shadowMap;
  44761. private _shadowMap2;
  44762. /**
  44763. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  44764. * @returns The render target texture if present otherwise, null
  44765. */
  44766. getShadowMap(): Nullable<RenderTargetTexture>;
  44767. /**
  44768. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  44769. * @returns The render target texture if the shadow map is present otherwise, null
  44770. */
  44771. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  44772. /**
  44773. * Helper function to add a mesh and its descendants to the list of shadow casters.
  44774. * @param mesh Mesh to add
  44775. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  44776. * @returns the Shadow Generator itself
  44777. */
  44778. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  44779. /**
  44780. * Helper function to remove a mesh and its descendants from the list of shadow casters
  44781. * @param mesh Mesh to remove
  44782. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  44783. * @returns the Shadow Generator itself
  44784. */
  44785. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  44786. /**
  44787. * Controls the extent to which the shadows fade out at the edge of the frustum
  44788. * Used only by directionals and spots
  44789. */
  44790. frustumEdgeFalloff: number;
  44791. private _light;
  44792. /**
  44793. * Returns the associated light object.
  44794. * @returns the light generating the shadow
  44795. */
  44796. getLight(): IShadowLight;
  44797. /**
  44798. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  44799. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  44800. * It might on the other hand introduce peter panning.
  44801. */
  44802. forceBackFacesOnly: boolean;
  44803. private _scene;
  44804. private _lightDirection;
  44805. private _effect;
  44806. private _viewMatrix;
  44807. private _projectionMatrix;
  44808. private _transformMatrix;
  44809. private _cachedPosition;
  44810. private _cachedDirection;
  44811. private _cachedDefines;
  44812. private _currentRenderID;
  44813. private _boxBlurPostprocess;
  44814. private _kernelBlurXPostprocess;
  44815. private _kernelBlurYPostprocess;
  44816. private _blurPostProcesses;
  44817. private _mapSize;
  44818. private _currentFaceIndex;
  44819. private _currentFaceIndexCache;
  44820. private _textureType;
  44821. private _defaultTextureMatrix;
  44822. /**
  44823. * Creates a ShadowGenerator object.
  44824. * A ShadowGenerator is the required tool to use the shadows.
  44825. * Each light casting shadows needs to use its own ShadowGenerator.
  44826. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  44827. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  44828. * @param light The light object generating the shadows.
  44829. * @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.
  44830. */
  44831. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  44832. private _initializeGenerator;
  44833. private _initializeShadowMap;
  44834. private _initializeBlurRTTAndPostProcesses;
  44835. private _renderForShadowMap;
  44836. private _renderSubMeshForShadowMap;
  44837. private _applyFilterValues;
  44838. /**
  44839. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  44840. * @param onCompiled Callback triggered at the and of the effects compilation
  44841. * @param options Sets of optional options forcing the compilation with different modes
  44842. */
  44843. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  44844. useInstances: boolean;
  44845. }>): void;
  44846. /**
  44847. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  44848. * @param options Sets of optional options forcing the compilation with different modes
  44849. * @returns A promise that resolves when the compilation completes
  44850. */
  44851. forceCompilationAsync(options?: Partial<{
  44852. useInstances: boolean;
  44853. }>): Promise<void>;
  44854. /**
  44855. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  44856. * @param subMesh The submesh we want to render in the shadow map
  44857. * @param useInstances Defines wether will draw in the map using instances
  44858. * @returns true if ready otherwise, false
  44859. */
  44860. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  44861. /**
  44862. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  44863. * @param defines Defines of the material we want to update
  44864. * @param lightIndex Index of the light in the enabled light list of the material
  44865. */
  44866. prepareDefines(defines: any, lightIndex: number): void;
  44867. /**
  44868. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  44869. * defined in the generator but impacting the effect).
  44870. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  44871. * @param effect The effect we are binfing the information for
  44872. */
  44873. bindShadowLight(lightIndex: string, effect: Effect): void;
  44874. /**
  44875. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  44876. * (eq to shadow prjection matrix * light transform matrix)
  44877. * @returns The transform matrix used to create the shadow map
  44878. */
  44879. getTransformMatrix(): Matrix;
  44880. /**
  44881. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  44882. * Cube and 2D textures for instance.
  44883. */
  44884. recreateShadowMap(): void;
  44885. private _disposeBlurPostProcesses;
  44886. private _disposeRTTandPostProcesses;
  44887. /**
  44888. * Disposes the ShadowGenerator.
  44889. * Returns nothing.
  44890. */
  44891. dispose(): void;
  44892. /**
  44893. * Serializes the shadow generator setup to a json object.
  44894. * @returns The serialized JSON object
  44895. */
  44896. serialize(): any;
  44897. /**
  44898. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  44899. * @param parsedShadowGenerator The JSON object to parse
  44900. * @param scene The scene to create the shadow map for
  44901. * @returns The parsed shadow generator
  44902. */
  44903. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  44904. }
  44905. }
  44906. declare module BABYLON {
  44907. /**
  44908. * Defines the shadow generator component responsible to manage any shadow generators
  44909. * in a given scene.
  44910. */
  44911. class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  44912. /**
  44913. * The component name helpfull to identify the component in the list of scene components.
  44914. */
  44915. readonly name: string;
  44916. /**
  44917. * The scene the component belongs to.
  44918. */
  44919. scene: Scene;
  44920. /**
  44921. * Creates a new instance of the component for the given scene
  44922. * @param scene Defines the scene to register the component in
  44923. */
  44924. constructor(scene: Scene);
  44925. /**
  44926. * Registers the component in a given scene
  44927. */
  44928. register(): void;
  44929. /**
  44930. * Rebuilds the elements related to this component in case of
  44931. * context lost for instance.
  44932. */
  44933. rebuild(): void;
  44934. /**
  44935. * Serializes the component data to the specified json object
  44936. * @param serializationObject The object to serialize to
  44937. */
  44938. serialize(serializationObject: any): void;
  44939. /**
  44940. * Adds all the element from the container to the scene
  44941. * @param container the container holding the elements
  44942. */
  44943. addFromContainer(container: AbstractScene): void;
  44944. /**
  44945. * Removes all the elements in the container from the scene
  44946. * @param container contains the elements to remove
  44947. */
  44948. removeFromContainer(container: AbstractScene): void;
  44949. /**
  44950. * Rebuilds the elements related to this component in case of
  44951. * context lost for instance.
  44952. */
  44953. dispose(): void;
  44954. private _gatherRenderTargets;
  44955. }
  44956. }
  44957. declare module BABYLON {
  44958. }
  44959. declare module BABYLON {
  44960. /**
  44961. * Background material used to create an efficient environement around your scene.
  44962. */
  44963. class BackgroundMaterial extends PushMaterial {
  44964. /**
  44965. * Standard reflectance value at parallel view angle.
  44966. */
  44967. static StandardReflectance0: number;
  44968. /**
  44969. * Standard reflectance value at grazing angle.
  44970. */
  44971. static StandardReflectance90: number;
  44972. protected _primaryColor: Color3;
  44973. /**
  44974. * Key light Color (multiply against the environement texture)
  44975. */
  44976. primaryColor: Color3;
  44977. protected __perceptualColor: Nullable<Color3>;
  44978. /**
  44979. * Experimental Internal Use Only.
  44980. *
  44981. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  44982. * This acts as a helper to set the primary color to a more "human friendly" value.
  44983. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  44984. * output color as close as possible from the chosen value.
  44985. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  44986. * part of lighting setup.)
  44987. */
  44988. _perceptualColor: Nullable<Color3>;
  44989. protected _primaryColorShadowLevel: float;
  44990. /**
  44991. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  44992. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  44993. */
  44994. primaryColorShadowLevel: float;
  44995. protected _primaryColorHighlightLevel: float;
  44996. /**
  44997. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  44998. * The primary color is used at the level chosen to define what the white area would look.
  44999. */
  45000. primaryColorHighlightLevel: float;
  45001. protected _reflectionTexture: Nullable<BaseTexture>;
  45002. /**
  45003. * Reflection Texture used in the material.
  45004. * Should be author in a specific way for the best result (refer to the documentation).
  45005. */
  45006. reflectionTexture: Nullable<BaseTexture>;
  45007. protected _reflectionBlur: float;
  45008. /**
  45009. * Reflection Texture level of blur.
  45010. *
  45011. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  45012. * texture twice.
  45013. */
  45014. reflectionBlur: float;
  45015. protected _diffuseTexture: Nullable<BaseTexture>;
  45016. /**
  45017. * Diffuse Texture used in the material.
  45018. * Should be author in a specific way for the best result (refer to the documentation).
  45019. */
  45020. diffuseTexture: Nullable<BaseTexture>;
  45021. protected _shadowLights: Nullable<IShadowLight[]>;
  45022. /**
  45023. * Specify the list of lights casting shadow on the material.
  45024. * All scene shadow lights will be included if null.
  45025. */
  45026. shadowLights: Nullable<IShadowLight[]>;
  45027. protected _shadowLevel: float;
  45028. /**
  45029. * Helps adjusting the shadow to a softer level if required.
  45030. * 0 means black shadows and 1 means no shadows.
  45031. */
  45032. shadowLevel: float;
  45033. protected _sceneCenter: Vector3;
  45034. /**
  45035. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  45036. * It is usually zero but might be interesting to modify according to your setup.
  45037. */
  45038. sceneCenter: Vector3;
  45039. protected _opacityFresnel: boolean;
  45040. /**
  45041. * This helps specifying that the material is falling off to the sky box at grazing angle.
  45042. * This helps ensuring a nice transition when the camera goes under the ground.
  45043. */
  45044. opacityFresnel: boolean;
  45045. protected _reflectionFresnel: boolean;
  45046. /**
  45047. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  45048. * This helps adding a mirror texture on the ground.
  45049. */
  45050. reflectionFresnel: boolean;
  45051. protected _reflectionFalloffDistance: number;
  45052. /**
  45053. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  45054. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  45055. */
  45056. reflectionFalloffDistance: number;
  45057. protected _reflectionAmount: number;
  45058. /**
  45059. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  45060. */
  45061. reflectionAmount: number;
  45062. protected _reflectionReflectance0: number;
  45063. /**
  45064. * This specifies the weight of the reflection at grazing angle.
  45065. */
  45066. reflectionReflectance0: number;
  45067. protected _reflectionReflectance90: number;
  45068. /**
  45069. * This specifies the weight of the reflection at a perpendicular point of view.
  45070. */
  45071. reflectionReflectance90: number;
  45072. /**
  45073. * Sets the reflection reflectance fresnel values according to the default standard
  45074. * empirically know to work well :-)
  45075. */
  45076. reflectionStandardFresnelWeight: number;
  45077. protected _useRGBColor: boolean;
  45078. /**
  45079. * Helps to directly use the maps channels instead of their level.
  45080. */
  45081. useRGBColor: boolean;
  45082. protected _enableNoise: boolean;
  45083. /**
  45084. * This helps reducing the banding effect that could occur on the background.
  45085. */
  45086. enableNoise: boolean;
  45087. /**
  45088. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45089. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  45090. * Recommended to be keep at 1.0 except for special cases.
  45091. */
  45092. fovMultiplier: number;
  45093. private _fovMultiplier;
  45094. /**
  45095. * Enable the FOV adjustment feature controlled by fovMultiplier.
  45096. */
  45097. useEquirectangularFOV: boolean;
  45098. private _maxSimultaneousLights;
  45099. /**
  45100. * Number of Simultaneous lights allowed on the material.
  45101. */
  45102. maxSimultaneousLights: int;
  45103. /**
  45104. * Default configuration related to image processing available in the Background Material.
  45105. */
  45106. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45107. /**
  45108. * Keep track of the image processing observer to allow dispose and replace.
  45109. */
  45110. private _imageProcessingObserver;
  45111. /**
  45112. * Attaches a new image processing configuration to the PBR Material.
  45113. * @param configuration (if null the scene configuration will be use)
  45114. */
  45115. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45116. /**
  45117. * Gets the image processing configuration used either in this material.
  45118. */
  45119. /**
  45120. * Sets the Default image processing configuration used either in the this material.
  45121. *
  45122. * If sets to null, the scene one is in use.
  45123. */
  45124. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  45125. /**
  45126. * Gets wether the color curves effect is enabled.
  45127. */
  45128. /**
  45129. * Sets wether the color curves effect is enabled.
  45130. */
  45131. cameraColorCurvesEnabled: boolean;
  45132. /**
  45133. * Gets wether the color grading effect is enabled.
  45134. */
  45135. /**
  45136. * Gets wether the color grading effect is enabled.
  45137. */
  45138. cameraColorGradingEnabled: boolean;
  45139. /**
  45140. * Gets wether tonemapping is enabled or not.
  45141. */
  45142. /**
  45143. * Sets wether tonemapping is enabled or not
  45144. */
  45145. cameraToneMappingEnabled: boolean;
  45146. /**
  45147. * The camera exposure used on this material.
  45148. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45149. * This corresponds to a photographic exposure.
  45150. */
  45151. /**
  45152. * The camera exposure used on this material.
  45153. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45154. * This corresponds to a photographic exposure.
  45155. */
  45156. cameraExposure: float;
  45157. /**
  45158. * Gets The camera contrast used on this material.
  45159. */
  45160. /**
  45161. * Sets The camera contrast used on this material.
  45162. */
  45163. cameraContrast: float;
  45164. /**
  45165. * Gets the Color Grading 2D Lookup Texture.
  45166. */
  45167. /**
  45168. * Sets the Color Grading 2D Lookup Texture.
  45169. */
  45170. cameraColorGradingTexture: Nullable<BaseTexture>;
  45171. /**
  45172. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45173. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45174. * 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;
  45175. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45176. */
  45177. /**
  45178. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45179. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45180. * 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;
  45181. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45182. */
  45183. cameraColorCurves: Nullable<ColorCurves>;
  45184. /**
  45185. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  45186. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  45187. */
  45188. switchToBGR: boolean;
  45189. private _renderTargets;
  45190. private _reflectionControls;
  45191. private _white;
  45192. private _primaryShadowColor;
  45193. private _primaryHighlightColor;
  45194. /**
  45195. * Instantiates a Background Material in the given scene
  45196. * @param name The friendly name of the material
  45197. * @param scene The scene to add the material to
  45198. */
  45199. constructor(name: string, scene: Scene);
  45200. /**
  45201. * Gets a boolean indicating that current material needs to register RTT
  45202. */
  45203. readonly hasRenderTargetTextures: boolean;
  45204. /**
  45205. * The entire material has been created in order to prevent overdraw.
  45206. * @returns false
  45207. */
  45208. needAlphaTesting(): boolean;
  45209. /**
  45210. * The entire material has been created in order to prevent overdraw.
  45211. * @returns true if blending is enable
  45212. */
  45213. needAlphaBlending(): boolean;
  45214. /**
  45215. * Checks wether the material is ready to be rendered for a given mesh.
  45216. * @param mesh The mesh to render
  45217. * @param subMesh The submesh to check against
  45218. * @param useInstances Specify wether or not the material is used with instances
  45219. * @returns true if all the dependencies are ready (Textures, Effects...)
  45220. */
  45221. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45222. /**
  45223. * Compute the primary color according to the chosen perceptual color.
  45224. */
  45225. private _computePrimaryColorFromPerceptualColor;
  45226. /**
  45227. * Compute the highlights and shadow colors according to their chosen levels.
  45228. */
  45229. private _computePrimaryColors;
  45230. /**
  45231. * Build the uniform buffer used in the material.
  45232. */
  45233. buildUniformLayout(): void;
  45234. /**
  45235. * Unbind the material.
  45236. */
  45237. unbind(): void;
  45238. /**
  45239. * Bind only the world matrix to the material.
  45240. * @param world The world matrix to bind.
  45241. */
  45242. bindOnlyWorldMatrix(world: Matrix): void;
  45243. /**
  45244. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  45245. * @param world The world matrix to bind.
  45246. * @param subMesh The submesh to bind for.
  45247. */
  45248. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45249. /**
  45250. * Dispose the material.
  45251. * @param forceDisposeEffect Force disposal of the associated effect.
  45252. * @param forceDisposeTextures Force disposal of the associated textures.
  45253. */
  45254. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45255. /**
  45256. * Clones the material.
  45257. * @param name The cloned name.
  45258. * @returns The cloned material.
  45259. */
  45260. clone(name: string): BackgroundMaterial;
  45261. /**
  45262. * Serializes the current material to its JSON representation.
  45263. * @returns The JSON representation.
  45264. */
  45265. serialize(): any;
  45266. /**
  45267. * Gets the class name of the material
  45268. * @returns "BackgroundMaterial"
  45269. */
  45270. getClassName(): string;
  45271. /**
  45272. * Parse a JSON input to create back a background material.
  45273. * @param source The JSON data to parse
  45274. * @param scene The scene to create the parsed material in
  45275. * @param rootUrl The root url of the assets the material depends upon
  45276. * @returns the instantiated BackgroundMaterial.
  45277. */
  45278. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  45279. }
  45280. }
  45281. declare module BABYLON {
  45282. /**
  45283. * The Physically based material base class of BJS.
  45284. *
  45285. * This offers the main features of a standard PBR material.
  45286. * For more information, please refer to the documentation :
  45287. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  45288. */
  45289. abstract class PBRBaseMaterial extends PushMaterial {
  45290. /**
  45291. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  45292. */
  45293. static readonly LIGHTFALLOFF_PHYSICAL: number;
  45294. /**
  45295. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  45296. * to enhance interoperability with other engines.
  45297. */
  45298. static readonly LIGHTFALLOFF_GLTF: number;
  45299. /**
  45300. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  45301. * to enhance interoperability with other materials.
  45302. */
  45303. static readonly LIGHTFALLOFF_STANDARD: number;
  45304. /**
  45305. * Intensity of the direct lights e.g. the four lights available in your scene.
  45306. * This impacts both the direct diffuse and specular highlights.
  45307. */
  45308. protected _directIntensity: number;
  45309. /**
  45310. * Intensity of the emissive part of the material.
  45311. * This helps controlling the emissive effect without modifying the emissive color.
  45312. */
  45313. protected _emissiveIntensity: number;
  45314. /**
  45315. * Intensity of the environment e.g. how much the environment will light the object
  45316. * either through harmonics for rough material or through the refelction for shiny ones.
  45317. */
  45318. protected _environmentIntensity: number;
  45319. /**
  45320. * This is a special control allowing the reduction of the specular highlights coming from the
  45321. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45322. */
  45323. protected _specularIntensity: number;
  45324. /**
  45325. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  45326. */
  45327. private _lightingInfos;
  45328. /**
  45329. * Debug Control allowing disabling the bump map on this material.
  45330. */
  45331. protected _disableBumpMap: boolean;
  45332. /**
  45333. * AKA Diffuse Texture in standard nomenclature.
  45334. */
  45335. protected _albedoTexture: BaseTexture;
  45336. /**
  45337. * AKA Occlusion Texture in other nomenclature.
  45338. */
  45339. protected _ambientTexture: BaseTexture;
  45340. /**
  45341. * AKA Occlusion Texture Intensity in other nomenclature.
  45342. */
  45343. protected _ambientTextureStrength: number;
  45344. /**
  45345. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45346. * 1 means it completely occludes it
  45347. * 0 mean it has no impact
  45348. */
  45349. protected _ambientTextureImpactOnAnalyticalLights: number;
  45350. /**
  45351. * Stores the alpha values in a texture.
  45352. */
  45353. protected _opacityTexture: BaseTexture;
  45354. /**
  45355. * Stores the reflection values in a texture.
  45356. */
  45357. protected _reflectionTexture: BaseTexture;
  45358. /**
  45359. * Stores the refraction values in a texture.
  45360. */
  45361. protected _refractionTexture: BaseTexture;
  45362. /**
  45363. * Stores the emissive values in a texture.
  45364. */
  45365. protected _emissiveTexture: BaseTexture;
  45366. /**
  45367. * AKA Specular texture in other nomenclature.
  45368. */
  45369. protected _reflectivityTexture: BaseTexture;
  45370. /**
  45371. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45372. */
  45373. protected _metallicTexture: BaseTexture;
  45374. /**
  45375. * Specifies the metallic scalar of the metallic/roughness workflow.
  45376. * Can also be used to scale the metalness values of the metallic texture.
  45377. */
  45378. protected _metallic: Nullable<number>;
  45379. /**
  45380. * Specifies the roughness scalar of the metallic/roughness workflow.
  45381. * Can also be used to scale the roughness values of the metallic texture.
  45382. */
  45383. protected _roughness: Nullable<number>;
  45384. /**
  45385. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45386. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45387. */
  45388. protected _microSurfaceTexture: BaseTexture;
  45389. /**
  45390. * Stores surface normal data used to displace a mesh in a texture.
  45391. */
  45392. protected _bumpTexture: BaseTexture;
  45393. /**
  45394. * Stores the pre-calculated light information of a mesh in a texture.
  45395. */
  45396. protected _lightmapTexture: BaseTexture;
  45397. /**
  45398. * The color of a material in ambient lighting.
  45399. */
  45400. protected _ambientColor: Color3;
  45401. /**
  45402. * AKA Diffuse Color in other nomenclature.
  45403. */
  45404. protected _albedoColor: Color3;
  45405. /**
  45406. * AKA Specular Color in other nomenclature.
  45407. */
  45408. protected _reflectivityColor: Color3;
  45409. /**
  45410. * The color applied when light is reflected from a material.
  45411. */
  45412. protected _reflectionColor: Color3;
  45413. /**
  45414. * The color applied when light is emitted from a material.
  45415. */
  45416. protected _emissiveColor: Color3;
  45417. /**
  45418. * AKA Glossiness in other nomenclature.
  45419. */
  45420. protected _microSurface: number;
  45421. /**
  45422. * source material index of refraction (IOR)' / 'destination material IOR.
  45423. */
  45424. protected _indexOfRefraction: number;
  45425. /**
  45426. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45427. */
  45428. protected _invertRefractionY: boolean;
  45429. /**
  45430. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45431. * Materials half opaque for instance using refraction could benefit from this control.
  45432. */
  45433. protected _linkRefractionWithTransparency: boolean;
  45434. /**
  45435. * Specifies that the material will use the light map as a show map.
  45436. */
  45437. protected _useLightmapAsShadowmap: boolean;
  45438. /**
  45439. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45440. * makes the reflect vector face the model (under horizon).
  45441. */
  45442. protected _useHorizonOcclusion: boolean;
  45443. /**
  45444. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45445. * too much the area relying on ambient texture to define their ambient occlusion.
  45446. */
  45447. protected _useRadianceOcclusion: boolean;
  45448. /**
  45449. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45450. */
  45451. protected _useAlphaFromAlbedoTexture: boolean;
  45452. /**
  45453. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  45454. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45455. */
  45456. protected _useSpecularOverAlpha: boolean;
  45457. /**
  45458. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45459. */
  45460. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45461. /**
  45462. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45463. */
  45464. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  45465. /**
  45466. * Specifies if the metallic texture contains the roughness information in its green channel.
  45467. */
  45468. protected _useRoughnessFromMetallicTextureGreen: boolean;
  45469. /**
  45470. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45471. */
  45472. protected _useMetallnessFromMetallicTextureBlue: boolean;
  45473. /**
  45474. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45475. */
  45476. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  45477. /**
  45478. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45479. */
  45480. protected _useAmbientInGrayScale: boolean;
  45481. /**
  45482. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45483. * The material will try to infer what glossiness each pixel should be.
  45484. */
  45485. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  45486. /**
  45487. * Defines the falloff type used in this material.
  45488. * It by default is Physical.
  45489. */
  45490. protected _lightFalloff: number;
  45491. /**
  45492. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45493. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45494. */
  45495. protected _useRadianceOverAlpha: boolean;
  45496. /**
  45497. * Allows using an object space normal map (instead of tangent space).
  45498. */
  45499. protected _useObjectSpaceNormalMap: boolean;
  45500. /**
  45501. * Allows using the bump map in parallax mode.
  45502. */
  45503. protected _useParallax: boolean;
  45504. /**
  45505. * Allows using the bump map in parallax occlusion mode.
  45506. */
  45507. protected _useParallaxOcclusion: boolean;
  45508. /**
  45509. * Controls the scale bias of the parallax mode.
  45510. */
  45511. protected _parallaxScaleBias: number;
  45512. /**
  45513. * If sets to true, disables all the lights affecting the material.
  45514. */
  45515. protected _disableLighting: boolean;
  45516. /**
  45517. * Number of Simultaneous lights allowed on the material.
  45518. */
  45519. protected _maxSimultaneousLights: number;
  45520. /**
  45521. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45522. */
  45523. protected _invertNormalMapX: boolean;
  45524. /**
  45525. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45526. */
  45527. protected _invertNormalMapY: boolean;
  45528. /**
  45529. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45530. */
  45531. protected _twoSidedLighting: boolean;
  45532. /**
  45533. * Defines the alpha limits in alpha test mode.
  45534. */
  45535. protected _alphaCutOff: number;
  45536. /**
  45537. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45538. */
  45539. protected _forceAlphaTest: boolean;
  45540. /**
  45541. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45542. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45543. */
  45544. protected _useAlphaFresnel: boolean;
  45545. /**
  45546. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45547. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45548. */
  45549. protected _useLinearAlphaFresnel: boolean;
  45550. /**
  45551. * The transparency mode of the material.
  45552. */
  45553. protected _transparencyMode: Nullable<number>;
  45554. /**
  45555. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  45556. * from cos thetav and roughness:
  45557. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  45558. */
  45559. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  45560. /**
  45561. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45562. */
  45563. protected _forceIrradianceInFragment: boolean;
  45564. /**
  45565. * Force normal to face away from face.
  45566. */
  45567. protected _forceNormalForward: boolean;
  45568. /**
  45569. * Enables specular anti aliasing in the PBR shader.
  45570. * It will both interacts on the Geometry for analytical and IBL lighting.
  45571. * It also prefilter the roughness map based on the bump values.
  45572. */
  45573. protected _enableSpecularAntiAliasing: boolean;
  45574. /**
  45575. * Default configuration related to image processing available in the PBR Material.
  45576. */
  45577. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45578. /**
  45579. * Keep track of the image processing observer to allow dispose and replace.
  45580. */
  45581. private _imageProcessingObserver;
  45582. /**
  45583. * Attaches a new image processing configuration to the PBR Material.
  45584. * @param configuration
  45585. */
  45586. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45587. /**
  45588. * Stores the available render targets.
  45589. */
  45590. private _renderTargets;
  45591. /**
  45592. * Sets the global ambient color for the material used in lighting calculations.
  45593. */
  45594. private _globalAmbientColor;
  45595. /**
  45596. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  45597. */
  45598. private _useLogarithmicDepth;
  45599. /**
  45600. * If set to true, no lighting calculations will be applied.
  45601. */
  45602. private _unlit;
  45603. /**
  45604. * Instantiates a new PBRMaterial instance.
  45605. *
  45606. * @param name The material name
  45607. * @param scene The scene the material will be use in.
  45608. */
  45609. constructor(name: string, scene: Scene);
  45610. /**
  45611. * Gets a boolean indicating that current material needs to register RTT
  45612. */
  45613. readonly hasRenderTargetTextures: boolean;
  45614. /**
  45615. * Gets the name of the material class.
  45616. */
  45617. getClassName(): string;
  45618. /**
  45619. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45620. */
  45621. /**
  45622. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45623. */
  45624. useLogarithmicDepth: boolean;
  45625. /**
  45626. * Gets the current transparency mode.
  45627. */
  45628. /**
  45629. * Sets the transparency mode of the material.
  45630. *
  45631. * | Value | Type | Description |
  45632. * | ----- | ----------------------------------- | ----------- |
  45633. * | 0 | OPAQUE | |
  45634. * | 1 | ALPHATEST | |
  45635. * | 2 | ALPHABLEND | |
  45636. * | 3 | ALPHATESTANDBLEND | |
  45637. *
  45638. */
  45639. transparencyMode: Nullable<number>;
  45640. /**
  45641. * Returns true if alpha blending should be disabled.
  45642. */
  45643. private readonly _disableAlphaBlending;
  45644. /**
  45645. * Specifies whether or not this material should be rendered in alpha blend mode.
  45646. */
  45647. needAlphaBlending(): boolean;
  45648. /**
  45649. * Specifies if the mesh will require alpha blending.
  45650. * @param mesh - BJS mesh.
  45651. */
  45652. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  45653. /**
  45654. * Specifies whether or not this material should be rendered in alpha test mode.
  45655. */
  45656. needAlphaTesting(): boolean;
  45657. /**
  45658. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  45659. */
  45660. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  45661. /**
  45662. * Gets the texture used for the alpha test.
  45663. */
  45664. getAlphaTestTexture(): BaseTexture;
  45665. /**
  45666. * Stores the reflectivity values based on metallic roughness workflow.
  45667. */
  45668. private static _scaledReflectivity;
  45669. /**
  45670. * Specifies that the submesh is ready to be used.
  45671. * @param mesh - BJS mesh.
  45672. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  45673. * @param useInstances - Specifies that instances should be used.
  45674. * @returns - boolean indicating that the submesh is ready or not.
  45675. */
  45676. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45677. /**
  45678. * Specifies if the material uses metallic roughness workflow.
  45679. * @returns boolean specifiying if the material uses metallic roughness workflow.
  45680. */
  45681. isMetallicWorkflow(): boolean;
  45682. private _prepareEffect;
  45683. private _prepareDefines;
  45684. /**
  45685. * Force shader compilation
  45686. */
  45687. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  45688. clipPlane: boolean;
  45689. }>): void;
  45690. /**
  45691. * Initializes the uniform buffer layout for the shader.
  45692. */
  45693. buildUniformLayout(): void;
  45694. /**
  45695. * Unbinds the textures.
  45696. */
  45697. unbind(): void;
  45698. /**
  45699. * Binds the submesh data.
  45700. * @param world - The world matrix.
  45701. * @param mesh - The BJS mesh.
  45702. * @param subMesh - A submesh of the BJS mesh.
  45703. */
  45704. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45705. /**
  45706. * Returns the animatable textures.
  45707. * @returns - Array of animatable textures.
  45708. */
  45709. getAnimatables(): IAnimatable[];
  45710. /**
  45711. * Returns the texture used for reflections.
  45712. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  45713. */
  45714. private _getReflectionTexture;
  45715. /**
  45716. * Returns the texture used for refraction or null if none is used.
  45717. * @returns - Refection texture if present. If no refraction texture and refraction
  45718. * is linked with transparency, returns environment texture. Otherwise, returns null.
  45719. */
  45720. private _getRefractionTexture;
  45721. /**
  45722. * Disposes the resources of the material.
  45723. * @param forceDisposeEffect - Forces the disposal of effects.
  45724. * @param forceDisposeTextures - Forces the disposal of all textures.
  45725. */
  45726. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45727. }
  45728. }
  45729. declare module BABYLON {
  45730. /**
  45731. * The Physically based simple base material of BJS.
  45732. *
  45733. * This enables better naming and convention enforcements on top of the pbrMaterial.
  45734. * It is used as the base class for both the specGloss and metalRough conventions.
  45735. */
  45736. abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  45737. /**
  45738. * Number of Simultaneous lights allowed on the material.
  45739. */
  45740. maxSimultaneousLights: number;
  45741. /**
  45742. * If sets to true, disables all the lights affecting the material.
  45743. */
  45744. disableLighting: boolean;
  45745. /**
  45746. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  45747. */
  45748. environmentTexture: BaseTexture;
  45749. /**
  45750. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  45751. */
  45752. invertNormalMapX: boolean;
  45753. /**
  45754. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  45755. */
  45756. invertNormalMapY: boolean;
  45757. /**
  45758. * Normal map used in the model.
  45759. */
  45760. normalTexture: BaseTexture;
  45761. /**
  45762. * Emissivie color used to self-illuminate the model.
  45763. */
  45764. emissiveColor: Color3;
  45765. /**
  45766. * Emissivie texture used to self-illuminate the model.
  45767. */
  45768. emissiveTexture: BaseTexture;
  45769. /**
  45770. * Occlusion Channel Strenght.
  45771. */
  45772. occlusionStrength: number;
  45773. /**
  45774. * Occlusion Texture of the material (adding extra occlusion effects).
  45775. */
  45776. occlusionTexture: BaseTexture;
  45777. /**
  45778. * Defines the alpha limits in alpha test mode.
  45779. */
  45780. alphaCutOff: number;
  45781. /**
  45782. * Gets the current double sided mode.
  45783. */
  45784. /**
  45785. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45786. */
  45787. doubleSided: boolean;
  45788. /**
  45789. * Stores the pre-calculated light information of a mesh in a texture.
  45790. */
  45791. lightmapTexture: BaseTexture;
  45792. /**
  45793. * If true, the light map contains occlusion information instead of lighting info.
  45794. */
  45795. useLightmapAsShadowmap: boolean;
  45796. /**
  45797. * Return the active textures of the material.
  45798. */
  45799. getActiveTextures(): BaseTexture[];
  45800. hasTexture(texture: BaseTexture): boolean;
  45801. /**
  45802. * Instantiates a new PBRMaterial instance.
  45803. *
  45804. * @param name The material name
  45805. * @param scene The scene the material will be use in.
  45806. */
  45807. constructor(name: string, scene: Scene);
  45808. getClassName(): string;
  45809. }
  45810. }
  45811. declare module BABYLON {
  45812. /**
  45813. * The Physically based material of BJS.
  45814. *
  45815. * This offers the main features of a standard PBR material.
  45816. * For more information, please refer to the documentation :
  45817. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  45818. */
  45819. class PBRMaterial extends PBRBaseMaterial {
  45820. /**
  45821. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45822. */
  45823. static readonly PBRMATERIAL_OPAQUE: number;
  45824. /**
  45825. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45826. */
  45827. static readonly PBRMATERIAL_ALPHATEST: number;
  45828. /**
  45829. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45830. */
  45831. static readonly PBRMATERIAL_ALPHABLEND: number;
  45832. /**
  45833. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45834. * They are also discarded below the alpha cutoff threshold to improve performances.
  45835. */
  45836. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45837. /**
  45838. * Defines the default value of how much AO map is occluding the analytical lights
  45839. * (point spot...).
  45840. */
  45841. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45842. /**
  45843. * Intensity of the direct lights e.g. the four lights available in your scene.
  45844. * This impacts both the direct diffuse and specular highlights.
  45845. */
  45846. directIntensity: number;
  45847. /**
  45848. * Intensity of the emissive part of the material.
  45849. * This helps controlling the emissive effect without modifying the emissive color.
  45850. */
  45851. emissiveIntensity: number;
  45852. /**
  45853. * Intensity of the environment e.g. how much the environment will light the object
  45854. * either through harmonics for rough material or through the refelction for shiny ones.
  45855. */
  45856. environmentIntensity: number;
  45857. /**
  45858. * This is a special control allowing the reduction of the specular highlights coming from the
  45859. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45860. */
  45861. specularIntensity: number;
  45862. /**
  45863. * Debug Control allowing disabling the bump map on this material.
  45864. */
  45865. disableBumpMap: boolean;
  45866. /**
  45867. * AKA Diffuse Texture in standard nomenclature.
  45868. */
  45869. albedoTexture: BaseTexture;
  45870. /**
  45871. * AKA Occlusion Texture in other nomenclature.
  45872. */
  45873. ambientTexture: BaseTexture;
  45874. /**
  45875. * AKA Occlusion Texture Intensity in other nomenclature.
  45876. */
  45877. ambientTextureStrength: number;
  45878. /**
  45879. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45880. * 1 means it completely occludes it
  45881. * 0 mean it has no impact
  45882. */
  45883. ambientTextureImpactOnAnalyticalLights: number;
  45884. /**
  45885. * Stores the alpha values in a texture.
  45886. */
  45887. opacityTexture: BaseTexture;
  45888. /**
  45889. * Stores the reflection values in a texture.
  45890. */
  45891. reflectionTexture: Nullable<BaseTexture>;
  45892. /**
  45893. * Stores the emissive values in a texture.
  45894. */
  45895. emissiveTexture: BaseTexture;
  45896. /**
  45897. * AKA Specular texture in other nomenclature.
  45898. */
  45899. reflectivityTexture: BaseTexture;
  45900. /**
  45901. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45902. */
  45903. metallicTexture: BaseTexture;
  45904. /**
  45905. * Specifies the metallic scalar of the metallic/roughness workflow.
  45906. * Can also be used to scale the metalness values of the metallic texture.
  45907. */
  45908. metallic: Nullable<number>;
  45909. /**
  45910. * Specifies the roughness scalar of the metallic/roughness workflow.
  45911. * Can also be used to scale the roughness values of the metallic texture.
  45912. */
  45913. roughness: Nullable<number>;
  45914. /**
  45915. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45916. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45917. */
  45918. microSurfaceTexture: BaseTexture;
  45919. /**
  45920. * Stores surface normal data used to displace a mesh in a texture.
  45921. */
  45922. bumpTexture: BaseTexture;
  45923. /**
  45924. * Stores the pre-calculated light information of a mesh in a texture.
  45925. */
  45926. lightmapTexture: BaseTexture;
  45927. /**
  45928. * Stores the refracted light information in a texture.
  45929. */
  45930. refractionTexture: BaseTexture;
  45931. /**
  45932. * The color of a material in ambient lighting.
  45933. */
  45934. ambientColor: Color3;
  45935. /**
  45936. * AKA Diffuse Color in other nomenclature.
  45937. */
  45938. albedoColor: Color3;
  45939. /**
  45940. * AKA Specular Color in other nomenclature.
  45941. */
  45942. reflectivityColor: Color3;
  45943. /**
  45944. * The color reflected from the material.
  45945. */
  45946. reflectionColor: Color3;
  45947. /**
  45948. * The color emitted from the material.
  45949. */
  45950. emissiveColor: Color3;
  45951. /**
  45952. * AKA Glossiness in other nomenclature.
  45953. */
  45954. microSurface: number;
  45955. /**
  45956. * source material index of refraction (IOR)' / 'destination material IOR.
  45957. */
  45958. indexOfRefraction: number;
  45959. /**
  45960. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45961. */
  45962. invertRefractionY: boolean;
  45963. /**
  45964. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45965. * Materials half opaque for instance using refraction could benefit from this control.
  45966. */
  45967. linkRefractionWithTransparency: boolean;
  45968. /**
  45969. * If true, the light map contains occlusion information instead of lighting info.
  45970. */
  45971. useLightmapAsShadowmap: boolean;
  45972. /**
  45973. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45974. */
  45975. useAlphaFromAlbedoTexture: boolean;
  45976. /**
  45977. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45978. */
  45979. forceAlphaTest: boolean;
  45980. /**
  45981. * Defines the alpha limits in alpha test mode.
  45982. */
  45983. alphaCutOff: number;
  45984. /**
  45985. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  45986. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45987. */
  45988. useSpecularOverAlpha: boolean;
  45989. /**
  45990. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45991. */
  45992. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45993. /**
  45994. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45995. */
  45996. useRoughnessFromMetallicTextureAlpha: boolean;
  45997. /**
  45998. * Specifies if the metallic texture contains the roughness information in its green channel.
  45999. */
  46000. useRoughnessFromMetallicTextureGreen: boolean;
  46001. /**
  46002. * Specifies if the metallic texture contains the metallness information in its blue channel.
  46003. */
  46004. useMetallnessFromMetallicTextureBlue: boolean;
  46005. /**
  46006. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  46007. */
  46008. useAmbientOcclusionFromMetallicTextureRed: boolean;
  46009. /**
  46010. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  46011. */
  46012. useAmbientInGrayScale: boolean;
  46013. /**
  46014. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  46015. * The material will try to infer what glossiness each pixel should be.
  46016. */
  46017. useAutoMicroSurfaceFromReflectivityMap: boolean;
  46018. /**
  46019. * BJS is using an harcoded light falloff based on a manually sets up range.
  46020. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  46021. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  46022. */
  46023. /**
  46024. * BJS is using an harcoded light falloff based on a manually sets up range.
  46025. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  46026. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  46027. */
  46028. usePhysicalLightFalloff: boolean;
  46029. /**
  46030. * In order to support the falloff compatibility with gltf, a special mode has been added
  46031. * to reproduce the gltf light falloff.
  46032. */
  46033. /**
  46034. * In order to support the falloff compatibility with gltf, a special mode has been added
  46035. * to reproduce the gltf light falloff.
  46036. */
  46037. useGLTFLightFalloff: boolean;
  46038. /**
  46039. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  46040. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  46041. */
  46042. useRadianceOverAlpha: boolean;
  46043. /**
  46044. * Allows using an object space normal map (instead of tangent space).
  46045. */
  46046. useObjectSpaceNormalMap: boolean;
  46047. /**
  46048. * Allows using the bump map in parallax mode.
  46049. */
  46050. useParallax: boolean;
  46051. /**
  46052. * Allows using the bump map in parallax occlusion mode.
  46053. */
  46054. useParallaxOcclusion: boolean;
  46055. /**
  46056. * Controls the scale bias of the parallax mode.
  46057. */
  46058. parallaxScaleBias: number;
  46059. /**
  46060. * If sets to true, disables all the lights affecting the material.
  46061. */
  46062. disableLighting: boolean;
  46063. /**
  46064. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  46065. */
  46066. forceIrradianceInFragment: boolean;
  46067. /**
  46068. * Number of Simultaneous lights allowed on the material.
  46069. */
  46070. maxSimultaneousLights: number;
  46071. /**
  46072. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  46073. */
  46074. invertNormalMapX: boolean;
  46075. /**
  46076. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  46077. */
  46078. invertNormalMapY: boolean;
  46079. /**
  46080. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  46081. */
  46082. twoSidedLighting: boolean;
  46083. /**
  46084. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46085. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  46086. */
  46087. useAlphaFresnel: boolean;
  46088. /**
  46089. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46090. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  46091. */
  46092. useLinearAlphaFresnel: boolean;
  46093. /**
  46094. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46095. * And/Or occlude the blended part.
  46096. */
  46097. environmentBRDFTexture: Nullable<BaseTexture>;
  46098. /**
  46099. * Force normal to face away from face.
  46100. */
  46101. forceNormalForward: boolean;
  46102. /**
  46103. * Enables specular anti aliasing in the PBR shader.
  46104. * It will both interacts on the Geometry for analytical and IBL lighting.
  46105. * It also prefilter the roughness map based on the bump values.
  46106. */
  46107. enableSpecularAntiAliasing: boolean;
  46108. /**
  46109. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  46110. * makes the reflect vector face the model (under horizon).
  46111. */
  46112. useHorizonOcclusion: boolean;
  46113. /**
  46114. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  46115. * too much the area relying on ambient texture to define their ambient occlusion.
  46116. */
  46117. useRadianceOcclusion: boolean;
  46118. /**
  46119. * If set to true, no lighting calculations will be applied.
  46120. */
  46121. unlit: boolean;
  46122. /**
  46123. * Gets the image processing configuration used either in this material.
  46124. */
  46125. /**
  46126. * Sets the Default image processing configuration used either in the this material.
  46127. *
  46128. * If sets to null, the scene one is in use.
  46129. */
  46130. imageProcessingConfiguration: ImageProcessingConfiguration;
  46131. /**
  46132. * Gets wether the color curves effect is enabled.
  46133. */
  46134. /**
  46135. * Sets wether the color curves effect is enabled.
  46136. */
  46137. cameraColorCurvesEnabled: boolean;
  46138. /**
  46139. * Gets wether the color grading effect is enabled.
  46140. */
  46141. /**
  46142. * Gets wether the color grading effect is enabled.
  46143. */
  46144. cameraColorGradingEnabled: boolean;
  46145. /**
  46146. * Gets wether tonemapping is enabled or not.
  46147. */
  46148. /**
  46149. * Sets wether tonemapping is enabled or not
  46150. */
  46151. cameraToneMappingEnabled: boolean;
  46152. /**
  46153. * The camera exposure used on this material.
  46154. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46155. * This corresponds to a photographic exposure.
  46156. */
  46157. /**
  46158. * The camera exposure used on this material.
  46159. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46160. * This corresponds to a photographic exposure.
  46161. */
  46162. cameraExposure: number;
  46163. /**
  46164. * Gets The camera contrast used on this material.
  46165. */
  46166. /**
  46167. * Sets The camera contrast used on this material.
  46168. */
  46169. cameraContrast: number;
  46170. /**
  46171. * Gets the Color Grading 2D Lookup Texture.
  46172. */
  46173. /**
  46174. * Sets the Color Grading 2D Lookup Texture.
  46175. */
  46176. cameraColorGradingTexture: Nullable<BaseTexture>;
  46177. /**
  46178. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46179. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46180. * 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;
  46181. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46182. */
  46183. /**
  46184. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46185. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46186. * 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;
  46187. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46188. */
  46189. cameraColorCurves: Nullable<ColorCurves>;
  46190. /**
  46191. * Instantiates a new PBRMaterial instance.
  46192. *
  46193. * @param name The material name
  46194. * @param scene The scene the material will be use in.
  46195. */
  46196. constructor(name: string, scene: Scene);
  46197. /**
  46198. * Returns the name of this material class.
  46199. */
  46200. getClassName(): string;
  46201. /**
  46202. * Returns an array of the actively used textures.
  46203. * @returns - Array of BaseTextures
  46204. */
  46205. getActiveTextures(): BaseTexture[];
  46206. /**
  46207. * Checks to see if a texture is used in the material.
  46208. * @param texture - Base texture to use.
  46209. * @returns - Boolean specifying if a texture is used in the material.
  46210. */
  46211. hasTexture(texture: BaseTexture): boolean;
  46212. /**
  46213. * Makes a duplicate of the current material.
  46214. * @param name - name to use for the new material.
  46215. */
  46216. clone(name: string): PBRMaterial;
  46217. /**
  46218. * Serializes this PBR Material.
  46219. * @returns - An object with the serialized material.
  46220. */
  46221. serialize(): any;
  46222. /**
  46223. * Parses a PBR Material from a serialized object.
  46224. * @param source - Serialized object.
  46225. * @param scene - BJS scene instance.
  46226. * @param rootUrl - url for the scene object
  46227. * @returns - PBRMaterial
  46228. */
  46229. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  46230. }
  46231. }
  46232. declare module BABYLON {
  46233. /**
  46234. * The PBR material of BJS following the metal roughness convention.
  46235. *
  46236. * This fits to the PBR convention in the GLTF definition:
  46237. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  46238. */
  46239. class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  46240. /**
  46241. * The base color has two different interpretations depending on the value of metalness.
  46242. * When the material is a metal, the base color is the specific measured reflectance value
  46243. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  46244. * of the material.
  46245. */
  46246. baseColor: Color3;
  46247. /**
  46248. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  46249. * well as opacity information in the alpha channel.
  46250. */
  46251. baseTexture: BaseTexture;
  46252. /**
  46253. * Specifies the metallic scalar value of the material.
  46254. * Can also be used to scale the metalness values of the metallic texture.
  46255. */
  46256. metallic: number;
  46257. /**
  46258. * Specifies the roughness scalar value of the material.
  46259. * Can also be used to scale the roughness values of the metallic texture.
  46260. */
  46261. roughness: number;
  46262. /**
  46263. * Texture containing both the metallic value in the B channel and the
  46264. * roughness value in the G channel to keep better precision.
  46265. */
  46266. metallicRoughnessTexture: BaseTexture;
  46267. /**
  46268. * Instantiates a new PBRMetalRoughnessMaterial instance.
  46269. *
  46270. * @param name The material name
  46271. * @param scene The scene the material will be use in.
  46272. */
  46273. constructor(name: string, scene: Scene);
  46274. /**
  46275. * Return the currrent class name of the material.
  46276. */
  46277. getClassName(): string;
  46278. /**
  46279. * Return the active textures of the material.
  46280. */
  46281. getActiveTextures(): BaseTexture[];
  46282. /**
  46283. * Checks to see if a texture is used in the material.
  46284. * @param texture - Base texture to use.
  46285. * @returns - Boolean specifying if a texture is used in the material.
  46286. */
  46287. hasTexture(texture: BaseTexture): boolean;
  46288. /**
  46289. * Makes a duplicate of the current material.
  46290. * @param name - name to use for the new material.
  46291. */
  46292. clone(name: string): PBRMetallicRoughnessMaterial;
  46293. /**
  46294. * Serialize the material to a parsable JSON object.
  46295. */
  46296. serialize(): any;
  46297. /**
  46298. * Parses a JSON object correponding to the serialize function.
  46299. */
  46300. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  46301. }
  46302. }
  46303. declare module BABYLON {
  46304. /**
  46305. * The PBR material of BJS following the specular glossiness convention.
  46306. *
  46307. * This fits to the PBR convention in the GLTF definition:
  46308. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  46309. */
  46310. class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  46311. /**
  46312. * Specifies the diffuse color of the material.
  46313. */
  46314. diffuseColor: Color3;
  46315. /**
  46316. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  46317. * channel.
  46318. */
  46319. diffuseTexture: BaseTexture;
  46320. /**
  46321. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  46322. */
  46323. specularColor: Color3;
  46324. /**
  46325. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  46326. */
  46327. glossiness: number;
  46328. /**
  46329. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  46330. */
  46331. specularGlossinessTexture: BaseTexture;
  46332. /**
  46333. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  46334. *
  46335. * @param name The material name
  46336. * @param scene The scene the material will be use in.
  46337. */
  46338. constructor(name: string, scene: Scene);
  46339. /**
  46340. * Return the currrent class name of the material.
  46341. */
  46342. getClassName(): string;
  46343. /**
  46344. * Return the active textures of the material.
  46345. */
  46346. getActiveTextures(): BaseTexture[];
  46347. /**
  46348. * Checks to see if a texture is used in the material.
  46349. * @param texture - Base texture to use.
  46350. * @returns - Boolean specifying if a texture is used in the material.
  46351. */
  46352. hasTexture(texture: BaseTexture): boolean;
  46353. /**
  46354. * Makes a duplicate of the current material.
  46355. * @param name - name to use for the new material.
  46356. */
  46357. clone(name: string): PBRSpecularGlossinessMaterial;
  46358. /**
  46359. * Serialize the material to a parsable JSON object.
  46360. */
  46361. serialize(): any;
  46362. /**
  46363. * Parses a JSON object correponding to the serialize function.
  46364. */
  46365. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  46366. }
  46367. }
  46368. declare module BABYLON {
  46369. /**
  46370. * Base class of all the textures in babylon.
  46371. * It groups all the common properties the materials, post process, lights... might need
  46372. * in order to make a correct use of the texture.
  46373. */
  46374. class BaseTexture {
  46375. /**
  46376. * Default anisotropic filtering level for the application.
  46377. * It is set to 4 as a good tradeoff between perf and quality.
  46378. */
  46379. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  46380. /**
  46381. * Gets or sets the unique id of the texture
  46382. */
  46383. uniqueId: number;
  46384. /**
  46385. * Define the name of the texture.
  46386. */
  46387. name: string;
  46388. /**
  46389. * Gets or sets an object used to store user defined information.
  46390. */
  46391. metadata: any;
  46392. /**
  46393. * For internal use only. Please do not use.
  46394. */
  46395. reservedDataStore: any;
  46396. private _hasAlpha;
  46397. /**
  46398. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  46399. */
  46400. hasAlpha: boolean;
  46401. /**
  46402. * Defines if the alpha value should be determined via the rgb values.
  46403. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  46404. */
  46405. getAlphaFromRGB: boolean;
  46406. /**
  46407. * Intensity or strength of the texture.
  46408. * It is commonly used by materials to fine tune the intensity of the texture
  46409. */
  46410. level: number;
  46411. /**
  46412. * Define the UV chanel to use starting from 0 and defaulting to 0.
  46413. * This is part of the texture as textures usually maps to one uv set.
  46414. */
  46415. coordinatesIndex: number;
  46416. private _coordinatesMode;
  46417. /**
  46418. * How a texture is mapped.
  46419. *
  46420. * | Value | Type | Description |
  46421. * | ----- | ----------------------------------- | ----------- |
  46422. * | 0 | EXPLICIT_MODE | |
  46423. * | 1 | SPHERICAL_MODE | |
  46424. * | 2 | PLANAR_MODE | |
  46425. * | 3 | CUBIC_MODE | |
  46426. * | 4 | PROJECTION_MODE | |
  46427. * | 5 | SKYBOX_MODE | |
  46428. * | 6 | INVCUBIC_MODE | |
  46429. * | 7 | EQUIRECTANGULAR_MODE | |
  46430. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  46431. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  46432. */
  46433. coordinatesMode: number;
  46434. /**
  46435. * | Value | Type | Description |
  46436. * | ----- | ------------------ | ----------- |
  46437. * | 0 | CLAMP_ADDRESSMODE | |
  46438. * | 1 | WRAP_ADDRESSMODE | |
  46439. * | 2 | MIRROR_ADDRESSMODE | |
  46440. */
  46441. wrapU: number;
  46442. /**
  46443. * | Value | Type | Description |
  46444. * | ----- | ------------------ | ----------- |
  46445. * | 0 | CLAMP_ADDRESSMODE | |
  46446. * | 1 | WRAP_ADDRESSMODE | |
  46447. * | 2 | MIRROR_ADDRESSMODE | |
  46448. */
  46449. wrapV: number;
  46450. /**
  46451. * | Value | Type | Description |
  46452. * | ----- | ------------------ | ----------- |
  46453. * | 0 | CLAMP_ADDRESSMODE | |
  46454. * | 1 | WRAP_ADDRESSMODE | |
  46455. * | 2 | MIRROR_ADDRESSMODE | |
  46456. */
  46457. wrapR: number;
  46458. /**
  46459. * With compliant hardware and browser (supporting anisotropic filtering)
  46460. * this defines the level of anisotropic filtering in the texture.
  46461. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  46462. */
  46463. anisotropicFilteringLevel: number;
  46464. /**
  46465. * Define if the texture is a cube texture or if false a 2d texture.
  46466. */
  46467. isCube: boolean;
  46468. /**
  46469. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  46470. */
  46471. is3D: boolean;
  46472. /**
  46473. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  46474. * HDR texture are usually stored in linear space.
  46475. * This only impacts the PBR and Background materials
  46476. */
  46477. gammaSpace: boolean;
  46478. /**
  46479. * Gets whether or not the texture contains RGBD data.
  46480. */
  46481. readonly isRGBD: boolean;
  46482. /**
  46483. * Is Z inverted in the texture (useful in a cube texture).
  46484. */
  46485. invertZ: boolean;
  46486. /**
  46487. * Are mip maps generated for this texture or not.
  46488. */
  46489. readonly noMipmap: boolean;
  46490. /**
  46491. * @hidden
  46492. */
  46493. lodLevelInAlpha: boolean;
  46494. /**
  46495. * With prefiltered texture, defined the offset used during the prefiltering steps.
  46496. */
  46497. lodGenerationOffset: number;
  46498. /**
  46499. * With prefiltered texture, defined the scale used during the prefiltering steps.
  46500. */
  46501. lodGenerationScale: number;
  46502. /**
  46503. * Define if the texture is a render target.
  46504. */
  46505. isRenderTarget: boolean;
  46506. /**
  46507. * Define the unique id of the texture in the scene.
  46508. */
  46509. readonly uid: string;
  46510. /**
  46511. * Return a string representation of the texture.
  46512. * @returns the texture as a string
  46513. */
  46514. toString(): string;
  46515. /**
  46516. * Get the class name of the texture.
  46517. * @returns "BaseTexture"
  46518. */
  46519. getClassName(): string;
  46520. /**
  46521. * Define the list of animation attached to the texture.
  46522. */
  46523. animations: Animation[];
  46524. /**
  46525. * An event triggered when the texture is disposed.
  46526. */
  46527. onDisposeObservable: Observable<BaseTexture>;
  46528. private _onDisposeObserver;
  46529. /**
  46530. * Callback triggered when the texture has been disposed.
  46531. * Kept for back compatibility, you can use the onDisposeObservable instead.
  46532. */
  46533. onDispose: () => void;
  46534. /**
  46535. * Define the current state of the loading sequence when in delayed load mode.
  46536. */
  46537. delayLoadState: number;
  46538. private _scene;
  46539. /** @hidden */
  46540. _samplingMode: number;
  46541. /** @hidden */
  46542. _texture: Nullable<InternalTexture>;
  46543. private _uid;
  46544. /**
  46545. * Define if the texture is preventinga material to render or not.
  46546. * If not and the texture is not ready, the engine will use a default black texture instead.
  46547. */
  46548. readonly isBlocking: boolean;
  46549. /**
  46550. * Instantiates a new BaseTexture.
  46551. * Base class of all the textures in babylon.
  46552. * It groups all the common properties the materials, post process, lights... might need
  46553. * in order to make a correct use of the texture.
  46554. * @param scene Define the scene the texture blongs to
  46555. */
  46556. constructor(scene: Nullable<Scene>);
  46557. /**
  46558. * Get the scene the texture belongs to.
  46559. * @returns the scene or null if undefined
  46560. */
  46561. getScene(): Nullable<Scene>;
  46562. /**
  46563. * Get the texture transform matrix used to offset tile the texture for istance.
  46564. * @returns the transformation matrix
  46565. */
  46566. getTextureMatrix(): Matrix;
  46567. /**
  46568. * Get the texture reflection matrix used to rotate/transform the reflection.
  46569. * @returns the reflection matrix
  46570. */
  46571. getReflectionTextureMatrix(): Matrix;
  46572. /**
  46573. * Get the underlying lower level texture from Babylon.
  46574. * @returns the insternal texture
  46575. */
  46576. getInternalTexture(): Nullable<InternalTexture>;
  46577. /**
  46578. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  46579. * @returns true if ready or not blocking
  46580. */
  46581. isReadyOrNotBlocking(): boolean;
  46582. /**
  46583. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  46584. * @returns true if fully ready
  46585. */
  46586. isReady(): boolean;
  46587. private _cachedSize;
  46588. /**
  46589. * Get the size of the texture.
  46590. * @returns the texture size.
  46591. */
  46592. getSize(): ISize;
  46593. /**
  46594. * Get the base size of the texture.
  46595. * It can be different from the size if the texture has been resized for POT for instance
  46596. * @returns the base size
  46597. */
  46598. getBaseSize(): ISize;
  46599. /**
  46600. * Update the sampling mode of the texture.
  46601. * Default is Trilinear mode.
  46602. *
  46603. * | Value | Type | Description |
  46604. * | ----- | ------------------ | ----------- |
  46605. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  46606. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  46607. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  46608. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  46609. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  46610. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  46611. * | 7 | NEAREST_LINEAR | |
  46612. * | 8 | NEAREST_NEAREST | |
  46613. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  46614. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  46615. * | 11 | LINEAR_LINEAR | |
  46616. * | 12 | LINEAR_NEAREST | |
  46617. *
  46618. * > _mag_: magnification filter (close to the viewer)
  46619. * > _min_: minification filter (far from the viewer)
  46620. * > _mip_: filter used between mip map levels
  46621. *@param samplingMode Define the new sampling mode of the texture
  46622. */
  46623. updateSamplingMode(samplingMode: number): void;
  46624. /**
  46625. * Scales the texture if is `canRescale()`
  46626. * @param ratio the resize factor we want to use to rescale
  46627. */
  46628. scale(ratio: number): void;
  46629. /**
  46630. * Get if the texture can rescale.
  46631. */
  46632. readonly canRescale: boolean;
  46633. /** @hidden */
  46634. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  46635. /** @hidden */
  46636. _rebuild(): void;
  46637. /**
  46638. * Triggers the load sequence in delayed load mode.
  46639. */
  46640. delayLoad(): void;
  46641. /**
  46642. * Clones the texture.
  46643. * @returns the cloned texture
  46644. */
  46645. clone(): Nullable<BaseTexture>;
  46646. /**
  46647. * Get the texture underlying type (INT, FLOAT...)
  46648. */
  46649. readonly textureType: number;
  46650. /**
  46651. * Get the texture underlying format (RGB, RGBA...)
  46652. */
  46653. readonly textureFormat: number;
  46654. /**
  46655. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  46656. * This will returns an RGBA array buffer containing either in values (0-255) or
  46657. * float values (0-1) depending of the underlying buffer type.
  46658. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  46659. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  46660. * @param buffer defines a user defined buffer to fill with data (can be null)
  46661. * @returns The Array buffer containing the pixels data.
  46662. */
  46663. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  46664. /**
  46665. * Release and destroy the underlying lower level texture aka internalTexture.
  46666. */
  46667. releaseInternalTexture(): void;
  46668. /**
  46669. * Get the polynomial representation of the texture data.
  46670. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  46671. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  46672. */
  46673. sphericalPolynomial: Nullable<SphericalPolynomial>;
  46674. /** @hidden */
  46675. readonly _lodTextureHigh: Nullable<BaseTexture>;
  46676. /** @hidden */
  46677. readonly _lodTextureMid: Nullable<BaseTexture>;
  46678. /** @hidden */
  46679. readonly _lodTextureLow: Nullable<BaseTexture>;
  46680. /**
  46681. * Dispose the texture and release its associated resources.
  46682. */
  46683. dispose(): void;
  46684. /**
  46685. * Serialize the texture into a JSON representation that can be parsed later on.
  46686. * @returns the JSON representation of the texture
  46687. */
  46688. serialize(): any;
  46689. /**
  46690. * Helper function to be called back once a list of texture contains only ready textures.
  46691. * @param textures Define the list of textures to wait for
  46692. * @param callback Define the callback triggered once the entire list will be ready
  46693. */
  46694. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  46695. }
  46696. }
  46697. declare module BABYLON {
  46698. /**
  46699. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  46700. * It can help converting any input color in a desired output one. This can then be used to create effects
  46701. * from sepia, black and white to sixties or futuristic rendering...
  46702. *
  46703. * The only supported format is currently 3dl.
  46704. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  46705. */
  46706. class ColorGradingTexture extends BaseTexture {
  46707. /**
  46708. * The current texture matrix. (will always be identity in color grading texture)
  46709. */
  46710. private _textureMatrix;
  46711. /**
  46712. * The texture URL.
  46713. */
  46714. url: string;
  46715. /**
  46716. * Empty line regex stored for GC.
  46717. */
  46718. private static _noneEmptyLineRegex;
  46719. private _engine;
  46720. /**
  46721. * Instantiates a ColorGradingTexture from the following parameters.
  46722. *
  46723. * @param url The location of the color gradind data (currently only supporting 3dl)
  46724. * @param scene The scene the texture will be used in
  46725. */
  46726. constructor(url: string, scene: Scene);
  46727. /**
  46728. * Returns the texture matrix used in most of the material.
  46729. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  46730. */
  46731. getTextureMatrix(): Matrix;
  46732. /**
  46733. * Occurs when the file being loaded is a .3dl LUT file.
  46734. */
  46735. private load3dlTexture;
  46736. /**
  46737. * Starts the loading process of the texture.
  46738. */
  46739. private loadTexture;
  46740. /**
  46741. * Clones the color gradind texture.
  46742. */
  46743. clone(): ColorGradingTexture;
  46744. /**
  46745. * Called during delayed load for textures.
  46746. */
  46747. delayLoad(): void;
  46748. /**
  46749. * Parses a color grading texture serialized by Babylon.
  46750. * @param parsedTexture The texture information being parsedTexture
  46751. * @param scene The scene to load the texture in
  46752. * @param rootUrl The root url of the data assets to load
  46753. * @return A color gradind texture
  46754. */
  46755. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<ColorGradingTexture>;
  46756. /**
  46757. * Serializes the LUT texture to json format.
  46758. */
  46759. serialize(): any;
  46760. }
  46761. }
  46762. declare module BABYLON {
  46763. /**
  46764. * Class for creating a cube texture
  46765. */
  46766. class CubeTexture extends BaseTexture {
  46767. private _delayedOnLoad;
  46768. /**
  46769. * The url of the texture
  46770. */
  46771. url: string;
  46772. /**
  46773. * Gets or sets the center of the bounding box associated with the cube texture.
  46774. * It must define where the camera used to render the texture was set
  46775. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  46776. */
  46777. boundingBoxPosition: Vector3;
  46778. private _boundingBoxSize;
  46779. /**
  46780. * Gets or sets the size of the bounding box associated with the cube texture
  46781. * When defined, the cubemap will switch to local mode
  46782. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  46783. * @example https://www.babylonjs-playground.com/#RNASML
  46784. */
  46785. /**
  46786. * Returns the bounding box size
  46787. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  46788. */
  46789. boundingBoxSize: Vector3;
  46790. protected _rotationY: number;
  46791. /**
  46792. * Sets texture matrix rotation angle around Y axis in radians.
  46793. */
  46794. /**
  46795. * Gets texture matrix rotation angle around Y axis radians.
  46796. */
  46797. rotationY: number;
  46798. /**
  46799. * Are mip maps generated for this texture or not.
  46800. */
  46801. readonly noMipmap: boolean;
  46802. private _noMipmap;
  46803. private _files;
  46804. private _extensions;
  46805. private _textureMatrix;
  46806. private _format;
  46807. private _createPolynomials;
  46808. /** @hidden */
  46809. _prefiltered: boolean;
  46810. /**
  46811. * Creates a cube texture from an array of image urls
  46812. * @param files defines an array of image urls
  46813. * @param scene defines the hosting scene
  46814. * @param noMipmap specifies if mip maps are not used
  46815. * @returns a cube texture
  46816. */
  46817. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  46818. /**
  46819. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  46820. * @param url defines the url of the prefiltered texture
  46821. * @param scene defines the scene the texture is attached to
  46822. * @param forcedExtension defines the extension of the file if different from the url
  46823. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  46824. * @return the prefiltered texture
  46825. */
  46826. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  46827. /**
  46828. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  46829. * as prefiltered data.
  46830. * @param rootUrl defines the url of the texture or the root name of the six images
  46831. * @param scene defines the scene the texture is attached to
  46832. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  46833. * @param noMipmap defines if mipmaps should be created or not
  46834. * @param files defines the six files to load for the different faces
  46835. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  46836. * @param onError defines a callback triggered in case of error during load
  46837. * @param format defines the internal format to use for the texture once loaded
  46838. * @param prefiltered defines whether or not the texture is created from prefiltered data
  46839. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  46840. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  46841. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  46842. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  46843. * @return the cube texture
  46844. */
  46845. 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);
  46846. /**
  46847. * Get the current class name of the texture useful for serialization or dynamic coding.
  46848. * @returns "CubeTexture"
  46849. */
  46850. getClassName(): string;
  46851. /**
  46852. * Update the url (and optional buffer) of this texture if url was null during construction.
  46853. * @param url the url of the texture
  46854. * @param forcedExtension defines the extension to use
  46855. * @param onLoad callback called when the texture is loaded (defaults to null)
  46856. */
  46857. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  46858. /**
  46859. * Delays loading of the cube texture
  46860. * @param forcedExtension defines the extension to use
  46861. */
  46862. delayLoad(forcedExtension?: string): void;
  46863. /**
  46864. * Returns the reflection texture matrix
  46865. * @returns the reflection texture matrix
  46866. */
  46867. getReflectionTextureMatrix(): Matrix;
  46868. /**
  46869. * Sets the reflection texture matrix
  46870. * @param value Reflection texture matrix
  46871. */
  46872. setReflectionTextureMatrix(value: Matrix): void;
  46873. /**
  46874. * Parses text to create a cube texture
  46875. * @param parsedTexture define the serialized text to read from
  46876. * @param scene defines the hosting scene
  46877. * @param rootUrl defines the root url of the cube texture
  46878. * @returns a cube texture
  46879. */
  46880. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  46881. /**
  46882. * Makes a clone, or deep copy, of the cube texture
  46883. * @returns a new cube texture
  46884. */
  46885. clone(): CubeTexture;
  46886. }
  46887. }
  46888. declare module BABYLON {
  46889. /**
  46890. * A class extending Texture allowing drawing on a texture
  46891. * @see http://doc.babylonjs.com/how_to/dynamictexture
  46892. */
  46893. class DynamicTexture extends Texture {
  46894. private _generateMipMaps;
  46895. private _canvas;
  46896. private _context;
  46897. private _engine;
  46898. /**
  46899. * Creates a DynamicTexture
  46900. * @param name defines the name of the texture
  46901. * @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
  46902. * @param scene defines the scene where you want the texture
  46903. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  46904. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  46905. * @param format defines the texture format to use (default is BABYLON.Engine.TEXTUREFORMAT_RGBA)
  46906. */
  46907. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  46908. /**
  46909. * Get the current class name of the texture useful for serialization or dynamic coding.
  46910. * @returns "DynamicTexture"
  46911. */
  46912. getClassName(): string;
  46913. /**
  46914. * Gets the current state of canRescale
  46915. */
  46916. readonly canRescale: boolean;
  46917. private _recreate;
  46918. /**
  46919. * Scales the texture
  46920. * @param ratio the scale factor to apply to both width and height
  46921. */
  46922. scale(ratio: number): void;
  46923. /**
  46924. * Resizes the texture
  46925. * @param width the new width
  46926. * @param height the new height
  46927. */
  46928. scaleTo(width: number, height: number): void;
  46929. /**
  46930. * Gets the context of the canvas used by the texture
  46931. * @returns the canvas context of the dynamic texture
  46932. */
  46933. getContext(): CanvasRenderingContext2D;
  46934. /**
  46935. * Clears the texture
  46936. */
  46937. clear(): void;
  46938. /**
  46939. * Updates the texture
  46940. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  46941. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  46942. */
  46943. update(invertY?: boolean, premulAlpha?: boolean): void;
  46944. /**
  46945. * Draws text onto the texture
  46946. * @param text defines the text to be drawn
  46947. * @param x defines the placement of the text from the left
  46948. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  46949. * @param font defines the font to be used with font-style, font-size, font-name
  46950. * @param color defines the color used for the text
  46951. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  46952. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  46953. * @param update defines whether texture is immediately update (default is true)
  46954. */
  46955. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  46956. /**
  46957. * Clones the texture
  46958. * @returns the clone of the texture.
  46959. */
  46960. clone(): DynamicTexture;
  46961. /**
  46962. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  46963. * @returns a serialized dynamic texture object
  46964. */
  46965. serialize(): any;
  46966. /** @hidden */
  46967. _rebuild(): void;
  46968. }
  46969. }
  46970. declare module BABYLON {
  46971. /**
  46972. * This represents a texture coming from an HDR input.
  46973. *
  46974. * The only supported format is currently panorama picture stored in RGBE format.
  46975. * Example of such files can be found on HDRLib: http://hdrlib.com/
  46976. */
  46977. class HDRCubeTexture extends BaseTexture {
  46978. private static _facesMapping;
  46979. private _generateHarmonics;
  46980. private _noMipmap;
  46981. private _textureMatrix;
  46982. private _size;
  46983. private _onLoad;
  46984. private _onError;
  46985. /**
  46986. * The texture URL.
  46987. */
  46988. url: string;
  46989. /**
  46990. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  46991. */
  46992. coordinatesMode: number;
  46993. protected _isBlocking: boolean;
  46994. /**
  46995. * Sets wether or not the texture is blocking during loading.
  46996. */
  46997. /**
  46998. * Gets wether or not the texture is blocking during loading.
  46999. */
  47000. isBlocking: boolean;
  47001. protected _rotationY: number;
  47002. /**
  47003. * Sets texture matrix rotation angle around Y axis in radians.
  47004. */
  47005. /**
  47006. * Gets texture matrix rotation angle around Y axis radians.
  47007. */
  47008. rotationY: number;
  47009. /**
  47010. * Gets or sets the center of the bounding box associated with the cube texture
  47011. * It must define where the camera used to render the texture was set
  47012. */
  47013. boundingBoxPosition: Vector3;
  47014. private _boundingBoxSize;
  47015. /**
  47016. * Gets or sets the size of the bounding box associated with the cube texture
  47017. * When defined, the cubemap will switch to local mode
  47018. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  47019. * @example https://www.babylonjs-playground.com/#RNASML
  47020. */
  47021. boundingBoxSize: Vector3;
  47022. /**
  47023. * Instantiates an HDRTexture from the following parameters.
  47024. *
  47025. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  47026. * @param scene The scene the texture will be used in
  47027. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  47028. * @param noMipmap Forces to not generate the mipmap if true
  47029. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  47030. * @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)
  47031. * @param reserved Reserved flag for internal use.
  47032. */
  47033. 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>);
  47034. /**
  47035. * Get the current class name of the texture useful for serialization or dynamic coding.
  47036. * @returns "HDRCubeTexture"
  47037. */
  47038. getClassName(): string;
  47039. /**
  47040. * Occurs when the file is raw .hdr file.
  47041. */
  47042. private loadTexture;
  47043. clone(): HDRCubeTexture;
  47044. delayLoad(): void;
  47045. /**
  47046. * Get the texture reflection matrix used to rotate/transform the reflection.
  47047. * @returns the reflection matrix
  47048. */
  47049. getReflectionTextureMatrix(): Matrix;
  47050. /**
  47051. * Set the texture reflection matrix used to rotate/transform the reflection.
  47052. * @param value Define the reflection matrix to set
  47053. */
  47054. setReflectionTextureMatrix(value: Matrix): void;
  47055. /**
  47056. * Parses a JSON representation of an HDR Texture in order to create the texture
  47057. * @param parsedTexture Define the JSON representation
  47058. * @param scene Define the scene the texture should be created in
  47059. * @param rootUrl Define the root url in case we need to load relative dependencies
  47060. * @returns the newly created texture after parsing
  47061. */
  47062. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  47063. serialize(): any;
  47064. }
  47065. }
  47066. declare module BABYLON {
  47067. /**
  47068. * Class used to store data associated with WebGL texture data for the engine
  47069. * This class should not be used directly
  47070. */
  47071. class InternalTexture implements IInternalTextureTracker {
  47072. /**
  47073. * The source of the texture data is unknown
  47074. */
  47075. static DATASOURCE_UNKNOWN: number;
  47076. /**
  47077. * Texture data comes from an URL
  47078. */
  47079. static DATASOURCE_URL: number;
  47080. /**
  47081. * Texture data is only used for temporary storage
  47082. */
  47083. static DATASOURCE_TEMP: number;
  47084. /**
  47085. * Texture data comes from raw data (ArrayBuffer)
  47086. */
  47087. static DATASOURCE_RAW: number;
  47088. /**
  47089. * Texture content is dynamic (video or dynamic texture)
  47090. */
  47091. static DATASOURCE_DYNAMIC: number;
  47092. /**
  47093. * Texture content is generated by rendering to it
  47094. */
  47095. static DATASOURCE_RENDERTARGET: number;
  47096. /**
  47097. * Texture content is part of a multi render target process
  47098. */
  47099. static DATASOURCE_MULTIRENDERTARGET: number;
  47100. /**
  47101. * Texture data comes from a cube data file
  47102. */
  47103. static DATASOURCE_CUBE: number;
  47104. /**
  47105. * Texture data comes from a raw cube data
  47106. */
  47107. static DATASOURCE_CUBERAW: number;
  47108. /**
  47109. * Texture data come from a prefiltered cube data file
  47110. */
  47111. static DATASOURCE_CUBEPREFILTERED: number;
  47112. /**
  47113. * Texture content is raw 3D data
  47114. */
  47115. static DATASOURCE_RAW3D: number;
  47116. /**
  47117. * Texture content is a depth texture
  47118. */
  47119. static DATASOURCE_DEPTHTEXTURE: number;
  47120. /**
  47121. * Texture data comes from a raw cube data encoded with RGBD
  47122. */
  47123. static DATASOURCE_CUBERAW_RGBD: number;
  47124. /**
  47125. * Defines if the texture is ready
  47126. */
  47127. isReady: boolean;
  47128. /**
  47129. * Defines if the texture is a cube texture
  47130. */
  47131. isCube: boolean;
  47132. /**
  47133. * Defines if the texture contains 3D data
  47134. */
  47135. is3D: boolean;
  47136. /**
  47137. * Gets the URL used to load this texture
  47138. */
  47139. url: string;
  47140. /**
  47141. * Gets the sampling mode of the texture
  47142. */
  47143. samplingMode: number;
  47144. /**
  47145. * Gets a boolean indicating if the texture needs mipmaps generation
  47146. */
  47147. generateMipMaps: boolean;
  47148. /**
  47149. * Gets the number of samples used by the texture (WebGL2+ only)
  47150. */
  47151. samples: number;
  47152. /**
  47153. * Gets the type of the texture (int, float...)
  47154. */
  47155. type: number;
  47156. /**
  47157. * Gets the format of the texture (RGB, RGBA...)
  47158. */
  47159. format: number;
  47160. /**
  47161. * Observable called when the texture is loaded
  47162. */
  47163. onLoadedObservable: Observable<InternalTexture>;
  47164. /**
  47165. * Gets the width of the texture
  47166. */
  47167. width: number;
  47168. /**
  47169. * Gets the height of the texture
  47170. */
  47171. height: number;
  47172. /**
  47173. * Gets the depth of the texture
  47174. */
  47175. depth: number;
  47176. /**
  47177. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  47178. */
  47179. baseWidth: number;
  47180. /**
  47181. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  47182. */
  47183. baseHeight: number;
  47184. /**
  47185. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  47186. */
  47187. baseDepth: number;
  47188. /**
  47189. * Gets a boolean indicating if the texture is inverted on Y axis
  47190. */
  47191. invertY: boolean;
  47192. /**
  47193. * Gets or set the previous tracker in the list
  47194. */
  47195. previous: Nullable<IInternalTextureTracker>;
  47196. /**
  47197. * Gets or set the next tracker in the list
  47198. */
  47199. next: Nullable<IInternalTextureTracker>;
  47200. /** @hidden */
  47201. _invertVScale: boolean;
  47202. /** @hidden */
  47203. _initialSlot: number;
  47204. /** @hidden */
  47205. _designatedSlot: number;
  47206. /** @hidden */
  47207. _dataSource: number;
  47208. /** @hidden */
  47209. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  47210. /** @hidden */
  47211. _bufferView: Nullable<ArrayBufferView>;
  47212. /** @hidden */
  47213. _bufferViewArray: Nullable<ArrayBufferView[]>;
  47214. /** @hidden */
  47215. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  47216. /** @hidden */
  47217. _size: number;
  47218. /** @hidden */
  47219. _extension: string;
  47220. /** @hidden */
  47221. _files: Nullable<string[]>;
  47222. /** @hidden */
  47223. _workingCanvas: HTMLCanvasElement;
  47224. /** @hidden */
  47225. _workingContext: CanvasRenderingContext2D;
  47226. /** @hidden */
  47227. _framebuffer: Nullable<WebGLFramebuffer>;
  47228. /** @hidden */
  47229. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  47230. /** @hidden */
  47231. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  47232. /** @hidden */
  47233. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  47234. /** @hidden */
  47235. _attachments: Nullable<number[]>;
  47236. /** @hidden */
  47237. _cachedCoordinatesMode: Nullable<number>;
  47238. /** @hidden */
  47239. _cachedWrapU: Nullable<number>;
  47240. /** @hidden */
  47241. _cachedWrapV: Nullable<number>;
  47242. /** @hidden */
  47243. _cachedWrapR: Nullable<number>;
  47244. /** @hidden */
  47245. _cachedAnisotropicFilteringLevel: Nullable<number>;
  47246. /** @hidden */
  47247. _isDisabled: boolean;
  47248. /** @hidden */
  47249. _compression: Nullable<string>;
  47250. /** @hidden */
  47251. _generateStencilBuffer: boolean;
  47252. /** @hidden */
  47253. _generateDepthBuffer: boolean;
  47254. /** @hidden */
  47255. _comparisonFunction: number;
  47256. /** @hidden */
  47257. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  47258. /** @hidden */
  47259. _lodGenerationScale: number;
  47260. /** @hidden */
  47261. _lodGenerationOffset: number;
  47262. /** @hidden */
  47263. _lodTextureHigh: BaseTexture;
  47264. /** @hidden */
  47265. _lodTextureMid: BaseTexture;
  47266. /** @hidden */
  47267. _lodTextureLow: BaseTexture;
  47268. /** @hidden */
  47269. _isRGBD: boolean;
  47270. /** @hidden */
  47271. _webGLTexture: Nullable<WebGLTexture>;
  47272. /** @hidden */
  47273. _references: number;
  47274. private _engine;
  47275. /**
  47276. * Gets the Engine the texture belongs to.
  47277. * @returns The babylon engine
  47278. */
  47279. getEngine(): Engine;
  47280. /**
  47281. * Gets the data source type of the texture (can be one of the BABYLON.InternalTexture.DATASOURCE_XXXX)
  47282. */
  47283. readonly dataSource: number;
  47284. /**
  47285. * Creates a new InternalTexture
  47286. * @param engine defines the engine to use
  47287. * @param dataSource defines the type of data that will be used
  47288. * @param delayAllocation if the texture allocation should be delayed (default: false)
  47289. */
  47290. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  47291. /**
  47292. * Increments the number of references (ie. the number of Texture that point to it)
  47293. */
  47294. incrementReferences(): void;
  47295. /**
  47296. * Change the size of the texture (not the size of the content)
  47297. * @param width defines the new width
  47298. * @param height defines the new height
  47299. * @param depth defines the new depth (1 by default)
  47300. */
  47301. updateSize(width: int, height: int, depth?: int): void;
  47302. /** @hidden */
  47303. _rebuild(): void;
  47304. /** @hidden */
  47305. _swapAndDie(target: InternalTexture): void;
  47306. /**
  47307. * Dispose the current allocated resources
  47308. */
  47309. dispose(): void;
  47310. }
  47311. }
  47312. declare module BABYLON {
  47313. /**
  47314. * This represents the required contract to create a new type of texture loader.
  47315. */
  47316. interface IInternalTextureLoader {
  47317. /**
  47318. * Defines wether the loader supports cascade loading the different faces.
  47319. */
  47320. supportCascades: boolean;
  47321. /**
  47322. * This returns if the loader support the current file information.
  47323. * @param extension defines the file extension of the file being loaded
  47324. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47325. * @param fallback defines the fallback internal texture if any
  47326. * @param isBase64 defines whether the texture is encoded as a base64
  47327. * @param isBuffer defines whether the texture data are stored as a buffer
  47328. * @returns true if the loader can load the specified file
  47329. */
  47330. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47331. /**
  47332. * Transform the url before loading if required.
  47333. * @param rootUrl the url of the texture
  47334. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47335. * @returns the transformed texture
  47336. */
  47337. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47338. /**
  47339. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47340. * @param rootUrl the url of the texture
  47341. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47342. * @returns the fallback texture
  47343. */
  47344. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47345. /**
  47346. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47347. * @param data contains the texture data
  47348. * @param texture defines the BabylonJS internal texture
  47349. * @param createPolynomials will be true if polynomials have been requested
  47350. * @param onLoad defines the callback to trigger once the texture is ready
  47351. * @param onError defines the callback to trigger in case of error
  47352. */
  47353. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47354. /**
  47355. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47356. * @param data contains the texture data
  47357. * @param texture defines the BabylonJS internal texture
  47358. * @param callback defines the method to call once ready to upload
  47359. */
  47360. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  47361. }
  47362. }
  47363. declare module BABYLON {
  47364. /**
  47365. * Internal interface used to track InternalTexture already bound to the GL context
  47366. */
  47367. interface IInternalTextureTracker {
  47368. /**
  47369. * Gets or set the previous tracker in the list
  47370. */
  47371. previous: Nullable<IInternalTextureTracker>;
  47372. /**
  47373. * Gets or set the next tracker in the list
  47374. */
  47375. next: Nullable<IInternalTextureTracker>;
  47376. }
  47377. /**
  47378. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  47379. */
  47380. class DummyInternalTextureTracker {
  47381. /**
  47382. * Gets or set the previous tracker in the list
  47383. */
  47384. previous: Nullable<IInternalTextureTracker>;
  47385. /**
  47386. * Gets or set the next tracker in the list
  47387. */
  47388. next: Nullable<IInternalTextureTracker>;
  47389. }
  47390. }
  47391. declare module BABYLON {
  47392. /**
  47393. * Mirror texture can be used to simulate the view from a mirror in a scene.
  47394. * It will dynamically be rendered every frame to adapt to the camera point of view.
  47395. * You can then easily use it as a reflectionTexture on a flat surface.
  47396. * In case the surface is not a plane, please consider relying on reflection probes.
  47397. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  47398. */
  47399. class MirrorTexture extends RenderTargetTexture {
  47400. private scene;
  47401. /**
  47402. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  47403. * 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.
  47404. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  47405. */
  47406. mirrorPlane: Plane;
  47407. /**
  47408. * Define the blur ratio used to blur the reflection if needed.
  47409. */
  47410. blurRatio: number;
  47411. /**
  47412. * Define the adaptive blur kernel used to blur the reflection if needed.
  47413. * This will autocompute the closest best match for the `blurKernel`
  47414. */
  47415. adaptiveBlurKernel: number;
  47416. /**
  47417. * Define the blur kernel used to blur the reflection if needed.
  47418. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  47419. */
  47420. blurKernel: number;
  47421. /**
  47422. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  47423. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  47424. */
  47425. blurKernelX: number;
  47426. /**
  47427. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  47428. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  47429. */
  47430. blurKernelY: number;
  47431. private _autoComputeBlurKernel;
  47432. protected _onRatioRescale(): void;
  47433. private _updateGammaSpace;
  47434. private _imageProcessingConfigChangeObserver;
  47435. private _transformMatrix;
  47436. private _mirrorMatrix;
  47437. private _savedViewMatrix;
  47438. private _blurX;
  47439. private _blurY;
  47440. private _adaptiveBlurKernel;
  47441. private _blurKernelX;
  47442. private _blurKernelY;
  47443. private _blurRatio;
  47444. /**
  47445. * Instantiates a Mirror Texture.
  47446. * Mirror texture can be used to simulate the view from a mirror in a scene.
  47447. * It will dynamically be rendered every frame to adapt to the camera point of view.
  47448. * You can then easily use it as a reflectionTexture on a flat surface.
  47449. * In case the surface is not a plane, please consider relying on reflection probes.
  47450. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  47451. * @param name
  47452. * @param size
  47453. * @param scene
  47454. * @param generateMipMaps
  47455. * @param type
  47456. * @param samplingMode
  47457. * @param generateDepthBuffer
  47458. */
  47459. constructor(name: string, size: number | {
  47460. width: number;
  47461. height: number;
  47462. } | {
  47463. ratio: number;
  47464. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  47465. private _preparePostProcesses;
  47466. /**
  47467. * Clone the mirror texture.
  47468. * @returns the cloned texture
  47469. */
  47470. clone(): MirrorTexture;
  47471. /**
  47472. * Serialize the texture to a JSON representation you could use in Parse later on
  47473. * @returns the serialized JSON representation
  47474. */
  47475. serialize(): any;
  47476. /**
  47477. * Dispose the texture and release its associated resources.
  47478. */
  47479. dispose(): void;
  47480. }
  47481. }
  47482. declare module BABYLON {
  47483. /**
  47484. * Creation options of the multi render target texture.
  47485. */
  47486. interface IMultiRenderTargetOptions {
  47487. /**
  47488. * Define if the texture needs to create mip maps after render.
  47489. */
  47490. generateMipMaps?: boolean;
  47491. /**
  47492. * Define the types of all the draw buffers we want to create
  47493. */
  47494. types?: number[];
  47495. /**
  47496. * Define the sampling modes of all the draw buffers we want to create
  47497. */
  47498. samplingModes?: number[];
  47499. /**
  47500. * Define if a depth buffer is required
  47501. */
  47502. generateDepthBuffer?: boolean;
  47503. /**
  47504. * Define if a stencil buffer is required
  47505. */
  47506. generateStencilBuffer?: boolean;
  47507. /**
  47508. * Define if a depth texture is required instead of a depth buffer
  47509. */
  47510. generateDepthTexture?: boolean;
  47511. /**
  47512. * Define the number of desired draw buffers
  47513. */
  47514. textureCount?: number;
  47515. /**
  47516. * Define if aspect ratio should be adapted to the texture or stay the scene one
  47517. */
  47518. doNotChangeAspectRatio?: boolean;
  47519. /**
  47520. * Define the default type of the buffers we are creating
  47521. */
  47522. defaultType?: number;
  47523. }
  47524. /**
  47525. * A multi render target, like a render target provides the ability to render to a texture.
  47526. * Unlike the render target, it can render to several draw buffers in one draw.
  47527. * This is specially interesting in deferred rendering or for any effects requiring more than
  47528. * just one color from a single pass.
  47529. */
  47530. class MultiRenderTarget extends RenderTargetTexture {
  47531. private _internalTextures;
  47532. private _textures;
  47533. private _multiRenderTargetOptions;
  47534. /**
  47535. * Get if draw buffers are currently supported by the used hardware and browser.
  47536. */
  47537. readonly isSupported: boolean;
  47538. /**
  47539. * Get the list of textures generated by the multi render target.
  47540. */
  47541. readonly textures: Texture[];
  47542. /**
  47543. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  47544. */
  47545. readonly depthTexture: Texture;
  47546. /**
  47547. * Set the wrapping mode on U of all the textures we are rendering to.
  47548. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47549. */
  47550. wrapU: number;
  47551. /**
  47552. * Set the wrapping mode on V of all the textures we are rendering to.
  47553. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47554. */
  47555. wrapV: number;
  47556. /**
  47557. * Instantiate a new multi render target texture.
  47558. * A multi render target, like a render target provides the ability to render to a texture.
  47559. * Unlike the render target, it can render to several draw buffers in one draw.
  47560. * This is specially interesting in deferred rendering or for any effects requiring more than
  47561. * just one color from a single pass.
  47562. * @param name Define the name of the texture
  47563. * @param size Define the size of the buffers to render to
  47564. * @param count Define the number of target we are rendering into
  47565. * @param scene Define the scene the texture belongs to
  47566. * @param options Define the options used to create the multi render target
  47567. */
  47568. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  47569. /** @hidden */
  47570. _rebuild(): void;
  47571. private _createInternalTextures;
  47572. private _createTextures;
  47573. /**
  47574. * Define the number of samples used if MSAA is enabled.
  47575. */
  47576. samples: number;
  47577. /**
  47578. * Resize all the textures in the multi render target.
  47579. * Be carrefull as it will recreate all the data in the new texture.
  47580. * @param size Define the new size
  47581. */
  47582. resize(size: any): void;
  47583. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  47584. /**
  47585. * Dispose the render targets and their associated resources
  47586. */
  47587. dispose(): void;
  47588. /**
  47589. * Release all the underlying texture used as draw buffers.
  47590. */
  47591. releaseInternalTextures(): void;
  47592. }
  47593. }
  47594. declare module BABYLON {
  47595. /**
  47596. * Raw cube texture where the raw buffers are passed in
  47597. */
  47598. class RawCubeTexture extends CubeTexture {
  47599. /**
  47600. * Creates a cube texture where the raw buffers are passed in.
  47601. * @param scene defines the scene the texture is attached to
  47602. * @param data defines the array of data to use to create each face
  47603. * @param size defines the size of the textures
  47604. * @param format defines the format of the data
  47605. * @param type defines the type of the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  47606. * @param generateMipMaps defines if the engine should generate the mip levels
  47607. * @param invertY defines if data must be stored with Y axis inverted
  47608. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  47609. * @param compression defines the compression used (null by default)
  47610. */
  47611. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  47612. /**
  47613. * Updates the raw cube texture.
  47614. * @param data defines the data to store
  47615. * @param format defines the data format
  47616. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  47617. * @param invertY defines if data must be stored with Y axis inverted
  47618. * @param compression defines the compression used (null by default)
  47619. * @param level defines which level of the texture to update
  47620. */
  47621. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  47622. /**
  47623. * Updates a raw cube texture with RGBD encoded data.
  47624. * @param data defines the array of data [mipmap][face] to use to create each face
  47625. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  47626. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  47627. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  47628. * @returns a promsie that resolves when the operation is complete
  47629. */
  47630. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  47631. /**
  47632. * Clones the raw cube texture.
  47633. * @return a new cube texture
  47634. */
  47635. clone(): CubeTexture;
  47636. /** @hidden */
  47637. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47638. }
  47639. }
  47640. declare module BABYLON {
  47641. /**
  47642. * Raw texture can help creating a texture directly from an array of data.
  47643. * This can be super useful if you either get the data from an uncompressed source or
  47644. * if you wish to create your texture pixel by pixel.
  47645. */
  47646. class RawTexture extends Texture {
  47647. /**
  47648. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  47649. */
  47650. format: number;
  47651. private _engine;
  47652. /**
  47653. * Instantiates a new RawTexture.
  47654. * Raw texture can help creating a texture directly from an array of data.
  47655. * This can be super useful if you either get the data from an uncompressed source or
  47656. * if you wish to create your texture pixel by pixel.
  47657. * @param data define the array of data to use to create the texture
  47658. * @param width define the width of the texture
  47659. * @param height define the height of the texture
  47660. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  47661. * @param scene define the scene the texture belongs to
  47662. * @param generateMipMaps define whether mip maps should be generated or not
  47663. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47664. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47665. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  47666. */
  47667. constructor(data: ArrayBufferView, width: number, height: number,
  47668. /**
  47669. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  47670. */
  47671. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  47672. /**
  47673. * Updates the texture underlying data.
  47674. * @param data Define the new data of the texture
  47675. */
  47676. update(data: ArrayBufferView): void;
  47677. /**
  47678. * Creates a luminance texture from some data.
  47679. * @param data Define the texture data
  47680. * @param width Define the width of the texture
  47681. * @param height Define the height of the texture
  47682. * @param scene Define the scene the texture belongs to
  47683. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47684. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47685. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47686. * @returns the luminance texture
  47687. */
  47688. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  47689. /**
  47690. * Creates a luminance alpha texture from some data.
  47691. * @param data Define the texture data
  47692. * @param width Define the width of the texture
  47693. * @param height Define the height of the texture
  47694. * @param scene Define the scene the texture belongs to
  47695. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47696. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47697. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47698. * @returns the luminance alpha texture
  47699. */
  47700. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  47701. /**
  47702. * Creates an alpha texture from some data.
  47703. * @param data Define the texture data
  47704. * @param width Define the width of the texture
  47705. * @param height Define the height of the texture
  47706. * @param scene Define the scene the texture belongs to
  47707. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47708. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47709. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47710. * @returns the alpha texture
  47711. */
  47712. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  47713. /**
  47714. * Creates a RGB texture from some data.
  47715. * @param data Define the texture data
  47716. * @param width Define the width of the texture
  47717. * @param height Define the height of the texture
  47718. * @param scene Define the scene the texture belongs to
  47719. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47720. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47721. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47722. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  47723. * @returns the RGB alpha texture
  47724. */
  47725. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  47726. /**
  47727. * Creates a RGBA 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. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  47736. * @returns the RGBA texture
  47737. */
  47738. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  47739. /**
  47740. * Creates a R texture from some data.
  47741. * @param data Define the texture data
  47742. * @param width Define the width of the texture
  47743. * @param height Define the height of the texture
  47744. * @param scene Define the scene the texture belongs to
  47745. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47746. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47747. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47748. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  47749. * @returns the R texture
  47750. */
  47751. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  47752. }
  47753. }
  47754. declare module BABYLON {
  47755. /**
  47756. * Class used to store 3D textures containing user data
  47757. */
  47758. class RawTexture3D extends Texture {
  47759. /** Gets or sets the texture format to use */
  47760. format: number;
  47761. private _engine;
  47762. /**
  47763. * Create a new RawTexture3D
  47764. * @param data defines the data of the texture
  47765. * @param width defines the width of the texture
  47766. * @param height defines the height of the texture
  47767. * @param depth defines the depth of the texture
  47768. * @param format defines the texture format to use
  47769. * @param scene defines the hosting scene
  47770. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  47771. * @param invertY defines if texture must be stored with Y axis inverted
  47772. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  47773. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  47774. */
  47775. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  47776. /** Gets or sets the texture format to use */
  47777. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  47778. /**
  47779. * Update the texture with new data
  47780. * @param data defines the data to store in the texture
  47781. */
  47782. update(data: ArrayBufferView): void;
  47783. }
  47784. }
  47785. declare module BABYLON {
  47786. /**
  47787. * Creates a refraction texture used by refraction channel of the standard material.
  47788. * It is like a mirror but to see through a material.
  47789. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  47790. */
  47791. class RefractionTexture extends RenderTargetTexture {
  47792. /**
  47793. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  47794. * 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.
  47795. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  47796. */
  47797. refractionPlane: Plane;
  47798. /**
  47799. * Define how deep under the surface we should see.
  47800. */
  47801. depth: number;
  47802. /**
  47803. * Creates a refraction texture used by refraction channel of the standard material.
  47804. * It is like a mirror but to see through a material.
  47805. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  47806. * @param name Define the texture name
  47807. * @param size Define the size of the underlying texture
  47808. * @param scene Define the scene the refraction belongs to
  47809. * @param generateMipMaps Define if we need to generate mips level for the refraction
  47810. */
  47811. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  47812. /**
  47813. * Clone the refraction texture.
  47814. * @returns the cloned texture
  47815. */
  47816. clone(): RefractionTexture;
  47817. /**
  47818. * Serialize the texture to a JSON representation you could use in Parse later on
  47819. * @returns the serialized JSON representation
  47820. */
  47821. serialize(): any;
  47822. }
  47823. }
  47824. declare module BABYLON {
  47825. /**
  47826. * This Helps creating a texture that will be created from a camera in your scene.
  47827. * It is basically a dynamic texture that could be used to create special effects for instance.
  47828. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  47829. */
  47830. class RenderTargetTexture extends Texture {
  47831. isCube: boolean;
  47832. /**
  47833. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  47834. */
  47835. static readonly REFRESHRATE_RENDER_ONCE: number;
  47836. /**
  47837. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  47838. */
  47839. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  47840. /**
  47841. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  47842. * the central point of your effect and can save a lot of performances.
  47843. */
  47844. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  47845. /**
  47846. * Use this predicate to dynamically define the list of mesh you want to render.
  47847. * If set, the renderList property will be overwritten.
  47848. */
  47849. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  47850. private _renderList;
  47851. /**
  47852. * Use this list to define the list of mesh you want to render.
  47853. */
  47854. renderList: Nullable<Array<AbstractMesh>>;
  47855. private _hookArray;
  47856. /**
  47857. * Define if particles should be rendered in your texture.
  47858. */
  47859. renderParticles: boolean;
  47860. /**
  47861. * Define if sprites should be rendered in your texture.
  47862. */
  47863. renderSprites: boolean;
  47864. /**
  47865. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  47866. */
  47867. coordinatesMode: number;
  47868. /**
  47869. * Define the camera used to render the texture.
  47870. */
  47871. activeCamera: Nullable<Camera>;
  47872. /**
  47873. * Override the render function of the texture with your own one.
  47874. */
  47875. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  47876. /**
  47877. * Define if camera post processes should be use while rendering the texture.
  47878. */
  47879. useCameraPostProcesses: boolean;
  47880. /**
  47881. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  47882. */
  47883. ignoreCameraViewport: boolean;
  47884. private _postProcessManager;
  47885. private _postProcesses;
  47886. private _resizeObserver;
  47887. /**
  47888. * An event triggered when the texture is unbind.
  47889. */
  47890. onBeforeBindObservable: Observable<RenderTargetTexture>;
  47891. /**
  47892. * An event triggered when the texture is unbind.
  47893. */
  47894. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  47895. private _onAfterUnbindObserver;
  47896. /**
  47897. * Set a after unbind callback in the texture.
  47898. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  47899. */
  47900. onAfterUnbind: () => void;
  47901. /**
  47902. * An event triggered before rendering the texture
  47903. */
  47904. onBeforeRenderObservable: Observable<number>;
  47905. private _onBeforeRenderObserver;
  47906. /**
  47907. * Set a before render callback in the texture.
  47908. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  47909. */
  47910. onBeforeRender: (faceIndex: number) => void;
  47911. /**
  47912. * An event triggered after rendering the texture
  47913. */
  47914. onAfterRenderObservable: Observable<number>;
  47915. private _onAfterRenderObserver;
  47916. /**
  47917. * Set a after render callback in the texture.
  47918. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  47919. */
  47920. onAfterRender: (faceIndex: number) => void;
  47921. /**
  47922. * An event triggered after the texture clear
  47923. */
  47924. onClearObservable: Observable<Engine>;
  47925. private _onClearObserver;
  47926. /**
  47927. * Set a clear callback in the texture.
  47928. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  47929. */
  47930. onClear: (Engine: Engine) => void;
  47931. /**
  47932. * Define the clear color of the Render Target if it should be different from the scene.
  47933. */
  47934. clearColor: Color4;
  47935. protected _size: number | {
  47936. width: number;
  47937. height: number;
  47938. };
  47939. protected _initialSizeParameter: number | {
  47940. width: number;
  47941. height: number;
  47942. } | {
  47943. ratio: number;
  47944. };
  47945. protected _sizeRatio: Nullable<number>;
  47946. /** @hidden */
  47947. _generateMipMaps: boolean;
  47948. protected _renderingManager: RenderingManager;
  47949. /** @hidden */
  47950. _waitingRenderList: string[];
  47951. protected _doNotChangeAspectRatio: boolean;
  47952. protected _currentRefreshId: number;
  47953. protected _refreshRate: number;
  47954. protected _textureMatrix: Matrix;
  47955. protected _samples: number;
  47956. protected _renderTargetOptions: RenderTargetCreationOptions;
  47957. /**
  47958. * Gets render target creation options that were used.
  47959. */
  47960. readonly renderTargetOptions: RenderTargetCreationOptions;
  47961. protected _engine: Engine;
  47962. protected _onRatioRescale(): void;
  47963. /**
  47964. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  47965. * It must define where the camera used to render the texture is set
  47966. */
  47967. boundingBoxPosition: Vector3;
  47968. private _boundingBoxSize;
  47969. /**
  47970. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  47971. * When defined, the cubemap will switch to local mode
  47972. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  47973. * @example https://www.babylonjs-playground.com/#RNASML
  47974. */
  47975. boundingBoxSize: Vector3;
  47976. /**
  47977. * In case the RTT has been created with a depth texture, get the associated
  47978. * depth texture.
  47979. * Otherwise, return null.
  47980. */
  47981. depthStencilTexture: Nullable<InternalTexture>;
  47982. /**
  47983. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  47984. * or used a shadow, depth texture...
  47985. * @param name The friendly name of the texture
  47986. * @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)
  47987. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  47988. * @param generateMipMaps True if mip maps need to be generated after render.
  47989. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  47990. * @param type The type of the buffer in the RTT (int, half float, float...)
  47991. * @param isCube True if a cube texture needs to be created
  47992. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  47993. * @param generateDepthBuffer True to generate a depth buffer
  47994. * @param generateStencilBuffer True to generate a stencil buffer
  47995. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  47996. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  47997. * @param delayAllocation if the texture allocation should be delayed (default: false)
  47998. */
  47999. constructor(name: string, size: number | {
  48000. width: number;
  48001. height: number;
  48002. } | {
  48003. ratio: number;
  48004. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  48005. /**
  48006. * Creates a depth stencil texture.
  48007. * This is only available in WebGL 2 or with the depth texture extension available.
  48008. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  48009. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  48010. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  48011. */
  48012. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  48013. private _processSizeParameter;
  48014. /**
  48015. * Define the number of samples to use in case of MSAA.
  48016. * It defaults to one meaning no MSAA has been enabled.
  48017. */
  48018. samples: number;
  48019. /**
  48020. * Resets the refresh counter of the texture and start bak from scratch.
  48021. * Could be useful to regenerate the texture if it is setup to render only once.
  48022. */
  48023. resetRefreshCounter(): void;
  48024. /**
  48025. * Define the refresh rate of the texture or the rendering frequency.
  48026. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  48027. */
  48028. refreshRate: number;
  48029. /**
  48030. * Adds a post process to the render target rendering passes.
  48031. * @param postProcess define the post process to add
  48032. */
  48033. addPostProcess(postProcess: PostProcess): void;
  48034. /**
  48035. * Clear all the post processes attached to the render target
  48036. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  48037. */
  48038. clearPostProcesses(dispose?: boolean): void;
  48039. /**
  48040. * Remove one of the post process from the list of attached post processes to the texture
  48041. * @param postProcess define the post process to remove from the list
  48042. */
  48043. removePostProcess(postProcess: PostProcess): void;
  48044. /** @hidden */
  48045. _shouldRender(): boolean;
  48046. /**
  48047. * Gets the actual render size of the texture.
  48048. * @returns the width of the render size
  48049. */
  48050. getRenderSize(): number;
  48051. /**
  48052. * Gets the actual render width of the texture.
  48053. * @returns the width of the render size
  48054. */
  48055. getRenderWidth(): number;
  48056. /**
  48057. * Gets the actual render height of the texture.
  48058. * @returns the height of the render size
  48059. */
  48060. getRenderHeight(): number;
  48061. /**
  48062. * Get if the texture can be rescaled or not.
  48063. */
  48064. readonly canRescale: boolean;
  48065. /**
  48066. * Resize the texture using a ratio.
  48067. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  48068. */
  48069. scale(ratio: number): void;
  48070. /**
  48071. * Get the texture reflection matrix used to rotate/transform the reflection.
  48072. * @returns the reflection matrix
  48073. */
  48074. getReflectionTextureMatrix(): Matrix;
  48075. /**
  48076. * Resize the texture to a new desired size.
  48077. * Be carrefull as it will recreate all the data in the new texture.
  48078. * @param size Define the new size. It can be:
  48079. * - a number for squared texture,
  48080. * - an object containing { width: number, height: number }
  48081. * - or an object containing a ratio { ratio: number }
  48082. */
  48083. resize(size: number | {
  48084. width: number;
  48085. height: number;
  48086. } | {
  48087. ratio: number;
  48088. }): void;
  48089. /**
  48090. * Renders all the objects from the render list into the texture.
  48091. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  48092. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  48093. */
  48094. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  48095. private _bestReflectionRenderTargetDimension;
  48096. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  48097. private renderToTarget;
  48098. /**
  48099. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  48100. * This allowed control for front to back rendering or reversly depending of the special needs.
  48101. *
  48102. * @param renderingGroupId The rendering group id corresponding to its index
  48103. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  48104. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  48105. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  48106. */
  48107. 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;
  48108. /**
  48109. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  48110. *
  48111. * @param renderingGroupId The rendering group id corresponding to its index
  48112. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  48113. */
  48114. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  48115. /**
  48116. * Clones the texture.
  48117. * @returns the cloned texture
  48118. */
  48119. clone(): RenderTargetTexture;
  48120. /**
  48121. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  48122. * @returns The JSON representation of the texture
  48123. */
  48124. serialize(): any;
  48125. /**
  48126. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  48127. */
  48128. disposeFramebufferObjects(): void;
  48129. /**
  48130. * Dispose the texture and release its associated resources.
  48131. */
  48132. dispose(): void;
  48133. /** @hidden */
  48134. _rebuild(): void;
  48135. /**
  48136. * Clear the info related to rendering groups preventing retention point in material dispose.
  48137. */
  48138. freeRenderingGroups(): void;
  48139. }
  48140. }
  48141. declare module BABYLON {
  48142. /**
  48143. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  48144. * @see http://doc.babylonjs.com/babylon101/materials#texture
  48145. */
  48146. class Texture extends BaseTexture {
  48147. /** nearest is mag = nearest and min = nearest and mip = linear */
  48148. static readonly NEAREST_SAMPLINGMODE: number;
  48149. /** nearest is mag = nearest and min = nearest and mip = linear */
  48150. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  48151. /** Bilinear is mag = linear and min = linear and mip = nearest */
  48152. static readonly BILINEAR_SAMPLINGMODE: number;
  48153. /** Bilinear is mag = linear and min = linear and mip = nearest */
  48154. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  48155. /** Trilinear is mag = linear and min = linear and mip = linear */
  48156. static readonly TRILINEAR_SAMPLINGMODE: number;
  48157. /** Trilinear is mag = linear and min = linear and mip = linear */
  48158. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  48159. /** mag = nearest and min = nearest and mip = nearest */
  48160. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  48161. /** mag = nearest and min = linear and mip = nearest */
  48162. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  48163. /** mag = nearest and min = linear and mip = linear */
  48164. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  48165. /** mag = nearest and min = linear and mip = none */
  48166. static readonly NEAREST_LINEAR: number;
  48167. /** mag = nearest and min = nearest and mip = none */
  48168. static readonly NEAREST_NEAREST: number;
  48169. /** mag = linear and min = nearest and mip = nearest */
  48170. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  48171. /** mag = linear and min = nearest and mip = linear */
  48172. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  48173. /** mag = linear and min = linear and mip = none */
  48174. static readonly LINEAR_LINEAR: number;
  48175. /** mag = linear and min = nearest and mip = none */
  48176. static readonly LINEAR_NEAREST: number;
  48177. /** Explicit coordinates mode */
  48178. static readonly EXPLICIT_MODE: number;
  48179. /** Spherical coordinates mode */
  48180. static readonly SPHERICAL_MODE: number;
  48181. /** Planar coordinates mode */
  48182. static readonly PLANAR_MODE: number;
  48183. /** Cubic coordinates mode */
  48184. static readonly CUBIC_MODE: number;
  48185. /** Projection coordinates mode */
  48186. static readonly PROJECTION_MODE: number;
  48187. /** Inverse Cubic coordinates mode */
  48188. static readonly SKYBOX_MODE: number;
  48189. /** Inverse Cubic coordinates mode */
  48190. static readonly INVCUBIC_MODE: number;
  48191. /** Equirectangular coordinates mode */
  48192. static readonly EQUIRECTANGULAR_MODE: number;
  48193. /** Equirectangular Fixed coordinates mode */
  48194. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  48195. /** Equirectangular Fixed Mirrored coordinates mode */
  48196. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  48197. /** Texture is not repeating outside of 0..1 UVs */
  48198. static readonly CLAMP_ADDRESSMODE: number;
  48199. /** Texture is repeating outside of 0..1 UVs */
  48200. static readonly WRAP_ADDRESSMODE: number;
  48201. /** Texture is repeating and mirrored */
  48202. static readonly MIRROR_ADDRESSMODE: number;
  48203. /**
  48204. * 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
  48205. */
  48206. static UseSerializedUrlIfAny: boolean;
  48207. /**
  48208. * Define the url of the texture.
  48209. */
  48210. url: Nullable<string>;
  48211. /**
  48212. * Define an offset on the texture to offset the u coordinates of the UVs
  48213. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  48214. */
  48215. uOffset: number;
  48216. /**
  48217. * Define an offset on the texture to offset the v coordinates of the UVs
  48218. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  48219. */
  48220. vOffset: number;
  48221. /**
  48222. * Define an offset on the texture to scale the u coordinates of the UVs
  48223. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  48224. */
  48225. uScale: number;
  48226. /**
  48227. * Define an offset on the texture to scale the v coordinates of the UVs
  48228. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  48229. */
  48230. vScale: number;
  48231. /**
  48232. * Define an offset on the texture to rotate around the u coordinates of the UVs
  48233. * @see http://doc.babylonjs.com/how_to/more_materials
  48234. */
  48235. uAng: number;
  48236. /**
  48237. * Define an offset on the texture to rotate around the v coordinates of the UVs
  48238. * @see http://doc.babylonjs.com/how_to/more_materials
  48239. */
  48240. vAng: number;
  48241. /**
  48242. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  48243. * @see http://doc.babylonjs.com/how_to/more_materials
  48244. */
  48245. wAng: number;
  48246. /**
  48247. * Defines the center of rotation (U)
  48248. */
  48249. uRotationCenter: number;
  48250. /**
  48251. * Defines the center of rotation (V)
  48252. */
  48253. vRotationCenter: number;
  48254. /**
  48255. * Defines the center of rotation (W)
  48256. */
  48257. wRotationCenter: number;
  48258. /**
  48259. * Are mip maps generated for this texture or not.
  48260. */
  48261. readonly noMipmap: boolean;
  48262. private _noMipmap;
  48263. /** @hidden */
  48264. _invertY: boolean;
  48265. private _rowGenerationMatrix;
  48266. private _cachedTextureMatrix;
  48267. private _projectionModeMatrix;
  48268. private _t0;
  48269. private _t1;
  48270. private _t2;
  48271. private _cachedUOffset;
  48272. private _cachedVOffset;
  48273. private _cachedUScale;
  48274. private _cachedVScale;
  48275. private _cachedUAng;
  48276. private _cachedVAng;
  48277. private _cachedWAng;
  48278. private _cachedProjectionMatrixId;
  48279. private _cachedCoordinatesMode;
  48280. /** @hidden */
  48281. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  48282. private _deleteBuffer;
  48283. protected _format: Nullable<number>;
  48284. private _delayedOnLoad;
  48285. private _delayedOnError;
  48286. /**
  48287. * Observable triggered once the texture has been loaded.
  48288. */
  48289. onLoadObservable: Observable<Texture>;
  48290. protected _isBlocking: boolean;
  48291. /**
  48292. * Is the texture preventing material to render while loading.
  48293. * If false, a default texture will be used instead of the loading one during the preparation step.
  48294. */
  48295. isBlocking: boolean;
  48296. /**
  48297. * Get the current sampling mode associated with the texture.
  48298. */
  48299. readonly samplingMode: number;
  48300. /**
  48301. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  48302. */
  48303. readonly invertY: boolean;
  48304. /**
  48305. * Instantiates a new texture.
  48306. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  48307. * @see http://doc.babylonjs.com/babylon101/materials#texture
  48308. * @param url define the url of the picture to load as a texture
  48309. * @param scene define the scene the texture will belong to
  48310. * @param noMipmap define if the texture will require mip maps or not
  48311. * @param invertY define if the texture needs to be inverted on the y axis during loading
  48312. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  48313. * @param onLoad define a callback triggered when the texture has been loaded
  48314. * @param onError define a callback triggered when an error occurred during the loading session
  48315. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  48316. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  48317. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  48318. */
  48319. 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);
  48320. /**
  48321. * Update the url (and optional buffer) of this texture if url was null during construction.
  48322. * @param url the url of the texture
  48323. * @param buffer the buffer of the texture (defaults to null)
  48324. * @param onLoad callback called when the texture is loaded (defaults to null)
  48325. */
  48326. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  48327. /**
  48328. * Finish the loading sequence of a texture flagged as delayed load.
  48329. * @hidden
  48330. */
  48331. delayLoad(): void;
  48332. private _prepareRowForTextureGeneration;
  48333. /**
  48334. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  48335. * @returns the transform matrix of the texture.
  48336. */
  48337. getTextureMatrix(): Matrix;
  48338. /**
  48339. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  48340. * @returns The reflection texture transform
  48341. */
  48342. getReflectionTextureMatrix(): Matrix;
  48343. /**
  48344. * Clones the texture.
  48345. * @returns the cloned texture
  48346. */
  48347. clone(): Texture;
  48348. /**
  48349. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  48350. * @returns The JSON representation of the texture
  48351. */
  48352. serialize(): any;
  48353. /**
  48354. * Get the current class name of the texture useful for serialization or dynamic coding.
  48355. * @returns "Texture"
  48356. */
  48357. getClassName(): string;
  48358. /**
  48359. * Dispose the texture and release its associated resources.
  48360. */
  48361. dispose(): void;
  48362. /**
  48363. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  48364. * @param parsedTexture Define the JSON representation of the texture
  48365. * @param scene Define the scene the parsed texture should be instantiated in
  48366. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  48367. * @returns The parsed texture if successful
  48368. */
  48369. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  48370. /**
  48371. * Creates a texture from its base 64 representation.
  48372. * @param data Define the base64 payload without the data: prefix
  48373. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  48374. * @param scene Define the scene the texture should belong to
  48375. * @param noMipmap Forces the texture to not create mip map information if true
  48376. * @param invertY define if the texture needs to be inverted on the y axis during loading
  48377. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  48378. * @param onLoad define a callback triggered when the texture has been loaded
  48379. * @param onError define a callback triggered when an error occurred during the loading session
  48380. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  48381. * @returns the created texture
  48382. */
  48383. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  48384. /**
  48385. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  48386. * @param data Define the base64 payload without the data: prefix
  48387. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  48388. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  48389. * @param scene Define the scene the texture should belong to
  48390. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  48391. * @param noMipmap Forces the texture to not create mip map information if true
  48392. * @param invertY define if the texture needs to be inverted on the y axis during loading
  48393. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  48394. * @param onLoad define a callback triggered when the texture has been loaded
  48395. * @param onError define a callback triggered when an error occurred during the loading session
  48396. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  48397. * @returns the created texture
  48398. */
  48399. 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;
  48400. }
  48401. }
  48402. declare module BABYLON {
  48403. /**
  48404. * Settings for finer control over video usage
  48405. */
  48406. interface VideoTextureSettings {
  48407. /**
  48408. * Applies `autoplay` to video, if specified
  48409. */
  48410. autoPlay?: boolean;
  48411. /**
  48412. * Applies `loop` to video, if specified
  48413. */
  48414. loop?: boolean;
  48415. /**
  48416. * Automatically updates internal texture from video at every frame in the render loop
  48417. */
  48418. autoUpdateTexture: boolean;
  48419. /**
  48420. * Image src displayed during the video loading or until the user interacts with the video.
  48421. */
  48422. poster?: string;
  48423. }
  48424. /**
  48425. * If you want to display a video in your scene, this is the special texture for that.
  48426. * This special texture works similar to other textures, with the exception of a few parameters.
  48427. * @see https://doc.babylonjs.com/how_to/video_texture
  48428. */
  48429. class VideoTexture extends Texture {
  48430. /**
  48431. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  48432. */
  48433. readonly autoUpdateTexture: boolean;
  48434. /**
  48435. * The video instance used by the texture internally
  48436. */
  48437. readonly video: HTMLVideoElement;
  48438. private _onUserActionRequestedObservable;
  48439. /**
  48440. * Event triggerd when a dom action is required by the user to play the video.
  48441. * This happens due to recent changes in browser policies preventing video to auto start.
  48442. */
  48443. readonly onUserActionRequestedObservable: Observable<Texture>;
  48444. private _generateMipMaps;
  48445. private _engine;
  48446. private _stillImageCaptured;
  48447. private _displayingPosterTexture;
  48448. private _settings;
  48449. private _createInternalTextureOnEvent;
  48450. /**
  48451. * Creates a video texture.
  48452. * If you want to display a video in your scene, this is the special texture for that.
  48453. * This special texture works similar to other textures, with the exception of a few parameters.
  48454. * @see https://doc.babylonjs.com/how_to/video_texture
  48455. * @param name optional name, will detect from video source, if not defined
  48456. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  48457. * @param scene is obviously the current scene.
  48458. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  48459. * @param invertY is false by default but can be used to invert video on Y axis
  48460. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  48461. * @param settings allows finer control over video usage
  48462. */
  48463. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  48464. private _getName;
  48465. private _getVideo;
  48466. private _createInternalTexture;
  48467. private reset;
  48468. /**
  48469. * @hidden Internal method to initiate `update`.
  48470. */
  48471. _rebuild(): void;
  48472. /**
  48473. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  48474. */
  48475. update(): void;
  48476. /**
  48477. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  48478. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  48479. */
  48480. updateTexture(isVisible: boolean): void;
  48481. protected _updateInternalTexture: (e?: Event | undefined) => void;
  48482. /**
  48483. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  48484. * @param url New url.
  48485. */
  48486. updateURL(url: string): void;
  48487. /**
  48488. * Dispose the texture and release its associated resources.
  48489. */
  48490. dispose(): void;
  48491. /**
  48492. * Creates a video texture straight from your WebCam video feed.
  48493. * @param scene Define the scene the texture should be created in
  48494. * @param onReady Define a callback to triggered once the texture will be ready
  48495. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  48496. */
  48497. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  48498. minWidth: number;
  48499. maxWidth: number;
  48500. minHeight: number;
  48501. maxHeight: number;
  48502. deviceId: string;
  48503. }): void;
  48504. }
  48505. }
  48506. declare var DracoDecoderModule: any;
  48507. declare var WebAssembly: any;
  48508. declare module BABYLON {
  48509. /**
  48510. * Configuration for Draco compression
  48511. */
  48512. interface IDracoCompressionConfiguration {
  48513. /**
  48514. * Configuration for the decoder.
  48515. */
  48516. decoder?: {
  48517. /**
  48518. * The url to the WebAssembly module.
  48519. */
  48520. wasmUrl?: string;
  48521. /**
  48522. * The url to the WebAssembly binary.
  48523. */
  48524. wasmBinaryUrl?: string;
  48525. /**
  48526. * The url to the fallback JavaScript module.
  48527. */
  48528. fallbackUrl?: string;
  48529. };
  48530. }
  48531. /**
  48532. * Draco compression (https://google.github.io/draco/)
  48533. *
  48534. * This class wraps the Draco module.
  48535. *
  48536. * **Encoder**
  48537. *
  48538. * The encoder is not currently implemented.
  48539. *
  48540. * **Decoder**
  48541. *
  48542. * 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.
  48543. *
  48544. * To update the configuration, use the following code:
  48545. * ```javascript
  48546. * BABYLON.DracoCompression.Configuration = {
  48547. * decoder: {
  48548. * wasmUrl: "<url to the WebAssembly library>",
  48549. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  48550. * fallbackUrl: "<url to the fallback JavaScript library>",
  48551. * }
  48552. * };
  48553. * ```
  48554. *
  48555. * 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.
  48556. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  48557. * Use `BABYLON.DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  48558. *
  48559. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  48560. * ```javascript
  48561. * var dracoCompression = new BABYLON.DracoCompression();
  48562. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  48563. * [BABYLON.VertexBuffer.PositionKind]: 0
  48564. * });
  48565. * ```
  48566. *
  48567. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  48568. */
  48569. class DracoCompression implements IDisposable {
  48570. private static _DecoderModulePromise;
  48571. /**
  48572. * The configuration. Defaults to the following urls:
  48573. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  48574. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  48575. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  48576. */
  48577. static Configuration: IDracoCompressionConfiguration;
  48578. /**
  48579. * Returns true if the decoder is available.
  48580. */
  48581. static readonly DecoderAvailable: boolean;
  48582. /**
  48583. * Constructor
  48584. */
  48585. constructor();
  48586. /**
  48587. * Stop all async operations and release resources.
  48588. */
  48589. dispose(): void;
  48590. /**
  48591. * Decode Draco compressed mesh data to vertex data.
  48592. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  48593. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  48594. * @returns A promise that resolves with the decoded vertex data
  48595. */
  48596. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  48597. [kind: string]: number;
  48598. }): Promise<VertexData>;
  48599. private static _GetDecoderModule;
  48600. private static _LoadScriptAsync;
  48601. private static _LoadFileAsync;
  48602. }
  48603. }
  48604. declare module BABYLON {
  48605. /**
  48606. * Particle emitter emitting particles from the inside of a box.
  48607. * It emits the particles randomly between 2 given directions.
  48608. */
  48609. class BoxParticleEmitter implements IParticleEmitterType {
  48610. /**
  48611. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  48612. */
  48613. direction1: Vector3;
  48614. /**
  48615. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  48616. */
  48617. direction2: Vector3;
  48618. /**
  48619. * 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.
  48620. */
  48621. minEmitBox: Vector3;
  48622. /**
  48623. * 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.
  48624. */
  48625. maxEmitBox: Vector3;
  48626. /**
  48627. * Creates a new instance BoxParticleEmitter
  48628. */
  48629. constructor();
  48630. /**
  48631. * Called by the particle System when the direction is computed for the created particle.
  48632. * @param worldMatrix is the world matrix of the particle system
  48633. * @param directionToUpdate is the direction vector to update with the result
  48634. * @param particle is the particle we are computed the direction for
  48635. */
  48636. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48637. /**
  48638. * Called by the particle System when the position is computed for the created particle.
  48639. * @param worldMatrix is the world matrix of the particle system
  48640. * @param positionToUpdate is the position vector to update with the result
  48641. * @param particle is the particle we are computed the position for
  48642. */
  48643. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48644. /**
  48645. * Clones the current emitter and returns a copy of it
  48646. * @returns the new emitter
  48647. */
  48648. clone(): BoxParticleEmitter;
  48649. /**
  48650. * Called by the GPUParticleSystem to setup the update shader
  48651. * @param effect defines the update shader
  48652. */
  48653. applyToShader(effect: Effect): void;
  48654. /**
  48655. * Returns a string to use to update the GPU particles update shader
  48656. * @returns a string containng the defines string
  48657. */
  48658. getEffectDefines(): string;
  48659. /**
  48660. * Returns the string "BoxParticleEmitter"
  48661. * @returns a string containing the class name
  48662. */
  48663. getClassName(): string;
  48664. /**
  48665. * Serializes the particle system to a JSON object.
  48666. * @returns the JSON object
  48667. */
  48668. serialize(): any;
  48669. /**
  48670. * Parse properties from a JSON object
  48671. * @param serializationObject defines the JSON object
  48672. */
  48673. parse(serializationObject: any): void;
  48674. }
  48675. }
  48676. declare module BABYLON {
  48677. /**
  48678. * Particle emitter emitting particles from the inside of a cone.
  48679. * It emits the particles alongside the cone volume from the base to the particle.
  48680. * The emission direction might be randomized.
  48681. */
  48682. class ConeParticleEmitter implements IParticleEmitterType {
  48683. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  48684. directionRandomizer: number;
  48685. private _radius;
  48686. private _angle;
  48687. private _height;
  48688. /**
  48689. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  48690. */
  48691. radiusRange: number;
  48692. /**
  48693. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  48694. */
  48695. heightRange: number;
  48696. /**
  48697. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  48698. */
  48699. emitFromSpawnPointOnly: boolean;
  48700. /**
  48701. * Gets or sets the radius of the emission cone
  48702. */
  48703. radius: number;
  48704. /**
  48705. * Gets or sets the angle of the emission cone
  48706. */
  48707. angle: number;
  48708. private _buildHeight;
  48709. /**
  48710. * Creates a new instance ConeParticleEmitter
  48711. * @param radius the radius of the emission cone (1 by default)
  48712. * @param angles the cone base angle (PI by default)
  48713. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  48714. */
  48715. constructor(radius?: number, angle?: number,
  48716. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  48717. directionRandomizer?: number);
  48718. /**
  48719. * Called by the particle System when the direction is computed for the created particle.
  48720. * @param worldMatrix is the world matrix of the particle system
  48721. * @param directionToUpdate is the direction vector to update with the result
  48722. * @param particle is the particle we are computed the direction for
  48723. */
  48724. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48725. /**
  48726. * Called by the particle System when the position is computed for the created particle.
  48727. * @param worldMatrix is the world matrix of the particle system
  48728. * @param positionToUpdate is the position vector to update with the result
  48729. * @param particle is the particle we are computed the position for
  48730. */
  48731. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48732. /**
  48733. * Clones the current emitter and returns a copy of it
  48734. * @returns the new emitter
  48735. */
  48736. clone(): ConeParticleEmitter;
  48737. /**
  48738. * Called by the GPUParticleSystem to setup the update shader
  48739. * @param effect defines the update shader
  48740. */
  48741. applyToShader(effect: Effect): void;
  48742. /**
  48743. * Returns a string to use to update the GPU particles update shader
  48744. * @returns a string containng the defines string
  48745. */
  48746. getEffectDefines(): string;
  48747. /**
  48748. * Returns the string "ConeParticleEmitter"
  48749. * @returns a string containing the class name
  48750. */
  48751. getClassName(): string;
  48752. /**
  48753. * Serializes the particle system to a JSON object.
  48754. * @returns the JSON object
  48755. */
  48756. serialize(): any;
  48757. /**
  48758. * Parse properties from a JSON object
  48759. * @param serializationObject defines the JSON object
  48760. */
  48761. parse(serializationObject: any): void;
  48762. }
  48763. }
  48764. declare module BABYLON {
  48765. /**
  48766. * Particle emitter emitting particles from the inside of a cylinder.
  48767. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  48768. */
  48769. class CylinderParticleEmitter implements IParticleEmitterType {
  48770. /**
  48771. * The radius of the emission cylinder.
  48772. */
  48773. radius: number;
  48774. /**
  48775. * The height of the emission cylinder.
  48776. */
  48777. height: number;
  48778. /**
  48779. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  48780. */
  48781. radiusRange: number;
  48782. /**
  48783. * How much to randomize the particle direction [0-1].
  48784. */
  48785. directionRandomizer: number;
  48786. /**
  48787. * Creates a new instance CylinderParticleEmitter
  48788. * @param radius the radius of the emission cylinder (1 by default)
  48789. * @param height the height of the emission cylinder (1 by default)
  48790. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  48791. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  48792. */
  48793. constructor(
  48794. /**
  48795. * The radius of the emission cylinder.
  48796. */
  48797. radius?: number,
  48798. /**
  48799. * The height of the emission cylinder.
  48800. */
  48801. height?: number,
  48802. /**
  48803. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  48804. */
  48805. radiusRange?: number,
  48806. /**
  48807. * How much to randomize the particle direction [0-1].
  48808. */
  48809. directionRandomizer?: number);
  48810. /**
  48811. * Called by the particle System when the direction is computed for the created particle.
  48812. * @param worldMatrix is the world matrix of the particle system
  48813. * @param directionToUpdate is the direction vector to update with the result
  48814. * @param particle is the particle we are computed the direction for
  48815. */
  48816. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48817. /**
  48818. * Called by the particle System when the position is computed for the created particle.
  48819. * @param worldMatrix is the world matrix of the particle system
  48820. * @param positionToUpdate is the position vector to update with the result
  48821. * @param particle is the particle we are computed the position for
  48822. */
  48823. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48824. /**
  48825. * Clones the current emitter and returns a copy of it
  48826. * @returns the new emitter
  48827. */
  48828. clone(): CylinderParticleEmitter;
  48829. /**
  48830. * Called by the GPUParticleSystem to setup the update shader
  48831. * @param effect defines the update shader
  48832. */
  48833. applyToShader(effect: Effect): void;
  48834. /**
  48835. * Returns a string to use to update the GPU particles update shader
  48836. * @returns a string containng the defines string
  48837. */
  48838. getEffectDefines(): string;
  48839. /**
  48840. * Returns the string "CylinderParticleEmitter"
  48841. * @returns a string containing the class name
  48842. */
  48843. getClassName(): string;
  48844. /**
  48845. * Serializes the particle system to a JSON object.
  48846. * @returns the JSON object
  48847. */
  48848. serialize(): any;
  48849. /**
  48850. * Parse properties from a JSON object
  48851. * @param serializationObject defines the JSON object
  48852. */
  48853. parse(serializationObject: any): void;
  48854. }
  48855. /**
  48856. * Particle emitter emitting particles from the inside of a cylinder.
  48857. * It emits the particles randomly between two vectors.
  48858. */
  48859. class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  48860. /**
  48861. * The min limit of the emission direction.
  48862. */
  48863. direction1: Vector3;
  48864. /**
  48865. * The max limit of the emission direction.
  48866. */
  48867. direction2: Vector3;
  48868. /**
  48869. * Creates a new instance CylinderDirectedParticleEmitter
  48870. * @param radius the radius of the emission cylinder (1 by default)
  48871. * @param height the height of the emission cylinder (1 by default)
  48872. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  48873. * @param direction1 the min limit of the emission direction (up vector by default)
  48874. * @param direction2 the max limit of the emission direction (up vector by default)
  48875. */
  48876. constructor(radius?: number, height?: number, radiusRange?: number,
  48877. /**
  48878. * The min limit of the emission direction.
  48879. */
  48880. direction1?: Vector3,
  48881. /**
  48882. * The max limit of the emission direction.
  48883. */
  48884. direction2?: Vector3);
  48885. /**
  48886. * Called by the particle System when the direction is computed for the created particle.
  48887. * @param worldMatrix is the world matrix of the particle system
  48888. * @param directionToUpdate is the direction vector to update with the result
  48889. * @param particle is the particle we are computed the direction for
  48890. */
  48891. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48892. /**
  48893. * Clones the current emitter and returns a copy of it
  48894. * @returns the new emitter
  48895. */
  48896. clone(): CylinderDirectedParticleEmitter;
  48897. /**
  48898. * Called by the GPUParticleSystem to setup the update shader
  48899. * @param effect defines the update shader
  48900. */
  48901. applyToShader(effect: Effect): void;
  48902. /**
  48903. * Returns a string to use to update the GPU particles update shader
  48904. * @returns a string containng the defines string
  48905. */
  48906. getEffectDefines(): string;
  48907. /**
  48908. * Returns the string "CylinderDirectedParticleEmitter"
  48909. * @returns a string containing the class name
  48910. */
  48911. getClassName(): string;
  48912. /**
  48913. * Serializes the particle system to a JSON object.
  48914. * @returns the JSON object
  48915. */
  48916. serialize(): any;
  48917. /**
  48918. * Parse properties from a JSON object
  48919. * @param serializationObject defines the JSON object
  48920. */
  48921. parse(serializationObject: any): void;
  48922. }
  48923. }
  48924. declare module BABYLON {
  48925. /**
  48926. * Particle emitter emitting particles from the inside of a hemisphere.
  48927. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  48928. */
  48929. class HemisphericParticleEmitter implements IParticleEmitterType {
  48930. /**
  48931. * The radius of the emission hemisphere.
  48932. */
  48933. radius: number;
  48934. /**
  48935. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  48936. */
  48937. radiusRange: number;
  48938. /**
  48939. * How much to randomize the particle direction [0-1].
  48940. */
  48941. directionRandomizer: number;
  48942. /**
  48943. * Creates a new instance HemisphericParticleEmitter
  48944. * @param radius the radius of the emission hemisphere (1 by default)
  48945. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  48946. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  48947. */
  48948. constructor(
  48949. /**
  48950. * The radius of the emission hemisphere.
  48951. */
  48952. radius?: number,
  48953. /**
  48954. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  48955. */
  48956. radiusRange?: number,
  48957. /**
  48958. * How much to randomize the particle direction [0-1].
  48959. */
  48960. directionRandomizer?: number);
  48961. /**
  48962. * Called by the particle System when the direction is computed for the created particle.
  48963. * @param worldMatrix is the world matrix of the particle system
  48964. * @param directionToUpdate is the direction vector to update with the result
  48965. * @param particle is the particle we are computed the direction for
  48966. */
  48967. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48968. /**
  48969. * Called by the particle System when the position is computed for the created particle.
  48970. * @param worldMatrix is the world matrix of the particle system
  48971. * @param positionToUpdate is the position vector to update with the result
  48972. * @param particle is the particle we are computed the position for
  48973. */
  48974. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48975. /**
  48976. * Clones the current emitter and returns a copy of it
  48977. * @returns the new emitter
  48978. */
  48979. clone(): HemisphericParticleEmitter;
  48980. /**
  48981. * Called by the GPUParticleSystem to setup the update shader
  48982. * @param effect defines the update shader
  48983. */
  48984. applyToShader(effect: Effect): void;
  48985. /**
  48986. * Returns a string to use to update the GPU particles update shader
  48987. * @returns a string containng the defines string
  48988. */
  48989. getEffectDefines(): string;
  48990. /**
  48991. * Returns the string "HemisphericParticleEmitter"
  48992. * @returns a string containing the class name
  48993. */
  48994. getClassName(): string;
  48995. /**
  48996. * Serializes the particle system to a JSON object.
  48997. * @returns the JSON object
  48998. */
  48999. serialize(): any;
  49000. /**
  49001. * Parse properties from a JSON object
  49002. * @param serializationObject defines the JSON object
  49003. */
  49004. parse(serializationObject: any): void;
  49005. }
  49006. }
  49007. declare module BABYLON {
  49008. /**
  49009. * Particle emitter represents a volume emitting particles.
  49010. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  49011. */
  49012. interface IParticleEmitterType {
  49013. /**
  49014. * Called by the particle System when the direction is computed for the created particle.
  49015. * @param worldMatrix is the world matrix of the particle system
  49016. * @param directionToUpdate is the direction vector to update with the result
  49017. * @param particle is the particle we are computed the direction for
  49018. */
  49019. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  49020. /**
  49021. * Called by the particle System when the position is computed for the created particle.
  49022. * @param worldMatrix is the world matrix of the particle system
  49023. * @param positionToUpdate is the position vector to update with the result
  49024. * @param particle is the particle we are computed the position for
  49025. */
  49026. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  49027. /**
  49028. * Clones the current emitter and returns a copy of it
  49029. * @returns the new emitter
  49030. */
  49031. clone(): IParticleEmitterType;
  49032. /**
  49033. * Called by the GPUParticleSystem to setup the update shader
  49034. * @param effect defines the update shader
  49035. */
  49036. applyToShader(effect: Effect): void;
  49037. /**
  49038. * Returns a string to use to update the GPU particles update shader
  49039. * @returns the effect defines string
  49040. */
  49041. getEffectDefines(): string;
  49042. /**
  49043. * Returns a string representing the class name
  49044. * @returns a string containing the class name
  49045. */
  49046. getClassName(): string;
  49047. /**
  49048. * Serializes the particle system to a JSON object.
  49049. * @returns the JSON object
  49050. */
  49051. serialize(): any;
  49052. /**
  49053. * Parse properties from a JSON object
  49054. * @param serializationObject defines the JSON object
  49055. */
  49056. parse(serializationObject: any): void;
  49057. }
  49058. }
  49059. declare module BABYLON {
  49060. /**
  49061. * Particle emitter emitting particles from a point.
  49062. * It emits the particles randomly between 2 given directions.
  49063. */
  49064. class PointParticleEmitter implements IParticleEmitterType {
  49065. /**
  49066. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  49067. */
  49068. direction1: Vector3;
  49069. /**
  49070. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  49071. */
  49072. direction2: Vector3;
  49073. /**
  49074. * Creates a new instance PointParticleEmitter
  49075. */
  49076. constructor();
  49077. /**
  49078. * Called by the particle System when the direction is computed for the created particle.
  49079. * @param worldMatrix is the world matrix of the particle system
  49080. * @param directionToUpdate is the direction vector to update with the result
  49081. * @param particle is the particle we are computed the direction for
  49082. */
  49083. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  49084. /**
  49085. * Called by the particle System when the position is computed for the created particle.
  49086. * @param worldMatrix is the world matrix of the particle system
  49087. * @param positionToUpdate is the position vector to update with the result
  49088. * @param particle is the particle we are computed the position for
  49089. */
  49090. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  49091. /**
  49092. * Clones the current emitter and returns a copy of it
  49093. * @returns the new emitter
  49094. */
  49095. clone(): PointParticleEmitter;
  49096. /**
  49097. * Called by the GPUParticleSystem to setup the update shader
  49098. * @param effect defines the update shader
  49099. */
  49100. applyToShader(effect: Effect): void;
  49101. /**
  49102. * Returns a string to use to update the GPU particles update shader
  49103. * @returns a string containng the defines string
  49104. */
  49105. getEffectDefines(): string;
  49106. /**
  49107. * Returns the string "PointParticleEmitter"
  49108. * @returns a string containing the class name
  49109. */
  49110. getClassName(): string;
  49111. /**
  49112. * Serializes the particle system to a JSON object.
  49113. * @returns the JSON object
  49114. */
  49115. serialize(): any;
  49116. /**
  49117. * Parse properties from a JSON object
  49118. * @param serializationObject defines the JSON object
  49119. */
  49120. parse(serializationObject: any): void;
  49121. }
  49122. }
  49123. declare module BABYLON {
  49124. /**
  49125. * Particle emitter emitting particles from the inside of a sphere.
  49126. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  49127. */
  49128. class SphereParticleEmitter implements IParticleEmitterType {
  49129. /**
  49130. * The radius of the emission sphere.
  49131. */
  49132. radius: number;
  49133. /**
  49134. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  49135. */
  49136. radiusRange: number;
  49137. /**
  49138. * How much to randomize the particle direction [0-1].
  49139. */
  49140. directionRandomizer: number;
  49141. /**
  49142. * Creates a new instance SphereParticleEmitter
  49143. * @param radius the radius of the emission sphere (1 by default)
  49144. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  49145. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  49146. */
  49147. constructor(
  49148. /**
  49149. * The radius of the emission sphere.
  49150. */
  49151. radius?: number,
  49152. /**
  49153. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  49154. */
  49155. radiusRange?: number,
  49156. /**
  49157. * How much to randomize the particle direction [0-1].
  49158. */
  49159. directionRandomizer?: number);
  49160. /**
  49161. * Called by the particle System when the direction is computed for the created particle.
  49162. * @param worldMatrix is the world matrix of the particle system
  49163. * @param directionToUpdate is the direction vector to update with the result
  49164. * @param particle is the particle we are computed the direction for
  49165. */
  49166. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  49167. /**
  49168. * Called by the particle System when the position is computed for the created particle.
  49169. * @param worldMatrix is the world matrix of the particle system
  49170. * @param positionToUpdate is the position vector to update with the result
  49171. * @param particle is the particle we are computed the position for
  49172. */
  49173. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  49174. /**
  49175. * Clones the current emitter and returns a copy of it
  49176. * @returns the new emitter
  49177. */
  49178. clone(): SphereParticleEmitter;
  49179. /**
  49180. * Called by the GPUParticleSystem to setup the update shader
  49181. * @param effect defines the update shader
  49182. */
  49183. applyToShader(effect: Effect): void;
  49184. /**
  49185. * Returns a string to use to update the GPU particles update shader
  49186. * @returns a string containng the defines string
  49187. */
  49188. getEffectDefines(): string;
  49189. /**
  49190. * Returns the string "SphereParticleEmitter"
  49191. * @returns a string containing the class name
  49192. */
  49193. getClassName(): string;
  49194. /**
  49195. * Serializes the particle system to a JSON object.
  49196. * @returns the JSON object
  49197. */
  49198. serialize(): any;
  49199. /**
  49200. * Parse properties from a JSON object
  49201. * @param serializationObject defines the JSON object
  49202. */
  49203. parse(serializationObject: any): void;
  49204. }
  49205. /**
  49206. * Particle emitter emitting particles from the inside of a sphere.
  49207. * It emits the particles randomly between two vectors.
  49208. */
  49209. class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  49210. /**
  49211. * The min limit of the emission direction.
  49212. */
  49213. direction1: Vector3;
  49214. /**
  49215. * The max limit of the emission direction.
  49216. */
  49217. direction2: Vector3;
  49218. /**
  49219. * Creates a new instance SphereDirectedParticleEmitter
  49220. * @param radius the radius of the emission sphere (1 by default)
  49221. * @param direction1 the min limit of the emission direction (up vector by default)
  49222. * @param direction2 the max limit of the emission direction (up vector by default)
  49223. */
  49224. constructor(radius?: number,
  49225. /**
  49226. * The min limit of the emission direction.
  49227. */
  49228. direction1?: Vector3,
  49229. /**
  49230. * The max limit of the emission direction.
  49231. */
  49232. direction2?: Vector3);
  49233. /**
  49234. * Called by the particle System when the direction is computed for the created particle.
  49235. * @param worldMatrix is the world matrix of the particle system
  49236. * @param directionToUpdate is the direction vector to update with the result
  49237. * @param particle is the particle we are computed the direction for
  49238. */
  49239. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  49240. /**
  49241. * Clones the current emitter and returns a copy of it
  49242. * @returns the new emitter
  49243. */
  49244. clone(): SphereDirectedParticleEmitter;
  49245. /**
  49246. * Called by the GPUParticleSystem to setup the update shader
  49247. * @param effect defines the update shader
  49248. */
  49249. applyToShader(effect: Effect): void;
  49250. /**
  49251. * Returns a string to use to update the GPU particles update shader
  49252. * @returns a string containng the defines string
  49253. */
  49254. getEffectDefines(): string;
  49255. /**
  49256. * Returns the string "SphereDirectedParticleEmitter"
  49257. * @returns a string containing the class name
  49258. */
  49259. getClassName(): string;
  49260. /**
  49261. * Serializes the particle system to a JSON object.
  49262. * @returns the JSON object
  49263. */
  49264. serialize(): any;
  49265. /**
  49266. * Parse properties from a JSON object
  49267. * @param serializationObject defines the JSON object
  49268. */
  49269. parse(serializationObject: any): void;
  49270. }
  49271. }
  49272. declare module BABYLON {
  49273. /**
  49274. * AmmoJS Physics plugin
  49275. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  49276. * @see https://github.com/kripken/ammo.js/
  49277. */
  49278. class AmmoJSPlugin implements IPhysicsEnginePlugin {
  49279. private _useDeltaForWorldStep;
  49280. /**
  49281. * Reference to the Ammo library
  49282. */
  49283. bjsAMMO: any;
  49284. /**
  49285. * Created ammoJS world which physics bodies are added to
  49286. */
  49287. world: any;
  49288. /**
  49289. * Name of the plugin
  49290. */
  49291. name: string;
  49292. private _timeStep;
  49293. private _fixedTimeStep;
  49294. private _maxSteps;
  49295. private _tmpQuaternion;
  49296. private _tmpAmmoTransform;
  49297. private _tmpAmmoQuaternion;
  49298. private _tmpAmmoConcreteContactResultCallback;
  49299. private _collisionConfiguration;
  49300. private _dispatcher;
  49301. private _overlappingPairCache;
  49302. private _solver;
  49303. private _tmpAmmoVectorA;
  49304. private _tmpAmmoVectorB;
  49305. private _tmpAmmoVectorC;
  49306. private _tmpContactCallbackResult;
  49307. private static readonly DISABLE_COLLISION_FLAG;
  49308. private static readonly KINEMATIC_FLAG;
  49309. private static readonly DISABLE_DEACTIVATION_FLAG;
  49310. /**
  49311. * Initializes the ammoJS plugin
  49312. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  49313. */
  49314. constructor(_useDeltaForWorldStep?: boolean);
  49315. /**
  49316. * Sets the gravity of the physics world (m/(s^2))
  49317. * @param gravity Gravity to set
  49318. */
  49319. setGravity(gravity: Vector3): void;
  49320. /**
  49321. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  49322. * @param timeStep timestep to use in seconds
  49323. */
  49324. setTimeStep(timeStep: number): void;
  49325. /**
  49326. * 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)
  49327. * @param fixedTimeStep fixedTimeStep to use in seconds
  49328. */
  49329. setFixedTimeStep(fixedTimeStep: number): void;
  49330. /**
  49331. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  49332. * @param maxSteps the maximum number of steps by the physics engine per frame
  49333. */
  49334. setMaxSteps(maxSteps: number): void;
  49335. /**
  49336. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  49337. * @returns the current timestep in seconds
  49338. */
  49339. getTimeStep(): number;
  49340. private _isImpostorInContact;
  49341. private _isImpostorPairInContact;
  49342. private _stepSimulation;
  49343. /**
  49344. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  49345. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  49346. * After the step the babylon meshes are set to the position of the physics imposters
  49347. * @param delta amount of time to step forward
  49348. * @param impostors array of imposters to update before/after the step
  49349. */
  49350. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  49351. /**
  49352. * Applies an implulse on the imposter
  49353. * @param impostor imposter to apply impulse
  49354. * @param force amount of force to be applied to the imposter
  49355. * @param contactPoint the location to apply the impulse on the imposter
  49356. */
  49357. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49358. /**
  49359. * Applies a force on the imposter
  49360. * @param impostor imposter to apply force
  49361. * @param force amount of force to be applied to the imposter
  49362. * @param contactPoint the location to apply the force on the imposter
  49363. */
  49364. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49365. /**
  49366. * Creates a physics body using the plugin
  49367. * @param impostor the imposter to create the physics body on
  49368. */
  49369. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49370. /**
  49371. * Removes the physics body from the imposter and disposes of the body's memory
  49372. * @param impostor imposter to remove the physics body from
  49373. */
  49374. removePhysicsBody(impostor: PhysicsImpostor): void;
  49375. /**
  49376. * Generates a joint
  49377. * @param impostorJoint the imposter joint to create the joint with
  49378. */
  49379. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49380. /**
  49381. * Removes a joint
  49382. * @param impostorJoint the imposter joint to remove the joint from
  49383. */
  49384. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49385. private _addMeshVerts;
  49386. private _createShape;
  49387. /**
  49388. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  49389. * @param impostor imposter containing the physics body and babylon object
  49390. */
  49391. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49392. /**
  49393. * Sets the babylon object's position/rotation from the physics body's position/rotation
  49394. * @param impostor imposter containing the physics body and babylon object
  49395. * @param newPosition new position
  49396. * @param newRotation new rotation
  49397. */
  49398. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49399. /**
  49400. * If this plugin is supported
  49401. * @returns true if its supported
  49402. */
  49403. isSupported(): boolean;
  49404. /**
  49405. * Sets the linear velocity of the physics body
  49406. * @param impostor imposter to set the velocity on
  49407. * @param velocity velocity to set
  49408. */
  49409. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49410. /**
  49411. * Sets the angular velocity of the physics body
  49412. * @param impostor imposter to set the velocity on
  49413. * @param velocity velocity to set
  49414. */
  49415. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49416. /**
  49417. * gets the linear velocity
  49418. * @param impostor imposter to get linear velocity from
  49419. * @returns linear velocity
  49420. */
  49421. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49422. /**
  49423. * gets the angular velocity
  49424. * @param impostor imposter to get angular velocity from
  49425. * @returns angular velocity
  49426. */
  49427. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49428. /**
  49429. * Sets the mass of physics body
  49430. * @param impostor imposter to set the mass on
  49431. * @param mass mass to set
  49432. */
  49433. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49434. /**
  49435. * Gets the mass of the physics body
  49436. * @param impostor imposter to get the mass from
  49437. * @returns mass
  49438. */
  49439. getBodyMass(impostor: PhysicsImpostor): number;
  49440. /**
  49441. * Gets friction of the impostor
  49442. * @param impostor impostor to get friction from
  49443. * @returns friction value
  49444. */
  49445. getBodyFriction(impostor: PhysicsImpostor): number;
  49446. /**
  49447. * Sets friction of the impostor
  49448. * @param impostor impostor to set friction on
  49449. * @param friction friction value
  49450. */
  49451. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49452. /**
  49453. * Gets restitution of the impostor
  49454. * @param impostor impostor to get restitution from
  49455. * @returns restitution value
  49456. */
  49457. getBodyRestitution(impostor: PhysicsImpostor): number;
  49458. /**
  49459. * Sets resitution of the impostor
  49460. * @param impostor impostor to set resitution on
  49461. * @param restitution resitution value
  49462. */
  49463. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49464. /**
  49465. * Sleeps the physics body and stops it from being active
  49466. * @param impostor impostor to sleep
  49467. */
  49468. sleepBody(impostor: PhysicsImpostor): void;
  49469. /**
  49470. * Activates the physics body
  49471. * @param impostor impostor to activate
  49472. */
  49473. wakeUpBody(impostor: PhysicsImpostor): void;
  49474. /**
  49475. * Updates the distance parameters of the joint
  49476. * @param joint joint to update
  49477. * @param maxDistance maximum distance of the joint
  49478. * @param minDistance minimum distance of the joint
  49479. */
  49480. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  49481. /**
  49482. * Sets a motor on the joint
  49483. * @param joint joint to set motor on
  49484. * @param speed speed of the motor
  49485. * @param maxForce maximum force of the motor
  49486. * @param motorIndex index of the motor
  49487. */
  49488. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  49489. /**
  49490. * Sets the motors limit
  49491. * @param joint joint to set limit on
  49492. * @param upperLimit upper limit
  49493. * @param lowerLimit lower limit
  49494. */
  49495. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  49496. /**
  49497. * Syncs the position and rotation of a mesh with the impostor
  49498. * @param mesh mesh to sync
  49499. * @param impostor impostor to update the mesh with
  49500. */
  49501. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49502. /**
  49503. * Gets the radius of the impostor
  49504. * @param impostor impostor to get radius from
  49505. * @returns the radius
  49506. */
  49507. getRadius(impostor: PhysicsImpostor): number;
  49508. /**
  49509. * Gets the box size of the impostor
  49510. * @param impostor impostor to get box size from
  49511. * @param result the resulting box size
  49512. */
  49513. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49514. /**
  49515. * Disposes of the impostor
  49516. */
  49517. dispose(): void;
  49518. }
  49519. }
  49520. declare module BABYLON {
  49521. /** @hidden */
  49522. class CannonJSPlugin implements IPhysicsEnginePlugin {
  49523. private _useDeltaForWorldStep;
  49524. world: any;
  49525. name: string;
  49526. private _physicsMaterials;
  49527. private _fixedTimeStep;
  49528. BJSCANNON: any;
  49529. constructor(_useDeltaForWorldStep?: boolean, iterations?: number);
  49530. setGravity(gravity: Vector3): void;
  49531. setTimeStep(timeStep: number): void;
  49532. getTimeStep(): number;
  49533. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  49534. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49535. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49536. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49537. private _processChildMeshes;
  49538. removePhysicsBody(impostor: PhysicsImpostor): void;
  49539. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49540. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49541. private _addMaterial;
  49542. private _checkWithEpsilon;
  49543. private _createShape;
  49544. private _createHeightmap;
  49545. private _minus90X;
  49546. private _plus90X;
  49547. private _tmpPosition;
  49548. private _tmpDeltaPosition;
  49549. private _tmpUnityRotation;
  49550. private _updatePhysicsBodyTransformation;
  49551. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49552. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49553. isSupported(): boolean;
  49554. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49555. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49556. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49557. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49558. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49559. getBodyMass(impostor: PhysicsImpostor): number;
  49560. getBodyFriction(impostor: PhysicsImpostor): number;
  49561. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49562. getBodyRestitution(impostor: PhysicsImpostor): number;
  49563. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49564. sleepBody(impostor: PhysicsImpostor): void;
  49565. wakeUpBody(impostor: PhysicsImpostor): void;
  49566. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  49567. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  49568. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  49569. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49570. getRadius(impostor: PhysicsImpostor): number;
  49571. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49572. dispose(): void;
  49573. private _extendNamespace;
  49574. }
  49575. }
  49576. declare module BABYLON {
  49577. /** @hidden */
  49578. class OimoJSPlugin implements IPhysicsEnginePlugin {
  49579. world: any;
  49580. name: string;
  49581. BJSOIMO: any;
  49582. constructor(iterations?: number);
  49583. setGravity(gravity: Vector3): void;
  49584. setTimeStep(timeStep: number): void;
  49585. getTimeStep(): number;
  49586. private _tmpImpostorsArray;
  49587. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  49588. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49589. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49590. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49591. private _tmpPositionVector;
  49592. removePhysicsBody(impostor: PhysicsImpostor): void;
  49593. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49594. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49595. isSupported(): boolean;
  49596. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49597. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49598. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49599. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49600. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49601. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49602. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49603. getBodyMass(impostor: PhysicsImpostor): number;
  49604. getBodyFriction(impostor: PhysicsImpostor): number;
  49605. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49606. getBodyRestitution(impostor: PhysicsImpostor): number;
  49607. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49608. sleepBody(impostor: PhysicsImpostor): void;
  49609. wakeUpBody(impostor: PhysicsImpostor): void;
  49610. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  49611. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  49612. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  49613. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49614. getRadius(impostor: PhysicsImpostor): number;
  49615. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49616. dispose(): void;
  49617. }
  49618. }
  49619. declare module BABYLON {
  49620. /**
  49621. * This represents a set of one or more post processes in Babylon.
  49622. * A post process can be used to apply a shader to a texture after it is rendered.
  49623. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49624. */
  49625. class PostProcessRenderEffect {
  49626. private _postProcesses;
  49627. private _getPostProcesses;
  49628. private _singleInstance;
  49629. private _cameras;
  49630. private _indicesForCamera;
  49631. /**
  49632. * Name of the effect
  49633. * @hidden
  49634. */
  49635. _name: string;
  49636. /**
  49637. * Instantiates a post process render effect.
  49638. * A post process can be used to apply a shader to a texture after it is rendered.
  49639. * @param engine The engine the effect is tied to
  49640. * @param name The name of the effect
  49641. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  49642. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  49643. */
  49644. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  49645. /**
  49646. * Checks if all the post processes in the effect are supported.
  49647. */
  49648. readonly isSupported: boolean;
  49649. /**
  49650. * Updates the current state of the effect
  49651. * @hidden
  49652. */
  49653. _update(): void;
  49654. /**
  49655. * Attaches the effect on cameras
  49656. * @param cameras The camera to attach to.
  49657. * @hidden
  49658. */
  49659. _attachCameras(cameras: Camera): void;
  49660. /**
  49661. * Attaches the effect on cameras
  49662. * @param cameras The camera to attach to.
  49663. * @hidden
  49664. */
  49665. _attachCameras(cameras: Camera[]): void;
  49666. /**
  49667. * Detatches the effect on cameras
  49668. * @param cameras The camera to detatch from.
  49669. * @hidden
  49670. */
  49671. _detachCameras(cameras: Camera): void;
  49672. /**
  49673. * Detatches the effect on cameras
  49674. * @param cameras The camera to detatch from.
  49675. * @hidden
  49676. */
  49677. _detachCameras(cameras: Camera[]): void;
  49678. /**
  49679. * Enables the effect on given cameras
  49680. * @param cameras The camera to enable.
  49681. * @hidden
  49682. */
  49683. _enable(cameras: Camera): void;
  49684. /**
  49685. * Enables the effect on given cameras
  49686. * @param cameras The camera to enable.
  49687. * @hidden
  49688. */
  49689. _enable(cameras: Nullable<Camera[]>): void;
  49690. /**
  49691. * Disables the effect on the given cameras
  49692. * @param cameras The camera to disable.
  49693. * @hidden
  49694. */
  49695. _disable(cameras: Camera): void;
  49696. /**
  49697. * Disables the effect on the given cameras
  49698. * @param cameras The camera to disable.
  49699. * @hidden
  49700. */
  49701. _disable(cameras: Nullable<Camera[]>): void;
  49702. /**
  49703. * Gets a list of the post processes contained in the effect.
  49704. * @param camera The camera to get the post processes on.
  49705. * @returns The list of the post processes in the effect.
  49706. */
  49707. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  49708. }
  49709. }
  49710. declare module BABYLON {
  49711. /**
  49712. * PostProcessRenderPipeline
  49713. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49714. */
  49715. class PostProcessRenderPipeline {
  49716. private engine;
  49717. private _renderEffects;
  49718. private _renderEffectsForIsolatedPass;
  49719. /**
  49720. * @hidden
  49721. */
  49722. protected _cameras: Camera[];
  49723. /** @hidden */
  49724. _name: string;
  49725. /**
  49726. * Initializes a PostProcessRenderPipeline
  49727. * @param engine engine to add the pipeline to
  49728. * @param name name of the pipeline
  49729. */
  49730. constructor(engine: Engine, name: string);
  49731. /**
  49732. * "PostProcessRenderPipeline"
  49733. * @returns "PostProcessRenderPipeline"
  49734. */
  49735. getClassName(): string;
  49736. /**
  49737. * If all the render effects in the pipeline are support
  49738. */
  49739. readonly isSupported: boolean;
  49740. /**
  49741. * Adds an effect to the pipeline
  49742. * @param renderEffect the effect to add
  49743. */
  49744. addEffect(renderEffect: PostProcessRenderEffect): void;
  49745. /** @hidden */
  49746. _rebuild(): void;
  49747. /** @hidden */
  49748. _enableEffect(renderEffectName: string, cameras: Camera): void;
  49749. /** @hidden */
  49750. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  49751. /** @hidden */
  49752. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  49753. /** @hidden */
  49754. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  49755. /** @hidden */
  49756. _attachCameras(cameras: Camera, unique: boolean): void;
  49757. /** @hidden */
  49758. _attachCameras(cameras: Camera[], unique: boolean): void;
  49759. /** @hidden */
  49760. _detachCameras(cameras: Camera): void;
  49761. /** @hidden */
  49762. _detachCameras(cameras: Nullable<Camera[]>): void;
  49763. /** @hidden */
  49764. _update(): void;
  49765. /** @hidden */
  49766. _reset(): void;
  49767. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  49768. /**
  49769. * Disposes of the pipeline
  49770. */
  49771. dispose(): void;
  49772. }
  49773. }
  49774. declare module BABYLON {
  49775. /**
  49776. * PostProcessRenderPipelineManager class
  49777. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49778. */
  49779. class PostProcessRenderPipelineManager {
  49780. private _renderPipelines;
  49781. /**
  49782. * Initializes a PostProcessRenderPipelineManager
  49783. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49784. */
  49785. constructor();
  49786. /**
  49787. * Adds a pipeline to the manager
  49788. * @param renderPipeline The pipeline to add
  49789. */
  49790. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  49791. /**
  49792. * Attaches a camera to the pipeline
  49793. * @param renderPipelineName The name of the pipeline to attach to
  49794. * @param cameras the camera to attach
  49795. * @param unique if the camera can be attached multiple times to the pipeline
  49796. */
  49797. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  49798. /**
  49799. * Detaches a camera from the pipeline
  49800. * @param renderPipelineName The name of the pipeline to detach from
  49801. * @param cameras the camera to detach
  49802. */
  49803. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  49804. /**
  49805. * Enables an effect by name on a pipeline
  49806. * @param renderPipelineName the name of the pipeline to enable the effect in
  49807. * @param renderEffectName the name of the effect to enable
  49808. * @param cameras the cameras that the effect should be enabled on
  49809. */
  49810. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  49811. /**
  49812. * Disables an effect by name on a pipeline
  49813. * @param renderPipelineName the name of the pipeline to disable the effect in
  49814. * @param renderEffectName the name of the effect to disable
  49815. * @param cameras the cameras that the effect should be disabled on
  49816. */
  49817. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  49818. /**
  49819. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  49820. */
  49821. update(): void;
  49822. /** @hidden */
  49823. _rebuild(): void;
  49824. /**
  49825. * Disposes of the manager and pipelines
  49826. */
  49827. dispose(): void;
  49828. }
  49829. }
  49830. declare module BABYLON {
  49831. interface Scene {
  49832. /** @hidden (Backing field) */
  49833. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  49834. /**
  49835. * Gets the postprocess render pipeline manager
  49836. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49837. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  49838. */
  49839. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  49840. }
  49841. /**
  49842. * Defines the Render Pipeline scene component responsible to rendering pipelines
  49843. */
  49844. class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  49845. /**
  49846. * The component name helpfull to identify the component in the list of scene components.
  49847. */
  49848. readonly name: string;
  49849. /**
  49850. * The scene the component belongs to.
  49851. */
  49852. scene: Scene;
  49853. /**
  49854. * Creates a new instance of the component for the given scene
  49855. * @param scene Defines the scene to register the component in
  49856. */
  49857. constructor(scene: Scene);
  49858. /**
  49859. * Registers the component in a given scene
  49860. */
  49861. register(): void;
  49862. /**
  49863. * Rebuilds the elements related to this component in case of
  49864. * context lost for instance.
  49865. */
  49866. rebuild(): void;
  49867. /**
  49868. * Disposes the component and the associated ressources
  49869. */
  49870. dispose(): void;
  49871. private _gatherRenderTargets;
  49872. }
  49873. }
  49874. declare module BABYLON {
  49875. /**
  49876. * Helper class dealing with the extraction of spherical polynomial dataArray
  49877. * from a cube map.
  49878. */
  49879. class CubeMapToSphericalPolynomialTools {
  49880. private static FileFaces;
  49881. /**
  49882. * Converts a texture to the according Spherical Polynomial data.
  49883. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49884. *
  49885. * @param texture The texture to extract the information from.
  49886. * @return The Spherical Polynomial data.
  49887. */
  49888. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  49889. /**
  49890. * Converts a cubemap to the according Spherical Polynomial data.
  49891. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49892. *
  49893. * @param cubeInfo The Cube map to extract the information from.
  49894. * @return The Spherical Polynomial data.
  49895. */
  49896. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  49897. }
  49898. }
  49899. declare module BABYLON {
  49900. /**
  49901. * Header information of HDR texture files.
  49902. */
  49903. interface HDRInfo {
  49904. /**
  49905. * The height of the texture in pixels.
  49906. */
  49907. height: number;
  49908. /**
  49909. * The width of the texture in pixels.
  49910. */
  49911. width: number;
  49912. /**
  49913. * The index of the beginning of the data in the binary file.
  49914. */
  49915. dataPosition: number;
  49916. }
  49917. /**
  49918. * This groups tools to convert HDR texture to native colors array.
  49919. */
  49920. class HDRTools {
  49921. private static Ldexp;
  49922. private static Rgbe2float;
  49923. private static readStringLine;
  49924. /**
  49925. * Reads header information from an RGBE texture stored in a native array.
  49926. * More information on this format are available here:
  49927. * https://en.wikipedia.org/wiki/RGBE_image_format
  49928. *
  49929. * @param uint8array The binary file stored in native array.
  49930. * @return The header information.
  49931. */
  49932. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  49933. /**
  49934. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  49935. * This RGBE texture needs to store the information as a panorama.
  49936. *
  49937. * More information on this format are available here:
  49938. * https://en.wikipedia.org/wiki/RGBE_image_format
  49939. *
  49940. * @param buffer The binary file stored in an array buffer.
  49941. * @param size The expected size of the extracted cubemap.
  49942. * @return The Cube Map information.
  49943. */
  49944. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  49945. /**
  49946. * Returns the pixels data extracted from an RGBE texture.
  49947. * This pixels will be stored left to right up to down in the R G B order in one array.
  49948. *
  49949. * More information on this format are available here:
  49950. * https://en.wikipedia.org/wiki/RGBE_image_format
  49951. *
  49952. * @param uint8array The binary file stored in an array buffer.
  49953. * @param hdrInfo The header information of the file.
  49954. * @return The pixels data in RGB right to left up to down order.
  49955. */
  49956. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  49957. private static RGBE_ReadPixels_RLE;
  49958. }
  49959. }
  49960. declare module BABYLON {
  49961. /**
  49962. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  49963. */
  49964. interface CubeMapInfo {
  49965. /**
  49966. * The pixel array for the front face.
  49967. * This is stored in format, left to right, up to down format.
  49968. */
  49969. front: Nullable<ArrayBufferView>;
  49970. /**
  49971. * The pixel array for the back face.
  49972. * This is stored in format, left to right, up to down format.
  49973. */
  49974. back: Nullable<ArrayBufferView>;
  49975. /**
  49976. * The pixel array for the left face.
  49977. * This is stored in format, left to right, up to down format.
  49978. */
  49979. left: Nullable<ArrayBufferView>;
  49980. /**
  49981. * The pixel array for the right face.
  49982. * This is stored in format, left to right, up to down format.
  49983. */
  49984. right: Nullable<ArrayBufferView>;
  49985. /**
  49986. * The pixel array for the up face.
  49987. * This is stored in format, left to right, up to down format.
  49988. */
  49989. up: Nullable<ArrayBufferView>;
  49990. /**
  49991. * The pixel array for the down face.
  49992. * This is stored in format, left to right, up to down format.
  49993. */
  49994. down: Nullable<ArrayBufferView>;
  49995. /**
  49996. * The size of the cubemap stored.
  49997. *
  49998. * Each faces will be size * size pixels.
  49999. */
  50000. size: number;
  50001. /**
  50002. * The format of the texture.
  50003. *
  50004. * RGBA, RGB.
  50005. */
  50006. format: number;
  50007. /**
  50008. * The type of the texture data.
  50009. *
  50010. * UNSIGNED_INT, FLOAT.
  50011. */
  50012. type: number;
  50013. /**
  50014. * Specifies whether the texture is in gamma space.
  50015. */
  50016. gammaSpace: boolean;
  50017. }
  50018. /**
  50019. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  50020. */
  50021. class PanoramaToCubeMapTools {
  50022. private static FACE_FRONT;
  50023. private static FACE_BACK;
  50024. private static FACE_RIGHT;
  50025. private static FACE_LEFT;
  50026. private static FACE_DOWN;
  50027. private static FACE_UP;
  50028. /**
  50029. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  50030. *
  50031. * @param float32Array The source data.
  50032. * @param inputWidth The width of the input panorama.
  50033. * @param inputHeight The height of the input panorama.
  50034. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  50035. * @return The cubemap data
  50036. */
  50037. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  50038. private static CreateCubemapTexture;
  50039. private static CalcProjectionSpherical;
  50040. }
  50041. }
  50042. declare module BABYLON {
  50043. /**
  50044. * 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.
  50045. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  50046. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  50047. */
  50048. class CustomProceduralTexture extends ProceduralTexture {
  50049. private _animate;
  50050. private _time;
  50051. private _config;
  50052. private _texturePath;
  50053. /**
  50054. * Instantiates a new Custom Procedural Texture.
  50055. * 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.
  50056. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  50057. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  50058. * @param name Define the name of the texture
  50059. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  50060. * @param size Define the size of the texture to create
  50061. * @param scene Define the scene the texture belongs to
  50062. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  50063. * @param generateMipMaps Define if the texture should creates mip maps or not
  50064. */
  50065. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  50066. private _loadJson;
  50067. /**
  50068. * Is the texture ready to be used ? (rendered at least once)
  50069. * @returns true if ready, otherwise, false.
  50070. */
  50071. isReady(): boolean;
  50072. /**
  50073. * Render the texture to its associated render target.
  50074. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  50075. */
  50076. render(useCameraPostProcess?: boolean): void;
  50077. /**
  50078. * Update the list of dependant textures samplers in the shader.
  50079. */
  50080. updateTextures(): void;
  50081. /**
  50082. * Update the uniform values of the procedural texture in the shader.
  50083. */
  50084. updateShaderUniforms(): void;
  50085. /**
  50086. * Define if the texture animates or not.
  50087. */
  50088. animate: boolean;
  50089. }
  50090. }
  50091. declare module BABYLON {
  50092. /**
  50093. * Class used to generate noise procedural textures
  50094. */
  50095. class NoiseProceduralTexture extends ProceduralTexture {
  50096. private _time;
  50097. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  50098. brightness: number;
  50099. /** Defines the number of octaves to process */
  50100. octaves: number;
  50101. /** Defines the level of persistence (0.8 by default) */
  50102. persistence: number;
  50103. /** Gets or sets animation speed factor (default is 1) */
  50104. animationSpeedFactor: number;
  50105. /**
  50106. * Creates a new NoiseProceduralTexture
  50107. * @param name defines the name fo the texture
  50108. * @param size defines the size of the texture (default is 256)
  50109. * @param scene defines the hosting scene
  50110. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  50111. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  50112. */
  50113. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  50114. private _updateShaderUniforms;
  50115. protected _getDefines(): string;
  50116. /** Generate the current state of the procedural texture */
  50117. render(useCameraPostProcess?: boolean): void;
  50118. /**
  50119. * Serializes this noise procedural texture
  50120. * @returns a serialized noise procedural texture object
  50121. */
  50122. serialize(): any;
  50123. /**
  50124. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  50125. * @param parsedTexture defines parsed texture data
  50126. * @param scene defines the current scene
  50127. * @param rootUrl defines the root URL containing noise procedural texture information
  50128. * @returns a parsed NoiseProceduralTexture
  50129. */
  50130. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): NoiseProceduralTexture;
  50131. }
  50132. }
  50133. declare module BABYLON {
  50134. /**
  50135. * 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.
  50136. * This is the base class of any Procedural texture and contains most of the shareable code.
  50137. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  50138. */
  50139. class ProceduralTexture extends Texture {
  50140. isCube: boolean;
  50141. /**
  50142. * Define if the texture is enabled or not (disabled texture will not render)
  50143. */
  50144. isEnabled: boolean;
  50145. /**
  50146. * Define if the texture must be cleared before rendering (default is true)
  50147. */
  50148. autoClear: boolean;
  50149. /**
  50150. * Callback called when the texture is generated
  50151. */
  50152. onGenerated: () => void;
  50153. /**
  50154. * Event raised when the texture is generated
  50155. */
  50156. onGeneratedObservable: Observable<ProceduralTexture>;
  50157. /** @hidden */
  50158. _generateMipMaps: boolean;
  50159. /** @hidden **/
  50160. _effect: Effect;
  50161. /** @hidden */
  50162. _textures: {
  50163. [key: string]: Texture;
  50164. };
  50165. private _size;
  50166. private _currentRefreshId;
  50167. private _refreshRate;
  50168. private _vertexBuffers;
  50169. private _indexBuffer;
  50170. private _uniforms;
  50171. private _samplers;
  50172. private _fragment;
  50173. private _floats;
  50174. private _ints;
  50175. private _floatsArrays;
  50176. private _colors3;
  50177. private _colors4;
  50178. private _vectors2;
  50179. private _vectors3;
  50180. private _matrices;
  50181. private _fallbackTexture;
  50182. private _fallbackTextureUsed;
  50183. private _engine;
  50184. private _cachedDefines;
  50185. private _contentUpdateId;
  50186. private _contentData;
  50187. /**
  50188. * Instantiates a new procedural texture.
  50189. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  50190. * This is the base class of any Procedural texture and contains most of the shareable code.
  50191. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  50192. * @param name Define the name of the texture
  50193. * @param size Define the size of the texture to create
  50194. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  50195. * @param scene Define the scene the texture belongs to
  50196. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  50197. * @param generateMipMaps Define if the texture should creates mip maps or not
  50198. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  50199. */
  50200. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  50201. /**
  50202. * The effect that is created when initializing the post process.
  50203. * @returns The created effect corrisponding the the postprocess.
  50204. */
  50205. getEffect(): Effect;
  50206. /**
  50207. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  50208. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  50209. */
  50210. getContent(): Nullable<ArrayBufferView>;
  50211. private _createIndexBuffer;
  50212. /** @hidden */
  50213. _rebuild(): void;
  50214. /**
  50215. * Resets the texture in order to recreate its associated resources.
  50216. * This can be called in case of context loss
  50217. */
  50218. reset(): void;
  50219. protected _getDefines(): string;
  50220. /**
  50221. * Is the texture ready to be used ? (rendered at least once)
  50222. * @returns true if ready, otherwise, false.
  50223. */
  50224. isReady(): boolean;
  50225. /**
  50226. * Resets the refresh counter of the texture and start bak from scratch.
  50227. * Could be useful to regenerate the texture if it is setup to render only once.
  50228. */
  50229. resetRefreshCounter(): void;
  50230. /**
  50231. * Set the fragment shader to use in order to render the texture.
  50232. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  50233. */
  50234. setFragment(fragment: any): void;
  50235. /**
  50236. * Define the refresh rate of the texture or the rendering frequency.
  50237. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  50238. */
  50239. refreshRate: number;
  50240. /** @hidden */
  50241. _shouldRender(): boolean;
  50242. /**
  50243. * Get the size the texture is rendering at.
  50244. * @returns the size (texture is always squared)
  50245. */
  50246. getRenderSize(): number;
  50247. /**
  50248. * Resize the texture to new value.
  50249. * @param size Define the new size the texture should have
  50250. * @param generateMipMaps Define whether the new texture should create mip maps
  50251. */
  50252. resize(size: number, generateMipMaps: boolean): void;
  50253. private _checkUniform;
  50254. /**
  50255. * Set a texture in the shader program used to render.
  50256. * @param name Define the name of the uniform samplers as defined in the shader
  50257. * @param texture Define the texture to bind to this sampler
  50258. * @return the texture itself allowing "fluent" like uniform updates
  50259. */
  50260. setTexture(name: string, texture: Texture): ProceduralTexture;
  50261. /**
  50262. * Set a float in the shader.
  50263. * @param name Define the name of the uniform as defined in the shader
  50264. * @param value Define the value to give to the uniform
  50265. * @return the texture itself allowing "fluent" like uniform updates
  50266. */
  50267. setFloat(name: string, value: number): ProceduralTexture;
  50268. /**
  50269. * Set a int in the shader.
  50270. * @param name Define the name of the uniform as defined in the shader
  50271. * @param value Define the value to give to the uniform
  50272. * @return the texture itself allowing "fluent" like uniform updates
  50273. */
  50274. setInt(name: string, value: number): ProceduralTexture;
  50275. /**
  50276. * Set an array of floats in the shader.
  50277. * @param name Define the name of the uniform as defined in the shader
  50278. * @param value Define the value to give to the uniform
  50279. * @return the texture itself allowing "fluent" like uniform updates
  50280. */
  50281. setFloats(name: string, value: number[]): ProceduralTexture;
  50282. /**
  50283. * Set a vec3 in the shader from a Color3.
  50284. * @param name Define the name of the uniform as defined in the shader
  50285. * @param value Define the value to give to the uniform
  50286. * @return the texture itself allowing "fluent" like uniform updates
  50287. */
  50288. setColor3(name: string, value: Color3): ProceduralTexture;
  50289. /**
  50290. * Set a vec4 in the shader from a Color4.
  50291. * @param name Define the name of the uniform as defined in the shader
  50292. * @param value Define the value to give to the uniform
  50293. * @return the texture itself allowing "fluent" like uniform updates
  50294. */
  50295. setColor4(name: string, value: Color4): ProceduralTexture;
  50296. /**
  50297. * Set a vec2 in the shader from a Vector2.
  50298. * @param name Define the name of the uniform as defined in the shader
  50299. * @param value Define the value to give to the uniform
  50300. * @return the texture itself allowing "fluent" like uniform updates
  50301. */
  50302. setVector2(name: string, value: Vector2): ProceduralTexture;
  50303. /**
  50304. * Set a vec3 in the shader from a Vector3.
  50305. * @param name Define the name of the uniform as defined in the shader
  50306. * @param value Define the value to give to the uniform
  50307. * @return the texture itself allowing "fluent" like uniform updates
  50308. */
  50309. setVector3(name: string, value: Vector3): ProceduralTexture;
  50310. /**
  50311. * Set a mat4 in the shader from a MAtrix.
  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. setMatrix(name: string, value: Matrix): ProceduralTexture;
  50317. /**
  50318. * Render the texture to its associated render target.
  50319. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  50320. */
  50321. render(useCameraPostProcess?: boolean): void;
  50322. /**
  50323. * Clone the texture.
  50324. * @returns the cloned texture
  50325. */
  50326. clone(): ProceduralTexture;
  50327. /**
  50328. * Dispose the texture and release its asoociated resources.
  50329. */
  50330. dispose(): void;
  50331. }
  50332. }
  50333. declare module BABYLON {
  50334. interface AbstractScene {
  50335. /**
  50336. * The list of procedural textures added to the scene
  50337. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  50338. */
  50339. proceduralTextures: Array<ProceduralTexture>;
  50340. }
  50341. /**
  50342. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  50343. * in a given scene.
  50344. */
  50345. class ProceduralTextureSceneComponent implements ISceneComponent {
  50346. /**
  50347. * The component name helpfull to identify the component in the list of scene components.
  50348. */
  50349. readonly name: string;
  50350. /**
  50351. * The scene the component belongs to.
  50352. */
  50353. scene: Scene;
  50354. /**
  50355. * Creates a new instance of the component for the given scene
  50356. * @param scene Defines the scene to register the component in
  50357. */
  50358. constructor(scene: Scene);
  50359. /**
  50360. * Registers the component in a given scene
  50361. */
  50362. register(): void;
  50363. /**
  50364. * Rebuilds the elements related to this component in case of
  50365. * context lost for instance.
  50366. */
  50367. rebuild(): void;
  50368. /**
  50369. * Disposes the component and the associated ressources.
  50370. */
  50371. dispose(): void;
  50372. private _beforeClear;
  50373. }
  50374. }
  50375. declare module BABYLON {
  50376. }
  50377. declare module BABYLON {
  50378. }
  50379. declare module BABYLON {
  50380. }
  50381. declare module BABYLON {
  50382. }
  50383. declare module BABYLON {
  50384. /**
  50385. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  50386. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  50387. */
  50388. class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  50389. private _scene;
  50390. private _camerasToBeAttached;
  50391. /**
  50392. * ID of the sharpen post process,
  50393. */
  50394. private readonly SharpenPostProcessId;
  50395. /**
  50396. * @ignore
  50397. * ID of the image processing post process;
  50398. */
  50399. readonly ImageProcessingPostProcessId: string;
  50400. /**
  50401. * @ignore
  50402. * ID of the Fast Approximate Anti-Aliasing post process;
  50403. */
  50404. readonly FxaaPostProcessId: string;
  50405. /**
  50406. * ID of the chromatic aberration post process,
  50407. */
  50408. private readonly ChromaticAberrationPostProcessId;
  50409. /**
  50410. * ID of the grain post process
  50411. */
  50412. private readonly GrainPostProcessId;
  50413. /**
  50414. * Sharpen post process which will apply a sharpen convolution to enhance edges
  50415. */
  50416. sharpen: SharpenPostProcess;
  50417. private _sharpenEffect;
  50418. private bloom;
  50419. /**
  50420. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  50421. */
  50422. depthOfField: DepthOfFieldEffect;
  50423. /**
  50424. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  50425. */
  50426. fxaa: FxaaPostProcess;
  50427. /**
  50428. * Image post processing pass used to perform operations such as tone mapping or color grading.
  50429. */
  50430. imageProcessing: ImageProcessingPostProcess;
  50431. /**
  50432. * Chromatic aberration post process which will shift rgb colors in the image
  50433. */
  50434. chromaticAberration: ChromaticAberrationPostProcess;
  50435. private _chromaticAberrationEffect;
  50436. /**
  50437. * Grain post process which add noise to the image
  50438. */
  50439. grain: GrainPostProcess;
  50440. private _grainEffect;
  50441. /**
  50442. * Glow post process which adds a glow to emmisive areas of the image
  50443. */
  50444. private _glowLayer;
  50445. /**
  50446. * Animations which can be used to tweak settings over a period of time
  50447. */
  50448. animations: Animation[];
  50449. private _imageProcessingConfigurationObserver;
  50450. private _sharpenEnabled;
  50451. private _bloomEnabled;
  50452. private _depthOfFieldEnabled;
  50453. private _depthOfFieldBlurLevel;
  50454. private _fxaaEnabled;
  50455. private _imageProcessingEnabled;
  50456. private _defaultPipelineTextureType;
  50457. private _bloomScale;
  50458. private _chromaticAberrationEnabled;
  50459. private _grainEnabled;
  50460. private _buildAllowed;
  50461. /**
  50462. * Enable or disable the sharpen process from the pipeline
  50463. */
  50464. sharpenEnabled: boolean;
  50465. private _resizeObserver;
  50466. private _hardwareScaleLevel;
  50467. private _bloomKernel;
  50468. /**
  50469. * Specifies the size of the bloom blur kernel, relative to the final output size
  50470. */
  50471. bloomKernel: number;
  50472. /**
  50473. * Specifies the weight of the bloom in the final rendering
  50474. */
  50475. private _bloomWeight;
  50476. /**
  50477. * Specifies the luma threshold for the area that will be blurred by the bloom
  50478. */
  50479. private _bloomThreshold;
  50480. private _hdr;
  50481. /**
  50482. * The strength of the bloom.
  50483. */
  50484. bloomWeight: number;
  50485. /**
  50486. * The strength of the bloom.
  50487. */
  50488. bloomThreshold: number;
  50489. /**
  50490. * The scale of the bloom, lower value will provide better performance.
  50491. */
  50492. bloomScale: number;
  50493. /**
  50494. * Enable or disable the bloom from the pipeline
  50495. */
  50496. bloomEnabled: boolean;
  50497. private _rebuildBloom;
  50498. /**
  50499. * If the depth of field is enabled.
  50500. */
  50501. depthOfFieldEnabled: boolean;
  50502. /**
  50503. * Blur level of the depth of field effect. (Higher blur will effect performance)
  50504. */
  50505. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  50506. /**
  50507. * If the anti aliasing is enabled.
  50508. */
  50509. fxaaEnabled: boolean;
  50510. private _samples;
  50511. /**
  50512. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  50513. */
  50514. samples: number;
  50515. /**
  50516. * If image processing is enabled.
  50517. */
  50518. imageProcessingEnabled: boolean;
  50519. /**
  50520. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  50521. */
  50522. glowLayerEnabled: boolean;
  50523. /**
  50524. * Enable or disable the chromaticAberration process from the pipeline
  50525. */
  50526. chromaticAberrationEnabled: boolean;
  50527. /**
  50528. * Enable or disable the grain process from the pipeline
  50529. */
  50530. grainEnabled: boolean;
  50531. /**
  50532. * @constructor
  50533. * @param name - The rendering pipeline name (default: "")
  50534. * @param hdr - If high dynamic range textures should be used (default: true)
  50535. * @param scene - The scene linked to this pipeline (default: the last created scene)
  50536. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  50537. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  50538. */
  50539. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  50540. /**
  50541. * Force the compilation of the entire pipeline.
  50542. */
  50543. prepare(): void;
  50544. private _hasCleared;
  50545. private _prevPostProcess;
  50546. private _prevPrevPostProcess;
  50547. private _setAutoClearAndTextureSharing;
  50548. private _depthOfFieldSceneObserver;
  50549. private _buildPipeline;
  50550. private _disposePostProcesses;
  50551. /**
  50552. * Adds a camera to the pipeline
  50553. * @param camera the camera to be added
  50554. */
  50555. addCamera(camera: Camera): void;
  50556. /**
  50557. * Removes a camera from the pipeline
  50558. * @param camera the camera to remove
  50559. */
  50560. removeCamera(camera: Camera): void;
  50561. /**
  50562. * Dispose of the pipeline and stop all post processes
  50563. */
  50564. dispose(): void;
  50565. /**
  50566. * Serialize the rendering pipeline (Used when exporting)
  50567. * @returns the serialized object
  50568. */
  50569. serialize(): any;
  50570. /**
  50571. * Parse the serialized pipeline
  50572. * @param source Source pipeline.
  50573. * @param scene The scene to load the pipeline to.
  50574. * @param rootUrl The URL of the serialized pipeline.
  50575. * @returns An instantiated pipeline from the serialized object.
  50576. */
  50577. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  50578. }
  50579. }
  50580. declare module BABYLON {
  50581. /**
  50582. * BABYLON.JS Chromatic Aberration GLSL Shader
  50583. * Author: Olivier Guyot
  50584. * Separates very slightly R, G and B colors on the edges of the screen
  50585. * Inspired by Francois Tarlier & Martins Upitis
  50586. */
  50587. class LensRenderingPipeline extends PostProcessRenderPipeline {
  50588. /**
  50589. * @ignore
  50590. * The chromatic aberration PostProcess id in the pipeline
  50591. */
  50592. LensChromaticAberrationEffect: string;
  50593. /**
  50594. * @ignore
  50595. * The highlights enhancing PostProcess id in the pipeline
  50596. */
  50597. HighlightsEnhancingEffect: string;
  50598. /**
  50599. * @ignore
  50600. * The depth-of-field PostProcess id in the pipeline
  50601. */
  50602. LensDepthOfFieldEffect: string;
  50603. private _scene;
  50604. private _depthTexture;
  50605. private _grainTexture;
  50606. private _chromaticAberrationPostProcess;
  50607. private _highlightsPostProcess;
  50608. private _depthOfFieldPostProcess;
  50609. private _edgeBlur;
  50610. private _grainAmount;
  50611. private _chromaticAberration;
  50612. private _distortion;
  50613. private _highlightsGain;
  50614. private _highlightsThreshold;
  50615. private _dofDistance;
  50616. private _dofAperture;
  50617. private _dofDarken;
  50618. private _dofPentagon;
  50619. private _blurNoise;
  50620. /**
  50621. * @constructor
  50622. *
  50623. * Effect parameters are as follow:
  50624. * {
  50625. * chromatic_aberration: number; // from 0 to x (1 for realism)
  50626. * edge_blur: number; // from 0 to x (1 for realism)
  50627. * distortion: number; // from 0 to x (1 for realism)
  50628. * grain_amount: number; // from 0 to 1
  50629. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  50630. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  50631. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  50632. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  50633. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  50634. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  50635. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  50636. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  50637. * }
  50638. * Note: if an effect parameter is unset, effect is disabled
  50639. *
  50640. * @param name The rendering pipeline name
  50641. * @param parameters - An object containing all parameters (see above)
  50642. * @param scene The scene linked to this pipeline
  50643. * @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)
  50644. * @param cameras The array of cameras that the rendering pipeline will be attached to
  50645. */
  50646. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  50647. /**
  50648. * Sets the amount of blur at the edges
  50649. * @param amount blur amount
  50650. */
  50651. setEdgeBlur(amount: number): void;
  50652. /**
  50653. * Sets edge blur to 0
  50654. */
  50655. disableEdgeBlur(): void;
  50656. /**
  50657. * Sets the amout of grain
  50658. * @param amount Amount of grain
  50659. */
  50660. setGrainAmount(amount: number): void;
  50661. /**
  50662. * Set grain amount to 0
  50663. */
  50664. disableGrain(): void;
  50665. /**
  50666. * Sets the chromatic aberration amount
  50667. * @param amount amount of chromatic aberration
  50668. */
  50669. setChromaticAberration(amount: number): void;
  50670. /**
  50671. * Sets chromatic aberration amount to 0
  50672. */
  50673. disableChromaticAberration(): void;
  50674. /**
  50675. * Sets the EdgeDistortion amount
  50676. * @param amount amount of EdgeDistortion
  50677. */
  50678. setEdgeDistortion(amount: number): void;
  50679. /**
  50680. * Sets edge distortion to 0
  50681. */
  50682. disableEdgeDistortion(): void;
  50683. /**
  50684. * Sets the FocusDistance amount
  50685. * @param amount amount of FocusDistance
  50686. */
  50687. setFocusDistance(amount: number): void;
  50688. /**
  50689. * Disables depth of field
  50690. */
  50691. disableDepthOfField(): void;
  50692. /**
  50693. * Sets the Aperture amount
  50694. * @param amount amount of Aperture
  50695. */
  50696. setAperture(amount: number): void;
  50697. /**
  50698. * Sets the DarkenOutOfFocus amount
  50699. * @param amount amount of DarkenOutOfFocus
  50700. */
  50701. setDarkenOutOfFocus(amount: number): void;
  50702. /**
  50703. * Creates a pentagon bokeh effect
  50704. */
  50705. enablePentagonBokeh(): void;
  50706. /**
  50707. * Disables the pentagon bokeh effect
  50708. */
  50709. disablePentagonBokeh(): void;
  50710. /**
  50711. * Enables noise blur
  50712. */
  50713. enableNoiseBlur(): void;
  50714. /**
  50715. * Disables noise blur
  50716. */
  50717. disableNoiseBlur(): void;
  50718. /**
  50719. * Sets the HighlightsGain amount
  50720. * @param amount amount of HighlightsGain
  50721. */
  50722. setHighlightsGain(amount: number): void;
  50723. /**
  50724. * Sets the HighlightsThreshold amount
  50725. * @param amount amount of HighlightsThreshold
  50726. */
  50727. setHighlightsThreshold(amount: number): void;
  50728. /**
  50729. * Disables highlights
  50730. */
  50731. disableHighlights(): void;
  50732. /**
  50733. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  50734. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  50735. */
  50736. dispose(disableDepthRender?: boolean): void;
  50737. private _createChromaticAberrationPostProcess;
  50738. private _createHighlightsPostProcess;
  50739. private _createDepthOfFieldPostProcess;
  50740. private _createGrainTexture;
  50741. }
  50742. }
  50743. declare module BABYLON {
  50744. /**
  50745. * Render pipeline to produce ssao effect
  50746. */
  50747. class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  50748. /**
  50749. * @ignore
  50750. * The PassPostProcess id in the pipeline that contains the original scene color
  50751. */
  50752. SSAOOriginalSceneColorEffect: string;
  50753. /**
  50754. * @ignore
  50755. * The SSAO PostProcess id in the pipeline
  50756. */
  50757. SSAORenderEffect: string;
  50758. /**
  50759. * @ignore
  50760. * The horizontal blur PostProcess id in the pipeline
  50761. */
  50762. SSAOBlurHRenderEffect: string;
  50763. /**
  50764. * @ignore
  50765. * The vertical blur PostProcess id in the pipeline
  50766. */
  50767. SSAOBlurVRenderEffect: string;
  50768. /**
  50769. * @ignore
  50770. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  50771. */
  50772. SSAOCombineRenderEffect: string;
  50773. /**
  50774. * The output strength of the SSAO post-process. Default value is 1.0.
  50775. */
  50776. totalStrength: number;
  50777. /**
  50778. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  50779. */
  50780. maxZ: number;
  50781. /**
  50782. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  50783. */
  50784. minZAspect: number;
  50785. private _samples;
  50786. /**
  50787. * Number of samples used for the SSAO calculations. Default value is 8
  50788. */
  50789. samples: number;
  50790. private _textureSamples;
  50791. /**
  50792. * Number of samples to use for antialiasing
  50793. */
  50794. textureSamples: number;
  50795. /**
  50796. * Ratio object used for SSAO ratio and blur ratio
  50797. */
  50798. private _ratio;
  50799. /**
  50800. * Dynamically generated sphere sampler.
  50801. */
  50802. private _sampleSphere;
  50803. /**
  50804. * Blur filter offsets
  50805. */
  50806. private _samplerOffsets;
  50807. private _expensiveBlur;
  50808. /**
  50809. * If bilateral blur should be used
  50810. */
  50811. expensiveBlur: boolean;
  50812. /**
  50813. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  50814. */
  50815. radius: number;
  50816. /**
  50817. * The base color of the SSAO post-process
  50818. * The final result is "base + ssao" between [0, 1]
  50819. */
  50820. base: number;
  50821. /**
  50822. * Support test.
  50823. */
  50824. static readonly IsSupported: boolean;
  50825. private _scene;
  50826. private _depthTexture;
  50827. private _normalTexture;
  50828. private _randomTexture;
  50829. private _originalColorPostProcess;
  50830. private _ssaoPostProcess;
  50831. private _blurHPostProcess;
  50832. private _blurVPostProcess;
  50833. private _ssaoCombinePostProcess;
  50834. private _firstUpdate;
  50835. /**
  50836. * @constructor
  50837. * @param name The rendering pipeline name
  50838. * @param scene The scene linked to this pipeline
  50839. * @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 }
  50840. * @param cameras The array of cameras that the rendering pipeline will be attached to
  50841. */
  50842. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  50843. /**
  50844. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  50845. */
  50846. dispose(disableGeometryBufferRenderer?: boolean): void;
  50847. private _createBlurPostProcess;
  50848. /** @hidden */
  50849. _rebuild(): void;
  50850. private _bits;
  50851. private _radicalInverse_VdC;
  50852. private _hammersley;
  50853. private _hemisphereSample_uniform;
  50854. private _generateHemisphere;
  50855. private _createSSAOPostProcess;
  50856. private _createSSAOCombinePostProcess;
  50857. private _createRandomTexture;
  50858. /**
  50859. * Serialize the rendering pipeline (Used when exporting)
  50860. * @returns the serialized object
  50861. */
  50862. serialize(): any;
  50863. /**
  50864. * Parse the serialized pipeline
  50865. * @param source Source pipeline.
  50866. * @param scene The scene to load the pipeline to.
  50867. * @param rootUrl The URL of the serialized pipeline.
  50868. * @returns An instantiated pipeline from the serialized object.
  50869. */
  50870. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  50871. }
  50872. }
  50873. declare module BABYLON {
  50874. /**
  50875. * Render pipeline to produce ssao effect
  50876. */
  50877. class SSAORenderingPipeline extends PostProcessRenderPipeline {
  50878. /**
  50879. * @ignore
  50880. * The PassPostProcess id in the pipeline that contains the original scene color
  50881. */
  50882. SSAOOriginalSceneColorEffect: string;
  50883. /**
  50884. * @ignore
  50885. * The SSAO PostProcess id in the pipeline
  50886. */
  50887. SSAORenderEffect: string;
  50888. /**
  50889. * @ignore
  50890. * The horizontal blur PostProcess id in the pipeline
  50891. */
  50892. SSAOBlurHRenderEffect: string;
  50893. /**
  50894. * @ignore
  50895. * The vertical blur PostProcess id in the pipeline
  50896. */
  50897. SSAOBlurVRenderEffect: string;
  50898. /**
  50899. * @ignore
  50900. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  50901. */
  50902. SSAOCombineRenderEffect: string;
  50903. /**
  50904. * The output strength of the SSAO post-process. Default value is 1.0.
  50905. */
  50906. totalStrength: number;
  50907. /**
  50908. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  50909. */
  50910. radius: number;
  50911. /**
  50912. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  50913. * Must not be equal to fallOff and superior to fallOff.
  50914. * Default value is 0.975
  50915. */
  50916. area: number;
  50917. /**
  50918. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  50919. * Must not be equal to area and inferior to area.
  50920. * Default value is 0.0
  50921. */
  50922. fallOff: number;
  50923. /**
  50924. * The base color of the SSAO post-process
  50925. * The final result is "base + ssao" between [0, 1]
  50926. */
  50927. base: number;
  50928. private _scene;
  50929. private _depthTexture;
  50930. private _randomTexture;
  50931. private _originalColorPostProcess;
  50932. private _ssaoPostProcess;
  50933. private _blurHPostProcess;
  50934. private _blurVPostProcess;
  50935. private _ssaoCombinePostProcess;
  50936. private _firstUpdate;
  50937. /**
  50938. * @constructor
  50939. * @param name - The rendering pipeline name
  50940. * @param scene - The scene linked to this pipeline
  50941. * @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 }
  50942. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  50943. */
  50944. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  50945. /**
  50946. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  50947. */
  50948. dispose(disableDepthRender?: boolean): void;
  50949. private _createBlurPostProcess;
  50950. /** @hidden */
  50951. _rebuild(): void;
  50952. private _createSSAOPostProcess;
  50953. private _createSSAOCombinePostProcess;
  50954. private _createRandomTexture;
  50955. }
  50956. }
  50957. declare module BABYLON {
  50958. /**
  50959. * Standard rendering pipeline
  50960. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  50961. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  50962. */
  50963. class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  50964. /**
  50965. * Public members
  50966. */
  50967. /**
  50968. * Post-process which contains the original scene color before the pipeline applies all the effects
  50969. */
  50970. originalPostProcess: Nullable<PostProcess>;
  50971. /**
  50972. * Post-process used to down scale an image x4
  50973. */
  50974. downSampleX4PostProcess: Nullable<PostProcess>;
  50975. /**
  50976. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  50977. */
  50978. brightPassPostProcess: Nullable<PostProcess>;
  50979. /**
  50980. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  50981. */
  50982. blurHPostProcesses: PostProcess[];
  50983. /**
  50984. * Post-process array storing all the vertical blur post-processes used by the pipeline
  50985. */
  50986. blurVPostProcesses: PostProcess[];
  50987. /**
  50988. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  50989. */
  50990. textureAdderPostProcess: Nullable<PostProcess>;
  50991. /**
  50992. * Post-process used to create volumetric lighting effect
  50993. */
  50994. volumetricLightPostProcess: Nullable<PostProcess>;
  50995. /**
  50996. * Post-process used to smooth the previous volumetric light post-process on the X axis
  50997. */
  50998. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  50999. /**
  51000. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  51001. */
  51002. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  51003. /**
  51004. * Post-process used to merge the volumetric light effect and the real scene color
  51005. */
  51006. volumetricLightMergePostProces: Nullable<PostProcess>;
  51007. /**
  51008. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  51009. */
  51010. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  51011. /**
  51012. * Base post-process used to calculate the average luminance of the final image for HDR
  51013. */
  51014. luminancePostProcess: Nullable<PostProcess>;
  51015. /**
  51016. * Post-processes used to create down sample post-processes in order to get
  51017. * the average luminance of the final image for HDR
  51018. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  51019. */
  51020. luminanceDownSamplePostProcesses: PostProcess[];
  51021. /**
  51022. * Post-process used to create a HDR effect (light adaptation)
  51023. */
  51024. hdrPostProcess: Nullable<PostProcess>;
  51025. /**
  51026. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  51027. */
  51028. textureAdderFinalPostProcess: Nullable<PostProcess>;
  51029. /**
  51030. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  51031. */
  51032. lensFlareFinalPostProcess: Nullable<PostProcess>;
  51033. /**
  51034. * Post-process used to merge the final HDR post-process and the real scene color
  51035. */
  51036. hdrFinalPostProcess: Nullable<PostProcess>;
  51037. /**
  51038. * Post-process used to create a lens flare effect
  51039. */
  51040. lensFlarePostProcess: Nullable<PostProcess>;
  51041. /**
  51042. * Post-process that merges the result of the lens flare post-process and the real scene color
  51043. */
  51044. lensFlareComposePostProcess: Nullable<PostProcess>;
  51045. /**
  51046. * Post-process used to create a motion blur effect
  51047. */
  51048. motionBlurPostProcess: Nullable<PostProcess>;
  51049. /**
  51050. * Post-process used to create a depth of field effect
  51051. */
  51052. depthOfFieldPostProcess: Nullable<PostProcess>;
  51053. /**
  51054. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  51055. */
  51056. fxaaPostProcess: Nullable<FxaaPostProcess>;
  51057. /**
  51058. * Represents the brightness threshold in order to configure the illuminated surfaces
  51059. */
  51060. brightThreshold: number;
  51061. /**
  51062. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  51063. */
  51064. blurWidth: number;
  51065. /**
  51066. * Sets if the blur for highlighted surfaces must be only horizontal
  51067. */
  51068. horizontalBlur: boolean;
  51069. /**
  51070. * Sets the overall exposure used by the pipeline
  51071. */
  51072. exposure: number;
  51073. /**
  51074. * Texture used typically to simulate "dirty" on camera lens
  51075. */
  51076. lensTexture: Nullable<Texture>;
  51077. /**
  51078. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  51079. */
  51080. volumetricLightCoefficient: number;
  51081. /**
  51082. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  51083. */
  51084. volumetricLightPower: number;
  51085. /**
  51086. * Used the set the blur intensity to smooth the volumetric lights
  51087. */
  51088. volumetricLightBlurScale: number;
  51089. /**
  51090. * Light (spot or directional) used to generate the volumetric lights rays
  51091. * The source light must have a shadow generate so the pipeline can get its
  51092. * depth map
  51093. */
  51094. sourceLight: Nullable<SpotLight | DirectionalLight>;
  51095. /**
  51096. * For eye adaptation, represents the minimum luminance the eye can see
  51097. */
  51098. hdrMinimumLuminance: number;
  51099. /**
  51100. * For eye adaptation, represents the decrease luminance speed
  51101. */
  51102. hdrDecreaseRate: number;
  51103. /**
  51104. * For eye adaptation, represents the increase luminance speed
  51105. */
  51106. hdrIncreaseRate: number;
  51107. /**
  51108. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  51109. */
  51110. lensColorTexture: Nullable<Texture>;
  51111. /**
  51112. * The overall strengh for the lens flare effect
  51113. */
  51114. lensFlareStrength: number;
  51115. /**
  51116. * Dispersion coefficient for lens flare ghosts
  51117. */
  51118. lensFlareGhostDispersal: number;
  51119. /**
  51120. * Main lens flare halo width
  51121. */
  51122. lensFlareHaloWidth: number;
  51123. /**
  51124. * Based on the lens distortion effect, defines how much the lens flare result
  51125. * is distorted
  51126. */
  51127. lensFlareDistortionStrength: number;
  51128. /**
  51129. * Lens star texture must be used to simulate rays on the flares and is available
  51130. * in the documentation
  51131. */
  51132. lensStarTexture: Nullable<Texture>;
  51133. /**
  51134. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  51135. * flare effect by taking account of the dirt texture
  51136. */
  51137. lensFlareDirtTexture: Nullable<Texture>;
  51138. /**
  51139. * Represents the focal length for the depth of field effect
  51140. */
  51141. depthOfFieldDistance: number;
  51142. /**
  51143. * Represents the blur intensity for the blurred part of the depth of field effect
  51144. */
  51145. depthOfFieldBlurWidth: number;
  51146. /**
  51147. * For motion blur, defines how much the image is blurred by the movement
  51148. */
  51149. motionStrength: number;
  51150. /**
  51151. * List of animations for the pipeline (IAnimatable implementation)
  51152. */
  51153. animations: Animation[];
  51154. /**
  51155. * Private members
  51156. */
  51157. private _scene;
  51158. private _currentDepthOfFieldSource;
  51159. private _basePostProcess;
  51160. private _hdrCurrentLuminance;
  51161. private _floatTextureType;
  51162. private _ratio;
  51163. private _bloomEnabled;
  51164. private _depthOfFieldEnabled;
  51165. private _vlsEnabled;
  51166. private _lensFlareEnabled;
  51167. private _hdrEnabled;
  51168. private _motionBlurEnabled;
  51169. private _fxaaEnabled;
  51170. private _motionBlurSamples;
  51171. private _volumetricLightStepsCount;
  51172. private _samples;
  51173. /**
  51174. * @ignore
  51175. * Specifies if the bloom pipeline is enabled
  51176. */
  51177. BloomEnabled: boolean;
  51178. /**
  51179. * @ignore
  51180. * Specifies if the depth of field pipeline is enabed
  51181. */
  51182. DepthOfFieldEnabled: boolean;
  51183. /**
  51184. * @ignore
  51185. * Specifies if the lens flare pipeline is enabed
  51186. */
  51187. LensFlareEnabled: boolean;
  51188. /**
  51189. * @ignore
  51190. * Specifies if the HDR pipeline is enabled
  51191. */
  51192. HDREnabled: boolean;
  51193. /**
  51194. * @ignore
  51195. * Specifies if the volumetric lights scattering effect is enabled
  51196. */
  51197. VLSEnabled: boolean;
  51198. /**
  51199. * @ignore
  51200. * Specifies if the motion blur effect is enabled
  51201. */
  51202. MotionBlurEnabled: boolean;
  51203. /**
  51204. * Specifies if anti-aliasing is enabled
  51205. */
  51206. fxaaEnabled: boolean;
  51207. /**
  51208. * Specifies the number of steps used to calculate the volumetric lights
  51209. * Typically in interval [50, 200]
  51210. */
  51211. volumetricLightStepsCount: number;
  51212. /**
  51213. * Specifies the number of samples used for the motion blur effect
  51214. * Typically in interval [16, 64]
  51215. */
  51216. motionBlurSamples: number;
  51217. /**
  51218. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  51219. */
  51220. samples: number;
  51221. /**
  51222. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  51223. * @constructor
  51224. * @param name The rendering pipeline name
  51225. * @param scene The scene linked to this pipeline
  51226. * @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)
  51227. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  51228. * @param cameras The array of cameras that the rendering pipeline will be attached to
  51229. */
  51230. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  51231. private _buildPipeline;
  51232. private _createDownSampleX4PostProcess;
  51233. private _createBrightPassPostProcess;
  51234. private _createBlurPostProcesses;
  51235. private _createTextureAdderPostProcess;
  51236. private _createVolumetricLightPostProcess;
  51237. private _createLuminancePostProcesses;
  51238. private _createHdrPostProcess;
  51239. private _createLensFlarePostProcess;
  51240. private _createDepthOfFieldPostProcess;
  51241. private _createMotionBlurPostProcess;
  51242. private _getDepthTexture;
  51243. private _disposePostProcesses;
  51244. /**
  51245. * Dispose of the pipeline and stop all post processes
  51246. */
  51247. dispose(): void;
  51248. /**
  51249. * Serialize the rendering pipeline (Used when exporting)
  51250. * @returns the serialized object
  51251. */
  51252. serialize(): any;
  51253. /**
  51254. * Parse the serialized pipeline
  51255. * @param source Source pipeline.
  51256. * @param scene The scene to load the pipeline to.
  51257. * @param rootUrl The URL of the serialized pipeline.
  51258. * @returns An instantiated pipeline from the serialized object.
  51259. */
  51260. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  51261. /**
  51262. * Luminance steps
  51263. */
  51264. static LuminanceSteps: number;
  51265. }
  51266. }