babylon.d.ts 2.4 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module BABYLON {
  50. /**
  51. * Class containing a set of static utilities functions for arrays.
  52. */
  53. export class ArrayTools {
  54. /**
  55. * Returns an array of the given size filled with element built from the given constructor and the paramters
  56. * @param size the number of element to construct and put in the array
  57. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  58. * @returns a new array filled with new objects
  59. */
  60. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  61. }
  62. }
  63. declare module BABYLON {
  64. /**
  65. * Scalar computation library
  66. */
  67. export class Scalar {
  68. /**
  69. * Two pi constants convenient for computation.
  70. */
  71. static TwoPi: number;
  72. /**
  73. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74. * @param a number
  75. * @param b number
  76. * @param epsilon (default = 1.401298E-45)
  77. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  78. */
  79. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  80. /**
  81. * Returns a string : the upper case translation of the number i to hexadecimal.
  82. * @param i number
  83. * @returns the upper case translation of the number i to hexadecimal.
  84. */
  85. static ToHex(i: number): string;
  86. /**
  87. * Returns -1 if value is negative and +1 is value is positive.
  88. * @param value the value
  89. * @returns the value itself if it's equal to zero.
  90. */
  91. static Sign(value: number): number;
  92. /**
  93. * Returns the value itself if it's between min and max.
  94. * Returns min if the value is lower than min.
  95. * Returns max if the value is greater than max.
  96. * @param value the value to clmap
  97. * @param min the min value to clamp to (default: 0)
  98. * @param max the max value to clamp to (default: 1)
  99. * @returns the clamped value
  100. */
  101. static Clamp(value: number, min?: number, max?: number): number;
  102. /**
  103. * the log2 of value.
  104. * @param value the value to compute log2 of
  105. * @returns the log2 of value.
  106. */
  107. static Log2(value: number): number;
  108. /**
  109. * Loops the value, so that it is never larger than length and never smaller than 0.
  110. *
  111. * This is similar to the modulo operator but it works with floating point numbers.
  112. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  113. * With t = 5 and length = 2.5, the result would be 0.0.
  114. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  115. * @param value the value
  116. * @param length the length
  117. * @returns the looped value
  118. */
  119. static Repeat(value: number, length: number): number;
  120. /**
  121. * Normalize the value between 0.0 and 1.0 using min and max values
  122. * @param value value to normalize
  123. * @param min max to normalize between
  124. * @param max min to normalize between
  125. * @returns the normalized value
  126. */
  127. static Normalize(value: number, min: number, max: number): number;
  128. /**
  129. * Denormalize the value from 0.0 and 1.0 using min and max values
  130. * @param normalized value to denormalize
  131. * @param min max to denormalize between
  132. * @param max min to denormalize between
  133. * @returns the denormalized value
  134. */
  135. static Denormalize(normalized: number, min: number, max: number): number;
  136. /**
  137. * Calculates the shortest difference between two given angles given in degrees.
  138. * @param current current angle in degrees
  139. * @param target target angle in degrees
  140. * @returns the delta
  141. */
  142. static DeltaAngle(current: number, target: number): number;
  143. /**
  144. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  145. * @param tx value
  146. * @param length length
  147. * @returns The returned value will move back and forth between 0 and length
  148. */
  149. static PingPong(tx: number, length: number): number;
  150. /**
  151. * Interpolates between min and max with smoothing at the limits.
  152. *
  153. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  154. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  155. * @param from from
  156. * @param to to
  157. * @param tx value
  158. * @returns the smooth stepped value
  159. */
  160. static SmoothStep(from: number, to: number, tx: number): number;
  161. /**
  162. * Moves a value current towards target.
  163. *
  164. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  165. * Negative values of maxDelta pushes the value away from target.
  166. * @param current current value
  167. * @param target target value
  168. * @param maxDelta max distance to move
  169. * @returns resulting value
  170. */
  171. static MoveTowards(current: number, target: number, maxDelta: number): number;
  172. /**
  173. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  174. *
  175. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  176. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  177. * @param current current value
  178. * @param target target value
  179. * @param maxDelta max distance to move
  180. * @returns resulting angle
  181. */
  182. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  183. /**
  184. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  185. * @param start start value
  186. * @param end target value
  187. * @param amount amount to lerp between
  188. * @returns the lerped value
  189. */
  190. static Lerp(start: number, end: number, amount: number): number;
  191. /**
  192. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  193. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  194. * @param start start value
  195. * @param end target value
  196. * @param amount amount to lerp between
  197. * @returns the lerped value
  198. */
  199. static LerpAngle(start: number, end: number, amount: number): number;
  200. /**
  201. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  202. * @param a start value
  203. * @param b target value
  204. * @param value value between a and b
  205. * @returns the inverseLerp value
  206. */
  207. static InverseLerp(a: number, b: number, value: number): number;
  208. /**
  209. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  210. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  211. * @param value1 spline value
  212. * @param tangent1 spline value
  213. * @param value2 spline value
  214. * @param tangent2 spline value
  215. * @param amount input value
  216. * @returns hermite result
  217. */
  218. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  219. /**
  220. * Returns a random float number between and min and max values
  221. * @param min min value of random
  222. * @param max max value of random
  223. * @returns random value
  224. */
  225. static RandomRange(min: number, max: number): number;
  226. /**
  227. * This function returns percentage of a number in a given range.
  228. *
  229. * RangeToPercent(40,20,60) will return 0.5 (50%)
  230. * RangeToPercent(34,0,100) will return 0.34 (34%)
  231. * @param number to convert to percentage
  232. * @param min min range
  233. * @param max max range
  234. * @returns the percentage
  235. */
  236. static RangeToPercent(number: number, min: number, max: number): number;
  237. /**
  238. * This function returns number that corresponds to the percentage in a given range.
  239. *
  240. * PercentToRange(0.34,0,100) will return 34.
  241. * @param percent to convert to number
  242. * @param min min range
  243. * @param max max range
  244. * @returns the number
  245. */
  246. static PercentToRange(percent: number, min: number, max: number): number;
  247. /**
  248. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  249. * @param angle The angle to normalize in radian.
  250. * @return The converted angle.
  251. */
  252. static NormalizeRadians(angle: number): number;
  253. }
  254. }
  255. declare module BABYLON {
  256. /**
  257. * Constant used to convert a value to gamma space
  258. * @ignorenaming
  259. */
  260. export const ToGammaSpace: number;
  261. /**
  262. * Constant used to convert a value to linear space
  263. * @ignorenaming
  264. */
  265. export const ToLinearSpace = 2.2;
  266. /**
  267. * Constant used to define the minimal number value in Babylon.js
  268. * @ignorenaming
  269. */
  270. export const Epsilon = 0.001;
  271. /**
  272. * Class used to hold a RBG color
  273. */
  274. export class Color3 {
  275. /**
  276. * Defines the red component (between 0 and 1, default is 0)
  277. */
  278. r: number;
  279. /**
  280. * Defines the green component (between 0 and 1, default is 0)
  281. */
  282. g: number;
  283. /**
  284. * Defines the blue component (between 0 and 1, default is 0)
  285. */
  286. b: number;
  287. /**
  288. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  289. * @param r defines the red component (between 0 and 1, default is 0)
  290. * @param g defines the green component (between 0 and 1, default is 0)
  291. * @param b defines the blue component (between 0 and 1, default is 0)
  292. */
  293. constructor(
  294. /**
  295. * Defines the red component (between 0 and 1, default is 0)
  296. */
  297. r?: number,
  298. /**
  299. * Defines the green component (between 0 and 1, default is 0)
  300. */
  301. g?: number,
  302. /**
  303. * Defines the blue component (between 0 and 1, default is 0)
  304. */
  305. b?: number);
  306. /**
  307. * Creates a string with the Color3 current values
  308. * @returns the string representation of the Color3 object
  309. */
  310. toString(): string;
  311. /**
  312. * Returns the string "Color3"
  313. * @returns "Color3"
  314. */
  315. getClassName(): string;
  316. /**
  317. * Compute the Color3 hash code
  318. * @returns an unique number that can be used to hash Color3 objects
  319. */
  320. getHashCode(): number;
  321. /**
  322. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  323. * @param array defines the array where to store the r,g,b components
  324. * @param index defines an optional index in the target array to define where to start storing values
  325. * @returns the current Color3 object
  326. */
  327. toArray(array: FloatArray, index?: number): Color3;
  328. /**
  329. * Returns a new Color4 object from the current Color3 and the given alpha
  330. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  331. * @returns a new Color4 object
  332. */
  333. toColor4(alpha?: number): Color4;
  334. /**
  335. * Returns a new array populated with 3 numeric elements : red, green and blue values
  336. * @returns the new array
  337. */
  338. asArray(): number[];
  339. /**
  340. * Returns the luminance value
  341. * @returns a float value
  342. */
  343. toLuminance(): number;
  344. /**
  345. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  346. * @param otherColor defines the second operand
  347. * @returns the new Color3 object
  348. */
  349. multiply(otherColor: DeepImmutable<Color3>): Color3;
  350. /**
  351. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  352. * @param otherColor defines the second operand
  353. * @param result defines the Color3 object where to store the result
  354. * @returns the current Color3
  355. */
  356. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  357. /**
  358. * Determines equality between Color3 objects
  359. * @param otherColor defines the second operand
  360. * @returns true if the rgb values are equal to the given ones
  361. */
  362. equals(otherColor: DeepImmutable<Color3>): boolean;
  363. /**
  364. * Determines equality between the current Color3 object and a set of r,b,g values
  365. * @param r defines the red component to check
  366. * @param g defines the green component to check
  367. * @param b defines the blue component to check
  368. * @returns true if the rgb values are equal to the given ones
  369. */
  370. equalsFloats(r: number, g: number, b: number): boolean;
  371. /**
  372. * Multiplies in place each rgb value by scale
  373. * @param scale defines the scaling factor
  374. * @returns the updated Color3
  375. */
  376. scale(scale: number): Color3;
  377. /**
  378. * Multiplies the rgb values by scale and stores the result into "result"
  379. * @param scale defines the scaling factor
  380. * @param result defines the Color3 object where to store the result
  381. * @returns the unmodified current Color3
  382. */
  383. scaleToRef(scale: number, result: Color3): Color3;
  384. /**
  385. * Scale the current Color3 values by a factor and add the result to a given Color3
  386. * @param scale defines the scale factor
  387. * @param result defines color to store the result into
  388. * @returns the unmodified current Color3
  389. */
  390. scaleAndAddToRef(scale: number, result: Color3): Color3;
  391. /**
  392. * Clamps the rgb values by the min and max values and stores the result into "result"
  393. * @param min defines minimum clamping value (default is 0)
  394. * @param max defines maximum clamping value (default is 1)
  395. * @param result defines color to store the result into
  396. * @returns the original Color3
  397. */
  398. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  399. /**
  400. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  401. * @param otherColor defines the second operand
  402. * @returns the new Color3
  403. */
  404. add(otherColor: DeepImmutable<Color3>): Color3;
  405. /**
  406. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  407. * @param otherColor defines the second operand
  408. * @param result defines Color3 object to store the result into
  409. * @returns the unmodified current Color3
  410. */
  411. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  412. /**
  413. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  414. * @param otherColor defines the second operand
  415. * @returns the new Color3
  416. */
  417. subtract(otherColor: DeepImmutable<Color3>): Color3;
  418. /**
  419. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  420. * @param otherColor defines the second operand
  421. * @param result defines Color3 object to store the result into
  422. * @returns the unmodified current Color3
  423. */
  424. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  425. /**
  426. * Copy the current object
  427. * @returns a new Color3 copied the current one
  428. */
  429. clone(): Color3;
  430. /**
  431. * Copies the rgb values from the source in the current Color3
  432. * @param source defines the source Color3 object
  433. * @returns the updated Color3 object
  434. */
  435. copyFrom(source: DeepImmutable<Color3>): Color3;
  436. /**
  437. * Updates the Color3 rgb values from the given floats
  438. * @param r defines the red component to read from
  439. * @param g defines the green component to read from
  440. * @param b defines the blue component to read from
  441. * @returns the current Color3 object
  442. */
  443. copyFromFloats(r: number, g: number, b: number): Color3;
  444. /**
  445. * Updates the Color3 rgb values from the given floats
  446. * @param r defines the red component to read from
  447. * @param g defines the green component to read from
  448. * @param b defines the blue component to read from
  449. * @returns the current Color3 object
  450. */
  451. set(r: number, g: number, b: number): Color3;
  452. /**
  453. * Compute the Color3 hexadecimal code as a string
  454. * @returns a string containing the hexadecimal representation of the Color3 object
  455. */
  456. toHexString(): string;
  457. /**
  458. * Computes a new Color3 converted from the current one to linear space
  459. * @returns a new Color3 object
  460. */
  461. toLinearSpace(): Color3;
  462. /**
  463. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  464. * @param convertedColor defines the Color3 object where to store the linear space version
  465. * @returns the unmodified Color3
  466. */
  467. toLinearSpaceToRef(convertedColor: Color3): Color3;
  468. /**
  469. * Computes a new Color3 converted from the current one to gamma space
  470. * @returns a new Color3 object
  471. */
  472. toGammaSpace(): Color3;
  473. /**
  474. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  475. * @param convertedColor defines the Color3 object where to store the gamma space version
  476. * @returns the unmodified Color3
  477. */
  478. toGammaSpaceToRef(convertedColor: Color3): Color3;
  479. private static _BlackReadOnly;
  480. /**
  481. * Creates a new Color3 from the string containing valid hexadecimal values
  482. * @param hex defines a string containing valid hexadecimal values
  483. * @returns a new Color3 object
  484. */
  485. static FromHexString(hex: string): Color3;
  486. /**
  487. * Creates a new Vector3 from the starting index of the given array
  488. * @param array defines the source array
  489. * @param offset defines an offset in the source array
  490. * @returns a new Color3 object
  491. */
  492. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  493. /**
  494. * Creates a new Color3 from integer values (< 256)
  495. * @param r defines the red component to read from (value between 0 and 255)
  496. * @param g defines the green component to read from (value between 0 and 255)
  497. * @param b defines the blue component to read from (value between 0 and 255)
  498. * @returns a new Color3 object
  499. */
  500. static FromInts(r: number, g: number, b: number): Color3;
  501. /**
  502. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  503. * @param start defines the start Color3 value
  504. * @param end defines the end Color3 value
  505. * @param amount defines the gradient value between start and end
  506. * @returns a new Color3 object
  507. */
  508. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  509. /**
  510. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  511. * @param left defines the start value
  512. * @param right defines the end value
  513. * @param amount defines the gradient factor
  514. * @param result defines the Color3 object where to store the result
  515. */
  516. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  517. /**
  518. * Returns a Color3 value containing a red color
  519. * @returns a new Color3 object
  520. */
  521. static Red(): Color3;
  522. /**
  523. * Returns a Color3 value containing a green color
  524. * @returns a new Color3 object
  525. */
  526. static Green(): Color3;
  527. /**
  528. * Returns a Color3 value containing a blue color
  529. * @returns a new Color3 object
  530. */
  531. static Blue(): Color3;
  532. /**
  533. * Returns a Color3 value containing a black color
  534. * @returns a new Color3 object
  535. */
  536. static Black(): Color3;
  537. /**
  538. * Gets a Color3 value containing a black color that must not be updated
  539. */
  540. static readonly BlackReadOnly: DeepImmutable<Color3>;
  541. /**
  542. * Returns a Color3 value containing a white color
  543. * @returns a new Color3 object
  544. */
  545. static White(): Color3;
  546. /**
  547. * Returns a Color3 value containing a purple color
  548. * @returns a new Color3 object
  549. */
  550. static Purple(): Color3;
  551. /**
  552. * Returns a Color3 value containing a magenta color
  553. * @returns a new Color3 object
  554. */
  555. static Magenta(): Color3;
  556. /**
  557. * Returns a Color3 value containing a yellow color
  558. * @returns a new Color3 object
  559. */
  560. static Yellow(): Color3;
  561. /**
  562. * Returns a Color3 value containing a gray color
  563. * @returns a new Color3 object
  564. */
  565. static Gray(): Color3;
  566. /**
  567. * Returns a Color3 value containing a teal color
  568. * @returns a new Color3 object
  569. */
  570. static Teal(): Color3;
  571. /**
  572. * Returns a Color3 value containing a random color
  573. * @returns a new Color3 object
  574. */
  575. static Random(): Color3;
  576. }
  577. /**
  578. * Class used to hold a RBGA color
  579. */
  580. export class Color4 {
  581. /**
  582. * Defines the red component (between 0 and 1, default is 0)
  583. */
  584. r: number;
  585. /**
  586. * Defines the green component (between 0 and 1, default is 0)
  587. */
  588. g: number;
  589. /**
  590. * Defines the blue component (between 0 and 1, default is 0)
  591. */
  592. b: number;
  593. /**
  594. * Defines the alpha component (between 0 and 1, default is 1)
  595. */
  596. a: number;
  597. /**
  598. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  599. * @param r defines the red component (between 0 and 1, default is 0)
  600. * @param g defines the green component (between 0 and 1, default is 0)
  601. * @param b defines the blue component (between 0 and 1, default is 0)
  602. * @param a defines the alpha component (between 0 and 1, default is 1)
  603. */
  604. constructor(
  605. /**
  606. * Defines the red component (between 0 and 1, default is 0)
  607. */
  608. r?: number,
  609. /**
  610. * Defines the green component (between 0 and 1, default is 0)
  611. */
  612. g?: number,
  613. /**
  614. * Defines the blue component (between 0 and 1, default is 0)
  615. */
  616. b?: number,
  617. /**
  618. * Defines the alpha component (between 0 and 1, default is 1)
  619. */
  620. a?: number);
  621. /**
  622. * Adds in place the given Color4 values to the current Color4 object
  623. * @param right defines the second operand
  624. * @returns the current updated Color4 object
  625. */
  626. addInPlace(right: DeepImmutable<Color4>): Color4;
  627. /**
  628. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  629. * @returns the new array
  630. */
  631. asArray(): number[];
  632. /**
  633. * Stores from the starting index in the given array the Color4 successive values
  634. * @param array defines the array where to store the r,g,b components
  635. * @param index defines an optional index in the target array to define where to start storing values
  636. * @returns the current Color4 object
  637. */
  638. toArray(array: number[], index?: number): Color4;
  639. /**
  640. * Determines equality between Color4 objects
  641. * @param otherColor defines the second operand
  642. * @returns true if the rgba values are equal to the given ones
  643. */
  644. equals(otherColor: DeepImmutable<Color4>): boolean;
  645. /**
  646. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  647. * @param right defines the second operand
  648. * @returns a new Color4 object
  649. */
  650. add(right: DeepImmutable<Color4>): Color4;
  651. /**
  652. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  653. * @param right defines the second operand
  654. * @returns a new Color4 object
  655. */
  656. subtract(right: DeepImmutable<Color4>): Color4;
  657. /**
  658. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  659. * @param right defines the second operand
  660. * @param result defines the Color4 object where to store the result
  661. * @returns the current Color4 object
  662. */
  663. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  664. /**
  665. * Creates a new Color4 with the current Color4 values multiplied by scale
  666. * @param scale defines the scaling factor to apply
  667. * @returns a new Color4 object
  668. */
  669. scale(scale: number): Color4;
  670. /**
  671. * Multiplies the current Color4 values by scale and stores the result in "result"
  672. * @param scale defines the scaling factor to apply
  673. * @param result defines the Color4 object where to store the result
  674. * @returns the current unmodified Color4
  675. */
  676. scaleToRef(scale: number, result: Color4): Color4;
  677. /**
  678. * Scale the current Color4 values by a factor and add the result to a given Color4
  679. * @param scale defines the scale factor
  680. * @param result defines the Color4 object where to store the result
  681. * @returns the unmodified current Color4
  682. */
  683. scaleAndAddToRef(scale: number, result: Color4): Color4;
  684. /**
  685. * Clamps the rgb values by the min and max values and stores the result into "result"
  686. * @param min defines minimum clamping value (default is 0)
  687. * @param max defines maximum clamping value (default is 1)
  688. * @param result defines color to store the result into.
  689. * @returns the cuurent Color4
  690. */
  691. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  692. /**
  693. * Multipy an Color4 value by another and return a new Color4 object
  694. * @param color defines the Color4 value to multiply by
  695. * @returns a new Color4 object
  696. */
  697. multiply(color: Color4): Color4;
  698. /**
  699. * Multipy a Color4 value by another and push the result in a reference value
  700. * @param color defines the Color4 value to multiply by
  701. * @param result defines the Color4 to fill the result in
  702. * @returns the result Color4
  703. */
  704. multiplyToRef(color: Color4, result: Color4): Color4;
  705. /**
  706. * Creates a string with the Color4 current values
  707. * @returns the string representation of the Color4 object
  708. */
  709. toString(): string;
  710. /**
  711. * Returns the string "Color4"
  712. * @returns "Color4"
  713. */
  714. getClassName(): string;
  715. /**
  716. * Compute the Color4 hash code
  717. * @returns an unique number that can be used to hash Color4 objects
  718. */
  719. getHashCode(): number;
  720. /**
  721. * Creates a new Color4 copied from the current one
  722. * @returns a new Color4 object
  723. */
  724. clone(): Color4;
  725. /**
  726. * Copies the given Color4 values into the current one
  727. * @param source defines the source Color4 object
  728. * @returns the current updated Color4 object
  729. */
  730. copyFrom(source: Color4): Color4;
  731. /**
  732. * Copies the given float values into the current one
  733. * @param r defines the red component to read from
  734. * @param g defines the green component to read from
  735. * @param b defines the blue component to read from
  736. * @param a defines the alpha component to read from
  737. * @returns the current updated Color4 object
  738. */
  739. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  740. /**
  741. * Copies the given float values into the current one
  742. * @param r defines the red component to read from
  743. * @param g defines the green component to read from
  744. * @param b defines the blue component to read from
  745. * @param a defines the alpha component to read from
  746. * @returns the current updated Color4 object
  747. */
  748. set(r: number, g: number, b: number, a: number): Color4;
  749. /**
  750. * Compute the Color4 hexadecimal code as a string
  751. * @returns a string containing the hexadecimal representation of the Color4 object
  752. */
  753. toHexString(): string;
  754. /**
  755. * Computes a new Color4 converted from the current one to linear space
  756. * @returns a new Color4 object
  757. */
  758. toLinearSpace(): Color4;
  759. /**
  760. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  761. * @param convertedColor defines the Color4 object where to store the linear space version
  762. * @returns the unmodified Color4
  763. */
  764. toLinearSpaceToRef(convertedColor: Color4): Color4;
  765. /**
  766. * Computes a new Color4 converted from the current one to gamma space
  767. * @returns a new Color4 object
  768. */
  769. toGammaSpace(): Color4;
  770. /**
  771. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  772. * @param convertedColor defines the Color4 object where to store the gamma space version
  773. * @returns the unmodified Color4
  774. */
  775. toGammaSpaceToRef(convertedColor: Color4): Color4;
  776. /**
  777. * Creates a new Color4 from the string containing valid hexadecimal values
  778. * @param hex defines a string containing valid hexadecimal values
  779. * @returns a new Color4 object
  780. */
  781. static FromHexString(hex: string): Color4;
  782. /**
  783. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  784. * @param left defines the start value
  785. * @param right defines the end value
  786. * @param amount defines the gradient factor
  787. * @returns a new Color4 object
  788. */
  789. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  790. /**
  791. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  792. * @param left defines the start value
  793. * @param right defines the end value
  794. * @param amount defines the gradient factor
  795. * @param result defines the Color4 object where to store data
  796. */
  797. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  798. /**
  799. * Creates a new Color4 from a Color3 and an alpha value
  800. * @param color3 defines the source Color3 to read from
  801. * @param alpha defines the alpha component (1.0 by default)
  802. * @returns a new Color4 object
  803. */
  804. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  805. /**
  806. * Creates a new Color4 from the starting index element of the given array
  807. * @param array defines the source array to read from
  808. * @param offset defines the offset in the source array
  809. * @returns a new Color4 object
  810. */
  811. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  812. /**
  813. * Creates a new Color3 from integer values (< 256)
  814. * @param r defines the red component to read from (value between 0 and 255)
  815. * @param g defines the green component to read from (value between 0 and 255)
  816. * @param b defines the blue component to read from (value between 0 and 255)
  817. * @param a defines the alpha component to read from (value between 0 and 255)
  818. * @returns a new Color3 object
  819. */
  820. static FromInts(r: number, g: number, b: number, a: number): Color4;
  821. /**
  822. * Check the content of a given array and convert it to an array containing RGBA data
  823. * If the original array was already containing count * 4 values then it is returned directly
  824. * @param colors defines the array to check
  825. * @param count defines the number of RGBA data to expect
  826. * @returns an array containing count * 4 values (RGBA)
  827. */
  828. static CheckColors4(colors: number[], count: number): number[];
  829. }
  830. /**
  831. * Class representing a vector containing 2 coordinates
  832. */
  833. export class Vector2 {
  834. /** defines the first coordinate */
  835. x: number;
  836. /** defines the second coordinate */
  837. y: number;
  838. /**
  839. * Creates a new Vector2 from the given x and y coordinates
  840. * @param x defines the first coordinate
  841. * @param y defines the second coordinate
  842. */
  843. constructor(
  844. /** defines the first coordinate */
  845. x?: number,
  846. /** defines the second coordinate */
  847. y?: number);
  848. /**
  849. * Gets a string with the Vector2 coordinates
  850. * @returns a string with the Vector2 coordinates
  851. */
  852. toString(): string;
  853. /**
  854. * Gets class name
  855. * @returns the string "Vector2"
  856. */
  857. getClassName(): string;
  858. /**
  859. * Gets current vector hash code
  860. * @returns the Vector2 hash code as a number
  861. */
  862. getHashCode(): number;
  863. /**
  864. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  865. * @param array defines the source array
  866. * @param index defines the offset in source array
  867. * @returns the current Vector2
  868. */
  869. toArray(array: FloatArray, index?: number): Vector2;
  870. /**
  871. * Copy the current vector to an array
  872. * @returns a new array with 2 elements: the Vector2 coordinates.
  873. */
  874. asArray(): number[];
  875. /**
  876. * Sets the Vector2 coordinates with the given Vector2 coordinates
  877. * @param source defines the source Vector2
  878. * @returns the current updated Vector2
  879. */
  880. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  881. /**
  882. * Sets the Vector2 coordinates with the given floats
  883. * @param x defines the first coordinate
  884. * @param y defines the second coordinate
  885. * @returns the current updated Vector2
  886. */
  887. copyFromFloats(x: number, y: number): Vector2;
  888. /**
  889. * Sets the Vector2 coordinates with the given floats
  890. * @param x defines the first coordinate
  891. * @param y defines the second coordinate
  892. * @returns the current updated Vector2
  893. */
  894. set(x: number, y: number): Vector2;
  895. /**
  896. * Add another vector with the current one
  897. * @param otherVector defines the other vector
  898. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  899. */
  900. add(otherVector: DeepImmutable<Vector2>): Vector2;
  901. /**
  902. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  903. * @param otherVector defines the other vector
  904. * @param result defines the target vector
  905. * @returns the unmodified current Vector2
  906. */
  907. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  908. /**
  909. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  910. * @param otherVector defines the other vector
  911. * @returns the current updated Vector2
  912. */
  913. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  914. /**
  915. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  916. * @param otherVector defines the other vector
  917. * @returns a new Vector2
  918. */
  919. addVector3(otherVector: Vector3): Vector2;
  920. /**
  921. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  922. * @param otherVector defines the other vector
  923. * @returns a new Vector2
  924. */
  925. subtract(otherVector: Vector2): Vector2;
  926. /**
  927. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  928. * @param otherVector defines the other vector
  929. * @param result defines the target vector
  930. * @returns the unmodified current Vector2
  931. */
  932. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  933. /**
  934. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  935. * @param otherVector defines the other vector
  936. * @returns the current updated Vector2
  937. */
  938. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  939. /**
  940. * Multiplies in place the current Vector2 coordinates by the given ones
  941. * @param otherVector defines the other vector
  942. * @returns the current updated Vector2
  943. */
  944. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  945. /**
  946. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  947. * @param otherVector defines the other vector
  948. * @returns a new Vector2
  949. */
  950. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  951. /**
  952. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  953. * @param otherVector defines the other vector
  954. * @param result defines the target vector
  955. * @returns the unmodified current Vector2
  956. */
  957. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  958. /**
  959. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  960. * @param x defines the first coordinate
  961. * @param y defines the second coordinate
  962. * @returns a new Vector2
  963. */
  964. multiplyByFloats(x: number, y: number): Vector2;
  965. /**
  966. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  967. * @param otherVector defines the other vector
  968. * @returns a new Vector2
  969. */
  970. divide(otherVector: Vector2): Vector2;
  971. /**
  972. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  973. * @param otherVector defines the other vector
  974. * @param result defines the target vector
  975. * @returns the unmodified current Vector2
  976. */
  977. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  978. /**
  979. * Divides the current Vector2 coordinates by the given ones
  980. * @param otherVector defines the other vector
  981. * @returns the current updated Vector2
  982. */
  983. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  984. /**
  985. * Gets a new Vector2 with current Vector2 negated coordinates
  986. * @returns a new Vector2
  987. */
  988. negate(): Vector2;
  989. /**
  990. * Multiply the Vector2 coordinates by scale
  991. * @param scale defines the scaling factor
  992. * @returns the current updated Vector2
  993. */
  994. scaleInPlace(scale: number): Vector2;
  995. /**
  996. * Returns a new Vector2 scaled by "scale" from the current Vector2
  997. * @param scale defines the scaling factor
  998. * @returns a new Vector2
  999. */
  1000. scale(scale: number): Vector2;
  1001. /**
  1002. * Scale the current Vector2 values by a factor to a given Vector2
  1003. * @param scale defines the scale factor
  1004. * @param result defines the Vector2 object where to store the result
  1005. * @returns the unmodified current Vector2
  1006. */
  1007. scaleToRef(scale: number, result: Vector2): Vector2;
  1008. /**
  1009. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1010. * @param scale defines the scale factor
  1011. * @param result defines the Vector2 object where to store the result
  1012. * @returns the unmodified current Vector2
  1013. */
  1014. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1015. /**
  1016. * Gets a boolean if two vectors are equals
  1017. * @param otherVector defines the other vector
  1018. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1019. */
  1020. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1021. /**
  1022. * Gets a boolean if two vectors are equals (using an epsilon value)
  1023. * @param otherVector defines the other vector
  1024. * @param epsilon defines the minimal distance to consider equality
  1025. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1026. */
  1027. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1028. /**
  1029. * Gets a new Vector2 from current Vector2 floored values
  1030. * @returns a new Vector2
  1031. */
  1032. floor(): Vector2;
  1033. /**
  1034. * Gets a new Vector2 from current Vector2 floored values
  1035. * @returns a new Vector2
  1036. */
  1037. fract(): Vector2;
  1038. /**
  1039. * Gets the length of the vector
  1040. * @returns the vector length (float)
  1041. */
  1042. length(): number;
  1043. /**
  1044. * Gets the vector squared length
  1045. * @returns the vector squared length (float)
  1046. */
  1047. lengthSquared(): number;
  1048. /**
  1049. * Normalize the vector
  1050. * @returns the current updated Vector2
  1051. */
  1052. normalize(): Vector2;
  1053. /**
  1054. * Gets a new Vector2 copied from the Vector2
  1055. * @returns a new Vector2
  1056. */
  1057. clone(): Vector2;
  1058. /**
  1059. * Gets a new Vector2(0, 0)
  1060. * @returns a new Vector2
  1061. */
  1062. static Zero(): Vector2;
  1063. /**
  1064. * Gets a new Vector2(1, 1)
  1065. * @returns a new Vector2
  1066. */
  1067. static One(): Vector2;
  1068. /**
  1069. * Gets a new Vector2 set from the given index element of the given array
  1070. * @param array defines the data source
  1071. * @param offset defines the offset in the data source
  1072. * @returns a new Vector2
  1073. */
  1074. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1075. /**
  1076. * Sets "result" from the given index element of the given array
  1077. * @param array defines the data source
  1078. * @param offset defines the offset in the data source
  1079. * @param result defines the target vector
  1080. */
  1081. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1082. /**
  1083. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1084. * @param value1 defines 1st point of control
  1085. * @param value2 defines 2nd point of control
  1086. * @param value3 defines 3rd point of control
  1087. * @param value4 defines 4th point of control
  1088. * @param amount defines the interpolation factor
  1089. * @returns a new Vector2
  1090. */
  1091. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1092. /**
  1093. * 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".
  1094. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1095. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1096. * @param value defines the value to clamp
  1097. * @param min defines the lower limit
  1098. * @param max defines the upper limit
  1099. * @returns a new Vector2
  1100. */
  1101. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1102. /**
  1103. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1104. * @param value1 defines the 1st control point
  1105. * @param tangent1 defines the outgoing tangent
  1106. * @param value2 defines the 2nd control point
  1107. * @param tangent2 defines the incoming tangent
  1108. * @param amount defines the interpolation factor
  1109. * @returns a new Vector2
  1110. */
  1111. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1112. /**
  1113. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1114. * @param start defines the start vector
  1115. * @param end defines the end vector
  1116. * @param amount defines the interpolation factor
  1117. * @returns a new Vector2
  1118. */
  1119. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1120. /**
  1121. * Gets the dot product of the vector "left" and the vector "right"
  1122. * @param left defines first vector
  1123. * @param right defines second vector
  1124. * @returns the dot product (float)
  1125. */
  1126. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1127. /**
  1128. * Returns a new Vector2 equal to the normalized given vector
  1129. * @param vector defines the vector to normalize
  1130. * @returns a new Vector2
  1131. */
  1132. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1133. /**
  1134. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1135. * @param left defines 1st vector
  1136. * @param right defines 2nd vector
  1137. * @returns a new Vector2
  1138. */
  1139. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1140. /**
  1141. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1142. * @param left defines 1st vector
  1143. * @param right defines 2nd vector
  1144. * @returns a new Vector2
  1145. */
  1146. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1147. /**
  1148. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1149. * @param vector defines the vector to transform
  1150. * @param transformation defines the matrix to apply
  1151. * @returns a new Vector2
  1152. */
  1153. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1154. /**
  1155. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1156. * @param vector defines the vector to transform
  1157. * @param transformation defines the matrix to apply
  1158. * @param result defines the target vector
  1159. */
  1160. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1161. /**
  1162. * Determines if a given vector is included in a triangle
  1163. * @param p defines the vector to test
  1164. * @param p0 defines 1st triangle point
  1165. * @param p1 defines 2nd triangle point
  1166. * @param p2 defines 3rd triangle point
  1167. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1168. */
  1169. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1170. /**
  1171. * Gets the distance between the vectors "value1" and "value2"
  1172. * @param value1 defines first vector
  1173. * @param value2 defines second vector
  1174. * @returns the distance between vectors
  1175. */
  1176. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1177. /**
  1178. * Returns the squared distance between the vectors "value1" and "value2"
  1179. * @param value1 defines first vector
  1180. * @param value2 defines second vector
  1181. * @returns the squared distance between vectors
  1182. */
  1183. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1184. /**
  1185. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1186. * @param value1 defines first vector
  1187. * @param value2 defines second vector
  1188. * @returns a new Vector2
  1189. */
  1190. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1191. /**
  1192. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1193. * @param p defines the middle point
  1194. * @param segA defines one point of the segment
  1195. * @param segB defines the other point of the segment
  1196. * @returns the shortest distance
  1197. */
  1198. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1199. }
  1200. /**
  1201. * Classed used to store (x,y,z) vector representation
  1202. * A Vector3 is the main object used in 3D geometry
  1203. * It can represent etiher the coordinates of a point the space, either a direction
  1204. * Reminder: js uses a left handed forward facing system
  1205. */
  1206. export class Vector3 {
  1207. /**
  1208. * Defines the first coordinates (on X axis)
  1209. */
  1210. x: number;
  1211. /**
  1212. * Defines the second coordinates (on Y axis)
  1213. */
  1214. y: number;
  1215. /**
  1216. * Defines the third coordinates (on Z axis)
  1217. */
  1218. z: number;
  1219. private static _UpReadOnly;
  1220. /**
  1221. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1222. * @param x defines the first coordinates (on X axis)
  1223. * @param y defines the second coordinates (on Y axis)
  1224. * @param z defines the third coordinates (on Z axis)
  1225. */
  1226. constructor(
  1227. /**
  1228. * Defines the first coordinates (on X axis)
  1229. */
  1230. x?: number,
  1231. /**
  1232. * Defines the second coordinates (on Y axis)
  1233. */
  1234. y?: number,
  1235. /**
  1236. * Defines the third coordinates (on Z axis)
  1237. */
  1238. z?: number);
  1239. /**
  1240. * Creates a string representation of the Vector3
  1241. * @returns a string with the Vector3 coordinates.
  1242. */
  1243. toString(): string;
  1244. /**
  1245. * Gets the class name
  1246. * @returns the string "Vector3"
  1247. */
  1248. getClassName(): string;
  1249. /**
  1250. * Creates the Vector3 hash code
  1251. * @returns a number which tends to be unique between Vector3 instances
  1252. */
  1253. getHashCode(): number;
  1254. /**
  1255. * Creates an array containing three elements : the coordinates of the Vector3
  1256. * @returns a new array of numbers
  1257. */
  1258. asArray(): number[];
  1259. /**
  1260. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1261. * @param array defines the destination array
  1262. * @param index defines the offset in the destination array
  1263. * @returns the current Vector3
  1264. */
  1265. toArray(array: FloatArray, index?: number): Vector3;
  1266. /**
  1267. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1268. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1269. */
  1270. toQuaternion(): Quaternion;
  1271. /**
  1272. * Adds the given vector to the current Vector3
  1273. * @param otherVector defines the second operand
  1274. * @returns the current updated Vector3
  1275. */
  1276. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1277. /**
  1278. * Adds the given coordinates to the current Vector3
  1279. * @param x defines the x coordinate of the operand
  1280. * @param y defines the y coordinate of the operand
  1281. * @param z defines the z coordinate of the operand
  1282. * @returns the current updated Vector3
  1283. */
  1284. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1285. /**
  1286. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1287. * @param otherVector defines the second operand
  1288. * @returns the resulting Vector3
  1289. */
  1290. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1291. /**
  1292. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1293. * @param otherVector defines the second operand
  1294. * @param result defines the Vector3 object where to store the result
  1295. * @returns the current Vector3
  1296. */
  1297. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1298. /**
  1299. * Subtract the given vector from the current Vector3
  1300. * @param otherVector defines the second operand
  1301. * @returns the current updated Vector3
  1302. */
  1303. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1304. /**
  1305. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1306. * @param otherVector defines the second operand
  1307. * @returns the resulting Vector3
  1308. */
  1309. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1310. /**
  1311. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1312. * @param otherVector defines the second operand
  1313. * @param result defines the Vector3 object where to store the result
  1314. * @returns the current Vector3
  1315. */
  1316. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1317. /**
  1318. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1319. * @param x defines the x coordinate of the operand
  1320. * @param y defines the y coordinate of the operand
  1321. * @param z defines the z coordinate of the operand
  1322. * @returns the resulting Vector3
  1323. */
  1324. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1325. /**
  1326. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1327. * @param x defines the x coordinate of the operand
  1328. * @param y defines the y coordinate of the operand
  1329. * @param z defines the z coordinate of the operand
  1330. * @param result defines the Vector3 object where to store the result
  1331. * @returns the current Vector3
  1332. */
  1333. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1334. /**
  1335. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1336. * @returns a new Vector3
  1337. */
  1338. negate(): Vector3;
  1339. /**
  1340. * Multiplies the Vector3 coordinates by the float "scale"
  1341. * @param scale defines the multiplier factor
  1342. * @returns the current updated Vector3
  1343. */
  1344. scaleInPlace(scale: number): Vector3;
  1345. /**
  1346. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1347. * @param scale defines the multiplier factor
  1348. * @returns a new Vector3
  1349. */
  1350. scale(scale: number): Vector3;
  1351. /**
  1352. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1353. * @param scale defines the multiplier factor
  1354. * @param result defines the Vector3 object where to store the result
  1355. * @returns the current Vector3
  1356. */
  1357. scaleToRef(scale: number, result: Vector3): Vector3;
  1358. /**
  1359. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1360. * @param scale defines the scale factor
  1361. * @param result defines the Vector3 object where to store the result
  1362. * @returns the unmodified current Vector3
  1363. */
  1364. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1365. /**
  1366. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1367. * @param otherVector defines the second operand
  1368. * @returns true if both vectors are equals
  1369. */
  1370. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1371. /**
  1372. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1373. * @param otherVector defines the second operand
  1374. * @param epsilon defines the minimal distance to define values as equals
  1375. * @returns true if both vectors are distant less than epsilon
  1376. */
  1377. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1378. /**
  1379. * Returns true if the current Vector3 coordinates equals the given floats
  1380. * @param x defines the x coordinate of the operand
  1381. * @param y defines the y coordinate of the operand
  1382. * @param z defines the z coordinate of the operand
  1383. * @returns true if both vectors are equals
  1384. */
  1385. equalsToFloats(x: number, y: number, z: number): boolean;
  1386. /**
  1387. * Multiplies the current Vector3 coordinates by the given ones
  1388. * @param otherVector defines the second operand
  1389. * @returns the current updated Vector3
  1390. */
  1391. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1392. /**
  1393. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1394. * @param otherVector defines the second operand
  1395. * @returns the new Vector3
  1396. */
  1397. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1398. /**
  1399. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1400. * @param otherVector defines the second operand
  1401. * @param result defines the Vector3 object where to store the result
  1402. * @returns the current Vector3
  1403. */
  1404. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1405. /**
  1406. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1407. * @param x defines the x coordinate of the operand
  1408. * @param y defines the y coordinate of the operand
  1409. * @param z defines the z coordinate of the operand
  1410. * @returns the new Vector3
  1411. */
  1412. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1413. /**
  1414. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1415. * @param otherVector defines the second operand
  1416. * @returns the new Vector3
  1417. */
  1418. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1419. /**
  1420. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1421. * @param otherVector defines the second operand
  1422. * @param result defines the Vector3 object where to store the result
  1423. * @returns the current Vector3
  1424. */
  1425. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1426. /**
  1427. * Divides the current Vector3 coordinates by the given ones.
  1428. * @param otherVector defines the second operand
  1429. * @returns the current updated Vector3
  1430. */
  1431. divideInPlace(otherVector: Vector3): Vector3;
  1432. /**
  1433. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1434. * @param other defines the second operand
  1435. * @returns the current updated Vector3
  1436. */
  1437. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1438. /**
  1439. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1440. * @param other defines the second operand
  1441. * @returns the current updated Vector3
  1442. */
  1443. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1444. /**
  1445. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1446. * @param x defines the x coordinate of the operand
  1447. * @param y defines the y coordinate of the operand
  1448. * @param z defines the z coordinate of the operand
  1449. * @returns the current updated Vector3
  1450. */
  1451. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1452. /**
  1453. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1454. * @param x defines the x coordinate of the operand
  1455. * @param y defines the y coordinate of the operand
  1456. * @param z defines the z coordinate of the operand
  1457. * @returns the current updated Vector3
  1458. */
  1459. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1460. /**
  1461. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1462. * Check if is non uniform within a certain amount of decimal places to account for this
  1463. * @param epsilon the amount the values can differ
  1464. * @returns if the the vector is non uniform to a certain number of decimal places
  1465. */
  1466. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1467. /**
  1468. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1469. */
  1470. readonly isNonUniform: boolean;
  1471. /**
  1472. * Gets a new Vector3 from current Vector3 floored values
  1473. * @returns a new Vector3
  1474. */
  1475. floor(): Vector3;
  1476. /**
  1477. * Gets a new Vector3 from current Vector3 floored values
  1478. * @returns a new Vector3
  1479. */
  1480. fract(): Vector3;
  1481. /**
  1482. * Gets the length of the Vector3
  1483. * @returns the length of the Vecto3
  1484. */
  1485. length(): number;
  1486. /**
  1487. * Gets the squared length of the Vector3
  1488. * @returns squared length of the Vector3
  1489. */
  1490. lengthSquared(): number;
  1491. /**
  1492. * Normalize the current Vector3.
  1493. * Please note that this is an in place operation.
  1494. * @returns the current updated Vector3
  1495. */
  1496. normalize(): Vector3;
  1497. /**
  1498. * Reorders the x y z properties of the vector in place
  1499. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1500. * @returns the current updated vector
  1501. */
  1502. reorderInPlace(order: string): this;
  1503. /**
  1504. * Rotates the vector around 0,0,0 by a quaternion
  1505. * @param quaternion the rotation quaternion
  1506. * @param result vector to store the result
  1507. * @returns the resulting vector
  1508. */
  1509. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1510. /**
  1511. * Rotates a vector around a given point
  1512. * @param quaternion the rotation quaternion
  1513. * @param point the point to rotate around
  1514. * @param result vector to store the result
  1515. * @returns the resulting vector
  1516. */
  1517. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1518. /**
  1519. * Normalize the current Vector3 with the given input length.
  1520. * Please note that this is an in place operation.
  1521. * @param len the length of the vector
  1522. * @returns the current updated Vector3
  1523. */
  1524. normalizeFromLength(len: number): Vector3;
  1525. /**
  1526. * Normalize the current Vector3 to a new vector
  1527. * @returns the new Vector3
  1528. */
  1529. normalizeToNew(): Vector3;
  1530. /**
  1531. * Normalize the current Vector3 to the reference
  1532. * @param reference define the Vector3 to update
  1533. * @returns the updated Vector3
  1534. */
  1535. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1536. /**
  1537. * Creates a new Vector3 copied from the current Vector3
  1538. * @returns the new Vector3
  1539. */
  1540. clone(): Vector3;
  1541. /**
  1542. * Copies the given vector coordinates to the current Vector3 ones
  1543. * @param source defines the source Vector3
  1544. * @returns the current updated Vector3
  1545. */
  1546. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1547. /**
  1548. * Copies the given floats to the current Vector3 coordinates
  1549. * @param x defines the x coordinate of the operand
  1550. * @param y defines the y coordinate of the operand
  1551. * @param z defines the z coordinate of the operand
  1552. * @returns the current updated Vector3
  1553. */
  1554. copyFromFloats(x: number, y: number, z: number): Vector3;
  1555. /**
  1556. * Copies the given floats to the current Vector3 coordinates
  1557. * @param x defines the x coordinate of the operand
  1558. * @param y defines the y coordinate of the operand
  1559. * @param z defines the z coordinate of the operand
  1560. * @returns the current updated Vector3
  1561. */
  1562. set(x: number, y: number, z: number): Vector3;
  1563. /**
  1564. * Copies the given float to the current Vector3 coordinates
  1565. * @param v defines the x, y and z coordinates of the operand
  1566. * @returns the current updated Vector3
  1567. */
  1568. setAll(v: number): Vector3;
  1569. /**
  1570. * Get the clip factor between two vectors
  1571. * @param vector0 defines the first operand
  1572. * @param vector1 defines the second operand
  1573. * @param axis defines the axis to use
  1574. * @param size defines the size along the axis
  1575. * @returns the clip factor
  1576. */
  1577. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1578. /**
  1579. * Get angle between two vectors
  1580. * @param vector0 angle between vector0 and vector1
  1581. * @param vector1 angle between vector0 and vector1
  1582. * @param normal direction of the normal
  1583. * @return the angle between vector0 and vector1
  1584. */
  1585. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1586. /**
  1587. * Returns a new Vector3 set from the index "offset" of the given array
  1588. * @param array defines the source array
  1589. * @param offset defines the offset in the source array
  1590. * @returns the new Vector3
  1591. */
  1592. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1593. /**
  1594. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1595. * This function is deprecated. Use FromArray instead
  1596. * @param array defines the source array
  1597. * @param offset defines the offset in the source array
  1598. * @returns the new Vector3
  1599. */
  1600. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1601. /**
  1602. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1603. * @param array defines the source array
  1604. * @param offset defines the offset in the source array
  1605. * @param result defines the Vector3 where to store the result
  1606. */
  1607. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1608. /**
  1609. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1610. * This function is deprecated. Use FromArrayToRef instead.
  1611. * @param array defines the source array
  1612. * @param offset defines the offset in the source array
  1613. * @param result defines the Vector3 where to store the result
  1614. */
  1615. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1616. /**
  1617. * Sets the given vector "result" with the given floats.
  1618. * @param x defines the x coordinate of the source
  1619. * @param y defines the y coordinate of the source
  1620. * @param z defines the z coordinate of the source
  1621. * @param result defines the Vector3 where to store the result
  1622. */
  1623. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1624. /**
  1625. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1626. * @returns a new empty Vector3
  1627. */
  1628. static Zero(): Vector3;
  1629. /**
  1630. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1631. * @returns a new unit Vector3
  1632. */
  1633. static One(): Vector3;
  1634. /**
  1635. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1636. * @returns a new up Vector3
  1637. */
  1638. static Up(): Vector3;
  1639. /**
  1640. * Gets a up Vector3 that must not be updated
  1641. */
  1642. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1643. /**
  1644. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1645. * @returns a new down Vector3
  1646. */
  1647. static Down(): Vector3;
  1648. /**
  1649. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1650. * @returns a new forward Vector3
  1651. */
  1652. static Forward(): Vector3;
  1653. /**
  1654. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1655. * @returns a new forward Vector3
  1656. */
  1657. static Backward(): Vector3;
  1658. /**
  1659. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1660. * @returns a new right Vector3
  1661. */
  1662. static Right(): Vector3;
  1663. /**
  1664. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1665. * @returns a new left Vector3
  1666. */
  1667. static Left(): Vector3;
  1668. /**
  1669. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1670. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1671. * @param vector defines the Vector3 to transform
  1672. * @param transformation defines the transformation matrix
  1673. * @returns the transformed Vector3
  1674. */
  1675. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1676. /**
  1677. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1678. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1679. * @param vector defines the Vector3 to transform
  1680. * @param transformation defines the transformation matrix
  1681. * @param result defines the Vector3 where to store the result
  1682. */
  1683. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1684. /**
  1685. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1686. * This method computes tranformed coordinates only, not transformed direction vectors
  1687. * @param x define the x coordinate of the source vector
  1688. * @param y define the y coordinate of the source vector
  1689. * @param z define the z coordinate of the source vector
  1690. * @param transformation defines the transformation matrix
  1691. * @param result defines the Vector3 where to store the result
  1692. */
  1693. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1694. /**
  1695. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1696. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1697. * @param vector defines the Vector3 to transform
  1698. * @param transformation defines the transformation matrix
  1699. * @returns the new Vector3
  1700. */
  1701. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1702. /**
  1703. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1704. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1705. * @param vector defines the Vector3 to transform
  1706. * @param transformation defines the transformation matrix
  1707. * @param result defines the Vector3 where to store the result
  1708. */
  1709. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1710. /**
  1711. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1712. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1713. * @param x define the x coordinate of the source vector
  1714. * @param y define the y coordinate of the source vector
  1715. * @param z define the z coordinate of the source vector
  1716. * @param transformation defines the transformation matrix
  1717. * @param result defines the Vector3 where to store the result
  1718. */
  1719. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1720. /**
  1721. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1722. * @param value1 defines the first control point
  1723. * @param value2 defines the second control point
  1724. * @param value3 defines the third control point
  1725. * @param value4 defines the fourth control point
  1726. * @param amount defines the amount on the spline to use
  1727. * @returns the new Vector3
  1728. */
  1729. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1730. /**
  1731. * 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"
  1732. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1733. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1734. * @param value defines the current value
  1735. * @param min defines the lower range value
  1736. * @param max defines the upper range value
  1737. * @returns the new Vector3
  1738. */
  1739. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1740. /**
  1741. * 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"
  1742. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1743. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1744. * @param value defines the current value
  1745. * @param min defines the lower range value
  1746. * @param max defines the upper range value
  1747. * @param result defines the Vector3 where to store the result
  1748. */
  1749. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1750. /**
  1751. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1752. * @param value1 defines the first control point
  1753. * @param tangent1 defines the first tangent vector
  1754. * @param value2 defines the second control point
  1755. * @param tangent2 defines the second tangent vector
  1756. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1757. * @returns the new Vector3
  1758. */
  1759. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1760. /**
  1761. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1762. * @param start defines the start value
  1763. * @param end defines the end value
  1764. * @param amount max defines amount between both (between 0 and 1)
  1765. * @returns the new Vector3
  1766. */
  1767. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1768. /**
  1769. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1770. * @param start defines the start value
  1771. * @param end defines the end value
  1772. * @param amount max defines amount between both (between 0 and 1)
  1773. * @param result defines the Vector3 where to store the result
  1774. */
  1775. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1776. /**
  1777. * Returns the dot product (float) between the vectors "left" and "right"
  1778. * @param left defines the left operand
  1779. * @param right defines the right operand
  1780. * @returns the dot product
  1781. */
  1782. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1783. /**
  1784. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1785. * The cross product is then orthogonal to both "left" and "right"
  1786. * @param left defines the left operand
  1787. * @param right defines the right operand
  1788. * @returns the cross product
  1789. */
  1790. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1791. /**
  1792. * Sets the given vector "result" with the cross product of "left" and "right"
  1793. * The cross product is then orthogonal to both "left" and "right"
  1794. * @param left defines the left operand
  1795. * @param right defines the right operand
  1796. * @param result defines the Vector3 where to store the result
  1797. */
  1798. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1799. /**
  1800. * Returns a new Vector3 as the normalization of the given vector
  1801. * @param vector defines the Vector3 to normalize
  1802. * @returns the new Vector3
  1803. */
  1804. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1805. /**
  1806. * Sets the given vector "result" with the normalization of the given first vector
  1807. * @param vector defines the Vector3 to normalize
  1808. * @param result defines the Vector3 where to store the result
  1809. */
  1810. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1811. /**
  1812. * Project a Vector3 onto screen space
  1813. * @param vector defines the Vector3 to project
  1814. * @param world defines the world matrix to use
  1815. * @param transform defines the transform (view x projection) matrix to use
  1816. * @param viewport defines the screen viewport to use
  1817. * @returns the new Vector3
  1818. */
  1819. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1820. /** @hidden */
  1821. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1822. /**
  1823. * Unproject from screen space to object space
  1824. * @param source defines the screen space Vector3 to use
  1825. * @param viewportWidth defines the current width of the viewport
  1826. * @param viewportHeight defines the current height of the viewport
  1827. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1828. * @param transform defines the transform (view x projection) matrix to use
  1829. * @returns the new Vector3
  1830. */
  1831. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1832. /**
  1833. * Unproject from screen space to object space
  1834. * @param source defines the screen space Vector3 to use
  1835. * @param viewportWidth defines the current width of the viewport
  1836. * @param viewportHeight defines the current height of the viewport
  1837. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1838. * @param view defines the view matrix to use
  1839. * @param projection defines the projection matrix to use
  1840. * @returns the new Vector3
  1841. */
  1842. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1843. /**
  1844. * Unproject from screen space to object space
  1845. * @param source defines the screen space Vector3 to use
  1846. * @param viewportWidth defines the current width of the viewport
  1847. * @param viewportHeight defines the current height of the viewport
  1848. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1849. * @param view defines the view matrix to use
  1850. * @param projection defines the projection matrix to use
  1851. * @param result defines the Vector3 where to store the result
  1852. */
  1853. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1854. /**
  1855. * Unproject from screen space to object space
  1856. * @param sourceX defines the screen space x coordinate to use
  1857. * @param sourceY defines the screen space y coordinate to use
  1858. * @param sourceZ defines the screen space z coordinate to use
  1859. * @param viewportWidth defines the current width of the viewport
  1860. * @param viewportHeight defines the current height of the viewport
  1861. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1862. * @param view defines the view matrix to use
  1863. * @param projection defines the projection matrix to use
  1864. * @param result defines the Vector3 where to store the result
  1865. */
  1866. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1867. /**
  1868. * Gets the minimal coordinate values between two Vector3
  1869. * @param left defines the first operand
  1870. * @param right defines the second operand
  1871. * @returns the new Vector3
  1872. */
  1873. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1874. /**
  1875. * Gets the maximal coordinate values between two Vector3
  1876. * @param left defines the first operand
  1877. * @param right defines the second operand
  1878. * @returns the new Vector3
  1879. */
  1880. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1881. /**
  1882. * Returns the distance between the vectors "value1" and "value2"
  1883. * @param value1 defines the first operand
  1884. * @param value2 defines the second operand
  1885. * @returns the distance
  1886. */
  1887. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1888. /**
  1889. * Returns the squared distance between the vectors "value1" and "value2"
  1890. * @param value1 defines the first operand
  1891. * @param value2 defines the second operand
  1892. * @returns the squared distance
  1893. */
  1894. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1895. /**
  1896. * Returns a new Vector3 located at the center between "value1" and "value2"
  1897. * @param value1 defines the first operand
  1898. * @param value2 defines the second operand
  1899. * @returns the new Vector3
  1900. */
  1901. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1902. /**
  1903. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1904. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1905. * to something in order to rotate it from its local system to the given target system
  1906. * Note: axis1, axis2 and axis3 are normalized during this operation
  1907. * @param axis1 defines the first axis
  1908. * @param axis2 defines the second axis
  1909. * @param axis3 defines the third axis
  1910. * @returns a new Vector3
  1911. */
  1912. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1913. /**
  1914. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1915. * @param axis1 defines the first axis
  1916. * @param axis2 defines the second axis
  1917. * @param axis3 defines the third axis
  1918. * @param ref defines the Vector3 where to store the result
  1919. */
  1920. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1921. }
  1922. /**
  1923. * Vector4 class created for EulerAngle class conversion to Quaternion
  1924. */
  1925. export class Vector4 {
  1926. /** x value of the vector */
  1927. x: number;
  1928. /** y value of the vector */
  1929. y: number;
  1930. /** z value of the vector */
  1931. z: number;
  1932. /** w value of the vector */
  1933. w: number;
  1934. /**
  1935. * Creates a Vector4 object from the given floats.
  1936. * @param x x value of the vector
  1937. * @param y y value of the vector
  1938. * @param z z value of the vector
  1939. * @param w w value of the vector
  1940. */
  1941. constructor(
  1942. /** x value of the vector */
  1943. x: number,
  1944. /** y value of the vector */
  1945. y: number,
  1946. /** z value of the vector */
  1947. z: number,
  1948. /** w value of the vector */
  1949. w: number);
  1950. /**
  1951. * Returns the string with the Vector4 coordinates.
  1952. * @returns a string containing all the vector values
  1953. */
  1954. toString(): string;
  1955. /**
  1956. * Returns the string "Vector4".
  1957. * @returns "Vector4"
  1958. */
  1959. getClassName(): string;
  1960. /**
  1961. * Returns the Vector4 hash code.
  1962. * @returns a unique hash code
  1963. */
  1964. getHashCode(): number;
  1965. /**
  1966. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1967. * @returns the resulting array
  1968. */
  1969. asArray(): number[];
  1970. /**
  1971. * Populates the given array from the given index with the Vector4 coordinates.
  1972. * @param array array to populate
  1973. * @param index index of the array to start at (default: 0)
  1974. * @returns the Vector4.
  1975. */
  1976. toArray(array: FloatArray, index?: number): Vector4;
  1977. /**
  1978. * Adds the given vector to the current Vector4.
  1979. * @param otherVector the vector to add
  1980. * @returns the updated Vector4.
  1981. */
  1982. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  1983. /**
  1984. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  1985. * @param otherVector the vector to add
  1986. * @returns the resulting vector
  1987. */
  1988. add(otherVector: DeepImmutable<Vector4>): Vector4;
  1989. /**
  1990. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  1991. * @param otherVector the vector to add
  1992. * @param result the vector to store the result
  1993. * @returns the current Vector4.
  1994. */
  1995. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  1996. /**
  1997. * Subtract in place the given vector from the current Vector4.
  1998. * @param otherVector the vector to subtract
  1999. * @returns the updated Vector4.
  2000. */
  2001. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2002. /**
  2003. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2004. * @param otherVector the vector to add
  2005. * @returns the new vector with the result
  2006. */
  2007. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2008. /**
  2009. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2010. * @param otherVector the vector to subtract
  2011. * @param result the vector to store the result
  2012. * @returns the current Vector4.
  2013. */
  2014. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2015. /**
  2016. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2017. */
  2018. /**
  2019. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2020. * @param x value to subtract
  2021. * @param y value to subtract
  2022. * @param z value to subtract
  2023. * @param w value to subtract
  2024. * @returns new vector containing the result
  2025. */
  2026. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2027. /**
  2028. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2029. * @param x value to subtract
  2030. * @param y value to subtract
  2031. * @param z value to subtract
  2032. * @param w value to subtract
  2033. * @param result the vector to store the result in
  2034. * @returns the current Vector4.
  2035. */
  2036. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2037. /**
  2038. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2039. * @returns a new vector with the negated values
  2040. */
  2041. negate(): Vector4;
  2042. /**
  2043. * Multiplies the current Vector4 coordinates by scale (float).
  2044. * @param scale the number to scale with
  2045. * @returns the updated Vector4.
  2046. */
  2047. scaleInPlace(scale: number): Vector4;
  2048. /**
  2049. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2050. * @param scale the number to scale with
  2051. * @returns a new vector with the result
  2052. */
  2053. scale(scale: number): Vector4;
  2054. /**
  2055. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2056. * @param scale the number to scale with
  2057. * @param result a vector to store the result in
  2058. * @returns the current Vector4.
  2059. */
  2060. scaleToRef(scale: number, result: Vector4): Vector4;
  2061. /**
  2062. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2063. * @param scale defines the scale factor
  2064. * @param result defines the Vector4 object where to store the result
  2065. * @returns the unmodified current Vector4
  2066. */
  2067. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2068. /**
  2069. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2070. * @param otherVector the vector to compare against
  2071. * @returns true if they are equal
  2072. */
  2073. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2074. /**
  2075. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2076. * @param otherVector vector to compare against
  2077. * @param epsilon (Default: very small number)
  2078. * @returns true if they are equal
  2079. */
  2080. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2081. /**
  2082. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2083. * @param x x value to compare against
  2084. * @param y y value to compare against
  2085. * @param z z value to compare against
  2086. * @param w w value to compare against
  2087. * @returns true if equal
  2088. */
  2089. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2090. /**
  2091. * Multiplies in place the current Vector4 by the given one.
  2092. * @param otherVector vector to multiple with
  2093. * @returns the updated Vector4.
  2094. */
  2095. multiplyInPlace(otherVector: Vector4): Vector4;
  2096. /**
  2097. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2098. * @param otherVector vector to multiple with
  2099. * @returns resulting new vector
  2100. */
  2101. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2102. /**
  2103. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2104. * @param otherVector vector to multiple with
  2105. * @param result vector to store the result
  2106. * @returns the current Vector4.
  2107. */
  2108. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2109. /**
  2110. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2111. * @param x x value multiply with
  2112. * @param y y value multiply with
  2113. * @param z z value multiply with
  2114. * @param w w value multiply with
  2115. * @returns resulting new vector
  2116. */
  2117. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2118. /**
  2119. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2120. * @param otherVector vector to devide with
  2121. * @returns resulting new vector
  2122. */
  2123. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2124. /**
  2125. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2126. * @param otherVector vector to devide with
  2127. * @param result vector to store the result
  2128. * @returns the current Vector4.
  2129. */
  2130. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2131. /**
  2132. * Divides the current Vector3 coordinates by the given ones.
  2133. * @param otherVector vector to devide with
  2134. * @returns the updated Vector3.
  2135. */
  2136. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2137. /**
  2138. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2139. * @param other defines the second operand
  2140. * @returns the current updated Vector4
  2141. */
  2142. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2143. /**
  2144. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2145. * @param other defines the second operand
  2146. * @returns the current updated Vector4
  2147. */
  2148. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2149. /**
  2150. * Gets a new Vector4 from current Vector4 floored values
  2151. * @returns a new Vector4
  2152. */
  2153. floor(): Vector4;
  2154. /**
  2155. * Gets a new Vector4 from current Vector3 floored values
  2156. * @returns a new Vector4
  2157. */
  2158. fract(): Vector4;
  2159. /**
  2160. * Returns the Vector4 length (float).
  2161. * @returns the length
  2162. */
  2163. length(): number;
  2164. /**
  2165. * Returns the Vector4 squared length (float).
  2166. * @returns the length squared
  2167. */
  2168. lengthSquared(): number;
  2169. /**
  2170. * Normalizes in place the Vector4.
  2171. * @returns the updated Vector4.
  2172. */
  2173. normalize(): Vector4;
  2174. /**
  2175. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2176. * @returns this converted to a new vector3
  2177. */
  2178. toVector3(): Vector3;
  2179. /**
  2180. * Returns a new Vector4 copied from the current one.
  2181. * @returns the new cloned vector
  2182. */
  2183. clone(): Vector4;
  2184. /**
  2185. * Updates the current Vector4 with the given one coordinates.
  2186. * @param source the source vector to copy from
  2187. * @returns the updated Vector4.
  2188. */
  2189. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2190. /**
  2191. * Updates the current Vector4 coordinates with the given floats.
  2192. * @param x float to copy from
  2193. * @param y float to copy from
  2194. * @param z float to copy from
  2195. * @param w float to copy from
  2196. * @returns the updated Vector4.
  2197. */
  2198. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2199. /**
  2200. * Updates the current Vector4 coordinates with the given floats.
  2201. * @param x float to set from
  2202. * @param y float to set from
  2203. * @param z float to set from
  2204. * @param w float to set from
  2205. * @returns the updated Vector4.
  2206. */
  2207. set(x: number, y: number, z: number, w: number): Vector4;
  2208. /**
  2209. * Copies the given float to the current Vector3 coordinates
  2210. * @param v defines the x, y, z and w coordinates of the operand
  2211. * @returns the current updated Vector3
  2212. */
  2213. setAll(v: number): Vector4;
  2214. /**
  2215. * Returns a new Vector4 set from the starting index of the given array.
  2216. * @param array the array to pull values from
  2217. * @param offset the offset into the array to start at
  2218. * @returns the new vector
  2219. */
  2220. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2221. /**
  2222. * Updates the given vector "result" from the starting index of the given array.
  2223. * @param array the array to pull values from
  2224. * @param offset the offset into the array to start at
  2225. * @param result the vector to store the result in
  2226. */
  2227. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2228. /**
  2229. * Updates the given vector "result" from the starting index of the given Float32Array.
  2230. * @param array the array to pull values from
  2231. * @param offset the offset into the array to start at
  2232. * @param result the vector to store the result in
  2233. */
  2234. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2235. /**
  2236. * Updates the given vector "result" coordinates from the given floats.
  2237. * @param x float to set from
  2238. * @param y float to set from
  2239. * @param z float to set from
  2240. * @param w float to set from
  2241. * @param result the vector to the floats in
  2242. */
  2243. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2244. /**
  2245. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2246. * @returns the new vector
  2247. */
  2248. static Zero(): Vector4;
  2249. /**
  2250. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2251. * @returns the new vector
  2252. */
  2253. static One(): Vector4;
  2254. /**
  2255. * Returns a new normalized Vector4 from the given one.
  2256. * @param vector the vector to normalize
  2257. * @returns the vector
  2258. */
  2259. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2260. /**
  2261. * Updates the given vector "result" from the normalization of the given one.
  2262. * @param vector the vector to normalize
  2263. * @param result the vector to store the result in
  2264. */
  2265. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2266. /**
  2267. * Returns a vector with the minimum values from the left and right vectors
  2268. * @param left left vector to minimize
  2269. * @param right right vector to minimize
  2270. * @returns a new vector with the minimum of the left and right vector values
  2271. */
  2272. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2273. /**
  2274. * Returns a vector with the maximum values from the left and right vectors
  2275. * @param left left vector to maximize
  2276. * @param right right vector to maximize
  2277. * @returns a new vector with the maximum of the left and right vector values
  2278. */
  2279. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2280. /**
  2281. * Returns the distance (float) between the vectors "value1" and "value2".
  2282. * @param value1 value to calulate the distance between
  2283. * @param value2 value to calulate the distance between
  2284. * @return the distance between the two vectors
  2285. */
  2286. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2287. /**
  2288. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2289. * @param value1 value to calulate the distance between
  2290. * @param value2 value to calulate the distance between
  2291. * @return the distance between the two vectors squared
  2292. */
  2293. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2294. /**
  2295. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2296. * @param value1 value to calulate the center between
  2297. * @param value2 value to calulate the center between
  2298. * @return the center between the two vectors
  2299. */
  2300. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2301. /**
  2302. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2303. * This methods computes transformed normalized direction vectors only.
  2304. * @param vector the vector to transform
  2305. * @param transformation the transformation matrix to apply
  2306. * @returns the new vector
  2307. */
  2308. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2309. /**
  2310. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2311. * This methods computes transformed normalized direction vectors only.
  2312. * @param vector the vector to transform
  2313. * @param transformation the transformation matrix to apply
  2314. * @param result the vector to store the result in
  2315. */
  2316. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2317. /**
  2318. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2319. * This methods computes transformed normalized direction vectors only.
  2320. * @param x value to transform
  2321. * @param y value to transform
  2322. * @param z value to transform
  2323. * @param w value to transform
  2324. * @param transformation the transformation matrix to apply
  2325. * @param result the vector to store the results in
  2326. */
  2327. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2328. /**
  2329. * Creates a new Vector4 from a Vector3
  2330. * @param source defines the source data
  2331. * @param w defines the 4th component (default is 0)
  2332. * @returns a new Vector4
  2333. */
  2334. static FromVector3(source: Vector3, w?: number): Vector4;
  2335. }
  2336. /**
  2337. * Interface for the size containing width and height
  2338. */
  2339. export interface ISize {
  2340. /**
  2341. * Width
  2342. */
  2343. width: number;
  2344. /**
  2345. * Heighht
  2346. */
  2347. height: number;
  2348. }
  2349. /**
  2350. * Size containing widht and height
  2351. */
  2352. export class Size implements ISize {
  2353. /**
  2354. * Width
  2355. */
  2356. width: number;
  2357. /**
  2358. * Height
  2359. */
  2360. height: number;
  2361. /**
  2362. * Creates a Size object from the given width and height (floats).
  2363. * @param width width of the new size
  2364. * @param height height of the new size
  2365. */
  2366. constructor(width: number, height: number);
  2367. /**
  2368. * Returns a string with the Size width and height
  2369. * @returns a string with the Size width and height
  2370. */
  2371. toString(): string;
  2372. /**
  2373. * "Size"
  2374. * @returns the string "Size"
  2375. */
  2376. getClassName(): string;
  2377. /**
  2378. * Returns the Size hash code.
  2379. * @returns a hash code for a unique width and height
  2380. */
  2381. getHashCode(): number;
  2382. /**
  2383. * Updates the current size from the given one.
  2384. * @param src the given size
  2385. */
  2386. copyFrom(src: Size): void;
  2387. /**
  2388. * Updates in place the current Size from the given floats.
  2389. * @param width width of the new size
  2390. * @param height height of the new size
  2391. * @returns the updated Size.
  2392. */
  2393. copyFromFloats(width: number, height: number): Size;
  2394. /**
  2395. * Updates in place the current Size from the given floats.
  2396. * @param width width to set
  2397. * @param height height to set
  2398. * @returns the updated Size.
  2399. */
  2400. set(width: number, height: number): Size;
  2401. /**
  2402. * Multiplies the width and height by numbers
  2403. * @param w factor to multiple the width by
  2404. * @param h factor to multiple the height by
  2405. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  2406. */
  2407. multiplyByFloats(w: number, h: number): Size;
  2408. /**
  2409. * Clones the size
  2410. * @returns a new Size copied from the given one.
  2411. */
  2412. clone(): Size;
  2413. /**
  2414. * True if the current Size and the given one width and height are strictly equal.
  2415. * @param other the other size to compare against
  2416. * @returns True if the current Size and the given one width and height are strictly equal.
  2417. */
  2418. equals(other: Size): boolean;
  2419. /**
  2420. * The surface of the Size : width * height (float).
  2421. */
  2422. readonly surface: number;
  2423. /**
  2424. * Create a new size of zero
  2425. * @returns a new Size set to (0.0, 0.0)
  2426. */
  2427. static Zero(): Size;
  2428. /**
  2429. * Sums the width and height of two sizes
  2430. * @param otherSize size to add to this size
  2431. * @returns a new Size set as the addition result of the current Size and the given one.
  2432. */
  2433. add(otherSize: Size): Size;
  2434. /**
  2435. * Subtracts the width and height of two
  2436. * @param otherSize size to subtract to this size
  2437. * @returns a new Size set as the subtraction result of the given one from the current Size.
  2438. */
  2439. subtract(otherSize: Size): Size;
  2440. /**
  2441. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  2442. * @param start starting size to lerp between
  2443. * @param end end size to lerp between
  2444. * @param amount amount to lerp between the start and end values
  2445. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  2446. */
  2447. static Lerp(start: Size, end: Size, amount: number): Size;
  2448. }
  2449. /**
  2450. * Class used to store quaternion data
  2451. * @see https://en.wikipedia.org/wiki/Quaternion
  2452. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2453. */
  2454. export class Quaternion {
  2455. /** defines the first component (0 by default) */
  2456. x: number;
  2457. /** defines the second component (0 by default) */
  2458. y: number;
  2459. /** defines the third component (0 by default) */
  2460. z: number;
  2461. /** defines the fourth component (1.0 by default) */
  2462. w: number;
  2463. /**
  2464. * Creates a new Quaternion from the given floats
  2465. * @param x defines the first component (0 by default)
  2466. * @param y defines the second component (0 by default)
  2467. * @param z defines the third component (0 by default)
  2468. * @param w defines the fourth component (1.0 by default)
  2469. */
  2470. constructor(
  2471. /** defines the first component (0 by default) */
  2472. x?: number,
  2473. /** defines the second component (0 by default) */
  2474. y?: number,
  2475. /** defines the third component (0 by default) */
  2476. z?: number,
  2477. /** defines the fourth component (1.0 by default) */
  2478. w?: number);
  2479. /**
  2480. * Gets a string representation for the current quaternion
  2481. * @returns a string with the Quaternion coordinates
  2482. */
  2483. toString(): string;
  2484. /**
  2485. * Gets the class name of the quaternion
  2486. * @returns the string "Quaternion"
  2487. */
  2488. getClassName(): string;
  2489. /**
  2490. * Gets a hash code for this quaternion
  2491. * @returns the quaternion hash code
  2492. */
  2493. getHashCode(): number;
  2494. /**
  2495. * Copy the quaternion to an array
  2496. * @returns a new array populated with 4 elements from the quaternion coordinates
  2497. */
  2498. asArray(): number[];
  2499. /**
  2500. * Check if two quaternions are equals
  2501. * @param otherQuaternion defines the second operand
  2502. * @return true if the current quaternion and the given one coordinates are strictly equals
  2503. */
  2504. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2505. /**
  2506. * Clone the current quaternion
  2507. * @returns a new quaternion copied from the current one
  2508. */
  2509. clone(): Quaternion;
  2510. /**
  2511. * Copy a quaternion to the current one
  2512. * @param other defines the other quaternion
  2513. * @returns the updated current quaternion
  2514. */
  2515. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2516. /**
  2517. * Updates the current quaternion with the given float coordinates
  2518. * @param x defines the x coordinate
  2519. * @param y defines the y coordinate
  2520. * @param z defines the z coordinate
  2521. * @param w defines the w coordinate
  2522. * @returns the updated current quaternion
  2523. */
  2524. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2525. /**
  2526. * Updates the current quaternion from the given float coordinates
  2527. * @param x defines the x coordinate
  2528. * @param y defines the y coordinate
  2529. * @param z defines the z coordinate
  2530. * @param w defines the w coordinate
  2531. * @returns the updated current quaternion
  2532. */
  2533. set(x: number, y: number, z: number, w: number): Quaternion;
  2534. /**
  2535. * Adds two quaternions
  2536. * @param other defines the second operand
  2537. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2538. */
  2539. add(other: DeepImmutable<Quaternion>): Quaternion;
  2540. /**
  2541. * Add a quaternion to the current one
  2542. * @param other defines the quaternion to add
  2543. * @returns the current quaternion
  2544. */
  2545. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2546. /**
  2547. * Subtract two quaternions
  2548. * @param other defines the second operand
  2549. * @returns a new quaternion as the subtraction result of the given one from the current one
  2550. */
  2551. subtract(other: Quaternion): Quaternion;
  2552. /**
  2553. * Multiplies the current quaternion by a scale factor
  2554. * @param value defines the scale factor
  2555. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2556. */
  2557. scale(value: number): Quaternion;
  2558. /**
  2559. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2560. * @param scale defines the scale factor
  2561. * @param result defines the Quaternion object where to store the result
  2562. * @returns the unmodified current quaternion
  2563. */
  2564. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2565. /**
  2566. * Multiplies in place the current quaternion by a scale factor
  2567. * @param value defines the scale factor
  2568. * @returns the current modified quaternion
  2569. */
  2570. scaleInPlace(value: number): Quaternion;
  2571. /**
  2572. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2573. * @param scale defines the scale factor
  2574. * @param result defines the Quaternion object where to store the result
  2575. * @returns the unmodified current quaternion
  2576. */
  2577. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2578. /**
  2579. * Multiplies two quaternions
  2580. * @param q1 defines the second operand
  2581. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2582. */
  2583. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2584. /**
  2585. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2586. * @param q1 defines the second operand
  2587. * @param result defines the target quaternion
  2588. * @returns the current quaternion
  2589. */
  2590. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2591. /**
  2592. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2593. * @param q1 defines the second operand
  2594. * @returns the currentupdated quaternion
  2595. */
  2596. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2597. /**
  2598. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2599. * @param ref defines the target quaternion
  2600. * @returns the current quaternion
  2601. */
  2602. conjugateToRef(ref: Quaternion): Quaternion;
  2603. /**
  2604. * Conjugates in place (1-q) the current quaternion
  2605. * @returns the current updated quaternion
  2606. */
  2607. conjugateInPlace(): Quaternion;
  2608. /**
  2609. * Conjugates in place (1-q) the current quaternion
  2610. * @returns a new quaternion
  2611. */
  2612. conjugate(): Quaternion;
  2613. /**
  2614. * Gets length of current quaternion
  2615. * @returns the quaternion length (float)
  2616. */
  2617. length(): number;
  2618. /**
  2619. * Normalize in place the current quaternion
  2620. * @returns the current updated quaternion
  2621. */
  2622. normalize(): Quaternion;
  2623. /**
  2624. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2625. * @param order is a reserved parameter and is ignore for now
  2626. * @returns a new Vector3 containing the Euler angles
  2627. */
  2628. toEulerAngles(order?: string): Vector3;
  2629. /**
  2630. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2631. * @param result defines the vector which will be filled with the Euler angles
  2632. * @param order is a reserved parameter and is ignore for now
  2633. * @returns the current unchanged quaternion
  2634. */
  2635. toEulerAnglesToRef(result: Vector3): Quaternion;
  2636. /**
  2637. * Updates the given rotation matrix with the current quaternion values
  2638. * @param result defines the target matrix
  2639. * @returns the current unchanged quaternion
  2640. */
  2641. toRotationMatrix(result: Matrix): Quaternion;
  2642. /**
  2643. * Updates the current quaternion from the given rotation matrix values
  2644. * @param matrix defines the source matrix
  2645. * @returns the current updated quaternion
  2646. */
  2647. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2648. /**
  2649. * Creates a new quaternion from a rotation matrix
  2650. * @param matrix defines the source matrix
  2651. * @returns a new quaternion created from the given rotation matrix values
  2652. */
  2653. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2654. /**
  2655. * Updates the given quaternion with the given rotation matrix values
  2656. * @param matrix defines the source matrix
  2657. * @param result defines the target quaternion
  2658. */
  2659. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2660. /**
  2661. * Returns the dot product (float) between the quaternions "left" and "right"
  2662. * @param left defines the left operand
  2663. * @param right defines the right operand
  2664. * @returns the dot product
  2665. */
  2666. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2667. /**
  2668. * Checks if the two quaternions are close to each other
  2669. * @param quat0 defines the first quaternion to check
  2670. * @param quat1 defines the second quaternion to check
  2671. * @returns true if the two quaternions are close to each other
  2672. */
  2673. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2674. /**
  2675. * Creates an empty quaternion
  2676. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2677. */
  2678. static Zero(): Quaternion;
  2679. /**
  2680. * Inverse a given quaternion
  2681. * @param q defines the source quaternion
  2682. * @returns a new quaternion as the inverted current quaternion
  2683. */
  2684. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2685. /**
  2686. * Inverse a given quaternion
  2687. * @param q defines the source quaternion
  2688. * @param result the quaternion the result will be stored in
  2689. * @returns the result quaternion
  2690. */
  2691. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2692. /**
  2693. * Creates an identity quaternion
  2694. * @returns the identity quaternion
  2695. */
  2696. static Identity(): Quaternion;
  2697. /**
  2698. * Gets a boolean indicating if the given quaternion is identity
  2699. * @param quaternion defines the quaternion to check
  2700. * @returns true if the quaternion is identity
  2701. */
  2702. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2703. /**
  2704. * Creates a quaternion from a rotation around an axis
  2705. * @param axis defines the axis to use
  2706. * @param angle defines the angle to use
  2707. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2708. */
  2709. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2710. /**
  2711. * Creates a rotation around an axis and stores it into the given quaternion
  2712. * @param axis defines the axis to use
  2713. * @param angle defines the angle to use
  2714. * @param result defines the target quaternion
  2715. * @returns the target quaternion
  2716. */
  2717. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2718. /**
  2719. * Creates a new quaternion from data stored into an array
  2720. * @param array defines the data source
  2721. * @param offset defines the offset in the source array where the data starts
  2722. * @returns a new quaternion
  2723. */
  2724. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2725. /**
  2726. * Create a quaternion from Euler rotation angles
  2727. * @param x Pitch
  2728. * @param y Yaw
  2729. * @param z Roll
  2730. * @returns the new Quaternion
  2731. */
  2732. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2733. /**
  2734. * Updates a quaternion from Euler rotation angles
  2735. * @param x Pitch
  2736. * @param y Yaw
  2737. * @param z Roll
  2738. * @param result the quaternion to store the result
  2739. * @returns the updated quaternion
  2740. */
  2741. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2742. /**
  2743. * Create a quaternion from Euler rotation vector
  2744. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2745. * @returns the new Quaternion
  2746. */
  2747. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2748. /**
  2749. * Updates a quaternion from Euler rotation vector
  2750. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2751. * @param result the quaternion to store the result
  2752. * @returns the updated quaternion
  2753. */
  2754. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2755. /**
  2756. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2757. * @param yaw defines the rotation around Y axis
  2758. * @param pitch defines the rotation around X axis
  2759. * @param roll defines the rotation around Z axis
  2760. * @returns the new quaternion
  2761. */
  2762. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2763. /**
  2764. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2765. * @param yaw defines the rotation around Y axis
  2766. * @param pitch defines the rotation around X axis
  2767. * @param roll defines the rotation around Z axis
  2768. * @param result defines the target quaternion
  2769. */
  2770. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2771. /**
  2772. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2773. * @param alpha defines the rotation around first axis
  2774. * @param beta defines the rotation around second axis
  2775. * @param gamma defines the rotation around third axis
  2776. * @returns the new quaternion
  2777. */
  2778. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2779. /**
  2780. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2781. * @param alpha defines the rotation around first axis
  2782. * @param beta defines the rotation around second axis
  2783. * @param gamma defines the rotation around third axis
  2784. * @param result defines the target quaternion
  2785. */
  2786. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2787. /**
  2788. * 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)
  2789. * @param axis1 defines the first axis
  2790. * @param axis2 defines the second axis
  2791. * @param axis3 defines the third axis
  2792. * @returns the new quaternion
  2793. */
  2794. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2795. /**
  2796. * 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
  2797. * @param axis1 defines the first axis
  2798. * @param axis2 defines the second axis
  2799. * @param axis3 defines the third axis
  2800. * @param ref defines the target quaternion
  2801. */
  2802. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2803. /**
  2804. * Interpolates between two quaternions
  2805. * @param left defines first quaternion
  2806. * @param right defines second quaternion
  2807. * @param amount defines the gradient to use
  2808. * @returns the new interpolated quaternion
  2809. */
  2810. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2811. /**
  2812. * Interpolates between two quaternions and stores it into a target quaternion
  2813. * @param left defines first quaternion
  2814. * @param right defines second quaternion
  2815. * @param amount defines the gradient to use
  2816. * @param result defines the target quaternion
  2817. */
  2818. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2819. /**
  2820. * Interpolate between two quaternions using Hermite interpolation
  2821. * @param value1 defines first quaternion
  2822. * @param tangent1 defines the incoming tangent
  2823. * @param value2 defines second quaternion
  2824. * @param tangent2 defines the outgoing tangent
  2825. * @param amount defines the target quaternion
  2826. * @returns the new interpolated quaternion
  2827. */
  2828. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2829. }
  2830. /**
  2831. * Class used to store matrix data (4x4)
  2832. */
  2833. export class Matrix {
  2834. private static _updateFlagSeed;
  2835. private static _identityReadOnly;
  2836. private _isIdentity;
  2837. private _isIdentityDirty;
  2838. private _isIdentity3x2;
  2839. private _isIdentity3x2Dirty;
  2840. /**
  2841. * Gets the update flag of the matrix which is an unique number for the matrix.
  2842. * It will be incremented every time the matrix data change.
  2843. * You can use it to speed the comparison between two versions of the same matrix.
  2844. */
  2845. updateFlag: number;
  2846. private readonly _m;
  2847. /**
  2848. * Gets the internal data of the matrix
  2849. */
  2850. readonly m: DeepImmutable<Float32Array>;
  2851. /** @hidden */
  2852. _markAsUpdated(): void;
  2853. /** @hidden */
  2854. private _updateIdentityStatus;
  2855. /**
  2856. * Creates an empty matrix (filled with zeros)
  2857. */
  2858. constructor();
  2859. /**
  2860. * Check if the current matrix is identity
  2861. * @returns true is the matrix is the identity matrix
  2862. */
  2863. isIdentity(): boolean;
  2864. /**
  2865. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2866. * @returns true is the matrix is the identity matrix
  2867. */
  2868. isIdentityAs3x2(): boolean;
  2869. /**
  2870. * Gets the determinant of the matrix
  2871. * @returns the matrix determinant
  2872. */
  2873. determinant(): number;
  2874. /**
  2875. * Returns the matrix as a Float32Array
  2876. * @returns the matrix underlying array
  2877. */
  2878. toArray(): DeepImmutable<Float32Array>;
  2879. /**
  2880. * Returns the matrix as a Float32Array
  2881. * @returns the matrix underlying array.
  2882. */
  2883. asArray(): DeepImmutable<Float32Array>;
  2884. /**
  2885. * Inverts the current matrix in place
  2886. * @returns the current inverted matrix
  2887. */
  2888. invert(): Matrix;
  2889. /**
  2890. * Sets all the matrix elements to zero
  2891. * @returns the current matrix
  2892. */
  2893. reset(): Matrix;
  2894. /**
  2895. * Adds the current matrix with a second one
  2896. * @param other defines the matrix to add
  2897. * @returns a new matrix as the addition of the current matrix and the given one
  2898. */
  2899. add(other: DeepImmutable<Matrix>): Matrix;
  2900. /**
  2901. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2902. * @param other defines the matrix to add
  2903. * @param result defines the target matrix
  2904. * @returns the current matrix
  2905. */
  2906. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2907. /**
  2908. * Adds in place the given matrix to the current matrix
  2909. * @param other defines the second operand
  2910. * @returns the current updated matrix
  2911. */
  2912. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2913. /**
  2914. * Sets the given matrix to the current inverted Matrix
  2915. * @param other defines the target matrix
  2916. * @returns the unmodified current matrix
  2917. */
  2918. invertToRef(other: Matrix): Matrix;
  2919. /**
  2920. * add a value at the specified position in the current Matrix
  2921. * @param index the index of the value within the matrix. between 0 and 15.
  2922. * @param value the value to be added
  2923. * @returns the current updated matrix
  2924. */
  2925. addAtIndex(index: number, value: number): Matrix;
  2926. /**
  2927. * mutiply the specified position in the current Matrix by a value
  2928. * @param index the index of the value within the matrix. between 0 and 15.
  2929. * @param value the value to be added
  2930. * @returns the current updated matrix
  2931. */
  2932. multiplyAtIndex(index: number, value: number): Matrix;
  2933. /**
  2934. * Inserts the translation vector (using 3 floats) in the current matrix
  2935. * @param x defines the 1st component of the translation
  2936. * @param y defines the 2nd component of the translation
  2937. * @param z defines the 3rd component of the translation
  2938. * @returns the current updated matrix
  2939. */
  2940. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2941. /**
  2942. * Inserts the translation vector in the current matrix
  2943. * @param vector3 defines the translation to insert
  2944. * @returns the current updated matrix
  2945. */
  2946. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2947. /**
  2948. * Gets the translation value of the current matrix
  2949. * @returns a new Vector3 as the extracted translation from the matrix
  2950. */
  2951. getTranslation(): Vector3;
  2952. /**
  2953. * Fill a Vector3 with the extracted translation from the matrix
  2954. * @param result defines the Vector3 where to store the translation
  2955. * @returns the current matrix
  2956. */
  2957. getTranslationToRef(result: Vector3): Matrix;
  2958. /**
  2959. * Remove rotation and scaling part from the matrix
  2960. * @returns the updated matrix
  2961. */
  2962. removeRotationAndScaling(): Matrix;
  2963. /**
  2964. * Multiply two matrices
  2965. * @param other defines the second operand
  2966. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  2967. */
  2968. multiply(other: DeepImmutable<Matrix>): Matrix;
  2969. /**
  2970. * Copy the current matrix from the given one
  2971. * @param other defines the source matrix
  2972. * @returns the current updated matrix
  2973. */
  2974. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  2975. /**
  2976. * Populates the given array from the starting index with the current matrix values
  2977. * @param array defines the target array
  2978. * @param offset defines the offset in the target array where to start storing values
  2979. * @returns the current matrix
  2980. */
  2981. copyToArray(array: Float32Array, offset?: number): Matrix;
  2982. /**
  2983. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  2984. * @param other defines the second operand
  2985. * @param result defines the matrix where to store the multiplication
  2986. * @returns the current matrix
  2987. */
  2988. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2989. /**
  2990. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  2991. * @param other defines the second operand
  2992. * @param result defines the array where to store the multiplication
  2993. * @param offset defines the offset in the target array where to start storing values
  2994. * @returns the current matrix
  2995. */
  2996. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  2997. /**
  2998. * Check equality between this matrix and a second one
  2999. * @param value defines the second matrix to compare
  3000. * @returns true is the current matrix and the given one values are strictly equal
  3001. */
  3002. equals(value: DeepImmutable<Matrix>): boolean;
  3003. /**
  3004. * Clone the current matrix
  3005. * @returns a new matrix from the current matrix
  3006. */
  3007. clone(): Matrix;
  3008. /**
  3009. * Returns the name of the current matrix class
  3010. * @returns the string "Matrix"
  3011. */
  3012. getClassName(): string;
  3013. /**
  3014. * Gets the hash code of the current matrix
  3015. * @returns the hash code
  3016. */
  3017. getHashCode(): number;
  3018. /**
  3019. * Decomposes the current Matrix into a translation, rotation and scaling components
  3020. * @param scale defines the scale vector3 given as a reference to update
  3021. * @param rotation defines the rotation quaternion given as a reference to update
  3022. * @param translation defines the translation vector3 given as a reference to update
  3023. * @returns true if operation was successful
  3024. */
  3025. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3026. /**
  3027. * Gets specific row of the matrix
  3028. * @param index defines the number of the row to get
  3029. * @returns the index-th row of the current matrix as a new Vector4
  3030. */
  3031. getRow(index: number): Nullable<Vector4>;
  3032. /**
  3033. * Sets the index-th row of the current matrix to the vector4 values
  3034. * @param index defines the number of the row to set
  3035. * @param row defines the target vector4
  3036. * @returns the updated current matrix
  3037. */
  3038. setRow(index: number, row: Vector4): Matrix;
  3039. /**
  3040. * Compute the transpose of the matrix
  3041. * @returns the new transposed matrix
  3042. */
  3043. transpose(): Matrix;
  3044. /**
  3045. * Compute the transpose of the matrix and store it in a given matrix
  3046. * @param result defines the target matrix
  3047. * @returns the current matrix
  3048. */
  3049. transposeToRef(result: Matrix): Matrix;
  3050. /**
  3051. * Sets the index-th row of the current matrix with the given 4 x float values
  3052. * @param index defines the row index
  3053. * @param x defines the x component to set
  3054. * @param y defines the y component to set
  3055. * @param z defines the z component to set
  3056. * @param w defines the w component to set
  3057. * @returns the updated current matrix
  3058. */
  3059. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3060. /**
  3061. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3062. * @param scale defines the scale factor
  3063. * @returns a new matrix
  3064. */
  3065. scale(scale: number): Matrix;
  3066. /**
  3067. * Scale the current matrix values by a factor to a given result matrix
  3068. * @param scale defines the scale factor
  3069. * @param result defines the matrix to store the result
  3070. * @returns the current matrix
  3071. */
  3072. scaleToRef(scale: number, result: Matrix): Matrix;
  3073. /**
  3074. * Scale the current matrix values by a factor and add the result to a given matrix
  3075. * @param scale defines the scale factor
  3076. * @param result defines the Matrix to store the result
  3077. * @returns the current matrix
  3078. */
  3079. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3080. /**
  3081. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3082. * @param ref matrix to store the result
  3083. */
  3084. toNormalMatrix(ref: Matrix): void;
  3085. /**
  3086. * Gets only rotation part of the current matrix
  3087. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3088. */
  3089. getRotationMatrix(): Matrix;
  3090. /**
  3091. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3092. * @param result defines the target matrix to store data to
  3093. * @returns the current matrix
  3094. */
  3095. getRotationMatrixToRef(result: Matrix): Matrix;
  3096. /**
  3097. * Toggles model matrix from being right handed to left handed in place and vice versa
  3098. */
  3099. toggleModelMatrixHandInPlace(): void;
  3100. /**
  3101. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3102. */
  3103. toggleProjectionMatrixHandInPlace(): void;
  3104. /**
  3105. * Creates a matrix from an array
  3106. * @param array defines the source array
  3107. * @param offset defines an offset in the source array
  3108. * @returns a new Matrix set from the starting index of the given array
  3109. */
  3110. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3111. /**
  3112. * Copy the content of an array into a given matrix
  3113. * @param array defines the source array
  3114. * @param offset defines an offset in the source array
  3115. * @param result defines the target matrix
  3116. */
  3117. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3118. /**
  3119. * Stores an array into a matrix after having multiplied each component by a given factor
  3120. * @param array defines the source array
  3121. * @param offset defines the offset in the source array
  3122. * @param scale defines the scaling factor
  3123. * @param result defines the target matrix
  3124. */
  3125. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3126. /**
  3127. * Gets an identity matrix that must not be updated
  3128. */
  3129. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3130. /**
  3131. * Stores a list of values (16) inside a given matrix
  3132. * @param initialM11 defines 1st value of 1st row
  3133. * @param initialM12 defines 2nd value of 1st row
  3134. * @param initialM13 defines 3rd value of 1st row
  3135. * @param initialM14 defines 4th value of 1st row
  3136. * @param initialM21 defines 1st value of 2nd row
  3137. * @param initialM22 defines 2nd value of 2nd row
  3138. * @param initialM23 defines 3rd value of 2nd row
  3139. * @param initialM24 defines 4th value of 2nd row
  3140. * @param initialM31 defines 1st value of 3rd row
  3141. * @param initialM32 defines 2nd value of 3rd row
  3142. * @param initialM33 defines 3rd value of 3rd row
  3143. * @param initialM34 defines 4th value of 3rd row
  3144. * @param initialM41 defines 1st value of 4th row
  3145. * @param initialM42 defines 2nd value of 4th row
  3146. * @param initialM43 defines 3rd value of 4th row
  3147. * @param initialM44 defines 4th value of 4th row
  3148. * @param result defines the target matrix
  3149. */
  3150. 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;
  3151. /**
  3152. * Creates new matrix from a list of values (16)
  3153. * @param initialM11 defines 1st value of 1st row
  3154. * @param initialM12 defines 2nd value of 1st row
  3155. * @param initialM13 defines 3rd value of 1st row
  3156. * @param initialM14 defines 4th value of 1st row
  3157. * @param initialM21 defines 1st value of 2nd row
  3158. * @param initialM22 defines 2nd value of 2nd row
  3159. * @param initialM23 defines 3rd value of 2nd row
  3160. * @param initialM24 defines 4th value of 2nd row
  3161. * @param initialM31 defines 1st value of 3rd row
  3162. * @param initialM32 defines 2nd value of 3rd row
  3163. * @param initialM33 defines 3rd value of 3rd row
  3164. * @param initialM34 defines 4th value of 3rd row
  3165. * @param initialM41 defines 1st value of 4th row
  3166. * @param initialM42 defines 2nd value of 4th row
  3167. * @param initialM43 defines 3rd value of 4th row
  3168. * @param initialM44 defines 4th value of 4th row
  3169. * @returns the new matrix
  3170. */
  3171. 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;
  3172. /**
  3173. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3174. * @param scale defines the scale vector3
  3175. * @param rotation defines the rotation quaternion
  3176. * @param translation defines the translation vector3
  3177. * @returns a new matrix
  3178. */
  3179. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3180. /**
  3181. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3182. * @param scale defines the scale vector3
  3183. * @param rotation defines the rotation quaternion
  3184. * @param translation defines the translation vector3
  3185. * @param result defines the target matrix
  3186. */
  3187. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3188. /**
  3189. * Creates a new identity matrix
  3190. * @returns a new identity matrix
  3191. */
  3192. static Identity(): Matrix;
  3193. /**
  3194. * Creates a new identity matrix and stores the result in a given matrix
  3195. * @param result defines the target matrix
  3196. */
  3197. static IdentityToRef(result: Matrix): void;
  3198. /**
  3199. * Creates a new zero matrix
  3200. * @returns a new zero matrix
  3201. */
  3202. static Zero(): Matrix;
  3203. /**
  3204. * Creates a new rotation matrix for "angle" radians around the X axis
  3205. * @param angle defines the angle (in radians) to use
  3206. * @return the new matrix
  3207. */
  3208. static RotationX(angle: number): Matrix;
  3209. /**
  3210. * Creates a new matrix as the invert of a given matrix
  3211. * @param source defines the source matrix
  3212. * @returns the new matrix
  3213. */
  3214. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3215. /**
  3216. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3217. * @param angle defines the angle (in radians) to use
  3218. * @param result defines the target matrix
  3219. */
  3220. static RotationXToRef(angle: number, result: Matrix): void;
  3221. /**
  3222. * Creates a new rotation matrix for "angle" radians around the Y axis
  3223. * @param angle defines the angle (in radians) to use
  3224. * @return the new matrix
  3225. */
  3226. static RotationY(angle: number): Matrix;
  3227. /**
  3228. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3229. * @param angle defines the angle (in radians) to use
  3230. * @param result defines the target matrix
  3231. */
  3232. static RotationYToRef(angle: number, result: Matrix): void;
  3233. /**
  3234. * Creates a new rotation matrix for "angle" radians around the Z axis
  3235. * @param angle defines the angle (in radians) to use
  3236. * @return the new matrix
  3237. */
  3238. static RotationZ(angle: number): Matrix;
  3239. /**
  3240. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3241. * @param angle defines the angle (in radians) to use
  3242. * @param result defines the target matrix
  3243. */
  3244. static RotationZToRef(angle: number, result: Matrix): void;
  3245. /**
  3246. * Creates a new rotation matrix for "angle" radians around the given axis
  3247. * @param axis defines the axis to use
  3248. * @param angle defines the angle (in radians) to use
  3249. * @return the new matrix
  3250. */
  3251. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3252. /**
  3253. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3254. * @param axis defines the axis to use
  3255. * @param angle defines the angle (in radians) to use
  3256. * @param result defines the target matrix
  3257. */
  3258. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3259. /**
  3260. * Creates a rotation matrix
  3261. * @param yaw defines the yaw angle in radians (Y axis)
  3262. * @param pitch defines the pitch angle in radians (X axis)
  3263. * @param roll defines the roll angle in radians (X axis)
  3264. * @returns the new rotation matrix
  3265. */
  3266. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3267. /**
  3268. * Creates a rotation matrix and stores it in a given matrix
  3269. * @param yaw defines the yaw angle in radians (Y axis)
  3270. * @param pitch defines the pitch angle in radians (X axis)
  3271. * @param roll defines the roll angle in radians (X axis)
  3272. * @param result defines the target matrix
  3273. */
  3274. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3275. /**
  3276. * Creates a scaling matrix
  3277. * @param x defines the scale factor on X axis
  3278. * @param y defines the scale factor on Y axis
  3279. * @param z defines the scale factor on Z axis
  3280. * @returns the new matrix
  3281. */
  3282. static Scaling(x: number, y: number, z: number): Matrix;
  3283. /**
  3284. * Creates a scaling matrix and stores it in a given matrix
  3285. * @param x defines the scale factor on X axis
  3286. * @param y defines the scale factor on Y axis
  3287. * @param z defines the scale factor on Z axis
  3288. * @param result defines the target matrix
  3289. */
  3290. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3291. /**
  3292. * Creates a translation matrix
  3293. * @param x defines the translation on X axis
  3294. * @param y defines the translation on Y axis
  3295. * @param z defines the translationon Z axis
  3296. * @returns the new matrix
  3297. */
  3298. static Translation(x: number, y: number, z: number): Matrix;
  3299. /**
  3300. * Creates a translation matrix and stores it in a given matrix
  3301. * @param x defines the translation on X axis
  3302. * @param y defines the translation on Y axis
  3303. * @param z defines the translationon Z axis
  3304. * @param result defines the target matrix
  3305. */
  3306. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3307. /**
  3308. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3309. * @param startValue defines the start value
  3310. * @param endValue defines the end value
  3311. * @param gradient defines the gradient factor
  3312. * @returns the new matrix
  3313. */
  3314. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3315. /**
  3316. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3317. * @param startValue defines the start value
  3318. * @param endValue defines the end value
  3319. * @param gradient defines the gradient factor
  3320. * @param result defines the Matrix object where to store data
  3321. */
  3322. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3323. /**
  3324. * Builds a new matrix whose values are computed by:
  3325. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3326. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3327. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3328. * @param startValue defines the first matrix
  3329. * @param endValue defines the second matrix
  3330. * @param gradient defines the gradient between the two matrices
  3331. * @returns the new matrix
  3332. */
  3333. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3334. /**
  3335. * Update a matrix to values which are computed by:
  3336. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3337. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3338. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3339. * @param startValue defines the first matrix
  3340. * @param endValue defines the second matrix
  3341. * @param gradient defines the gradient between the two matrices
  3342. * @param result defines the target matrix
  3343. */
  3344. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3345. /**
  3346. * 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"
  3347. * This function works in left handed mode
  3348. * @param eye defines the final position of the entity
  3349. * @param target defines where the entity should look at
  3350. * @param up defines the up vector for the entity
  3351. * @returns the new matrix
  3352. */
  3353. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3354. /**
  3355. * 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".
  3356. * This function works in left handed mode
  3357. * @param eye defines the final position of the entity
  3358. * @param target defines where the entity should look at
  3359. * @param up defines the up vector for the entity
  3360. * @param result defines the target matrix
  3361. */
  3362. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3363. /**
  3364. * 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"
  3365. * This function works in right handed mode
  3366. * @param eye defines the final position of the entity
  3367. * @param target defines where the entity should look at
  3368. * @param up defines the up vector for the entity
  3369. * @returns the new matrix
  3370. */
  3371. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3372. /**
  3373. * 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".
  3374. * This function works in right handed mode
  3375. * @param eye defines the final position of the entity
  3376. * @param target defines where the entity should look at
  3377. * @param up defines the up vector for the entity
  3378. * @param result defines the target matrix
  3379. */
  3380. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3381. /**
  3382. * Create a left-handed orthographic projection matrix
  3383. * @param width defines the viewport width
  3384. * @param height defines the viewport height
  3385. * @param znear defines the near clip plane
  3386. * @param zfar defines the far clip plane
  3387. * @returns a new matrix as a left-handed orthographic projection matrix
  3388. */
  3389. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3390. /**
  3391. * Store a left-handed orthographic projection to a given matrix
  3392. * @param width defines the viewport width
  3393. * @param height defines the viewport height
  3394. * @param znear defines the near clip plane
  3395. * @param zfar defines the far clip plane
  3396. * @param result defines the target matrix
  3397. */
  3398. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3399. /**
  3400. * Create a left-handed orthographic projection matrix
  3401. * @param left defines the viewport left coordinate
  3402. * @param right defines the viewport right coordinate
  3403. * @param bottom defines the viewport bottom coordinate
  3404. * @param top defines the viewport top coordinate
  3405. * @param znear defines the near clip plane
  3406. * @param zfar defines the far clip plane
  3407. * @returns a new matrix as a left-handed orthographic projection matrix
  3408. */
  3409. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3410. /**
  3411. * Stores a left-handed orthographic projection into a given matrix
  3412. * @param left defines the viewport left coordinate
  3413. * @param right defines the viewport right coordinate
  3414. * @param bottom defines the viewport bottom coordinate
  3415. * @param top defines the viewport top coordinate
  3416. * @param znear defines the near clip plane
  3417. * @param zfar defines the far clip plane
  3418. * @param result defines the target matrix
  3419. */
  3420. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3421. /**
  3422. * Creates a right-handed orthographic projection matrix
  3423. * @param left defines the viewport left coordinate
  3424. * @param right defines the viewport right coordinate
  3425. * @param bottom defines the viewport bottom coordinate
  3426. * @param top defines the viewport top coordinate
  3427. * @param znear defines the near clip plane
  3428. * @param zfar defines the far clip plane
  3429. * @returns a new matrix as a right-handed orthographic projection matrix
  3430. */
  3431. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3432. /**
  3433. * Stores a right-handed orthographic projection into a given matrix
  3434. * @param left defines the viewport left coordinate
  3435. * @param right defines the viewport right coordinate
  3436. * @param bottom defines the viewport bottom coordinate
  3437. * @param top defines the viewport top coordinate
  3438. * @param znear defines the near clip plane
  3439. * @param zfar defines the far clip plane
  3440. * @param result defines the target matrix
  3441. */
  3442. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3443. /**
  3444. * Creates a left-handed perspective projection matrix
  3445. * @param width defines the viewport width
  3446. * @param height defines the viewport height
  3447. * @param znear defines the near clip plane
  3448. * @param zfar defines the far clip plane
  3449. * @returns a new matrix as a left-handed perspective projection matrix
  3450. */
  3451. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3452. /**
  3453. * Creates a left-handed perspective projection matrix
  3454. * @param fov defines the horizontal field of view
  3455. * @param aspect defines the aspect ratio
  3456. * @param znear defines the near clip plane
  3457. * @param zfar defines the far clip plane
  3458. * @returns a new matrix as a left-handed perspective projection matrix
  3459. */
  3460. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3461. /**
  3462. * Stores a left-handed perspective projection into a given matrix
  3463. * @param fov defines the horizontal field of view
  3464. * @param aspect defines the aspect ratio
  3465. * @param znear defines the near clip plane
  3466. * @param zfar defines the far clip plane
  3467. * @param result defines the target matrix
  3468. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3469. */
  3470. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3471. /**
  3472. * Creates a right-handed perspective projection matrix
  3473. * @param fov defines the horizontal field of view
  3474. * @param aspect defines the aspect ratio
  3475. * @param znear defines the near clip plane
  3476. * @param zfar defines the far clip plane
  3477. * @returns a new matrix as a right-handed perspective projection matrix
  3478. */
  3479. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3480. /**
  3481. * Stores a right-handed perspective projection into a given matrix
  3482. * @param fov defines the horizontal field of view
  3483. * @param aspect defines the aspect ratio
  3484. * @param znear defines the near clip plane
  3485. * @param zfar defines the far clip plane
  3486. * @param result defines the target matrix
  3487. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3488. */
  3489. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3490. /**
  3491. * Stores a perspective projection for WebVR info a given matrix
  3492. * @param fov defines the field of view
  3493. * @param znear defines the near clip plane
  3494. * @param zfar defines the far clip plane
  3495. * @param result defines the target matrix
  3496. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3497. */
  3498. static PerspectiveFovWebVRToRef(fov: {
  3499. upDegrees: number;
  3500. downDegrees: number;
  3501. leftDegrees: number;
  3502. rightDegrees: number;
  3503. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3504. /**
  3505. * Computes a complete transformation matrix
  3506. * @param viewport defines the viewport to use
  3507. * @param world defines the world matrix
  3508. * @param view defines the view matrix
  3509. * @param projection defines the projection matrix
  3510. * @param zmin defines the near clip plane
  3511. * @param zmax defines the far clip plane
  3512. * @returns the transformation matrix
  3513. */
  3514. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3515. /**
  3516. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3517. * @param matrix defines the matrix to use
  3518. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3519. */
  3520. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3521. /**
  3522. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3523. * @param matrix defines the matrix to use
  3524. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3525. */
  3526. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3527. /**
  3528. * Compute the transpose of a given matrix
  3529. * @param matrix defines the matrix to transpose
  3530. * @returns the new matrix
  3531. */
  3532. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3533. /**
  3534. * Compute the transpose of a matrix and store it in a target matrix
  3535. * @param matrix defines the matrix to transpose
  3536. * @param result defines the target matrix
  3537. */
  3538. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3539. /**
  3540. * Computes a reflection matrix from a plane
  3541. * @param plane defines the reflection plane
  3542. * @returns a new matrix
  3543. */
  3544. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  3545. /**
  3546. * Computes a reflection matrix from a plane
  3547. * @param plane defines the reflection plane
  3548. * @param result defines the target matrix
  3549. */
  3550. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  3551. /**
  3552. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3553. * @param xaxis defines the value of the 1st axis
  3554. * @param yaxis defines the value of the 2nd axis
  3555. * @param zaxis defines the value of the 3rd axis
  3556. * @param result defines the target matrix
  3557. */
  3558. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3559. /**
  3560. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3561. * @param quat defines the quaternion to use
  3562. * @param result defines the target matrix
  3563. */
  3564. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3565. }
  3566. /**
  3567. * Represens a plane by the equation ax + by + cz + d = 0
  3568. */
  3569. export class Plane {
  3570. /**
  3571. * Normal of the plane (a,b,c)
  3572. */
  3573. normal: Vector3;
  3574. /**
  3575. * d component of the plane
  3576. */
  3577. d: number;
  3578. /**
  3579. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  3580. * @param a a component of the plane
  3581. * @param b b component of the plane
  3582. * @param c c component of the plane
  3583. * @param d d component of the plane
  3584. */
  3585. constructor(a: number, b: number, c: number, d: number);
  3586. /**
  3587. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  3588. */
  3589. asArray(): number[];
  3590. /**
  3591. * @returns a new plane copied from the current Plane.
  3592. */
  3593. clone(): Plane;
  3594. /**
  3595. * @returns the string "Plane".
  3596. */
  3597. getClassName(): string;
  3598. /**
  3599. * @returns the Plane hash code.
  3600. */
  3601. getHashCode(): number;
  3602. /**
  3603. * Normalize the current Plane in place.
  3604. * @returns the updated Plane.
  3605. */
  3606. normalize(): Plane;
  3607. /**
  3608. * Applies a transformation the plane and returns the result
  3609. * @param transformation the transformation matrix to be applied to the plane
  3610. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  3611. */
  3612. transform(transformation: DeepImmutable<Matrix>): Plane;
  3613. /**
  3614. * Calcualtte the dot product between the point and the plane normal
  3615. * @param point point to calculate the dot product with
  3616. * @returns the dot product (float) of the point coordinates and the plane normal.
  3617. */
  3618. dotCoordinate(point: DeepImmutable<Vector3>): number;
  3619. /**
  3620. * Updates the current Plane from the plane defined by the three given points.
  3621. * @param point1 one of the points used to contruct the plane
  3622. * @param point2 one of the points used to contruct the plane
  3623. * @param point3 one of the points used to contruct the plane
  3624. * @returns the updated Plane.
  3625. */
  3626. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3627. /**
  3628. * Checks if the plane is facing a given direction
  3629. * @param direction the direction to check if the plane is facing
  3630. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  3631. * @returns True is the vector "direction" is the same side than the plane normal.
  3632. */
  3633. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  3634. /**
  3635. * Calculates the distance to a point
  3636. * @param point point to calculate distance to
  3637. * @returns the signed distance (float) from the given point to the Plane.
  3638. */
  3639. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  3640. /**
  3641. * Creates a plane from an array
  3642. * @param array the array to create a plane from
  3643. * @returns a new Plane from the given array.
  3644. */
  3645. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  3646. /**
  3647. * Creates a plane from three points
  3648. * @param point1 point used to create the plane
  3649. * @param point2 point used to create the plane
  3650. * @param point3 point used to create the plane
  3651. * @returns a new Plane defined by the three given points.
  3652. */
  3653. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3654. /**
  3655. * Creates a plane from an origin point and a normal
  3656. * @param origin origin of the plane to be constructed
  3657. * @param normal normal of the plane to be constructed
  3658. * @returns a new Plane the normal vector to this plane at the given origin point.
  3659. * Note : the vector "normal" is updated because normalized.
  3660. */
  3661. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  3662. /**
  3663. * Calculates the distance from a plane and a point
  3664. * @param origin origin of the plane to be constructed
  3665. * @param normal normal of the plane to be constructed
  3666. * @param point point to calculate distance to
  3667. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  3668. */
  3669. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  3670. }
  3671. /**
  3672. * Class used to represent a viewport on screen
  3673. */
  3674. export class Viewport {
  3675. /** viewport left coordinate */
  3676. x: number;
  3677. /** viewport top coordinate */
  3678. y: number;
  3679. /**viewport width */
  3680. width: number;
  3681. /** viewport height */
  3682. height: number;
  3683. /**
  3684. * Creates a Viewport object located at (x, y) and sized (width, height)
  3685. * @param x defines viewport left coordinate
  3686. * @param y defines viewport top coordinate
  3687. * @param width defines the viewport width
  3688. * @param height defines the viewport height
  3689. */
  3690. constructor(
  3691. /** viewport left coordinate */
  3692. x: number,
  3693. /** viewport top coordinate */
  3694. y: number,
  3695. /**viewport width */
  3696. width: number,
  3697. /** viewport height */
  3698. height: number);
  3699. /**
  3700. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  3701. * @param renderWidth defines the rendering width
  3702. * @param renderHeight defines the rendering height
  3703. * @returns a new Viewport
  3704. */
  3705. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  3706. /**
  3707. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  3708. * @param renderWidth defines the rendering width
  3709. * @param renderHeight defines the rendering height
  3710. * @param ref defines the target viewport
  3711. * @returns the current viewport
  3712. */
  3713. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  3714. /**
  3715. * Returns a new Viewport copied from the current one
  3716. * @returns a new Viewport
  3717. */
  3718. clone(): Viewport;
  3719. }
  3720. /**
  3721. * Reprasents a camera frustum
  3722. */
  3723. export class Frustum {
  3724. /**
  3725. * Gets the planes representing the frustum
  3726. * @param transform matrix to be applied to the returned planes
  3727. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  3728. */
  3729. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  3730. /**
  3731. * Gets the near frustum plane transformed by the transform matrix
  3732. * @param transform transformation matrix to be applied to the resulting frustum plane
  3733. * @param frustumPlane the resuling frustum plane
  3734. */
  3735. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3736. /**
  3737. * Gets the far frustum plane transformed by the transform matrix
  3738. * @param transform transformation matrix to be applied to the resulting frustum plane
  3739. * @param frustumPlane the resuling frustum plane
  3740. */
  3741. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3742. /**
  3743. * Gets the left frustum plane transformed by the transform matrix
  3744. * @param transform transformation matrix to be applied to the resulting frustum plane
  3745. * @param frustumPlane the resuling frustum plane
  3746. */
  3747. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3748. /**
  3749. * Gets the right frustum plane transformed by the transform matrix
  3750. * @param transform transformation matrix to be applied to the resulting frustum plane
  3751. * @param frustumPlane the resuling frustum plane
  3752. */
  3753. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3754. /**
  3755. * Gets the top frustum plane transformed by the transform matrix
  3756. * @param transform transformation matrix to be applied to the resulting frustum plane
  3757. * @param frustumPlane the resuling frustum plane
  3758. */
  3759. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3760. /**
  3761. * Gets the bottom frustum plane transformed by the transform matrix
  3762. * @param transform transformation matrix to be applied to the resulting frustum plane
  3763. * @param frustumPlane the resuling frustum plane
  3764. */
  3765. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3766. /**
  3767. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  3768. * @param transform transformation matrix to be applied to the resulting frustum planes
  3769. * @param frustumPlanes the resuling frustum planes
  3770. */
  3771. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  3772. }
  3773. /** Defines supported spaces */
  3774. export enum Space {
  3775. /** Local (object) space */
  3776. LOCAL = 0,
  3777. /** World space */
  3778. WORLD = 1,
  3779. /** Bone space */
  3780. BONE = 2
  3781. }
  3782. /** Defines the 3 main axes */
  3783. export class Axis {
  3784. /** X axis */
  3785. static X: Vector3;
  3786. /** Y axis */
  3787. static Y: Vector3;
  3788. /** Z axis */
  3789. static Z: Vector3;
  3790. }
  3791. /** Class used to represent a Bezier curve */
  3792. export class BezierCurve {
  3793. /**
  3794. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  3795. * @param t defines the time
  3796. * @param x1 defines the left coordinate on X axis
  3797. * @param y1 defines the left coordinate on Y axis
  3798. * @param x2 defines the right coordinate on X axis
  3799. * @param y2 defines the right coordinate on Y axis
  3800. * @returns the interpolated value
  3801. */
  3802. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  3803. }
  3804. /**
  3805. * Defines potential orientation for back face culling
  3806. */
  3807. export enum Orientation {
  3808. /**
  3809. * Clockwise
  3810. */
  3811. CW = 0,
  3812. /** Counter clockwise */
  3813. CCW = 1
  3814. }
  3815. /**
  3816. * Defines angle representation
  3817. */
  3818. export class Angle {
  3819. private _radians;
  3820. /**
  3821. * Creates an Angle object of "radians" radians (float).
  3822. * @param radians the angle in radians
  3823. */
  3824. constructor(radians: number);
  3825. /**
  3826. * Get value in degrees
  3827. * @returns the Angle value in degrees (float)
  3828. */
  3829. degrees(): number;
  3830. /**
  3831. * Get value in radians
  3832. * @returns the Angle value in radians (float)
  3833. */
  3834. radians(): number;
  3835. /**
  3836. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  3837. * @param a defines first vector
  3838. * @param b defines second vector
  3839. * @returns a new Angle
  3840. */
  3841. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  3842. /**
  3843. * Gets a new Angle object from the given float in radians
  3844. * @param radians defines the angle value in radians
  3845. * @returns a new Angle
  3846. */
  3847. static FromRadians(radians: number): Angle;
  3848. /**
  3849. * Gets a new Angle object from the given float in degrees
  3850. * @param degrees defines the angle value in degrees
  3851. * @returns a new Angle
  3852. */
  3853. static FromDegrees(degrees: number): Angle;
  3854. }
  3855. /**
  3856. * This represents an arc in a 2d space.
  3857. */
  3858. export class Arc2 {
  3859. /** Defines the start point of the arc */
  3860. startPoint: Vector2;
  3861. /** Defines the mid point of the arc */
  3862. midPoint: Vector2;
  3863. /** Defines the end point of the arc */
  3864. endPoint: Vector2;
  3865. /**
  3866. * Defines the center point of the arc.
  3867. */
  3868. centerPoint: Vector2;
  3869. /**
  3870. * Defines the radius of the arc.
  3871. */
  3872. radius: number;
  3873. /**
  3874. * Defines the angle of the arc (from mid point to end point).
  3875. */
  3876. angle: Angle;
  3877. /**
  3878. * Defines the start angle of the arc (from start point to middle point).
  3879. */
  3880. startAngle: Angle;
  3881. /**
  3882. * Defines the orientation of the arc (clock wise/counter clock wise).
  3883. */
  3884. orientation: Orientation;
  3885. /**
  3886. * Creates an Arc object from the three given points : start, middle and end.
  3887. * @param startPoint Defines the start point of the arc
  3888. * @param midPoint Defines the midlle point of the arc
  3889. * @param endPoint Defines the end point of the arc
  3890. */
  3891. constructor(
  3892. /** Defines the start point of the arc */
  3893. startPoint: Vector2,
  3894. /** Defines the mid point of the arc */
  3895. midPoint: Vector2,
  3896. /** Defines the end point of the arc */
  3897. endPoint: Vector2);
  3898. }
  3899. /**
  3900. * Represents a 2D path made up of multiple 2D points
  3901. */
  3902. export class Path2 {
  3903. private _points;
  3904. private _length;
  3905. /**
  3906. * If the path start and end point are the same
  3907. */
  3908. closed: boolean;
  3909. /**
  3910. * Creates a Path2 object from the starting 2D coordinates x and y.
  3911. * @param x the starting points x value
  3912. * @param y the starting points y value
  3913. */
  3914. constructor(x: number, y: number);
  3915. /**
  3916. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  3917. * @param x the added points x value
  3918. * @param y the added points y value
  3919. * @returns the updated Path2.
  3920. */
  3921. addLineTo(x: number, y: number): Path2;
  3922. /**
  3923. * 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.
  3924. * @param midX middle point x value
  3925. * @param midY middle point y value
  3926. * @param endX end point x value
  3927. * @param endY end point y value
  3928. * @param numberOfSegments (default: 36)
  3929. * @returns the updated Path2.
  3930. */
  3931. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  3932. /**
  3933. * Closes the Path2.
  3934. * @returns the Path2.
  3935. */
  3936. close(): Path2;
  3937. /**
  3938. * Gets the sum of the distance between each sequential point in the path
  3939. * @returns the Path2 total length (float).
  3940. */
  3941. length(): number;
  3942. /**
  3943. * Gets the points which construct the path
  3944. * @returns the Path2 internal array of points.
  3945. */
  3946. getPoints(): Vector2[];
  3947. /**
  3948. * Retreives the point at the distance aways from the starting point
  3949. * @param normalizedLengthPosition the length along the path to retreive the point from
  3950. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  3951. */
  3952. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  3953. /**
  3954. * Creates a new path starting from an x and y position
  3955. * @param x starting x value
  3956. * @param y starting y value
  3957. * @returns a new Path2 starting at the coordinates (x, y).
  3958. */
  3959. static StartingAt(x: number, y: number): Path2;
  3960. }
  3961. /**
  3962. * Represents a 3D path made up of multiple 3D points
  3963. */
  3964. export class Path3D {
  3965. /**
  3966. * an array of Vector3, the curve axis of the Path3D
  3967. */
  3968. path: Vector3[];
  3969. private _curve;
  3970. private _distances;
  3971. private _tangents;
  3972. private _normals;
  3973. private _binormals;
  3974. private _raw;
  3975. /**
  3976. * new Path3D(path, normal, raw)
  3977. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  3978. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  3979. * @param path an array of Vector3, the curve axis of the Path3D
  3980. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  3981. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  3982. */
  3983. constructor(
  3984. /**
  3985. * an array of Vector3, the curve axis of the Path3D
  3986. */
  3987. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  3988. /**
  3989. * Returns the Path3D array of successive Vector3 designing its curve.
  3990. * @returns the Path3D array of successive Vector3 designing its curve.
  3991. */
  3992. getCurve(): Vector3[];
  3993. /**
  3994. * Returns an array populated with tangent vectors on each Path3D curve point.
  3995. * @returns an array populated with tangent vectors on each Path3D curve point.
  3996. */
  3997. getTangents(): Vector3[];
  3998. /**
  3999. * Returns an array populated with normal vectors on each Path3D curve point.
  4000. * @returns an array populated with normal vectors on each Path3D curve point.
  4001. */
  4002. getNormals(): Vector3[];
  4003. /**
  4004. * Returns an array populated with binormal vectors on each Path3D curve point.
  4005. * @returns an array populated with binormal vectors on each Path3D curve point.
  4006. */
  4007. getBinormals(): Vector3[];
  4008. /**
  4009. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4010. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4011. */
  4012. getDistances(): number[];
  4013. /**
  4014. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4015. * @param path path which all values are copied into the curves points
  4016. * @param firstNormal which should be projected onto the curve
  4017. * @returns the same object updated.
  4018. */
  4019. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4020. private _compute;
  4021. private _getFirstNonNullVector;
  4022. private _getLastNonNullVector;
  4023. private _normalVector;
  4024. }
  4025. /**
  4026. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4027. * A Curve3 is designed from a series of successive Vector3.
  4028. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4029. */
  4030. export class Curve3 {
  4031. private _points;
  4032. private _length;
  4033. /**
  4034. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4035. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4036. * @param v1 (Vector3) the control point
  4037. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4038. * @param nbPoints (integer) the wanted number of points in the curve
  4039. * @returns the created Curve3
  4040. */
  4041. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4042. /**
  4043. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4044. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4045. * @param v1 (Vector3) the first control point
  4046. * @param v2 (Vector3) the second control point
  4047. * @param v3 (Vector3) the end point of the Cubic Bezier
  4048. * @param nbPoints (integer) the wanted number of points in the curve
  4049. * @returns the created Curve3
  4050. */
  4051. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4052. /**
  4053. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4054. * @param p1 (Vector3) the origin point of the Hermite Spline
  4055. * @param t1 (Vector3) the tangent vector at the origin point
  4056. * @param p2 (Vector3) the end point of the Hermite Spline
  4057. * @param t2 (Vector3) the tangent vector at the end point
  4058. * @param nbPoints (integer) the wanted number of points in the curve
  4059. * @returns the created Curve3
  4060. */
  4061. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4062. /**
  4063. * Returns a Curve3 object along a CatmullRom Spline curve :
  4064. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4065. * @param nbPoints (integer) the wanted number of points between each curve control points
  4066. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4067. * @returns the created Curve3
  4068. */
  4069. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4070. /**
  4071. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4072. * A Curve3 is designed from a series of successive Vector3.
  4073. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4074. * @param points points which make up the curve
  4075. */
  4076. constructor(points: Vector3[]);
  4077. /**
  4078. * @returns the Curve3 stored array of successive Vector3
  4079. */
  4080. getPoints(): Vector3[];
  4081. /**
  4082. * @returns the computed length (float) of the curve.
  4083. */
  4084. length(): number;
  4085. /**
  4086. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4087. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4088. * curveA and curveB keep unchanged.
  4089. * @param curve the curve to continue from this curve
  4090. * @returns the newly constructed curve
  4091. */
  4092. continue(curve: DeepImmutable<Curve3>): Curve3;
  4093. private _computeLength;
  4094. }
  4095. /**
  4096. * Contains position and normal vectors for a vertex
  4097. */
  4098. export class PositionNormalVertex {
  4099. /** the position of the vertex (defaut: 0,0,0) */
  4100. position: Vector3;
  4101. /** the normal of the vertex (defaut: 0,1,0) */
  4102. normal: Vector3;
  4103. /**
  4104. * Creates a PositionNormalVertex
  4105. * @param position the position of the vertex (defaut: 0,0,0)
  4106. * @param normal the normal of the vertex (defaut: 0,1,0)
  4107. */
  4108. constructor(
  4109. /** the position of the vertex (defaut: 0,0,0) */
  4110. position?: Vector3,
  4111. /** the normal of the vertex (defaut: 0,1,0) */
  4112. normal?: Vector3);
  4113. /**
  4114. * Clones the PositionNormalVertex
  4115. * @returns the cloned PositionNormalVertex
  4116. */
  4117. clone(): PositionNormalVertex;
  4118. }
  4119. /**
  4120. * Contains position, normal and uv vectors for a vertex
  4121. */
  4122. export class PositionNormalTextureVertex {
  4123. /** the position of the vertex (defaut: 0,0,0) */
  4124. position: Vector3;
  4125. /** the normal of the vertex (defaut: 0,1,0) */
  4126. normal: Vector3;
  4127. /** the uv of the vertex (default: 0,0) */
  4128. uv: Vector2;
  4129. /**
  4130. * Creates a PositionNormalTextureVertex
  4131. * @param position the position of the vertex (defaut: 0,0,0)
  4132. * @param normal the normal of the vertex (defaut: 0,1,0)
  4133. * @param uv the uv of the vertex (default: 0,0)
  4134. */
  4135. constructor(
  4136. /** the position of the vertex (defaut: 0,0,0) */
  4137. position?: Vector3,
  4138. /** the normal of the vertex (defaut: 0,1,0) */
  4139. normal?: Vector3,
  4140. /** the uv of the vertex (default: 0,0) */
  4141. uv?: Vector2);
  4142. /**
  4143. * Clones the PositionNormalTextureVertex
  4144. * @returns the cloned PositionNormalTextureVertex
  4145. */
  4146. clone(): PositionNormalTextureVertex;
  4147. }
  4148. /**
  4149. * @hidden
  4150. */
  4151. export class Tmp {
  4152. static Color3: Color3[];
  4153. static Color4: Color4[];
  4154. static Vector2: Vector2[];
  4155. static Vector3: Vector3[];
  4156. static Vector4: Vector4[];
  4157. static Quaternion: Quaternion[];
  4158. static Matrix: Matrix[];
  4159. }
  4160. }
  4161. declare module BABYLON {
  4162. /**
  4163. * Class used to enable access to offline support
  4164. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4165. */
  4166. export interface IOfflineProvider {
  4167. /**
  4168. * Gets a boolean indicating if scene must be saved in the database
  4169. */
  4170. enableSceneOffline: boolean;
  4171. /**
  4172. * Gets a boolean indicating if textures must be saved in the database
  4173. */
  4174. enableTexturesOffline: boolean;
  4175. /**
  4176. * Open the offline support and make it available
  4177. * @param successCallback defines the callback to call on success
  4178. * @param errorCallback defines the callback to call on error
  4179. */
  4180. open(successCallback: () => void, errorCallback: () => void): void;
  4181. /**
  4182. * Loads an image from the offline support
  4183. * @param url defines the url to load from
  4184. * @param image defines the target DOM image
  4185. */
  4186. loadImage(url: string, image: HTMLImageElement): void;
  4187. /**
  4188. * Loads a file from offline support
  4189. * @param url defines the URL to load from
  4190. * @param sceneLoaded defines a callback to call on success
  4191. * @param progressCallBack defines a callback to call when progress changed
  4192. * @param errorCallback defines a callback to call on error
  4193. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4194. */
  4195. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4196. }
  4197. }
  4198. declare module BABYLON {
  4199. /**
  4200. * A class serves as a medium between the observable and its observers
  4201. */
  4202. export class EventState {
  4203. /**
  4204. * Create a new EventState
  4205. * @param mask defines the mask associated with this state
  4206. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4207. * @param target defines the original target of the state
  4208. * @param currentTarget defines the current target of the state
  4209. */
  4210. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  4211. /**
  4212. * Initialize the current event state
  4213. * @param mask defines the mask associated with this state
  4214. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4215. * @param target defines the original target of the state
  4216. * @param currentTarget defines the current target of the state
  4217. * @returns the current event state
  4218. */
  4219. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  4220. /**
  4221. * An Observer can set this property to true to prevent subsequent observers of being notified
  4222. */
  4223. skipNextObservers: boolean;
  4224. /**
  4225. * Get the mask value that were used to trigger the event corresponding to this EventState object
  4226. */
  4227. mask: number;
  4228. /**
  4229. * The object that originally notified the event
  4230. */
  4231. target?: any;
  4232. /**
  4233. * The current object in the bubbling phase
  4234. */
  4235. currentTarget?: any;
  4236. /**
  4237. * This will be populated with the return value of the last function that was executed.
  4238. * If it is the first function in the callback chain it will be the event data.
  4239. */
  4240. lastReturnValue?: any;
  4241. }
  4242. /**
  4243. * Represent an Observer registered to a given Observable object.
  4244. */
  4245. export class Observer<T> {
  4246. /**
  4247. * Defines the callback to call when the observer is notified
  4248. */
  4249. callback: (eventData: T, eventState: EventState) => void;
  4250. /**
  4251. * Defines the mask of the observer (used to filter notifications)
  4252. */
  4253. mask: number;
  4254. /**
  4255. * Defines the current scope used to restore the JS context
  4256. */
  4257. scope: any;
  4258. /** @hidden */
  4259. _willBeUnregistered: boolean;
  4260. /**
  4261. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  4262. */
  4263. unregisterOnNextCall: boolean;
  4264. /**
  4265. * Creates a new observer
  4266. * @param callback defines the callback to call when the observer is notified
  4267. * @param mask defines the mask of the observer (used to filter notifications)
  4268. * @param scope defines the current scope used to restore the JS context
  4269. */
  4270. constructor(
  4271. /**
  4272. * Defines the callback to call when the observer is notified
  4273. */
  4274. callback: (eventData: T, eventState: EventState) => void,
  4275. /**
  4276. * Defines the mask of the observer (used to filter notifications)
  4277. */
  4278. mask: number,
  4279. /**
  4280. * Defines the current scope used to restore the JS context
  4281. */
  4282. scope?: any);
  4283. }
  4284. /**
  4285. * Represent a list of observers registered to multiple Observables object.
  4286. */
  4287. export class MultiObserver<T> {
  4288. private _observers;
  4289. private _observables;
  4290. /**
  4291. * Release associated resources
  4292. */
  4293. dispose(): void;
  4294. /**
  4295. * Raise a callback when one of the observable will notify
  4296. * @param observables defines a list of observables to watch
  4297. * @param callback defines the callback to call on notification
  4298. * @param mask defines the mask used to filter notifications
  4299. * @param scope defines the current scope used to restore the JS context
  4300. * @returns the new MultiObserver
  4301. */
  4302. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  4303. }
  4304. /**
  4305. * The Observable class is a simple implementation of the Observable pattern.
  4306. *
  4307. * 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.
  4308. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  4309. * 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).
  4310. * 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.
  4311. */
  4312. export class Observable<T> {
  4313. private _observers;
  4314. private _eventState;
  4315. private _onObserverAdded;
  4316. /**
  4317. * Creates a new observable
  4318. * @param onObserverAdded defines a callback to call when a new observer is added
  4319. */
  4320. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  4321. /**
  4322. * Create a new Observer with the specified callback
  4323. * @param callback the callback that will be executed for that Observer
  4324. * @param mask the mask used to filter observers
  4325. * @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.
  4326. * @param scope optional scope for the callback to be called from
  4327. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  4328. * @returns the new observer created for the callback
  4329. */
  4330. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  4331. /**
  4332. * Create a new Observer with the specified callback and unregisters after the next notification
  4333. * @param callback the callback that will be executed for that Observer
  4334. * @returns the new observer created for the callback
  4335. */
  4336. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  4337. /**
  4338. * Remove an Observer from the Observable object
  4339. * @param observer the instance of the Observer to remove
  4340. * @returns false if it doesn't belong to this Observable
  4341. */
  4342. remove(observer: Nullable<Observer<T>>): boolean;
  4343. /**
  4344. * Remove a callback from the Observable object
  4345. * @param callback the callback to remove
  4346. * @param scope optional scope. If used only the callbacks with this scope will be removed
  4347. * @returns false if it doesn't belong to this Observable
  4348. */
  4349. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  4350. private _deferUnregister;
  4351. private _remove;
  4352. /**
  4353. * Moves the observable to the top of the observer list making it get called first when notified
  4354. * @param observer the observer to move
  4355. */
  4356. makeObserverTopPriority(observer: Observer<T>): void;
  4357. /**
  4358. * Moves the observable to the bottom of the observer list making it get called last when notified
  4359. * @param observer the observer to move
  4360. */
  4361. makeObserverBottomPriority(observer: Observer<T>): void;
  4362. /**
  4363. * Notify all Observers by calling their respective callback with the given data
  4364. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4365. * @param eventData defines the data to send to all observers
  4366. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4367. * @param target defines the original target of the state
  4368. * @param currentTarget defines the current target of the state
  4369. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4370. */
  4371. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4372. /**
  4373. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4374. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4375. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4376. * and it is crucial that all callbacks will be executed.
  4377. * The order of the callbacks is kept, callbacks are not executed parallel.
  4378. *
  4379. * @param eventData The data to be sent to each callback
  4380. * @param mask is used to filter observers defaults to -1
  4381. * @param target defines the callback target (see EventState)
  4382. * @param currentTarget defines he current object in the bubbling phase
  4383. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4384. */
  4385. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4386. /**
  4387. * Notify a specific observer
  4388. * @param observer defines the observer to notify
  4389. * @param eventData defines the data to be sent to each callback
  4390. * @param mask is used to filter observers defaults to -1
  4391. */
  4392. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4393. /**
  4394. * Gets a boolean indicating if the observable has at least one observer
  4395. * @returns true is the Observable has at least one Observer registered
  4396. */
  4397. hasObservers(): boolean;
  4398. /**
  4399. * Clear the list of observers
  4400. */
  4401. clear(): void;
  4402. /**
  4403. * Clone the current observable
  4404. * @returns a new observable
  4405. */
  4406. clone(): Observable<T>;
  4407. /**
  4408. * Does this observable handles observer registered with a given mask
  4409. * @param mask defines the mask to be tested
  4410. * @return whether or not one observer registered with the given mask is handeled
  4411. **/
  4412. hasSpecificMask(mask?: number): boolean;
  4413. }
  4414. }
  4415. declare module BABYLON {
  4416. /**
  4417. * Class used to help managing file picking and drag'n'drop
  4418. * File Storage
  4419. */
  4420. export class FilesInputStore {
  4421. /**
  4422. * List of files ready to be loaded
  4423. */
  4424. static FilesToLoad: {
  4425. [key: string]: File;
  4426. };
  4427. }
  4428. }
  4429. declare module BABYLON {
  4430. /** Defines the cross module used constants to avoid circular dependncies */
  4431. export class Constants {
  4432. /** Defines that alpha blending is disabled */
  4433. static readonly ALPHA_DISABLE: number;
  4434. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4435. static readonly ALPHA_ADD: number;
  4436. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4437. static readonly ALPHA_COMBINE: number;
  4438. /** Defines that alpha blending to DEST - SRC * DEST */
  4439. static readonly ALPHA_SUBTRACT: number;
  4440. /** Defines that alpha blending to SRC * DEST */
  4441. static readonly ALPHA_MULTIPLY: number;
  4442. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4443. static readonly ALPHA_MAXIMIZED: number;
  4444. /** Defines that alpha blending to SRC + DEST */
  4445. static readonly ALPHA_ONEONE: number;
  4446. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4447. static readonly ALPHA_PREMULTIPLIED: number;
  4448. /**
  4449. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4450. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4451. */
  4452. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4453. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4454. static readonly ALPHA_INTERPOLATE: number;
  4455. /**
  4456. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4457. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4458. */
  4459. static readonly ALPHA_SCREENMODE: number;
  4460. /** Defines that the ressource is not delayed*/
  4461. static readonly DELAYLOADSTATE_NONE: number;
  4462. /** Defines that the ressource was successfully delay loaded */
  4463. static readonly DELAYLOADSTATE_LOADED: number;
  4464. /** Defines that the ressource is currently delay loading */
  4465. static readonly DELAYLOADSTATE_LOADING: number;
  4466. /** Defines that the ressource is delayed and has not started loading */
  4467. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4468. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4469. static readonly NEVER: number;
  4470. /** 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 */
  4471. static readonly ALWAYS: number;
  4472. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4473. static readonly LESS: number;
  4474. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4475. static readonly EQUAL: number;
  4476. /** 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 */
  4477. static readonly LEQUAL: number;
  4478. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4479. static readonly GREATER: number;
  4480. /** 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 */
  4481. static readonly GEQUAL: number;
  4482. /** 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 */
  4483. static readonly NOTEQUAL: number;
  4484. /** Passed to stencilOperation to specify that stencil value must be kept */
  4485. static readonly KEEP: number;
  4486. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4487. static readonly REPLACE: number;
  4488. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4489. static readonly INCR: number;
  4490. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4491. static readonly DECR: number;
  4492. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4493. static readonly INVERT: number;
  4494. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4495. static readonly INCR_WRAP: number;
  4496. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4497. static readonly DECR_WRAP: number;
  4498. /** Texture is not repeating outside of 0..1 UVs */
  4499. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4500. /** Texture is repeating outside of 0..1 UVs */
  4501. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4502. /** Texture is repeating and mirrored */
  4503. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4504. /** ALPHA */
  4505. static readonly TEXTUREFORMAT_ALPHA: number;
  4506. /** LUMINANCE */
  4507. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4508. /** LUMINANCE_ALPHA */
  4509. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4510. /** RGB */
  4511. static readonly TEXTUREFORMAT_RGB: number;
  4512. /** RGBA */
  4513. static readonly TEXTUREFORMAT_RGBA: number;
  4514. /** RED */
  4515. static readonly TEXTUREFORMAT_RED: number;
  4516. /** RED (2nd reference) */
  4517. static readonly TEXTUREFORMAT_R: number;
  4518. /** RG */
  4519. static readonly TEXTUREFORMAT_RG: number;
  4520. /** RED_INTEGER */
  4521. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4522. /** RED_INTEGER (2nd reference) */
  4523. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4524. /** RG_INTEGER */
  4525. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4526. /** RGB_INTEGER */
  4527. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4528. /** RGBA_INTEGER */
  4529. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4530. /** UNSIGNED_BYTE */
  4531. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4532. /** UNSIGNED_BYTE (2nd reference) */
  4533. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4534. /** FLOAT */
  4535. static readonly TEXTURETYPE_FLOAT: number;
  4536. /** HALF_FLOAT */
  4537. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4538. /** BYTE */
  4539. static readonly TEXTURETYPE_BYTE: number;
  4540. /** SHORT */
  4541. static readonly TEXTURETYPE_SHORT: number;
  4542. /** UNSIGNED_SHORT */
  4543. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4544. /** INT */
  4545. static readonly TEXTURETYPE_INT: number;
  4546. /** UNSIGNED_INT */
  4547. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4548. /** UNSIGNED_SHORT_4_4_4_4 */
  4549. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4550. /** UNSIGNED_SHORT_5_5_5_1 */
  4551. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4552. /** UNSIGNED_SHORT_5_6_5 */
  4553. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4554. /** UNSIGNED_INT_2_10_10_10_REV */
  4555. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4556. /** UNSIGNED_INT_24_8 */
  4557. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4558. /** UNSIGNED_INT_10F_11F_11F_REV */
  4559. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4560. /** UNSIGNED_INT_5_9_9_9_REV */
  4561. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4562. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4563. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4564. /** nearest is mag = nearest and min = nearest and mip = linear */
  4565. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4566. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4567. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4568. /** Trilinear is mag = linear and min = linear and mip = linear */
  4569. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4570. /** nearest is mag = nearest and min = nearest and mip = linear */
  4571. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4572. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4573. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4574. /** Trilinear is mag = linear and min = linear and mip = linear */
  4575. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4576. /** mag = nearest and min = nearest and mip = nearest */
  4577. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4578. /** mag = nearest and min = linear and mip = nearest */
  4579. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4580. /** mag = nearest and min = linear and mip = linear */
  4581. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4582. /** mag = nearest and min = linear and mip = none */
  4583. static readonly TEXTURE_NEAREST_LINEAR: number;
  4584. /** mag = nearest and min = nearest and mip = none */
  4585. static readonly TEXTURE_NEAREST_NEAREST: number;
  4586. /** mag = linear and min = nearest and mip = nearest */
  4587. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4588. /** mag = linear and min = nearest and mip = linear */
  4589. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4590. /** mag = linear and min = linear and mip = none */
  4591. static readonly TEXTURE_LINEAR_LINEAR: number;
  4592. /** mag = linear and min = nearest and mip = none */
  4593. static readonly TEXTURE_LINEAR_NEAREST: number;
  4594. /** Explicit coordinates mode */
  4595. static readonly TEXTURE_EXPLICIT_MODE: number;
  4596. /** Spherical coordinates mode */
  4597. static readonly TEXTURE_SPHERICAL_MODE: number;
  4598. /** Planar coordinates mode */
  4599. static readonly TEXTURE_PLANAR_MODE: number;
  4600. /** Cubic coordinates mode */
  4601. static readonly TEXTURE_CUBIC_MODE: number;
  4602. /** Projection coordinates mode */
  4603. static readonly TEXTURE_PROJECTION_MODE: number;
  4604. /** Skybox coordinates mode */
  4605. static readonly TEXTURE_SKYBOX_MODE: number;
  4606. /** Inverse Cubic coordinates mode */
  4607. static readonly TEXTURE_INVCUBIC_MODE: number;
  4608. /** Equirectangular coordinates mode */
  4609. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4610. /** Equirectangular Fixed coordinates mode */
  4611. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4612. /** Equirectangular Fixed Mirrored coordinates mode */
  4613. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4614. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4615. static readonly SCALEMODE_FLOOR: number;
  4616. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4617. static readonly SCALEMODE_NEAREST: number;
  4618. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4619. static readonly SCALEMODE_CEILING: number;
  4620. /**
  4621. * The dirty texture flag value
  4622. */
  4623. static readonly MATERIAL_TextureDirtyFlag: number;
  4624. /**
  4625. * The dirty light flag value
  4626. */
  4627. static readonly MATERIAL_LightDirtyFlag: number;
  4628. /**
  4629. * The dirty fresnel flag value
  4630. */
  4631. static readonly MATERIAL_FresnelDirtyFlag: number;
  4632. /**
  4633. * The dirty attribute flag value
  4634. */
  4635. static readonly MATERIAL_AttributesDirtyFlag: number;
  4636. /**
  4637. * The dirty misc flag value
  4638. */
  4639. static readonly MATERIAL_MiscDirtyFlag: number;
  4640. /**
  4641. * The all dirty flag value
  4642. */
  4643. static readonly MATERIAL_AllDirtyFlag: number;
  4644. /**
  4645. * Returns the triangle fill mode
  4646. */
  4647. static readonly MATERIAL_TriangleFillMode: number;
  4648. /**
  4649. * Returns the wireframe mode
  4650. */
  4651. static readonly MATERIAL_WireFrameFillMode: number;
  4652. /**
  4653. * Returns the point fill mode
  4654. */
  4655. static readonly MATERIAL_PointFillMode: number;
  4656. /**
  4657. * Returns the point list draw mode
  4658. */
  4659. static readonly MATERIAL_PointListDrawMode: number;
  4660. /**
  4661. * Returns the line list draw mode
  4662. */
  4663. static readonly MATERIAL_LineListDrawMode: number;
  4664. /**
  4665. * Returns the line loop draw mode
  4666. */
  4667. static readonly MATERIAL_LineLoopDrawMode: number;
  4668. /**
  4669. * Returns the line strip draw mode
  4670. */
  4671. static readonly MATERIAL_LineStripDrawMode: number;
  4672. /**
  4673. * Returns the triangle strip draw mode
  4674. */
  4675. static readonly MATERIAL_TriangleStripDrawMode: number;
  4676. /**
  4677. * Returns the triangle fan draw mode
  4678. */
  4679. static readonly MATERIAL_TriangleFanDrawMode: number;
  4680. /**
  4681. * Stores the clock-wise side orientation
  4682. */
  4683. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4684. /**
  4685. * Stores the counter clock-wise side orientation
  4686. */
  4687. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4688. /**
  4689. * Nothing
  4690. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4691. */
  4692. static readonly ACTION_NothingTrigger: number;
  4693. /**
  4694. * On pick
  4695. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4696. */
  4697. static readonly ACTION_OnPickTrigger: number;
  4698. /**
  4699. * On left pick
  4700. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4701. */
  4702. static readonly ACTION_OnLeftPickTrigger: number;
  4703. /**
  4704. * On right pick
  4705. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4706. */
  4707. static readonly ACTION_OnRightPickTrigger: number;
  4708. /**
  4709. * On center pick
  4710. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4711. */
  4712. static readonly ACTION_OnCenterPickTrigger: number;
  4713. /**
  4714. * On pick down
  4715. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4716. */
  4717. static readonly ACTION_OnPickDownTrigger: number;
  4718. /**
  4719. * On double pick
  4720. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4721. */
  4722. static readonly ACTION_OnDoublePickTrigger: number;
  4723. /**
  4724. * On pick up
  4725. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4726. */
  4727. static readonly ACTION_OnPickUpTrigger: number;
  4728. /**
  4729. * On pick out.
  4730. * This trigger will only be raised if you also declared a OnPickDown
  4731. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4732. */
  4733. static readonly ACTION_OnPickOutTrigger: number;
  4734. /**
  4735. * On long press
  4736. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4737. */
  4738. static readonly ACTION_OnLongPressTrigger: number;
  4739. /**
  4740. * On pointer over
  4741. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4742. */
  4743. static readonly ACTION_OnPointerOverTrigger: number;
  4744. /**
  4745. * On pointer out
  4746. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4747. */
  4748. static readonly ACTION_OnPointerOutTrigger: number;
  4749. /**
  4750. * On every frame
  4751. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4752. */
  4753. static readonly ACTION_OnEveryFrameTrigger: number;
  4754. /**
  4755. * On intersection enter
  4756. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4757. */
  4758. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4759. /**
  4760. * On intersection exit
  4761. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4762. */
  4763. static readonly ACTION_OnIntersectionExitTrigger: number;
  4764. /**
  4765. * On key down
  4766. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4767. */
  4768. static readonly ACTION_OnKeyDownTrigger: number;
  4769. /**
  4770. * On key up
  4771. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4772. */
  4773. static readonly ACTION_OnKeyUpTrigger: number;
  4774. /**
  4775. * Billboard mode will only apply to Y axis
  4776. */
  4777. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4778. /**
  4779. * Billboard mode will apply to all axes
  4780. */
  4781. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4782. /**
  4783. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4784. */
  4785. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4786. /**
  4787. * Gets or sets base Assets URL
  4788. */
  4789. static readonly PARTICLES_BaseAssetsUrl: string;
  4790. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4791. * Test order :
  4792. * Is the bounding sphere outside the frustum ?
  4793. * If not, are the bounding box vertices outside the frustum ?
  4794. * It not, then the cullable object is in the frustum.
  4795. */
  4796. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4797. /** Culling strategy : Bounding Sphere Only.
  4798. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4799. * It's also less accurate than the standard because some not visible objects can still be selected.
  4800. * Test : is the bounding sphere outside the frustum ?
  4801. * If not, then the cullable object is in the frustum.
  4802. */
  4803. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4804. /** Culling strategy : Optimistic Inclusion.
  4805. * This in an inclusion test first, then the standard exclusion test.
  4806. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4807. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  4808. * Anyway, it's as accurate as the standard strategy.
  4809. * Test :
  4810. * Is the cullable object bounding sphere center in the frustum ?
  4811. * If not, apply the default culling strategy.
  4812. */
  4813. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4814. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4815. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4816. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4817. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  4818. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4819. * Test :
  4820. * Is the cullable object bounding sphere center in the frustum ?
  4821. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4822. */
  4823. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4824. /**
  4825. * No logging while loading
  4826. */
  4827. static readonly SCENELOADER_NO_LOGGING: number;
  4828. /**
  4829. * Minimal logging while loading
  4830. */
  4831. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4832. /**
  4833. * Summary logging while loading
  4834. */
  4835. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4836. /**
  4837. * Detailled logging while loading
  4838. */
  4839. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4840. }
  4841. }
  4842. declare module BABYLON {
  4843. /**
  4844. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4845. * Babylon.js
  4846. */
  4847. export class DomManagement {
  4848. /**
  4849. * Checks if the window object exists
  4850. * @returns true if the window object exists
  4851. */
  4852. static IsWindowObjectExist(): boolean;
  4853. /**
  4854. * Extracts text content from a DOM element hierarchy
  4855. * @param element defines the root element
  4856. * @returns a string
  4857. */
  4858. static GetDOMTextContent(element: HTMLElement): string;
  4859. }
  4860. }
  4861. declare module BABYLON {
  4862. /**
  4863. * Logger used througouht the application to allow configuration of
  4864. * the log level required for the messages.
  4865. */
  4866. export class Logger {
  4867. /**
  4868. * No log
  4869. */
  4870. static readonly NoneLogLevel: number;
  4871. /**
  4872. * Only message logs
  4873. */
  4874. static readonly MessageLogLevel: number;
  4875. /**
  4876. * Only warning logs
  4877. */
  4878. static readonly WarningLogLevel: number;
  4879. /**
  4880. * Only error logs
  4881. */
  4882. static readonly ErrorLogLevel: number;
  4883. /**
  4884. * All logs
  4885. */
  4886. static readonly AllLogLevel: number;
  4887. private static _LogCache;
  4888. /**
  4889. * Gets a value indicating the number of loading errors
  4890. * @ignorenaming
  4891. */
  4892. static errorsCount: number;
  4893. /**
  4894. * Callback called when a new log is added
  4895. */
  4896. static OnNewCacheEntry: (entry: string) => void;
  4897. private static _AddLogEntry;
  4898. private static _FormatMessage;
  4899. private static _LogDisabled;
  4900. private static _LogEnabled;
  4901. private static _WarnDisabled;
  4902. private static _WarnEnabled;
  4903. private static _ErrorDisabled;
  4904. private static _ErrorEnabled;
  4905. /**
  4906. * Log a message to the console
  4907. */
  4908. static Log: (message: string) => void;
  4909. /**
  4910. * Write a warning message to the console
  4911. */
  4912. static Warn: (message: string) => void;
  4913. /**
  4914. * Write an error message to the console
  4915. */
  4916. static Error: (message: string) => void;
  4917. /**
  4918. * Gets current log cache (list of logs)
  4919. */
  4920. static readonly LogCache: string;
  4921. /**
  4922. * Clears the log cache
  4923. */
  4924. static ClearLogCache(): void;
  4925. /**
  4926. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4927. */
  4928. static LogLevels: number;
  4929. }
  4930. }
  4931. declare module BABYLON {
  4932. /** @hidden */
  4933. export class _TypeStore {
  4934. /** @hidden */
  4935. static RegisteredTypes: {
  4936. [key: string]: Object;
  4937. };
  4938. /** @hidden */
  4939. static GetClass(fqdn: string): any;
  4940. }
  4941. }
  4942. declare module BABYLON {
  4943. /**
  4944. * Class containing a set of static utilities functions for deep copy.
  4945. */
  4946. export class DeepCopier {
  4947. /**
  4948. * Tries to copy an object by duplicating every property
  4949. * @param source defines the source object
  4950. * @param destination defines the target object
  4951. * @param doNotCopyList defines a list of properties to avoid
  4952. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4953. */
  4954. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  4955. }
  4956. }
  4957. declare module BABYLON {
  4958. /**
  4959. * Class containing a set of static utilities functions for precision date
  4960. */
  4961. export class PrecisionDate {
  4962. /**
  4963. * Gets either window.performance.now() if supported or Date.now() else
  4964. */
  4965. static readonly Now: number;
  4966. }
  4967. }
  4968. declare module BABYLON {
  4969. /** @hidden */
  4970. export class _DevTools {
  4971. static WarnImport(name: string): string;
  4972. }
  4973. }
  4974. declare module BABYLON {
  4975. /**
  4976. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  4977. */
  4978. export class WebRequest {
  4979. private _xhr;
  4980. /**
  4981. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  4982. * i.e. when loading files, where the server/service expects an Authorization header
  4983. */
  4984. static CustomRequestHeaders: {
  4985. [key: string]: string;
  4986. };
  4987. /**
  4988. * Add callback functions in this array to update all the requests before they get sent to the network
  4989. */
  4990. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  4991. private _injectCustomRequestHeaders;
  4992. /**
  4993. * Gets or sets a function to be called when loading progress changes
  4994. */
  4995. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  4996. /**
  4997. * Returns client's state
  4998. */
  4999. readonly readyState: number;
  5000. /**
  5001. * Returns client's status
  5002. */
  5003. readonly status: number;
  5004. /**
  5005. * Returns client's status as a text
  5006. */
  5007. readonly statusText: string;
  5008. /**
  5009. * Returns client's response
  5010. */
  5011. readonly response: any;
  5012. /**
  5013. * Returns client's response url
  5014. */
  5015. readonly responseURL: string;
  5016. /**
  5017. * Returns client's response as text
  5018. */
  5019. readonly responseText: string;
  5020. /**
  5021. * Gets or sets the expected response type
  5022. */
  5023. responseType: XMLHttpRequestResponseType;
  5024. /** @hidden */
  5025. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  5026. /** @hidden */
  5027. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  5028. /**
  5029. * Cancels any network activity
  5030. */
  5031. abort(): void;
  5032. /**
  5033. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  5034. * @param body defines an optional request body
  5035. */
  5036. send(body?: Document | BodyInit | null): void;
  5037. /**
  5038. * Sets the request method, request URL
  5039. * @param method defines the method to use (GET, POST, etc..)
  5040. * @param url defines the url to connect with
  5041. */
  5042. open(method: string, url: string): void;
  5043. }
  5044. }
  5045. declare module BABYLON {
  5046. /**
  5047. * Class used to evalaute queries containing `and` and `or` operators
  5048. */
  5049. export class AndOrNotEvaluator {
  5050. /**
  5051. * Evaluate a query
  5052. * @param query defines the query to evaluate
  5053. * @param evaluateCallback defines the callback used to filter result
  5054. * @returns true if the query matches
  5055. */
  5056. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5057. private static _HandleParenthesisContent;
  5058. private static _SimplifyNegation;
  5059. }
  5060. }
  5061. declare module BABYLON {
  5062. /**
  5063. * Class used to store custom tags
  5064. */
  5065. export class Tags {
  5066. /**
  5067. * Adds support for tags on the given object
  5068. * @param obj defines the object to use
  5069. */
  5070. static EnableFor(obj: any): void;
  5071. /**
  5072. * Removes tags support
  5073. * @param obj defines the object to use
  5074. */
  5075. static DisableFor(obj: any): void;
  5076. /**
  5077. * Gets a boolean indicating if the given object has tags
  5078. * @param obj defines the object to use
  5079. * @returns a boolean
  5080. */
  5081. static HasTags(obj: any): boolean;
  5082. /**
  5083. * Gets the tags available on a given object
  5084. * @param obj defines the object to use
  5085. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5086. * @returns the tags
  5087. */
  5088. static GetTags(obj: any, asString?: boolean): any;
  5089. /**
  5090. * Adds tags to an object
  5091. * @param obj defines the object to use
  5092. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5093. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5094. */
  5095. static AddTagsTo(obj: any, tagsString: string): void;
  5096. /**
  5097. * @hidden
  5098. */
  5099. static _AddTagTo(obj: any, tag: string): void;
  5100. /**
  5101. * Removes specific tags from a specific object
  5102. * @param obj defines the object to use
  5103. * @param tagsString defines the tags to remove
  5104. */
  5105. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5106. /**
  5107. * @hidden
  5108. */
  5109. static _RemoveTagFrom(obj: any, tag: string): void;
  5110. /**
  5111. * Defines if tags hosted on an object match a given query
  5112. * @param obj defines the object to use
  5113. * @param tagsQuery defines the tag query
  5114. * @returns a boolean
  5115. */
  5116. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5117. }
  5118. }
  5119. declare module BABYLON {
  5120. /**
  5121. * Manages the defines for the Material
  5122. */
  5123. export class MaterialDefines {
  5124. private _keys;
  5125. private _isDirty;
  5126. /** @hidden */
  5127. _renderId: number;
  5128. /** @hidden */
  5129. _areLightsDirty: boolean;
  5130. /** @hidden */
  5131. _areAttributesDirty: boolean;
  5132. /** @hidden */
  5133. _areTexturesDirty: boolean;
  5134. /** @hidden */
  5135. _areFresnelDirty: boolean;
  5136. /** @hidden */
  5137. _areMiscDirty: boolean;
  5138. /** @hidden */
  5139. _areImageProcessingDirty: boolean;
  5140. /** @hidden */
  5141. _normals: boolean;
  5142. /** @hidden */
  5143. _uvs: boolean;
  5144. /** @hidden */
  5145. _needNormals: boolean;
  5146. /** @hidden */
  5147. _needUVs: boolean;
  5148. /**
  5149. * Specifies if the material needs to be re-calculated
  5150. */
  5151. readonly isDirty: boolean;
  5152. /**
  5153. * Marks the material to indicate that it has been re-calculated
  5154. */
  5155. markAsProcessed(): void;
  5156. /**
  5157. * Marks the material to indicate that it needs to be re-calculated
  5158. */
  5159. markAsUnprocessed(): void;
  5160. /**
  5161. * Marks the material to indicate all of its defines need to be re-calculated
  5162. */
  5163. markAllAsDirty(): void;
  5164. /**
  5165. * Marks the material to indicate that image processing needs to be re-calculated
  5166. */
  5167. markAsImageProcessingDirty(): void;
  5168. /**
  5169. * Marks the material to indicate the lights need to be re-calculated
  5170. */
  5171. markAsLightDirty(): void;
  5172. /**
  5173. * Marks the attribute state as changed
  5174. */
  5175. markAsAttributesDirty(): void;
  5176. /**
  5177. * Marks the texture state as changed
  5178. */
  5179. markAsTexturesDirty(): void;
  5180. /**
  5181. * Marks the fresnel state as changed
  5182. */
  5183. markAsFresnelDirty(): void;
  5184. /**
  5185. * Marks the misc state as changed
  5186. */
  5187. markAsMiscDirty(): void;
  5188. /**
  5189. * Rebuilds the material defines
  5190. */
  5191. rebuild(): void;
  5192. /**
  5193. * Specifies if two material defines are equal
  5194. * @param other - A material define instance to compare to
  5195. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5196. */
  5197. isEqual(other: MaterialDefines): boolean;
  5198. /**
  5199. * Clones this instance's defines to another instance
  5200. * @param other - material defines to clone values to
  5201. */
  5202. cloneTo(other: MaterialDefines): void;
  5203. /**
  5204. * Resets the material define values
  5205. */
  5206. reset(): void;
  5207. /**
  5208. * Converts the material define values to a string
  5209. * @returns - String of material define information
  5210. */
  5211. toString(): string;
  5212. }
  5213. }
  5214. declare module BABYLON {
  5215. /**
  5216. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5217. */
  5218. export class PerformanceMonitor {
  5219. private _enabled;
  5220. private _rollingFrameTime;
  5221. private _lastFrameTimeMs;
  5222. /**
  5223. * constructor
  5224. * @param frameSampleSize The number of samples required to saturate the sliding window
  5225. */
  5226. constructor(frameSampleSize?: number);
  5227. /**
  5228. * Samples current frame
  5229. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5230. */
  5231. sampleFrame(timeMs?: number): void;
  5232. /**
  5233. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5234. */
  5235. readonly averageFrameTime: number;
  5236. /**
  5237. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5238. */
  5239. readonly averageFrameTimeVariance: number;
  5240. /**
  5241. * Returns the frame time of the most recent frame
  5242. */
  5243. readonly instantaneousFrameTime: number;
  5244. /**
  5245. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5246. */
  5247. readonly averageFPS: number;
  5248. /**
  5249. * Returns the average framerate in frames per second using the most recent frame time
  5250. */
  5251. readonly instantaneousFPS: number;
  5252. /**
  5253. * Returns true if enough samples have been taken to completely fill the sliding window
  5254. */
  5255. readonly isSaturated: boolean;
  5256. /**
  5257. * Enables contributions to the sliding window sample set
  5258. */
  5259. enable(): void;
  5260. /**
  5261. * Disables contributions to the sliding window sample set
  5262. * Samples will not be interpolated over the disabled period
  5263. */
  5264. disable(): void;
  5265. /**
  5266. * Returns true if sampling is enabled
  5267. */
  5268. readonly isEnabled: boolean;
  5269. /**
  5270. * Resets performance monitor
  5271. */
  5272. reset(): void;
  5273. }
  5274. /**
  5275. * RollingAverage
  5276. *
  5277. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5278. */
  5279. export class RollingAverage {
  5280. /**
  5281. * Current average
  5282. */
  5283. average: number;
  5284. /**
  5285. * Current variance
  5286. */
  5287. variance: number;
  5288. protected _samples: Array<number>;
  5289. protected _sampleCount: number;
  5290. protected _pos: number;
  5291. protected _m2: number;
  5292. /**
  5293. * constructor
  5294. * @param length The number of samples required to saturate the sliding window
  5295. */
  5296. constructor(length: number);
  5297. /**
  5298. * Adds a sample to the sample set
  5299. * @param v The sample value
  5300. */
  5301. add(v: number): void;
  5302. /**
  5303. * Returns previously added values or null if outside of history or outside the sliding window domain
  5304. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5305. * @return Value previously recorded with add() or null if outside of range
  5306. */
  5307. history(i: number): number;
  5308. /**
  5309. * Returns true if enough samples have been taken to completely fill the sliding window
  5310. * @return true if sample-set saturated
  5311. */
  5312. isSaturated(): boolean;
  5313. /**
  5314. * Resets the rolling average (equivalent to 0 samples taken so far)
  5315. */
  5316. reset(): void;
  5317. /**
  5318. * Wraps a value around the sample range boundaries
  5319. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5320. * @return Wrapped position in sample range
  5321. */
  5322. protected _wrapPosition(i: number): number;
  5323. }
  5324. }
  5325. declare module BABYLON {
  5326. /**
  5327. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5328. * The underlying implementation relies on an associative array to ensure the best performances.
  5329. * The value can be anything including 'null' but except 'undefined'
  5330. */
  5331. export class StringDictionary<T> {
  5332. /**
  5333. * This will clear this dictionary and copy the content from the 'source' one.
  5334. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5335. * @param source the dictionary to take the content from and copy to this dictionary
  5336. */
  5337. copyFrom(source: StringDictionary<T>): void;
  5338. /**
  5339. * Get a value based from its key
  5340. * @param key the given key to get the matching value from
  5341. * @return the value if found, otherwise undefined is returned
  5342. */
  5343. get(key: string): T | undefined;
  5344. /**
  5345. * Get a value from its key or add it if it doesn't exist.
  5346. * This method will ensure you that a given key/data will be present in the dictionary.
  5347. * @param key the given key to get the matching value from
  5348. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5349. * The factory will only be invoked if there's no data for the given key.
  5350. * @return the value corresponding to the key.
  5351. */
  5352. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5353. /**
  5354. * Get a value from its key if present in the dictionary otherwise add it
  5355. * @param key the key to get the value from
  5356. * @param val if there's no such key/value pair in the dictionary add it with this value
  5357. * @return the value corresponding to the key
  5358. */
  5359. getOrAdd(key: string, val: T): T;
  5360. /**
  5361. * Check if there's a given key in the dictionary
  5362. * @param key the key to check for
  5363. * @return true if the key is present, false otherwise
  5364. */
  5365. contains(key: string): boolean;
  5366. /**
  5367. * Add a new key and its corresponding value
  5368. * @param key the key to add
  5369. * @param value the value corresponding to the key
  5370. * @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
  5371. */
  5372. add(key: string, value: T): boolean;
  5373. /**
  5374. * Update a specific value associated to a key
  5375. * @param key defines the key to use
  5376. * @param value defines the value to store
  5377. * @returns true if the value was updated (or false if the key was not found)
  5378. */
  5379. set(key: string, value: T): boolean;
  5380. /**
  5381. * Get the element of the given key and remove it from the dictionary
  5382. * @param key defines the key to search
  5383. * @returns the value associated with the key or null if not found
  5384. */
  5385. getAndRemove(key: string): Nullable<T>;
  5386. /**
  5387. * Remove a key/value from the dictionary.
  5388. * @param key the key to remove
  5389. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5390. */
  5391. remove(key: string): boolean;
  5392. /**
  5393. * Clear the whole content of the dictionary
  5394. */
  5395. clear(): void;
  5396. /**
  5397. * Gets the current count
  5398. */
  5399. readonly count: number;
  5400. /**
  5401. * Execute a callback on each key/val of the dictionary.
  5402. * Note that you can remove any element in this dictionary in the callback implementation
  5403. * @param callback the callback to execute on a given key/value pair
  5404. */
  5405. forEach(callback: (key: string, val: T) => void): void;
  5406. /**
  5407. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5408. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5409. * Note that you can remove any element in this dictionary in the callback implementation
  5410. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5411. * @returns the first item
  5412. */
  5413. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5414. private _count;
  5415. private _data;
  5416. }
  5417. }
  5418. declare module BABYLON {
  5419. /**
  5420. * Helper class that provides a small promise polyfill
  5421. */
  5422. export class PromisePolyfill {
  5423. /**
  5424. * Static function used to check if the polyfill is required
  5425. * If this is the case then the function will inject the polyfill to window.Promise
  5426. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5427. */
  5428. static Apply(force?: boolean): void;
  5429. }
  5430. }
  5431. declare module BABYLON {
  5432. /**
  5433. * Class used to store data that will be store in GPU memory
  5434. */
  5435. export class Buffer {
  5436. private _engine;
  5437. private _buffer;
  5438. /** @hidden */
  5439. _data: Nullable<DataArray>;
  5440. private _updatable;
  5441. private _instanced;
  5442. /**
  5443. * Gets the byte stride.
  5444. */
  5445. readonly byteStride: number;
  5446. /**
  5447. * Constructor
  5448. * @param engine the engine
  5449. * @param data the data to use for this buffer
  5450. * @param updatable whether the data is updatable
  5451. * @param stride the stride (optional)
  5452. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5453. * @param instanced whether the buffer is instanced (optional)
  5454. * @param useBytes set to true if the stride in in bytes (optional)
  5455. */
  5456. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5457. /**
  5458. * Create a new VertexBuffer based on the current buffer
  5459. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5460. * @param offset defines offset in the buffer (0 by default)
  5461. * @param size defines the size in floats of attributes (position is 3 for instance)
  5462. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5463. * @param instanced defines if the vertex buffer contains indexed data
  5464. * @param useBytes defines if the offset and stride are in bytes
  5465. * @returns the new vertex buffer
  5466. */
  5467. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5468. /**
  5469. * Gets a boolean indicating if the Buffer is updatable?
  5470. * @returns true if the buffer is updatable
  5471. */
  5472. isUpdatable(): boolean;
  5473. /**
  5474. * Gets current buffer's data
  5475. * @returns a DataArray or null
  5476. */
  5477. getData(): Nullable<DataArray>;
  5478. /**
  5479. * Gets underlying native buffer
  5480. * @returns underlying native buffer
  5481. */
  5482. getBuffer(): Nullable<WebGLBuffer>;
  5483. /**
  5484. * Gets the stride in float32 units (i.e. byte stride / 4).
  5485. * May not be an integer if the byte stride is not divisible by 4.
  5486. * DEPRECATED. Use byteStride instead.
  5487. * @returns the stride in float32 units
  5488. */
  5489. getStrideSize(): number;
  5490. /**
  5491. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5492. * @param data defines the data to store
  5493. */
  5494. create(data?: Nullable<DataArray>): void;
  5495. /** @hidden */
  5496. _rebuild(): void;
  5497. /**
  5498. * Update current buffer data
  5499. * @param data defines the data to store
  5500. */
  5501. update(data: DataArray): void;
  5502. /**
  5503. * Updates the data directly.
  5504. * @param data the new data
  5505. * @param offset the new offset
  5506. * @param vertexCount the vertex count (optional)
  5507. * @param useBytes set to true if the offset is in bytes
  5508. */
  5509. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5510. /**
  5511. * Release all resources
  5512. */
  5513. dispose(): void;
  5514. }
  5515. /**
  5516. * Specialized buffer used to store vertex data
  5517. */
  5518. export class VertexBuffer {
  5519. /** @hidden */
  5520. _buffer: Buffer;
  5521. private _kind;
  5522. private _size;
  5523. private _ownsBuffer;
  5524. private _instanced;
  5525. private _instanceDivisor;
  5526. /**
  5527. * The byte type.
  5528. */
  5529. static readonly BYTE: number;
  5530. /**
  5531. * The unsigned byte type.
  5532. */
  5533. static readonly UNSIGNED_BYTE: number;
  5534. /**
  5535. * The short type.
  5536. */
  5537. static readonly SHORT: number;
  5538. /**
  5539. * The unsigned short type.
  5540. */
  5541. static readonly UNSIGNED_SHORT: number;
  5542. /**
  5543. * The integer type.
  5544. */
  5545. static readonly INT: number;
  5546. /**
  5547. * The unsigned integer type.
  5548. */
  5549. static readonly UNSIGNED_INT: number;
  5550. /**
  5551. * The float type.
  5552. */
  5553. static readonly FLOAT: number;
  5554. /**
  5555. * Gets or sets the instance divisor when in instanced mode
  5556. */
  5557. instanceDivisor: number;
  5558. /**
  5559. * Gets the byte stride.
  5560. */
  5561. readonly byteStride: number;
  5562. /**
  5563. * Gets the byte offset.
  5564. */
  5565. readonly byteOffset: number;
  5566. /**
  5567. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5568. */
  5569. readonly normalized: boolean;
  5570. /**
  5571. * Gets the data type of each component in the array.
  5572. */
  5573. readonly type: number;
  5574. /**
  5575. * Constructor
  5576. * @param engine the engine
  5577. * @param data the data to use for this vertex buffer
  5578. * @param kind the vertex buffer kind
  5579. * @param updatable whether the data is updatable
  5580. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5581. * @param stride the stride (optional)
  5582. * @param instanced whether the buffer is instanced (optional)
  5583. * @param offset the offset of the data (optional)
  5584. * @param size the number of components (optional)
  5585. * @param type the type of the component (optional)
  5586. * @param normalized whether the data contains normalized data (optional)
  5587. * @param useBytes set to true if stride and offset are in bytes (optional)
  5588. */
  5589. 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);
  5590. /** @hidden */
  5591. _rebuild(): void;
  5592. /**
  5593. * Returns the kind of the VertexBuffer (string)
  5594. * @returns a string
  5595. */
  5596. getKind(): string;
  5597. /**
  5598. * Gets a boolean indicating if the VertexBuffer is updatable?
  5599. * @returns true if the buffer is updatable
  5600. */
  5601. isUpdatable(): boolean;
  5602. /**
  5603. * Gets current buffer's data
  5604. * @returns a DataArray or null
  5605. */
  5606. getData(): Nullable<DataArray>;
  5607. /**
  5608. * Gets underlying native buffer
  5609. * @returns underlying native buffer
  5610. */
  5611. getBuffer(): Nullable<WebGLBuffer>;
  5612. /**
  5613. * Gets the stride in float32 units (i.e. byte stride / 4).
  5614. * May not be an integer if the byte stride is not divisible by 4.
  5615. * DEPRECATED. Use byteStride instead.
  5616. * @returns the stride in float32 units
  5617. */
  5618. getStrideSize(): number;
  5619. /**
  5620. * Returns the offset as a multiple of the type byte length.
  5621. * DEPRECATED. Use byteOffset instead.
  5622. * @returns the offset in bytes
  5623. */
  5624. getOffset(): number;
  5625. /**
  5626. * Returns the number of components per vertex attribute (integer)
  5627. * @returns the size in float
  5628. */
  5629. getSize(): number;
  5630. /**
  5631. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5632. * @returns true if this buffer is instanced
  5633. */
  5634. getIsInstanced(): boolean;
  5635. /**
  5636. * Returns the instancing divisor, zero for non-instanced (integer).
  5637. * @returns a number
  5638. */
  5639. getInstanceDivisor(): number;
  5640. /**
  5641. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5642. * @param data defines the data to store
  5643. */
  5644. create(data?: DataArray): void;
  5645. /**
  5646. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5647. * This function will create a new buffer if the current one is not updatable
  5648. * @param data defines the data to store
  5649. */
  5650. update(data: DataArray): void;
  5651. /**
  5652. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5653. * Returns the directly updated WebGLBuffer.
  5654. * @param data the new data
  5655. * @param offset the new offset
  5656. * @param useBytes set to true if the offset is in bytes
  5657. */
  5658. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5659. /**
  5660. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5661. */
  5662. dispose(): void;
  5663. /**
  5664. * Enumerates each value of this vertex buffer as numbers.
  5665. * @param count the number of values to enumerate
  5666. * @param callback the callback function called for each value
  5667. */
  5668. forEach(count: number, callback: (value: number, index: number) => void): void;
  5669. /**
  5670. * Positions
  5671. */
  5672. static readonly PositionKind: string;
  5673. /**
  5674. * Normals
  5675. */
  5676. static readonly NormalKind: string;
  5677. /**
  5678. * Tangents
  5679. */
  5680. static readonly TangentKind: string;
  5681. /**
  5682. * Texture coordinates
  5683. */
  5684. static readonly UVKind: string;
  5685. /**
  5686. * Texture coordinates 2
  5687. */
  5688. static readonly UV2Kind: string;
  5689. /**
  5690. * Texture coordinates 3
  5691. */
  5692. static readonly UV3Kind: string;
  5693. /**
  5694. * Texture coordinates 4
  5695. */
  5696. static readonly UV4Kind: string;
  5697. /**
  5698. * Texture coordinates 5
  5699. */
  5700. static readonly UV5Kind: string;
  5701. /**
  5702. * Texture coordinates 6
  5703. */
  5704. static readonly UV6Kind: string;
  5705. /**
  5706. * Colors
  5707. */
  5708. static readonly ColorKind: string;
  5709. /**
  5710. * Matrix indices (for bones)
  5711. */
  5712. static readonly MatricesIndicesKind: string;
  5713. /**
  5714. * Matrix weights (for bones)
  5715. */
  5716. static readonly MatricesWeightsKind: string;
  5717. /**
  5718. * Additional matrix indices (for bones)
  5719. */
  5720. static readonly MatricesIndicesExtraKind: string;
  5721. /**
  5722. * Additional matrix weights (for bones)
  5723. */
  5724. static readonly MatricesWeightsExtraKind: string;
  5725. /**
  5726. * Deduces the stride given a kind.
  5727. * @param kind The kind string to deduce
  5728. * @returns The deduced stride
  5729. */
  5730. static DeduceStride(kind: string): number;
  5731. /**
  5732. * Gets the byte length of the given type.
  5733. * @param type the type
  5734. * @returns the number of bytes
  5735. */
  5736. static GetTypeByteLength(type: number): number;
  5737. /**
  5738. * Enumerates each value of the given parameters as numbers.
  5739. * @param data the data to enumerate
  5740. * @param byteOffset the byte offset of the data
  5741. * @param byteStride the byte stride of the data
  5742. * @param componentCount the number of components per element
  5743. * @param componentType the type of the component
  5744. * @param count the total number of components
  5745. * @param normalized whether the data is normalized
  5746. * @param callback the callback function called for each value
  5747. */
  5748. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5749. private static _GetFloatValue;
  5750. }
  5751. }
  5752. declare module BABYLON {
  5753. /**
  5754. * Class representing spherical polynomial coefficients to the 3rd degree
  5755. */
  5756. export class SphericalPolynomial {
  5757. /**
  5758. * The x coefficients of the spherical polynomial
  5759. */
  5760. x: Vector3;
  5761. /**
  5762. * The y coefficients of the spherical polynomial
  5763. */
  5764. y: Vector3;
  5765. /**
  5766. * The z coefficients of the spherical polynomial
  5767. */
  5768. z: Vector3;
  5769. /**
  5770. * The xx coefficients of the spherical polynomial
  5771. */
  5772. xx: Vector3;
  5773. /**
  5774. * The yy coefficients of the spherical polynomial
  5775. */
  5776. yy: Vector3;
  5777. /**
  5778. * The zz coefficients of the spherical polynomial
  5779. */
  5780. zz: Vector3;
  5781. /**
  5782. * The xy coefficients of the spherical polynomial
  5783. */
  5784. xy: Vector3;
  5785. /**
  5786. * The yz coefficients of the spherical polynomial
  5787. */
  5788. yz: Vector3;
  5789. /**
  5790. * The zx coefficients of the spherical polynomial
  5791. */
  5792. zx: Vector3;
  5793. /**
  5794. * Adds an ambient color to the spherical polynomial
  5795. * @param color the color to add
  5796. */
  5797. addAmbient(color: Color3): void;
  5798. /**
  5799. * Scales the spherical polynomial by the given amount
  5800. * @param scale the amount to scale
  5801. */
  5802. scale(scale: number): void;
  5803. /**
  5804. * Gets the spherical polynomial from harmonics
  5805. * @param harmonics the spherical harmonics
  5806. * @returns the spherical polynomial
  5807. */
  5808. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5809. /**
  5810. * Constructs a spherical polynomial from an array.
  5811. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5812. * @returns the spherical polynomial
  5813. */
  5814. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5815. }
  5816. /**
  5817. * Class representing spherical harmonics coefficients to the 3rd degree
  5818. */
  5819. export class SphericalHarmonics {
  5820. /**
  5821. * The l0,0 coefficients of the spherical harmonics
  5822. */
  5823. l00: Vector3;
  5824. /**
  5825. * The l1,-1 coefficients of the spherical harmonics
  5826. */
  5827. l1_1: Vector3;
  5828. /**
  5829. * The l1,0 coefficients of the spherical harmonics
  5830. */
  5831. l10: Vector3;
  5832. /**
  5833. * The l1,1 coefficients of the spherical harmonics
  5834. */
  5835. l11: Vector3;
  5836. /**
  5837. * The l2,-2 coefficients of the spherical harmonics
  5838. */
  5839. l2_2: Vector3;
  5840. /**
  5841. * The l2,-1 coefficients of the spherical harmonics
  5842. */
  5843. l2_1: Vector3;
  5844. /**
  5845. * The l2,0 coefficients of the spherical harmonics
  5846. */
  5847. l20: Vector3;
  5848. /**
  5849. * The l2,1 coefficients of the spherical harmonics
  5850. */
  5851. l21: Vector3;
  5852. /**
  5853. * The l2,2 coefficients of the spherical harmonics
  5854. */
  5855. lL22: Vector3;
  5856. /**
  5857. * Adds a light to the spherical harmonics
  5858. * @param direction the direction of the light
  5859. * @param color the color of the light
  5860. * @param deltaSolidAngle the delta solid angle of the light
  5861. */
  5862. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5863. /**
  5864. * Scales the spherical harmonics by the given amount
  5865. * @param scale the amount to scale
  5866. */
  5867. scale(scale: number): void;
  5868. /**
  5869. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5870. *
  5871. * ```
  5872. * E_lm = A_l * L_lm
  5873. * ```
  5874. *
  5875. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5876. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5877. * the scaling factors are given in equation 9.
  5878. */
  5879. convertIncidentRadianceToIrradiance(): void;
  5880. /**
  5881. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5882. *
  5883. * ```
  5884. * L = (1/pi) * E * rho
  5885. * ```
  5886. *
  5887. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5888. */
  5889. convertIrradianceToLambertianRadiance(): void;
  5890. /**
  5891. * Gets the spherical harmonics from polynomial
  5892. * @param polynomial the spherical polynomial
  5893. * @returns the spherical harmonics
  5894. */
  5895. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5896. /**
  5897. * Constructs a spherical harmonics from an array.
  5898. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5899. * @returns the spherical harmonics
  5900. */
  5901. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5902. }
  5903. }
  5904. declare module BABYLON {
  5905. /**
  5906. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  5907. */
  5908. export interface CubeMapInfo {
  5909. /**
  5910. * The pixel array for the front face.
  5911. * This is stored in format, left to right, up to down format.
  5912. */
  5913. front: Nullable<ArrayBufferView>;
  5914. /**
  5915. * The pixel array for the back face.
  5916. * This is stored in format, left to right, up to down format.
  5917. */
  5918. back: Nullable<ArrayBufferView>;
  5919. /**
  5920. * The pixel array for the left face.
  5921. * This is stored in format, left to right, up to down format.
  5922. */
  5923. left: Nullable<ArrayBufferView>;
  5924. /**
  5925. * The pixel array for the right face.
  5926. * This is stored in format, left to right, up to down format.
  5927. */
  5928. right: Nullable<ArrayBufferView>;
  5929. /**
  5930. * The pixel array for the up face.
  5931. * This is stored in format, left to right, up to down format.
  5932. */
  5933. up: Nullable<ArrayBufferView>;
  5934. /**
  5935. * The pixel array for the down face.
  5936. * This is stored in format, left to right, up to down format.
  5937. */
  5938. down: Nullable<ArrayBufferView>;
  5939. /**
  5940. * The size of the cubemap stored.
  5941. *
  5942. * Each faces will be size * size pixels.
  5943. */
  5944. size: number;
  5945. /**
  5946. * The format of the texture.
  5947. *
  5948. * RGBA, RGB.
  5949. */
  5950. format: number;
  5951. /**
  5952. * The type of the texture data.
  5953. *
  5954. * UNSIGNED_INT, FLOAT.
  5955. */
  5956. type: number;
  5957. /**
  5958. * Specifies whether the texture is in gamma space.
  5959. */
  5960. gammaSpace: boolean;
  5961. }
  5962. /**
  5963. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  5964. */
  5965. export class PanoramaToCubeMapTools {
  5966. private static FACE_FRONT;
  5967. private static FACE_BACK;
  5968. private static FACE_RIGHT;
  5969. private static FACE_LEFT;
  5970. private static FACE_DOWN;
  5971. private static FACE_UP;
  5972. /**
  5973. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  5974. *
  5975. * @param float32Array The source data.
  5976. * @param inputWidth The width of the input panorama.
  5977. * @param inputHeight The height of the input panorama.
  5978. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  5979. * @return The cubemap data
  5980. */
  5981. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  5982. private static CreateCubemapTexture;
  5983. private static CalcProjectionSpherical;
  5984. }
  5985. }
  5986. declare module BABYLON {
  5987. /**
  5988. * Helper class dealing with the extraction of spherical polynomial dataArray
  5989. * from a cube map.
  5990. */
  5991. export class CubeMapToSphericalPolynomialTools {
  5992. private static FileFaces;
  5993. /**
  5994. * Converts a texture to the according Spherical Polynomial data.
  5995. * This extracts the first 3 orders only as they are the only one used in the lighting.
  5996. *
  5997. * @param texture The texture to extract the information from.
  5998. * @return The Spherical Polynomial data.
  5999. */
  6000. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  6001. /**
  6002. * Converts a cubemap to the according Spherical Polynomial data.
  6003. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6004. *
  6005. * @param cubeInfo The Cube map to extract the information from.
  6006. * @return The Spherical Polynomial data.
  6007. */
  6008. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  6009. }
  6010. }
  6011. declare module BABYLON {
  6012. /**
  6013. * The engine store class is responsible to hold all the instances of Engine and Scene created
  6014. * during the life time of the application.
  6015. */
  6016. export class EngineStore {
  6017. /** Gets the list of created engines */
  6018. static Instances: Engine[];
  6019. /**
  6020. * Gets the latest created engine
  6021. */
  6022. static readonly LastCreatedEngine: Nullable<Engine>;
  6023. /**
  6024. * Gets the latest created scene
  6025. */
  6026. static readonly LastCreatedScene: Nullable<Scene>;
  6027. }
  6028. }
  6029. declare module BABYLON {
  6030. /**
  6031. * Define options used to create a render target texture
  6032. */
  6033. export class RenderTargetCreationOptions {
  6034. /**
  6035. * Specifies is mipmaps must be generated
  6036. */
  6037. generateMipMaps?: boolean;
  6038. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6039. generateDepthBuffer?: boolean;
  6040. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6041. generateStencilBuffer?: boolean;
  6042. /** Defines texture type (int by default) */
  6043. type?: number;
  6044. /** Defines sampling mode (trilinear by default) */
  6045. samplingMode?: number;
  6046. /** Defines format (RGBA by default) */
  6047. format?: number;
  6048. }
  6049. }
  6050. declare module BABYLON {
  6051. /**
  6052. * @hidden
  6053. **/
  6054. export class _AlphaState {
  6055. private _isAlphaBlendDirty;
  6056. private _isBlendFunctionParametersDirty;
  6057. private _isBlendEquationParametersDirty;
  6058. private _isBlendConstantsDirty;
  6059. private _alphaBlend;
  6060. private _blendFunctionParameters;
  6061. private _blendEquationParameters;
  6062. private _blendConstants;
  6063. /**
  6064. * Initializes the state.
  6065. */
  6066. constructor();
  6067. readonly isDirty: boolean;
  6068. alphaBlend: boolean;
  6069. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6070. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6071. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6072. reset(): void;
  6073. apply(gl: WebGLRenderingContext): void;
  6074. }
  6075. }
  6076. declare module BABYLON {
  6077. /**
  6078. * @hidden
  6079. **/
  6080. export class _DepthCullingState {
  6081. private _isDepthTestDirty;
  6082. private _isDepthMaskDirty;
  6083. private _isDepthFuncDirty;
  6084. private _isCullFaceDirty;
  6085. private _isCullDirty;
  6086. private _isZOffsetDirty;
  6087. private _isFrontFaceDirty;
  6088. private _depthTest;
  6089. private _depthMask;
  6090. private _depthFunc;
  6091. private _cull;
  6092. private _cullFace;
  6093. private _zOffset;
  6094. private _frontFace;
  6095. /**
  6096. * Initializes the state.
  6097. */
  6098. constructor();
  6099. readonly isDirty: boolean;
  6100. zOffset: number;
  6101. cullFace: Nullable<number>;
  6102. cull: Nullable<boolean>;
  6103. depthFunc: Nullable<number>;
  6104. depthMask: boolean;
  6105. depthTest: boolean;
  6106. frontFace: Nullable<number>;
  6107. reset(): void;
  6108. apply(gl: WebGLRenderingContext): void;
  6109. }
  6110. }
  6111. declare module BABYLON {
  6112. /**
  6113. * @hidden
  6114. **/
  6115. export class _StencilState {
  6116. /** 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 */
  6117. static readonly ALWAYS: number;
  6118. /** Passed to stencilOperation to specify that stencil value must be kept */
  6119. static readonly KEEP: number;
  6120. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6121. static readonly REPLACE: number;
  6122. private _isStencilTestDirty;
  6123. private _isStencilMaskDirty;
  6124. private _isStencilFuncDirty;
  6125. private _isStencilOpDirty;
  6126. private _stencilTest;
  6127. private _stencilMask;
  6128. private _stencilFunc;
  6129. private _stencilFuncRef;
  6130. private _stencilFuncMask;
  6131. private _stencilOpStencilFail;
  6132. private _stencilOpDepthFail;
  6133. private _stencilOpStencilDepthPass;
  6134. readonly isDirty: boolean;
  6135. stencilFunc: number;
  6136. stencilFuncRef: number;
  6137. stencilFuncMask: number;
  6138. stencilOpStencilFail: number;
  6139. stencilOpDepthFail: number;
  6140. stencilOpStencilDepthPass: number;
  6141. stencilMask: number;
  6142. stencilTest: boolean;
  6143. constructor();
  6144. reset(): void;
  6145. apply(gl: WebGLRenderingContext): void;
  6146. }
  6147. }
  6148. declare module BABYLON {
  6149. /**
  6150. * @hidden
  6151. **/
  6152. export class _TimeToken {
  6153. _startTimeQuery: Nullable<WebGLQuery>;
  6154. _endTimeQuery: Nullable<WebGLQuery>;
  6155. _timeElapsedQuery: Nullable<WebGLQuery>;
  6156. _timeElapsedQueryEnded: boolean;
  6157. }
  6158. }
  6159. declare module BABYLON {
  6160. /**
  6161. * Internal interface used to track InternalTexture already bound to the GL context
  6162. */
  6163. export interface IInternalTextureTracker {
  6164. /**
  6165. * Gets or set the previous tracker in the list
  6166. */
  6167. previous: Nullable<IInternalTextureTracker>;
  6168. /**
  6169. * Gets or set the next tracker in the list
  6170. */
  6171. next: Nullable<IInternalTextureTracker>;
  6172. }
  6173. /**
  6174. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  6175. */
  6176. export class DummyInternalTextureTracker {
  6177. /**
  6178. * Gets or set the previous tracker in the list
  6179. */
  6180. previous: Nullable<IInternalTextureTracker>;
  6181. /**
  6182. * Gets or set the next tracker in the list
  6183. */
  6184. next: Nullable<IInternalTextureTracker>;
  6185. }
  6186. }
  6187. declare module BABYLON {
  6188. /**
  6189. * Class used to store data associated with WebGL texture data for the engine
  6190. * This class should not be used directly
  6191. */
  6192. export class InternalTexture implements IInternalTextureTracker {
  6193. /** hidden */
  6194. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6195. /**
  6196. * The source of the texture data is unknown
  6197. */
  6198. static DATASOURCE_UNKNOWN: number;
  6199. /**
  6200. * Texture data comes from an URL
  6201. */
  6202. static DATASOURCE_URL: number;
  6203. /**
  6204. * Texture data is only used for temporary storage
  6205. */
  6206. static DATASOURCE_TEMP: number;
  6207. /**
  6208. * Texture data comes from raw data (ArrayBuffer)
  6209. */
  6210. static DATASOURCE_RAW: number;
  6211. /**
  6212. * Texture content is dynamic (video or dynamic texture)
  6213. */
  6214. static DATASOURCE_DYNAMIC: number;
  6215. /**
  6216. * Texture content is generated by rendering to it
  6217. */
  6218. static DATASOURCE_RENDERTARGET: number;
  6219. /**
  6220. * Texture content is part of a multi render target process
  6221. */
  6222. static DATASOURCE_MULTIRENDERTARGET: number;
  6223. /**
  6224. * Texture data comes from a cube data file
  6225. */
  6226. static DATASOURCE_CUBE: number;
  6227. /**
  6228. * Texture data comes from a raw cube data
  6229. */
  6230. static DATASOURCE_CUBERAW: number;
  6231. /**
  6232. * Texture data come from a prefiltered cube data file
  6233. */
  6234. static DATASOURCE_CUBEPREFILTERED: number;
  6235. /**
  6236. * Texture content is raw 3D data
  6237. */
  6238. static DATASOURCE_RAW3D: number;
  6239. /**
  6240. * Texture content is a depth texture
  6241. */
  6242. static DATASOURCE_DEPTHTEXTURE: number;
  6243. /**
  6244. * Texture data comes from a raw cube data encoded with RGBD
  6245. */
  6246. static DATASOURCE_CUBERAW_RGBD: number;
  6247. /**
  6248. * Defines if the texture is ready
  6249. */
  6250. isReady: boolean;
  6251. /**
  6252. * Defines if the texture is a cube texture
  6253. */
  6254. isCube: boolean;
  6255. /**
  6256. * Defines if the texture contains 3D data
  6257. */
  6258. is3D: boolean;
  6259. /**
  6260. * Defines if the texture contains multiview data
  6261. */
  6262. isMultiview: boolean;
  6263. /**
  6264. * Gets the URL used to load this texture
  6265. */
  6266. url: string;
  6267. /**
  6268. * Gets the sampling mode of the texture
  6269. */
  6270. samplingMode: number;
  6271. /**
  6272. * Gets a boolean indicating if the texture needs mipmaps generation
  6273. */
  6274. generateMipMaps: boolean;
  6275. /**
  6276. * Gets the number of samples used by the texture (WebGL2+ only)
  6277. */
  6278. samples: number;
  6279. /**
  6280. * Gets the type of the texture (int, float...)
  6281. */
  6282. type: number;
  6283. /**
  6284. * Gets the format of the texture (RGB, RGBA...)
  6285. */
  6286. format: number;
  6287. /**
  6288. * Observable called when the texture is loaded
  6289. */
  6290. onLoadedObservable: Observable<InternalTexture>;
  6291. /**
  6292. * Gets the width of the texture
  6293. */
  6294. width: number;
  6295. /**
  6296. * Gets the height of the texture
  6297. */
  6298. height: number;
  6299. /**
  6300. * Gets the depth of the texture
  6301. */
  6302. depth: number;
  6303. /**
  6304. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6305. */
  6306. baseWidth: number;
  6307. /**
  6308. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6309. */
  6310. baseHeight: number;
  6311. /**
  6312. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6313. */
  6314. baseDepth: number;
  6315. /**
  6316. * Gets a boolean indicating if the texture is inverted on Y axis
  6317. */
  6318. invertY: boolean;
  6319. /**
  6320. * Gets or set the previous tracker in the list
  6321. */
  6322. previous: Nullable<IInternalTextureTracker>;
  6323. /**
  6324. * Gets or set the next tracker in the list
  6325. */
  6326. next: Nullable<IInternalTextureTracker>;
  6327. /** @hidden */
  6328. _invertVScale: boolean;
  6329. /** @hidden */
  6330. _initialSlot: number;
  6331. /** @hidden */
  6332. _designatedSlot: number;
  6333. /** @hidden */
  6334. _dataSource: number;
  6335. /** @hidden */
  6336. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6337. /** @hidden */
  6338. _bufferView: Nullable<ArrayBufferView>;
  6339. /** @hidden */
  6340. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6341. /** @hidden */
  6342. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6343. /** @hidden */
  6344. _size: number;
  6345. /** @hidden */
  6346. _extension: string;
  6347. /** @hidden */
  6348. _files: Nullable<string[]>;
  6349. /** @hidden */
  6350. _workingCanvas: HTMLCanvasElement;
  6351. /** @hidden */
  6352. _workingContext: CanvasRenderingContext2D;
  6353. /** @hidden */
  6354. _framebuffer: Nullable<WebGLFramebuffer>;
  6355. /** @hidden */
  6356. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6357. /** @hidden */
  6358. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6359. /** @hidden */
  6360. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6361. /** @hidden */
  6362. _attachments: Nullable<number[]>;
  6363. /** @hidden */
  6364. _cachedCoordinatesMode: Nullable<number>;
  6365. /** @hidden */
  6366. _cachedWrapU: Nullable<number>;
  6367. /** @hidden */
  6368. _cachedWrapV: Nullable<number>;
  6369. /** @hidden */
  6370. _cachedWrapR: Nullable<number>;
  6371. /** @hidden */
  6372. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6373. /** @hidden */
  6374. _isDisabled: boolean;
  6375. /** @hidden */
  6376. _compression: Nullable<string>;
  6377. /** @hidden */
  6378. _generateStencilBuffer: boolean;
  6379. /** @hidden */
  6380. _generateDepthBuffer: boolean;
  6381. /** @hidden */
  6382. _comparisonFunction: number;
  6383. /** @hidden */
  6384. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6385. /** @hidden */
  6386. _lodGenerationScale: number;
  6387. /** @hidden */
  6388. _lodGenerationOffset: number;
  6389. /** @hidden */
  6390. _colorTextureArray: Nullable<WebGLTexture>;
  6391. /** @hidden */
  6392. _depthStencilTextureArray: Nullable<WebGLTexture>;
  6393. /** @hidden */
  6394. _lodTextureHigh: BaseTexture;
  6395. /** @hidden */
  6396. _lodTextureMid: BaseTexture;
  6397. /** @hidden */
  6398. _lodTextureLow: BaseTexture;
  6399. /** @hidden */
  6400. _isRGBD: boolean;
  6401. /** @hidden */
  6402. _webGLTexture: Nullable<WebGLTexture>;
  6403. /** @hidden */
  6404. _references: number;
  6405. private _engine;
  6406. /**
  6407. * Gets the Engine the texture belongs to.
  6408. * @returns The babylon engine
  6409. */
  6410. getEngine(): Engine;
  6411. /**
  6412. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6413. */
  6414. readonly dataSource: number;
  6415. /**
  6416. * Creates a new InternalTexture
  6417. * @param engine defines the engine to use
  6418. * @param dataSource defines the type of data that will be used
  6419. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6420. */
  6421. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6422. /**
  6423. * Increments the number of references (ie. the number of Texture that point to it)
  6424. */
  6425. incrementReferences(): void;
  6426. /**
  6427. * Change the size of the texture (not the size of the content)
  6428. * @param width defines the new width
  6429. * @param height defines the new height
  6430. * @param depth defines the new depth (1 by default)
  6431. */
  6432. updateSize(width: int, height: int, depth?: int): void;
  6433. /** @hidden */
  6434. _rebuild(): void;
  6435. /** @hidden */
  6436. _swapAndDie(target: InternalTexture): void;
  6437. /**
  6438. * Dispose the current allocated resources
  6439. */
  6440. dispose(): void;
  6441. }
  6442. }
  6443. declare module BABYLON {
  6444. /**
  6445. * This represents the main contract an easing function should follow.
  6446. * Easing functions are used throughout the animation system.
  6447. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6448. */
  6449. export interface IEasingFunction {
  6450. /**
  6451. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6452. * of the easing function.
  6453. * The link below provides some of the most common examples of easing functions.
  6454. * @see https://easings.net/
  6455. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6456. * @returns the corresponding value on the curve defined by the easing function
  6457. */
  6458. ease(gradient: number): number;
  6459. }
  6460. /**
  6461. * Base class used for every default easing function.
  6462. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6463. */
  6464. export class EasingFunction implements IEasingFunction {
  6465. /**
  6466. * Interpolation follows the mathematical formula associated with the easing function.
  6467. */
  6468. static readonly EASINGMODE_EASEIN: number;
  6469. /**
  6470. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6471. */
  6472. static readonly EASINGMODE_EASEOUT: number;
  6473. /**
  6474. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6475. */
  6476. static readonly EASINGMODE_EASEINOUT: number;
  6477. private _easingMode;
  6478. /**
  6479. * Sets the easing mode of the current function.
  6480. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6481. */
  6482. setEasingMode(easingMode: number): void;
  6483. /**
  6484. * Gets the current easing mode.
  6485. * @returns the easing mode
  6486. */
  6487. getEasingMode(): number;
  6488. /**
  6489. * @hidden
  6490. */
  6491. easeInCore(gradient: number): number;
  6492. /**
  6493. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6494. * of the easing function.
  6495. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6496. * @returns the corresponding value on the curve defined by the easing function
  6497. */
  6498. ease(gradient: number): number;
  6499. }
  6500. /**
  6501. * Easing function with a circle shape (see link below).
  6502. * @see https://easings.net/#easeInCirc
  6503. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6504. */
  6505. export class CircleEase extends EasingFunction implements IEasingFunction {
  6506. /** @hidden */
  6507. easeInCore(gradient: number): number;
  6508. }
  6509. /**
  6510. * Easing function with a ease back shape (see link below).
  6511. * @see https://easings.net/#easeInBack
  6512. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6513. */
  6514. export class BackEase extends EasingFunction implements IEasingFunction {
  6515. /** Defines the amplitude of the function */
  6516. amplitude: number;
  6517. /**
  6518. * Instantiates a back ease easing
  6519. * @see https://easings.net/#easeInBack
  6520. * @param amplitude Defines the amplitude of the function
  6521. */
  6522. constructor(
  6523. /** Defines the amplitude of the function */
  6524. amplitude?: number);
  6525. /** @hidden */
  6526. easeInCore(gradient: number): number;
  6527. }
  6528. /**
  6529. * Easing function with a bouncing shape (see link below).
  6530. * @see https://easings.net/#easeInBounce
  6531. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6532. */
  6533. export class BounceEase extends EasingFunction implements IEasingFunction {
  6534. /** Defines the number of bounces */
  6535. bounces: number;
  6536. /** Defines the amplitude of the bounce */
  6537. bounciness: number;
  6538. /**
  6539. * Instantiates a bounce easing
  6540. * @see https://easings.net/#easeInBounce
  6541. * @param bounces Defines the number of bounces
  6542. * @param bounciness Defines the amplitude of the bounce
  6543. */
  6544. constructor(
  6545. /** Defines the number of bounces */
  6546. bounces?: number,
  6547. /** Defines the amplitude of the bounce */
  6548. bounciness?: number);
  6549. /** @hidden */
  6550. easeInCore(gradient: number): number;
  6551. }
  6552. /**
  6553. * Easing function with a power of 3 shape (see link below).
  6554. * @see https://easings.net/#easeInCubic
  6555. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6556. */
  6557. export class CubicEase extends EasingFunction implements IEasingFunction {
  6558. /** @hidden */
  6559. easeInCore(gradient: number): number;
  6560. }
  6561. /**
  6562. * Easing function with an elastic shape (see link below).
  6563. * @see https://easings.net/#easeInElastic
  6564. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6565. */
  6566. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6567. /** Defines the number of oscillations*/
  6568. oscillations: number;
  6569. /** Defines the amplitude of the oscillations*/
  6570. springiness: number;
  6571. /**
  6572. * Instantiates an elastic easing function
  6573. * @see https://easings.net/#easeInElastic
  6574. * @param oscillations Defines the number of oscillations
  6575. * @param springiness Defines the amplitude of the oscillations
  6576. */
  6577. constructor(
  6578. /** Defines the number of oscillations*/
  6579. oscillations?: number,
  6580. /** Defines the amplitude of the oscillations*/
  6581. springiness?: number);
  6582. /** @hidden */
  6583. easeInCore(gradient: number): number;
  6584. }
  6585. /**
  6586. * Easing function with an exponential shape (see link below).
  6587. * @see https://easings.net/#easeInExpo
  6588. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6589. */
  6590. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6591. /** Defines the exponent of the function */
  6592. exponent: number;
  6593. /**
  6594. * Instantiates an exponential easing function
  6595. * @see https://easings.net/#easeInExpo
  6596. * @param exponent Defines the exponent of the function
  6597. */
  6598. constructor(
  6599. /** Defines the exponent of the function */
  6600. exponent?: number);
  6601. /** @hidden */
  6602. easeInCore(gradient: number): number;
  6603. }
  6604. /**
  6605. * Easing function with a power shape (see link below).
  6606. * @see https://easings.net/#easeInQuad
  6607. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6608. */
  6609. export class PowerEase extends EasingFunction implements IEasingFunction {
  6610. /** Defines the power of the function */
  6611. power: number;
  6612. /**
  6613. * Instantiates an power base easing function
  6614. * @see https://easings.net/#easeInQuad
  6615. * @param power Defines the power of the function
  6616. */
  6617. constructor(
  6618. /** Defines the power of the function */
  6619. power?: number);
  6620. /** @hidden */
  6621. easeInCore(gradient: number): number;
  6622. }
  6623. /**
  6624. * Easing function with a power of 2 shape (see link below).
  6625. * @see https://easings.net/#easeInQuad
  6626. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6627. */
  6628. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6629. /** @hidden */
  6630. easeInCore(gradient: number): number;
  6631. }
  6632. /**
  6633. * Easing function with a power of 4 shape (see link below).
  6634. * @see https://easings.net/#easeInQuart
  6635. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6636. */
  6637. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6638. /** @hidden */
  6639. easeInCore(gradient: number): number;
  6640. }
  6641. /**
  6642. * Easing function with a power of 5 shape (see link below).
  6643. * @see https://easings.net/#easeInQuint
  6644. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6645. */
  6646. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6647. /** @hidden */
  6648. easeInCore(gradient: number): number;
  6649. }
  6650. /**
  6651. * Easing function with a sin shape (see link below).
  6652. * @see https://easings.net/#easeInSine
  6653. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6654. */
  6655. export class SineEase extends EasingFunction implements IEasingFunction {
  6656. /** @hidden */
  6657. easeInCore(gradient: number): number;
  6658. }
  6659. /**
  6660. * Easing function with a bezier shape (see link below).
  6661. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6662. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6663. */
  6664. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6665. /** Defines the x component of the start tangent in the bezier curve */
  6666. x1: number;
  6667. /** Defines the y component of the start tangent in the bezier curve */
  6668. y1: number;
  6669. /** Defines the x component of the end tangent in the bezier curve */
  6670. x2: number;
  6671. /** Defines the y component of the end tangent in the bezier curve */
  6672. y2: number;
  6673. /**
  6674. * Instantiates a bezier function
  6675. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6676. * @param x1 Defines the x component of the start tangent in the bezier curve
  6677. * @param y1 Defines the y component of the start tangent in the bezier curve
  6678. * @param x2 Defines the x component of the end tangent in the bezier curve
  6679. * @param y2 Defines the y component of the end tangent in the bezier curve
  6680. */
  6681. constructor(
  6682. /** Defines the x component of the start tangent in the bezier curve */
  6683. x1?: number,
  6684. /** Defines the y component of the start tangent in the bezier curve */
  6685. y1?: number,
  6686. /** Defines the x component of the end tangent in the bezier curve */
  6687. x2?: number,
  6688. /** Defines the y component of the end tangent in the bezier curve */
  6689. y2?: number);
  6690. /** @hidden */
  6691. easeInCore(gradient: number): number;
  6692. }
  6693. }
  6694. declare module BABYLON {
  6695. /**
  6696. * Defines an interface which represents an animation key frame
  6697. */
  6698. export interface IAnimationKey {
  6699. /**
  6700. * Frame of the key frame
  6701. */
  6702. frame: number;
  6703. /**
  6704. * Value at the specifies key frame
  6705. */
  6706. value: any;
  6707. /**
  6708. * The input tangent for the cubic hermite spline
  6709. */
  6710. inTangent?: any;
  6711. /**
  6712. * The output tangent for the cubic hermite spline
  6713. */
  6714. outTangent?: any;
  6715. /**
  6716. * The animation interpolation type
  6717. */
  6718. interpolation?: AnimationKeyInterpolation;
  6719. }
  6720. /**
  6721. * Enum for the animation key frame interpolation type
  6722. */
  6723. export enum AnimationKeyInterpolation {
  6724. /**
  6725. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6726. */
  6727. STEP = 1
  6728. }
  6729. }
  6730. declare module BABYLON {
  6731. /**
  6732. * Represents the range of an animation
  6733. */
  6734. export class AnimationRange {
  6735. /**The name of the animation range**/
  6736. name: string;
  6737. /**The starting frame of the animation */
  6738. from: number;
  6739. /**The ending frame of the animation*/
  6740. to: number;
  6741. /**
  6742. * Initializes the range of an animation
  6743. * @param name The name of the animation range
  6744. * @param from The starting frame of the animation
  6745. * @param to The ending frame of the animation
  6746. */
  6747. constructor(
  6748. /**The name of the animation range**/
  6749. name: string,
  6750. /**The starting frame of the animation */
  6751. from: number,
  6752. /**The ending frame of the animation*/
  6753. to: number);
  6754. /**
  6755. * Makes a copy of the animation range
  6756. * @returns A copy of the animation range
  6757. */
  6758. clone(): AnimationRange;
  6759. }
  6760. }
  6761. declare module BABYLON {
  6762. /**
  6763. * Composed of a frame, and an action function
  6764. */
  6765. export class AnimationEvent {
  6766. /** The frame for which the event is triggered **/
  6767. frame: number;
  6768. /** The event to perform when triggered **/
  6769. action: (currentFrame: number) => void;
  6770. /** Specifies if the event should be triggered only once**/
  6771. onlyOnce?: boolean | undefined;
  6772. /**
  6773. * Specifies if the animation event is done
  6774. */
  6775. isDone: boolean;
  6776. /**
  6777. * Initializes the animation event
  6778. * @param frame The frame for which the event is triggered
  6779. * @param action The event to perform when triggered
  6780. * @param onlyOnce Specifies if the event should be triggered only once
  6781. */
  6782. constructor(
  6783. /** The frame for which the event is triggered **/
  6784. frame: number,
  6785. /** The event to perform when triggered **/
  6786. action: (currentFrame: number) => void,
  6787. /** Specifies if the event should be triggered only once**/
  6788. onlyOnce?: boolean | undefined);
  6789. /** @hidden */
  6790. _clone(): AnimationEvent;
  6791. }
  6792. }
  6793. declare module BABYLON {
  6794. /**
  6795. * Interface used to define a behavior
  6796. */
  6797. export interface Behavior<T> {
  6798. /** gets or sets behavior's name */
  6799. name: string;
  6800. /**
  6801. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6802. */
  6803. init(): void;
  6804. /**
  6805. * Called when the behavior is attached to a target
  6806. * @param target defines the target where the behavior is attached to
  6807. */
  6808. attach(target: T): void;
  6809. /**
  6810. * Called when the behavior is detached from its target
  6811. */
  6812. detach(): void;
  6813. }
  6814. /**
  6815. * Interface implemented by classes supporting behaviors
  6816. */
  6817. export interface IBehaviorAware<T> {
  6818. /**
  6819. * Attach a behavior
  6820. * @param behavior defines the behavior to attach
  6821. * @returns the current host
  6822. */
  6823. addBehavior(behavior: Behavior<T>): T;
  6824. /**
  6825. * Remove a behavior from the current object
  6826. * @param behavior defines the behavior to detach
  6827. * @returns the current host
  6828. */
  6829. removeBehavior(behavior: Behavior<T>): T;
  6830. /**
  6831. * Gets a behavior using its name to search
  6832. * @param name defines the name to search
  6833. * @returns the behavior or null if not found
  6834. */
  6835. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6836. }
  6837. }
  6838. declare module BABYLON {
  6839. /**
  6840. * @hidden
  6841. */
  6842. export class IntersectionInfo {
  6843. bu: Nullable<number>;
  6844. bv: Nullable<number>;
  6845. distance: number;
  6846. faceId: number;
  6847. subMeshId: number;
  6848. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6849. }
  6850. }
  6851. declare module BABYLON {
  6852. /**
  6853. * Class used to store bounding sphere information
  6854. */
  6855. export class BoundingSphere {
  6856. /**
  6857. * Gets the center of the bounding sphere in local space
  6858. */
  6859. readonly center: Vector3;
  6860. /**
  6861. * Radius of the bounding sphere in local space
  6862. */
  6863. radius: number;
  6864. /**
  6865. * Gets the center of the bounding sphere in world space
  6866. */
  6867. readonly centerWorld: Vector3;
  6868. /**
  6869. * Radius of the bounding sphere in world space
  6870. */
  6871. radiusWorld: number;
  6872. /**
  6873. * Gets the minimum vector in local space
  6874. */
  6875. readonly minimum: Vector3;
  6876. /**
  6877. * Gets the maximum vector in local space
  6878. */
  6879. readonly maximum: Vector3;
  6880. private _worldMatrix;
  6881. private static readonly TmpVector3;
  6882. /**
  6883. * Creates a new bounding sphere
  6884. * @param min defines the minimum vector (in local space)
  6885. * @param max defines the maximum vector (in local space)
  6886. * @param worldMatrix defines the new world matrix
  6887. */
  6888. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6889. /**
  6890. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6891. * @param min defines the new minimum vector (in local space)
  6892. * @param max defines the new maximum vector (in local space)
  6893. * @param worldMatrix defines the new world matrix
  6894. */
  6895. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6896. /**
  6897. * Scale the current bounding sphere by applying a scale factor
  6898. * @param factor defines the scale factor to apply
  6899. * @returns the current bounding box
  6900. */
  6901. scale(factor: number): BoundingSphere;
  6902. /**
  6903. * Gets the world matrix of the bounding box
  6904. * @returns a matrix
  6905. */
  6906. getWorldMatrix(): DeepImmutable<Matrix>;
  6907. /** @hidden */
  6908. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6909. /**
  6910. * Tests if the bounding sphere is intersecting the frustum planes
  6911. * @param frustumPlanes defines the frustum planes to test
  6912. * @returns true if there is an intersection
  6913. */
  6914. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6915. /**
  6916. * Tests if the bounding sphere center is in between the frustum planes.
  6917. * Used for optimistic fast inclusion.
  6918. * @param frustumPlanes defines the frustum planes to test
  6919. * @returns true if the sphere center is in between the frustum planes
  6920. */
  6921. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6922. /**
  6923. * Tests if a point is inside the bounding sphere
  6924. * @param point defines the point to test
  6925. * @returns true if the point is inside the bounding sphere
  6926. */
  6927. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6928. /**
  6929. * Checks if two sphere intersct
  6930. * @param sphere0 sphere 0
  6931. * @param sphere1 sphere 1
  6932. * @returns true if the speres intersect
  6933. */
  6934. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6935. }
  6936. }
  6937. declare module BABYLON {
  6938. /**
  6939. * Class used to store bounding box information
  6940. */
  6941. export class BoundingBox implements ICullable {
  6942. /**
  6943. * Gets the 8 vectors representing the bounding box in local space
  6944. */
  6945. readonly vectors: Vector3[];
  6946. /**
  6947. * Gets the center of the bounding box in local space
  6948. */
  6949. readonly center: Vector3;
  6950. /**
  6951. * Gets the center of the bounding box in world space
  6952. */
  6953. readonly centerWorld: Vector3;
  6954. /**
  6955. * Gets the extend size in local space
  6956. */
  6957. readonly extendSize: Vector3;
  6958. /**
  6959. * Gets the extend size in world space
  6960. */
  6961. readonly extendSizeWorld: Vector3;
  6962. /**
  6963. * Gets the OBB (object bounding box) directions
  6964. */
  6965. readonly directions: Vector3[];
  6966. /**
  6967. * Gets the 8 vectors representing the bounding box in world space
  6968. */
  6969. readonly vectorsWorld: Vector3[];
  6970. /**
  6971. * Gets the minimum vector in world space
  6972. */
  6973. readonly minimumWorld: Vector3;
  6974. /**
  6975. * Gets the maximum vector in world space
  6976. */
  6977. readonly maximumWorld: Vector3;
  6978. /**
  6979. * Gets the minimum vector in local space
  6980. */
  6981. readonly minimum: Vector3;
  6982. /**
  6983. * Gets the maximum vector in local space
  6984. */
  6985. readonly maximum: Vector3;
  6986. private _worldMatrix;
  6987. private static readonly TmpVector3;
  6988. /**
  6989. * @hidden
  6990. */
  6991. _tag: number;
  6992. /**
  6993. * Creates a new bounding box
  6994. * @param min defines the minimum vector (in local space)
  6995. * @param max defines the maximum vector (in local space)
  6996. * @param worldMatrix defines the new world matrix
  6997. */
  6998. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6999. /**
  7000. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7001. * @param min defines the new minimum vector (in local space)
  7002. * @param max defines the new maximum vector (in local space)
  7003. * @param worldMatrix defines the new world matrix
  7004. */
  7005. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7006. /**
  7007. * Scale the current bounding box by applying a scale factor
  7008. * @param factor defines the scale factor to apply
  7009. * @returns the current bounding box
  7010. */
  7011. scale(factor: number): BoundingBox;
  7012. /**
  7013. * Gets the world matrix of the bounding box
  7014. * @returns a matrix
  7015. */
  7016. getWorldMatrix(): DeepImmutable<Matrix>;
  7017. /** @hidden */
  7018. _update(world: DeepImmutable<Matrix>): void;
  7019. /**
  7020. * Tests if the bounding box is intersecting the frustum planes
  7021. * @param frustumPlanes defines the frustum planes to test
  7022. * @returns true if there is an intersection
  7023. */
  7024. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7025. /**
  7026. * Tests if the bounding box is entirely inside the frustum planes
  7027. * @param frustumPlanes defines the frustum planes to test
  7028. * @returns true if there is an inclusion
  7029. */
  7030. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7031. /**
  7032. * Tests if a point is inside the bounding box
  7033. * @param point defines the point to test
  7034. * @returns true if the point is inside the bounding box
  7035. */
  7036. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7037. /**
  7038. * Tests if the bounding box intersects with a bounding sphere
  7039. * @param sphere defines the sphere to test
  7040. * @returns true if there is an intersection
  7041. */
  7042. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7043. /**
  7044. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7045. * @param min defines the min vector to use
  7046. * @param max defines the max vector to use
  7047. * @returns true if there is an intersection
  7048. */
  7049. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7050. /**
  7051. * Tests if two bounding boxes are intersections
  7052. * @param box0 defines the first box to test
  7053. * @param box1 defines the second box to test
  7054. * @returns true if there is an intersection
  7055. */
  7056. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7057. /**
  7058. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7059. * @param minPoint defines the minimum vector of the bounding box
  7060. * @param maxPoint defines the maximum vector of the bounding box
  7061. * @param sphereCenter defines the sphere center
  7062. * @param sphereRadius defines the sphere radius
  7063. * @returns true if there is an intersection
  7064. */
  7065. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7066. /**
  7067. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7068. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7069. * @param frustumPlanes defines the frustum planes to test
  7070. * @return true if there is an inclusion
  7071. */
  7072. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7073. /**
  7074. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7075. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7076. * @param frustumPlanes defines the frustum planes to test
  7077. * @return true if there is an intersection
  7078. */
  7079. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7080. }
  7081. }
  7082. declare module BABYLON {
  7083. /** @hidden */
  7084. export class Collider {
  7085. /** Define if a collision was found */
  7086. collisionFound: boolean;
  7087. /**
  7088. * Define last intersection point in local space
  7089. */
  7090. intersectionPoint: Vector3;
  7091. /**
  7092. * Define last collided mesh
  7093. */
  7094. collidedMesh: Nullable<AbstractMesh>;
  7095. private _collisionPoint;
  7096. private _planeIntersectionPoint;
  7097. private _tempVector;
  7098. private _tempVector2;
  7099. private _tempVector3;
  7100. private _tempVector4;
  7101. private _edge;
  7102. private _baseToVertex;
  7103. private _destinationPoint;
  7104. private _slidePlaneNormal;
  7105. private _displacementVector;
  7106. /** @hidden */
  7107. _radius: Vector3;
  7108. /** @hidden */
  7109. _retry: number;
  7110. private _velocity;
  7111. private _basePoint;
  7112. private _epsilon;
  7113. /** @hidden */
  7114. _velocityWorldLength: number;
  7115. /** @hidden */
  7116. _basePointWorld: Vector3;
  7117. private _velocityWorld;
  7118. private _normalizedVelocity;
  7119. /** @hidden */
  7120. _initialVelocity: Vector3;
  7121. /** @hidden */
  7122. _initialPosition: Vector3;
  7123. private _nearestDistance;
  7124. private _collisionMask;
  7125. collisionMask: number;
  7126. /**
  7127. * Gets the plane normal used to compute the sliding response (in local space)
  7128. */
  7129. readonly slidePlaneNormal: Vector3;
  7130. /** @hidden */
  7131. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7132. /** @hidden */
  7133. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7134. /** @hidden */
  7135. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7136. /** @hidden */
  7137. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7138. /** @hidden */
  7139. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7140. /** @hidden */
  7141. _getResponse(pos: Vector3, vel: Vector3): void;
  7142. }
  7143. }
  7144. declare module BABYLON {
  7145. /**
  7146. * Interface for cullable objects
  7147. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7148. */
  7149. export interface ICullable {
  7150. /**
  7151. * Checks if the object or part of the object is in the frustum
  7152. * @param frustumPlanes Camera near/planes
  7153. * @returns true if the object is in frustum otherwise false
  7154. */
  7155. isInFrustum(frustumPlanes: Plane[]): boolean;
  7156. /**
  7157. * Checks if a cullable object (mesh...) is in the camera frustum
  7158. * Unlike isInFrustum this cheks the full bounding box
  7159. * @param frustumPlanes Camera near/planes
  7160. * @returns true if the object is in frustum otherwise false
  7161. */
  7162. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7163. }
  7164. /**
  7165. * Info for a bounding data of a mesh
  7166. */
  7167. export class BoundingInfo implements ICullable {
  7168. /**
  7169. * Bounding box for the mesh
  7170. */
  7171. readonly boundingBox: BoundingBox;
  7172. /**
  7173. * Bounding sphere for the mesh
  7174. */
  7175. readonly boundingSphere: BoundingSphere;
  7176. private _isLocked;
  7177. private static readonly TmpVector3;
  7178. /**
  7179. * Constructs bounding info
  7180. * @param minimum min vector of the bounding box/sphere
  7181. * @param maximum max vector of the bounding box/sphere
  7182. * @param worldMatrix defines the new world matrix
  7183. */
  7184. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7185. /**
  7186. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7187. * @param min defines the new minimum vector (in local space)
  7188. * @param max defines the new maximum vector (in local space)
  7189. * @param worldMatrix defines the new world matrix
  7190. */
  7191. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7192. /**
  7193. * min vector of the bounding box/sphere
  7194. */
  7195. readonly minimum: Vector3;
  7196. /**
  7197. * max vector of the bounding box/sphere
  7198. */
  7199. readonly maximum: Vector3;
  7200. /**
  7201. * If the info is locked and won't be updated to avoid perf overhead
  7202. */
  7203. isLocked: boolean;
  7204. /**
  7205. * Updates the bounding sphere and box
  7206. * @param world world matrix to be used to update
  7207. */
  7208. update(world: DeepImmutable<Matrix>): void;
  7209. /**
  7210. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7211. * @param center New center of the bounding info
  7212. * @param extend New extend of the bounding info
  7213. * @returns the current bounding info
  7214. */
  7215. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7216. /**
  7217. * Scale the current bounding info by applying a scale factor
  7218. * @param factor defines the scale factor to apply
  7219. * @returns the current bounding info
  7220. */
  7221. scale(factor: number): BoundingInfo;
  7222. /**
  7223. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7224. * @param frustumPlanes defines the frustum to test
  7225. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7226. * @returns true if the bounding info is in the frustum planes
  7227. */
  7228. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7229. /**
  7230. * Gets the world distance between the min and max points of the bounding box
  7231. */
  7232. readonly diagonalLength: number;
  7233. /**
  7234. * Checks if a cullable object (mesh...) is in the camera frustum
  7235. * Unlike isInFrustum this cheks the full bounding box
  7236. * @param frustumPlanes Camera near/planes
  7237. * @returns true if the object is in frustum otherwise false
  7238. */
  7239. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7240. /** @hidden */
  7241. _checkCollision(collider: Collider): boolean;
  7242. /**
  7243. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7244. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7245. * @param point the point to check intersection with
  7246. * @returns if the point intersects
  7247. */
  7248. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7249. /**
  7250. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7251. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7252. * @param boundingInfo the bounding info to check intersection with
  7253. * @param precise if the intersection should be done using OBB
  7254. * @returns if the bounding info intersects
  7255. */
  7256. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7257. }
  7258. }
  7259. declare module BABYLON {
  7260. /**
  7261. * Defines an array and its length.
  7262. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7263. */
  7264. export interface ISmartArrayLike<T> {
  7265. /**
  7266. * The data of the array.
  7267. */
  7268. data: Array<T>;
  7269. /**
  7270. * The active length of the array.
  7271. */
  7272. length: number;
  7273. }
  7274. /**
  7275. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7276. */
  7277. export class SmartArray<T> implements ISmartArrayLike<T> {
  7278. /**
  7279. * The full set of data from the array.
  7280. */
  7281. data: Array<T>;
  7282. /**
  7283. * The active length of the array.
  7284. */
  7285. length: number;
  7286. protected _id: number;
  7287. /**
  7288. * Instantiates a Smart Array.
  7289. * @param capacity defines the default capacity of the array.
  7290. */
  7291. constructor(capacity: number);
  7292. /**
  7293. * Pushes a value at the end of the active data.
  7294. * @param value defines the object to push in the array.
  7295. */
  7296. push(value: T): void;
  7297. /**
  7298. * Iterates over the active data and apply the lambda to them.
  7299. * @param func defines the action to apply on each value.
  7300. */
  7301. forEach(func: (content: T) => void): void;
  7302. /**
  7303. * Sorts the full sets of data.
  7304. * @param compareFn defines the comparison function to apply.
  7305. */
  7306. sort(compareFn: (a: T, b: T) => number): void;
  7307. /**
  7308. * Resets the active data to an empty array.
  7309. */
  7310. reset(): void;
  7311. /**
  7312. * Releases all the data from the array as well as the array.
  7313. */
  7314. dispose(): void;
  7315. /**
  7316. * Concats the active data with a given array.
  7317. * @param array defines the data to concatenate with.
  7318. */
  7319. concat(array: any): void;
  7320. /**
  7321. * Returns the position of a value in the active data.
  7322. * @param value defines the value to find the index for
  7323. * @returns the index if found in the active data otherwise -1
  7324. */
  7325. indexOf(value: T): number;
  7326. /**
  7327. * Returns whether an element is part of the active data.
  7328. * @param value defines the value to look for
  7329. * @returns true if found in the active data otherwise false
  7330. */
  7331. contains(value: T): boolean;
  7332. private static _GlobalId;
  7333. }
  7334. /**
  7335. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7336. * The data in this array can only be present once
  7337. */
  7338. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7339. private _duplicateId;
  7340. /**
  7341. * Pushes a value at the end of the active data.
  7342. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7343. * @param value defines the object to push in the array.
  7344. */
  7345. push(value: T): void;
  7346. /**
  7347. * Pushes a value at the end of the active data.
  7348. * If the data is already present, it won t be added again
  7349. * @param value defines the object to push in the array.
  7350. * @returns true if added false if it was already present
  7351. */
  7352. pushNoDuplicate(value: T): boolean;
  7353. /**
  7354. * Resets the active data to an empty array.
  7355. */
  7356. reset(): void;
  7357. /**
  7358. * Concats the active data with a given array.
  7359. * This ensures no dupplicate will be present in the result.
  7360. * @param array defines the data to concatenate with.
  7361. */
  7362. concatWithNoDuplicate(array: any): void;
  7363. }
  7364. }
  7365. declare module BABYLON {
  7366. /**
  7367. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7368. * separate meshes. This can be use to improve performances.
  7369. * @see http://doc.babylonjs.com/how_to/multi_materials
  7370. */
  7371. export class MultiMaterial extends Material {
  7372. private _subMaterials;
  7373. /**
  7374. * Gets or Sets the list of Materials used within the multi material.
  7375. * They need to be ordered according to the submeshes order in the associated mesh
  7376. */
  7377. subMaterials: Nullable<Material>[];
  7378. /**
  7379. * Function used to align with Node.getChildren()
  7380. * @returns the list of Materials used within the multi material
  7381. */
  7382. getChildren(): Nullable<Material>[];
  7383. /**
  7384. * Instantiates a new Multi Material
  7385. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7386. * separate meshes. This can be use to improve performances.
  7387. * @see http://doc.babylonjs.com/how_to/multi_materials
  7388. * @param name Define the name in the scene
  7389. * @param scene Define the scene the material belongs to
  7390. */
  7391. constructor(name: string, scene: Scene);
  7392. private _hookArray;
  7393. /**
  7394. * Get one of the submaterial by its index in the submaterials array
  7395. * @param index The index to look the sub material at
  7396. * @returns The Material if the index has been defined
  7397. */
  7398. getSubMaterial(index: number): Nullable<Material>;
  7399. /**
  7400. * Get the list of active textures for the whole sub materials list.
  7401. * @returns All the textures that will be used during the rendering
  7402. */
  7403. getActiveTextures(): BaseTexture[];
  7404. /**
  7405. * Gets the current class name of the material e.g. "MultiMaterial"
  7406. * Mainly use in serialization.
  7407. * @returns the class name
  7408. */
  7409. getClassName(): string;
  7410. /**
  7411. * Checks if the material is ready to render the requested sub mesh
  7412. * @param mesh Define the mesh the submesh belongs to
  7413. * @param subMesh Define the sub mesh to look readyness for
  7414. * @param useInstances Define whether or not the material is used with instances
  7415. * @returns true if ready, otherwise false
  7416. */
  7417. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  7418. /**
  7419. * Clones the current material and its related sub materials
  7420. * @param name Define the name of the newly cloned material
  7421. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  7422. * @returns the cloned material
  7423. */
  7424. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  7425. /**
  7426. * Serializes the materials into a JSON representation.
  7427. * @returns the JSON representation
  7428. */
  7429. serialize(): any;
  7430. /**
  7431. * Dispose the material and release its associated resources
  7432. * @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)
  7433. * @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)
  7434. * @param forceDisposeChildren Define if we want to force disposing the associated submaterials (if false, they will not be disposed and can still be use elsewhere in the app)
  7435. */
  7436. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  7437. /**
  7438. * Creates a MultiMaterial from parsed MultiMaterial data.
  7439. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  7440. * @param scene defines the hosting scene
  7441. * @returns a new MultiMaterial
  7442. */
  7443. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  7444. }
  7445. }
  7446. declare module BABYLON {
  7447. /**
  7448. * Class used to represent data loading progression
  7449. */
  7450. export class SceneLoaderFlags {
  7451. private static _ForceFullSceneLoadingForIncremental;
  7452. private static _ShowLoadingScreen;
  7453. private static _CleanBoneMatrixWeights;
  7454. private static _loggingLevel;
  7455. /**
  7456. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  7457. */
  7458. static ForceFullSceneLoadingForIncremental: boolean;
  7459. /**
  7460. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  7461. */
  7462. static ShowLoadingScreen: boolean;
  7463. /**
  7464. * Defines the current logging level (while loading the scene)
  7465. * @ignorenaming
  7466. */
  7467. static loggingLevel: number;
  7468. /**
  7469. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  7470. */
  7471. static CleanBoneMatrixWeights: boolean;
  7472. }
  7473. }
  7474. declare module BABYLON {
  7475. /**
  7476. * 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.
  7477. * @see https://doc.babylonjs.com/how_to/transformnode
  7478. */
  7479. export class TransformNode extends Node {
  7480. /**
  7481. * Object will not rotate to face the camera
  7482. */
  7483. static BILLBOARDMODE_NONE: number;
  7484. /**
  7485. * Object will rotate to face the camera but only on the x axis
  7486. */
  7487. static BILLBOARDMODE_X: number;
  7488. /**
  7489. * Object will rotate to face the camera but only on the y axis
  7490. */
  7491. static BILLBOARDMODE_Y: number;
  7492. /**
  7493. * Object will rotate to face the camera but only on the z axis
  7494. */
  7495. static BILLBOARDMODE_Z: number;
  7496. /**
  7497. * Object will rotate to face the camera
  7498. */
  7499. static BILLBOARDMODE_ALL: number;
  7500. private _forward;
  7501. private _forwardInverted;
  7502. private _up;
  7503. private _right;
  7504. private _rightInverted;
  7505. private _position;
  7506. private _rotation;
  7507. private _rotationQuaternion;
  7508. protected _scaling: Vector3;
  7509. protected _isDirty: boolean;
  7510. private _transformToBoneReferal;
  7511. /**
  7512. * Set the billboard mode. Default is 0.
  7513. *
  7514. * | Value | Type | Description |
  7515. * | --- | --- | --- |
  7516. * | 0 | BILLBOARDMODE_NONE | |
  7517. * | 1 | BILLBOARDMODE_X | |
  7518. * | 2 | BILLBOARDMODE_Y | |
  7519. * | 4 | BILLBOARDMODE_Z | |
  7520. * | 7 | BILLBOARDMODE_ALL | |
  7521. *
  7522. */
  7523. billboardMode: number;
  7524. /**
  7525. * 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
  7526. */
  7527. scalingDeterminant: number;
  7528. /**
  7529. * Sets the distance of the object to max, often used by skybox
  7530. */
  7531. infiniteDistance: boolean;
  7532. /**
  7533. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  7534. * By default the system will update normals to compensate
  7535. */
  7536. ignoreNonUniformScaling: boolean;
  7537. /** @hidden */
  7538. _poseMatrix: Matrix;
  7539. /** @hidden */
  7540. _localMatrix: Matrix;
  7541. private _absolutePosition;
  7542. private _pivotMatrix;
  7543. private _pivotMatrixInverse;
  7544. protected _postMultiplyPivotMatrix: boolean;
  7545. private _tempMatrix;
  7546. private _tempMatrix2;
  7547. protected _isWorldMatrixFrozen: boolean;
  7548. /** @hidden */
  7549. _indexInSceneTransformNodesArray: number;
  7550. /**
  7551. * An event triggered after the world matrix is updated
  7552. */
  7553. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  7554. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  7555. /**
  7556. * Gets a string identifying the name of the class
  7557. * @returns "TransformNode" string
  7558. */
  7559. getClassName(): string;
  7560. /**
  7561. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  7562. */
  7563. position: Vector3;
  7564. /**
  7565. * 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)).
  7566. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  7567. */
  7568. rotation: Vector3;
  7569. /**
  7570. * 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)).
  7571. */
  7572. scaling: Vector3;
  7573. /**
  7574. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (undefined by default, but can be null).
  7575. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  7576. */
  7577. rotationQuaternion: Nullable<Quaternion>;
  7578. /**
  7579. * The forward direction of that transform in world space.
  7580. */
  7581. readonly forward: Vector3;
  7582. /**
  7583. * The up direction of that transform in world space.
  7584. */
  7585. readonly up: Vector3;
  7586. /**
  7587. * The right direction of that transform in world space.
  7588. */
  7589. readonly right: Vector3;
  7590. /**
  7591. * Copies the parameter passed Matrix into the mesh Pose matrix.
  7592. * @param matrix the matrix to copy the pose from
  7593. * @returns this TransformNode.
  7594. */
  7595. updatePoseMatrix(matrix: Matrix): TransformNode;
  7596. /**
  7597. * Returns the mesh Pose matrix.
  7598. * @returns the pose matrix
  7599. */
  7600. getPoseMatrix(): Matrix;
  7601. /** @hidden */
  7602. _isSynchronized(): boolean;
  7603. /** @hidden */
  7604. _initCache(): void;
  7605. /**
  7606. * Flag the transform node as dirty (Forcing it to update everything)
  7607. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  7608. * @returns this transform node
  7609. */
  7610. markAsDirty(property: string): TransformNode;
  7611. /**
  7612. * Returns the current mesh absolute position.
  7613. * Returns a Vector3.
  7614. */
  7615. readonly absolutePosition: Vector3;
  7616. /**
  7617. * Sets a new matrix to apply before all other transformation
  7618. * @param matrix defines the transform matrix
  7619. * @returns the current TransformNode
  7620. */
  7621. setPreTransformMatrix(matrix: Matrix): TransformNode;
  7622. /**
  7623. * Sets a new pivot matrix to the current node
  7624. * @param matrix defines the new pivot matrix to use
  7625. * @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
  7626. * @returns the current TransformNode
  7627. */
  7628. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  7629. /**
  7630. * Returns the mesh pivot matrix.
  7631. * Default : Identity.
  7632. * @returns the matrix
  7633. */
  7634. getPivotMatrix(): Matrix;
  7635. /**
  7636. * Prevents the World matrix to be computed any longer.
  7637. * @returns the TransformNode.
  7638. */
  7639. freezeWorldMatrix(): TransformNode;
  7640. /**
  7641. * Allows back the World matrix computation.
  7642. * @returns the TransformNode.
  7643. */
  7644. unfreezeWorldMatrix(): this;
  7645. /**
  7646. * True if the World matrix has been frozen.
  7647. */
  7648. readonly isWorldMatrixFrozen: boolean;
  7649. /**
  7650. * Retuns the mesh absolute position in the World.
  7651. * @returns a Vector3.
  7652. */
  7653. getAbsolutePosition(): Vector3;
  7654. /**
  7655. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  7656. * @param absolutePosition the absolute position to set
  7657. * @returns the TransformNode.
  7658. */
  7659. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  7660. /**
  7661. * Sets the mesh position in its local space.
  7662. * @param vector3 the position to set in localspace
  7663. * @returns the TransformNode.
  7664. */
  7665. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  7666. /**
  7667. * Returns the mesh position in the local space from the current World matrix values.
  7668. * @returns a new Vector3.
  7669. */
  7670. getPositionExpressedInLocalSpace(): Vector3;
  7671. /**
  7672. * Translates the mesh along the passed Vector3 in its local space.
  7673. * @param vector3 the distance to translate in localspace
  7674. * @returns the TransformNode.
  7675. */
  7676. locallyTranslate(vector3: Vector3): TransformNode;
  7677. private static _lookAtVectorCache;
  7678. /**
  7679. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  7680. * @param targetPoint the position (must be in same space as current mesh) to look at
  7681. * @param yawCor optional yaw (y-axis) correction in radians
  7682. * @param pitchCor optional pitch (x-axis) correction in radians
  7683. * @param rollCor optional roll (z-axis) correction in radians
  7684. * @param space the choosen space of the target
  7685. * @returns the TransformNode.
  7686. */
  7687. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  7688. /**
  7689. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7690. * This Vector3 is expressed in the World space.
  7691. * @param localAxis axis to rotate
  7692. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7693. */
  7694. getDirection(localAxis: Vector3): Vector3;
  7695. /**
  7696. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  7697. * localAxis is expressed in the mesh local space.
  7698. * result is computed in the Wordl space from the mesh World matrix.
  7699. * @param localAxis axis to rotate
  7700. * @param result the resulting transformnode
  7701. * @returns this TransformNode.
  7702. */
  7703. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  7704. /**
  7705. * Sets this transform node rotation to the given local axis.
  7706. * @param localAxis the axis in local space
  7707. * @param yawCor optional yaw (y-axis) correction in radians
  7708. * @param pitchCor optional pitch (x-axis) correction in radians
  7709. * @param rollCor optional roll (z-axis) correction in radians
  7710. * @returns this TransformNode
  7711. */
  7712. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  7713. /**
  7714. * Sets a new pivot point to the current node
  7715. * @param point defines the new pivot point to use
  7716. * @param space defines if the point is in world or local space (local by default)
  7717. * @returns the current TransformNode
  7718. */
  7719. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  7720. /**
  7721. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  7722. * @returns the pivot point
  7723. */
  7724. getPivotPoint(): Vector3;
  7725. /**
  7726. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  7727. * @param result the vector3 to store the result
  7728. * @returns this TransformNode.
  7729. */
  7730. getPivotPointToRef(result: Vector3): TransformNode;
  7731. /**
  7732. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  7733. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  7734. */
  7735. getAbsolutePivotPoint(): Vector3;
  7736. /**
  7737. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  7738. * @param result vector3 to store the result
  7739. * @returns this TransformNode.
  7740. */
  7741. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  7742. /**
  7743. * Defines the passed node as the parent of the current node.
  7744. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  7745. * @see https://doc.babylonjs.com/how_to/parenting
  7746. * @param node the node ot set as the parent
  7747. * @returns this TransformNode.
  7748. */
  7749. setParent(node: Nullable<Node>): TransformNode;
  7750. private _nonUniformScaling;
  7751. /**
  7752. * True if the scaling property of this object is non uniform eg. (1,2,1)
  7753. */
  7754. readonly nonUniformScaling: boolean;
  7755. /** @hidden */
  7756. _updateNonUniformScalingState(value: boolean): boolean;
  7757. /**
  7758. * Attach the current TransformNode to another TransformNode associated with a bone
  7759. * @param bone Bone affecting the TransformNode
  7760. * @param affectedTransformNode TransformNode associated with the bone
  7761. * @returns this object
  7762. */
  7763. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  7764. /**
  7765. * Detach the transform node if its associated with a bone
  7766. * @returns this object
  7767. */
  7768. detachFromBone(): TransformNode;
  7769. private static _rotationAxisCache;
  7770. /**
  7771. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  7772. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7773. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7774. * The passed axis is also normalized.
  7775. * @param axis the axis to rotate around
  7776. * @param amount the amount to rotate in radians
  7777. * @param space Space to rotate in (Default: local)
  7778. * @returns the TransformNode.
  7779. */
  7780. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  7781. /**
  7782. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  7783. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7784. * The passed axis is also normalized. .
  7785. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  7786. * @param point the point to rotate around
  7787. * @param axis the axis to rotate around
  7788. * @param amount the amount to rotate in radians
  7789. * @returns the TransformNode
  7790. */
  7791. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  7792. /**
  7793. * Translates the mesh along the axis vector for the passed distance in the given space.
  7794. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7795. * @param axis the axis to translate in
  7796. * @param distance the distance to translate
  7797. * @param space Space to rotate in (Default: local)
  7798. * @returns the TransformNode.
  7799. */
  7800. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  7801. /**
  7802. * Adds a rotation step to the mesh current rotation.
  7803. * x, y, z are Euler angles expressed in radians.
  7804. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  7805. * This means this rotation is made in the mesh local space only.
  7806. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  7807. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  7808. * ```javascript
  7809. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  7810. * ```
  7811. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  7812. * 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.
  7813. * @param x Rotation to add
  7814. * @param y Rotation to add
  7815. * @param z Rotation to add
  7816. * @returns the TransformNode.
  7817. */
  7818. addRotation(x: number, y: number, z: number): TransformNode;
  7819. /**
  7820. * Computes the world matrix of the node
  7821. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  7822. * @returns the world matrix
  7823. */
  7824. computeWorldMatrix(force?: boolean): Matrix;
  7825. protected _afterComputeWorldMatrix(): void;
  7826. /**
  7827. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  7828. * @param func callback function to add
  7829. *
  7830. * @returns the TransformNode.
  7831. */
  7832. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7833. /**
  7834. * Removes a registered callback function.
  7835. * @param func callback function to remove
  7836. * @returns the TransformNode.
  7837. */
  7838. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7839. /**
  7840. * Gets the position of the current mesh in camera space
  7841. * @param camera defines the camera to use
  7842. * @returns a position
  7843. */
  7844. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  7845. /**
  7846. * Returns the distance from the mesh to the active camera
  7847. * @param camera defines the camera to use
  7848. * @returns the distance
  7849. */
  7850. getDistanceToCamera(camera?: Nullable<Camera>): number;
  7851. /**
  7852. * Clone the current transform node
  7853. * @param name Name of the new clone
  7854. * @param newParent New parent for the clone
  7855. * @param doNotCloneChildren Do not clone children hierarchy
  7856. * @returns the new transform node
  7857. */
  7858. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  7859. /**
  7860. * Serializes the objects information.
  7861. * @param currentSerializationObject defines the object to serialize in
  7862. * @returns the serialized object
  7863. */
  7864. serialize(currentSerializationObject?: any): any;
  7865. /**
  7866. * Returns a new TransformNode object parsed from the source provided.
  7867. * @param parsedTransformNode is the source.
  7868. * @param scene the scne the object belongs to
  7869. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  7870. * @returns a new TransformNode object parsed from the source provided.
  7871. */
  7872. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  7873. /**
  7874. * Get all child-transformNodes of this node
  7875. * @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
  7876. * @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
  7877. * @returns an array of TransformNode
  7878. */
  7879. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  7880. /**
  7881. * Releases resources associated with this transform node.
  7882. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7883. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7884. */
  7885. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7886. }
  7887. }
  7888. declare module BABYLON {
  7889. /**
  7890. * Class used to override all child animations of a given target
  7891. */
  7892. export class AnimationPropertiesOverride {
  7893. /**
  7894. * Gets or sets a value indicating if animation blending must be used
  7895. */
  7896. enableBlending: boolean;
  7897. /**
  7898. * Gets or sets the blending speed to use when enableBlending is true
  7899. */
  7900. blendingSpeed: number;
  7901. /**
  7902. * Gets or sets the default loop mode to use
  7903. */
  7904. loopMode: number;
  7905. }
  7906. }
  7907. declare module BABYLON {
  7908. /**
  7909. * Class used to store bone information
  7910. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  7911. */
  7912. export class Bone extends Node {
  7913. /**
  7914. * defines the bone name
  7915. */
  7916. name: string;
  7917. private static _tmpVecs;
  7918. private static _tmpQuat;
  7919. private static _tmpMats;
  7920. /**
  7921. * Gets the list of child bones
  7922. */
  7923. children: Bone[];
  7924. /** Gets the animations associated with this bone */
  7925. animations: Animation[];
  7926. /**
  7927. * Gets or sets bone length
  7928. */
  7929. length: number;
  7930. /**
  7931. * @hidden Internal only
  7932. * Set this value to map this bone to a different index in the transform matrices
  7933. * Set this value to -1 to exclude the bone from the transform matrices
  7934. */
  7935. _index: Nullable<number>;
  7936. private _skeleton;
  7937. private _localMatrix;
  7938. private _restPose;
  7939. private _baseMatrix;
  7940. private _absoluteTransform;
  7941. private _invertedAbsoluteTransform;
  7942. private _parent;
  7943. private _scalingDeterminant;
  7944. private _worldTransform;
  7945. private _localScaling;
  7946. private _localRotation;
  7947. private _localPosition;
  7948. private _needToDecompose;
  7949. private _needToCompose;
  7950. /** @hidden */
  7951. _linkedTransformNode: Nullable<TransformNode>;
  7952. /** @hidden */
  7953. /** @hidden */
  7954. _matrix: Matrix;
  7955. /**
  7956. * Create a new bone
  7957. * @param name defines the bone name
  7958. * @param skeleton defines the parent skeleton
  7959. * @param parentBone defines the parent (can be null if the bone is the root)
  7960. * @param localMatrix defines the local matrix
  7961. * @param restPose defines the rest pose matrix
  7962. * @param baseMatrix defines the base matrix
  7963. * @param index defines index of the bone in the hiearchy
  7964. */
  7965. constructor(
  7966. /**
  7967. * defines the bone name
  7968. */
  7969. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  7970. /**
  7971. * Gets the current object class name.
  7972. * @return the class name
  7973. */
  7974. getClassName(): string;
  7975. /**
  7976. * Gets the parent skeleton
  7977. * @returns a skeleton
  7978. */
  7979. getSkeleton(): Skeleton;
  7980. /**
  7981. * Gets parent bone
  7982. * @returns a bone or null if the bone is the root of the bone hierarchy
  7983. */
  7984. getParent(): Nullable<Bone>;
  7985. /**
  7986. * Returns an array containing the root bones
  7987. * @returns an array containing the root bones
  7988. */
  7989. getChildren(): Array<Bone>;
  7990. /**
  7991. * Sets the parent bone
  7992. * @param parent defines the parent (can be null if the bone is the root)
  7993. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  7994. */
  7995. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  7996. /**
  7997. * Gets the local matrix
  7998. * @returns a matrix
  7999. */
  8000. getLocalMatrix(): Matrix;
  8001. /**
  8002. * Gets the base matrix (initial matrix which remains unchanged)
  8003. * @returns a matrix
  8004. */
  8005. getBaseMatrix(): Matrix;
  8006. /**
  8007. * Gets the rest pose matrix
  8008. * @returns a matrix
  8009. */
  8010. getRestPose(): Matrix;
  8011. /**
  8012. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  8013. */
  8014. getWorldMatrix(): Matrix;
  8015. /**
  8016. * Sets the local matrix to rest pose matrix
  8017. */
  8018. returnToRest(): void;
  8019. /**
  8020. * Gets the inverse of the absolute transform matrix.
  8021. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  8022. * @returns a matrix
  8023. */
  8024. getInvertedAbsoluteTransform(): Matrix;
  8025. /**
  8026. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  8027. * @returns a matrix
  8028. */
  8029. getAbsoluteTransform(): Matrix;
  8030. /**
  8031. * Links with the given transform node.
  8032. * The local matrix of this bone is copied from the transform node every frame.
  8033. * @param transformNode defines the transform node to link to
  8034. */
  8035. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  8036. /** Gets or sets current position (in local space) */
  8037. position: Vector3;
  8038. /** Gets or sets current rotation (in local space) */
  8039. rotation: Vector3;
  8040. /** Gets or sets current rotation quaternion (in local space) */
  8041. rotationQuaternion: Quaternion;
  8042. /** Gets or sets current scaling (in local space) */
  8043. scaling: Vector3;
  8044. /**
  8045. * Gets the animation properties override
  8046. */
  8047. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  8048. private _decompose;
  8049. private _compose;
  8050. /**
  8051. * Update the base and local matrices
  8052. * @param matrix defines the new base or local matrix
  8053. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8054. * @param updateLocalMatrix defines if the local matrix should be updated
  8055. */
  8056. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  8057. /** @hidden */
  8058. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  8059. /**
  8060. * Flag the bone as dirty (Forcing it to update everything)
  8061. */
  8062. markAsDirty(): void;
  8063. private _markAsDirtyAndCompose;
  8064. private _markAsDirtyAndDecompose;
  8065. /**
  8066. * Translate the bone in local or world space
  8067. * @param vec The amount to translate the bone
  8068. * @param space The space that the translation is in
  8069. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8070. */
  8071. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8072. /**
  8073. * Set the postion of the bone in local or world space
  8074. * @param position The position to set the bone
  8075. * @param space The space that the position is in
  8076. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8077. */
  8078. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8079. /**
  8080. * Set the absolute position of the bone (world space)
  8081. * @param position The position to set the bone
  8082. * @param mesh The mesh that this bone is attached to
  8083. */
  8084. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  8085. /**
  8086. * Scale the bone on the x, y and z axes (in local space)
  8087. * @param x The amount to scale the bone on the x axis
  8088. * @param y The amount to scale the bone on the y axis
  8089. * @param z The amount to scale the bone on the z axis
  8090. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  8091. */
  8092. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  8093. /**
  8094. * Set the bone scaling in local space
  8095. * @param scale defines the scaling vector
  8096. */
  8097. setScale(scale: Vector3): void;
  8098. /**
  8099. * Gets the current scaling in local space
  8100. * @returns the current scaling vector
  8101. */
  8102. getScale(): Vector3;
  8103. /**
  8104. * Gets the current scaling in local space and stores it in a target vector
  8105. * @param result defines the target vector
  8106. */
  8107. getScaleToRef(result: Vector3): void;
  8108. /**
  8109. * Set the yaw, pitch, and roll of the bone in local or world space
  8110. * @param yaw The rotation of the bone on the y axis
  8111. * @param pitch The rotation of the bone on the x axis
  8112. * @param roll The rotation of the bone on the z axis
  8113. * @param space The space that the axes of rotation are in
  8114. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8115. */
  8116. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  8117. /**
  8118. * Add a rotation to the bone on an axis in local or world space
  8119. * @param axis The axis to rotate the bone on
  8120. * @param amount The amount to rotate the bone
  8121. * @param space The space that the axis is in
  8122. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8123. */
  8124. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  8125. /**
  8126. * Set the rotation of the bone to a particular axis angle in local or world space
  8127. * @param axis The axis to rotate the bone on
  8128. * @param angle The angle that the bone should be rotated to
  8129. * @param space The space that the axis is in
  8130. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8131. */
  8132. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  8133. /**
  8134. * Set the euler rotation of the bone in local of world space
  8135. * @param rotation The euler rotation that the bone should be set to
  8136. * @param space The space that the rotation is in
  8137. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8138. */
  8139. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8140. /**
  8141. * Set the quaternion rotation of the bone in local of world space
  8142. * @param quat The quaternion rotation that the bone should be set to
  8143. * @param space The space that the rotation is in
  8144. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8145. */
  8146. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  8147. /**
  8148. * Set the rotation matrix of the bone in local of world space
  8149. * @param rotMat The rotation matrix that the bone should be set to
  8150. * @param space The space that the rotation is in
  8151. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8152. */
  8153. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  8154. private _rotateWithMatrix;
  8155. private _getNegativeRotationToRef;
  8156. /**
  8157. * Get the position of the bone in local or world space
  8158. * @param space The space that the returned position is in
  8159. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8160. * @returns The position of the bone
  8161. */
  8162. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8163. /**
  8164. * Copy the position of the bone to a vector3 in local or world space
  8165. * @param space The space that the returned position is in
  8166. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8167. * @param result The vector3 to copy the position to
  8168. */
  8169. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  8170. /**
  8171. * Get the absolute position of the bone (world space)
  8172. * @param mesh The mesh that this bone is attached to
  8173. * @returns The absolute position of the bone
  8174. */
  8175. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  8176. /**
  8177. * Copy the absolute position of the bone (world space) to the result param
  8178. * @param mesh The mesh that this bone is attached to
  8179. * @param result The vector3 to copy the absolute position to
  8180. */
  8181. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  8182. /**
  8183. * Compute the absolute transforms of this bone and its children
  8184. */
  8185. computeAbsoluteTransforms(): void;
  8186. /**
  8187. * Get the world direction from an axis that is in the local space of the bone
  8188. * @param localAxis The local direction that is used to compute the world direction
  8189. * @param mesh The mesh that this bone is attached to
  8190. * @returns The world direction
  8191. */
  8192. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8193. /**
  8194. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  8195. * @param localAxis The local direction that is used to compute the world direction
  8196. * @param mesh The mesh that this bone is attached to
  8197. * @param result The vector3 that the world direction will be copied to
  8198. */
  8199. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8200. /**
  8201. * Get the euler rotation of the bone in local or world space
  8202. * @param space The space that the rotation should be in
  8203. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8204. * @returns The euler rotation
  8205. */
  8206. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8207. /**
  8208. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  8209. * @param space The space that the rotation should be in
  8210. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8211. * @param result The vector3 that the rotation should be copied to
  8212. */
  8213. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8214. /**
  8215. * Get the quaternion rotation of the bone in either local or world space
  8216. * @param space The space that the rotation should be in
  8217. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8218. * @returns The quaternion rotation
  8219. */
  8220. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  8221. /**
  8222. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  8223. * @param space The space that the rotation should be in
  8224. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8225. * @param result The quaternion that the rotation should be copied to
  8226. */
  8227. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  8228. /**
  8229. * Get the rotation matrix of the bone in local or world space
  8230. * @param space The space that the rotation should be in
  8231. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8232. * @returns The rotation matrix
  8233. */
  8234. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  8235. /**
  8236. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  8237. * @param space The space that the rotation should be in
  8238. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8239. * @param result The quaternion that the rotation should be copied to
  8240. */
  8241. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  8242. /**
  8243. * Get the world position of a point that is in the local space of the bone
  8244. * @param position The local position
  8245. * @param mesh The mesh that this bone is attached to
  8246. * @returns The world position
  8247. */
  8248. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8249. /**
  8250. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  8251. * @param position The local position
  8252. * @param mesh The mesh that this bone is attached to
  8253. * @param result The vector3 that the world position should be copied to
  8254. */
  8255. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8256. /**
  8257. * Get the local position of a point that is in world space
  8258. * @param position The world position
  8259. * @param mesh The mesh that this bone is attached to
  8260. * @returns The local position
  8261. */
  8262. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8263. /**
  8264. * Get the local position of a point that is in world space and copy it to the result param
  8265. * @param position The world position
  8266. * @param mesh The mesh that this bone is attached to
  8267. * @param result The vector3 that the local position should be copied to
  8268. */
  8269. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8270. }
  8271. }
  8272. declare module BABYLON {
  8273. /**
  8274. * Enum that determines the text-wrapping mode to use.
  8275. */
  8276. export enum InspectableType {
  8277. /**
  8278. * Checkbox for booleans
  8279. */
  8280. Checkbox = 0,
  8281. /**
  8282. * Sliders for numbers
  8283. */
  8284. Slider = 1,
  8285. /**
  8286. * Vector3
  8287. */
  8288. Vector3 = 2,
  8289. /**
  8290. * Quaternions
  8291. */
  8292. Quaternion = 3,
  8293. /**
  8294. * Color3
  8295. */
  8296. Color3 = 4
  8297. }
  8298. /**
  8299. * Interface used to define custom inspectable properties.
  8300. * This interface is used by the inspector to display custom property grids
  8301. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  8302. */
  8303. export interface IInspectable {
  8304. /**
  8305. * Gets the label to display
  8306. */
  8307. label: string;
  8308. /**
  8309. * Gets the name of the property to edit
  8310. */
  8311. propertyName: string;
  8312. /**
  8313. * Gets the type of the editor to use
  8314. */
  8315. type: InspectableType;
  8316. /**
  8317. * Gets the minimum value of the property when using in "slider" mode
  8318. */
  8319. min?: number;
  8320. /**
  8321. * Gets the maximum value of the property when using in "slider" mode
  8322. */
  8323. max?: number;
  8324. /**
  8325. * Gets the setp to use when using in "slider" mode
  8326. */
  8327. step?: number;
  8328. }
  8329. }
  8330. declare module BABYLON {
  8331. /**
  8332. * Class for creating a cube texture
  8333. */
  8334. export class CubeTexture extends BaseTexture {
  8335. private _delayedOnLoad;
  8336. /**
  8337. * The url of the texture
  8338. */
  8339. url: string;
  8340. /**
  8341. * Gets or sets the center of the bounding box associated with the cube texture.
  8342. * It must define where the camera used to render the texture was set
  8343. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8344. */
  8345. boundingBoxPosition: Vector3;
  8346. private _boundingBoxSize;
  8347. /**
  8348. * Gets or sets the size of the bounding box associated with the cube texture
  8349. * When defined, the cubemap will switch to local mode
  8350. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  8351. * @example https://www.babylonjs-playground.com/#RNASML
  8352. */
  8353. /**
  8354. * Returns the bounding box size
  8355. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8356. */
  8357. boundingBoxSize: Vector3;
  8358. protected _rotationY: number;
  8359. /**
  8360. * Sets texture matrix rotation angle around Y axis in radians.
  8361. */
  8362. /**
  8363. * Gets texture matrix rotation angle around Y axis radians.
  8364. */
  8365. rotationY: number;
  8366. /**
  8367. * Are mip maps generated for this texture or not.
  8368. */
  8369. readonly noMipmap: boolean;
  8370. private _noMipmap;
  8371. private _files;
  8372. private _extensions;
  8373. private _textureMatrix;
  8374. private _format;
  8375. private _createPolynomials;
  8376. /** @hidden */
  8377. _prefiltered: boolean;
  8378. /**
  8379. * Creates a cube texture from an array of image urls
  8380. * @param files defines an array of image urls
  8381. * @param scene defines the hosting scene
  8382. * @param noMipmap specifies if mip maps are not used
  8383. * @returns a cube texture
  8384. */
  8385. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8386. /**
  8387. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8388. * @param url defines the url of the prefiltered texture
  8389. * @param scene defines the scene the texture is attached to
  8390. * @param forcedExtension defines the extension of the file if different from the url
  8391. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8392. * @return the prefiltered texture
  8393. */
  8394. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8395. /**
  8396. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8397. * as prefiltered data.
  8398. * @param rootUrl defines the url of the texture or the root name of the six images
  8399. * @param scene defines the scene the texture is attached to
  8400. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8401. * @param noMipmap defines if mipmaps should be created or not
  8402. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8403. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8404. * @param onError defines a callback triggered in case of error during load
  8405. * @param format defines the internal format to use for the texture once loaded
  8406. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8407. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8408. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8409. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8410. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8411. * @return the cube texture
  8412. */
  8413. 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);
  8414. /**
  8415. * Get the current class name of the texture useful for serialization or dynamic coding.
  8416. * @returns "CubeTexture"
  8417. */
  8418. getClassName(): string;
  8419. /**
  8420. * Update the url (and optional buffer) of this texture if url was null during construction.
  8421. * @param url the url of the texture
  8422. * @param forcedExtension defines the extension to use
  8423. * @param onLoad callback called when the texture is loaded (defaults to null)
  8424. */
  8425. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  8426. /**
  8427. * Delays loading of the cube texture
  8428. * @param forcedExtension defines the extension to use
  8429. */
  8430. delayLoad(forcedExtension?: string): void;
  8431. /**
  8432. * Returns the reflection texture matrix
  8433. * @returns the reflection texture matrix
  8434. */
  8435. getReflectionTextureMatrix(): Matrix;
  8436. /**
  8437. * Sets the reflection texture matrix
  8438. * @param value Reflection texture matrix
  8439. */
  8440. setReflectionTextureMatrix(value: Matrix): void;
  8441. /**
  8442. * Parses text to create a cube texture
  8443. * @param parsedTexture define the serialized text to read from
  8444. * @param scene defines the hosting scene
  8445. * @param rootUrl defines the root url of the cube texture
  8446. * @returns a cube texture
  8447. */
  8448. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8449. /**
  8450. * Makes a clone, or deep copy, of the cube texture
  8451. * @returns a new cube texture
  8452. */
  8453. clone(): CubeTexture;
  8454. }
  8455. }
  8456. declare module BABYLON {
  8457. /** @hidden */
  8458. export var postprocessVertexShader: {
  8459. name: string;
  8460. shader: string;
  8461. };
  8462. }
  8463. declare module BABYLON {
  8464. /**
  8465. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8466. * This is the base of the follow, arc rotate cameras and Free camera
  8467. * @see http://doc.babylonjs.com/features/cameras
  8468. */
  8469. export class TargetCamera extends Camera {
  8470. private static _RigCamTransformMatrix;
  8471. private static _TargetTransformMatrix;
  8472. private static _TargetFocalPoint;
  8473. /**
  8474. * Define the current direction the camera is moving to
  8475. */
  8476. cameraDirection: Vector3;
  8477. /**
  8478. * Define the current rotation the camera is rotating to
  8479. */
  8480. cameraRotation: Vector2;
  8481. /**
  8482. * When set, the up vector of the camera will be updated by the rotation of the camera
  8483. */
  8484. updateUpVectorFromRotation: boolean;
  8485. private _tmpQuaternion;
  8486. /**
  8487. * Define the current rotation of the camera
  8488. */
  8489. rotation: Vector3;
  8490. /**
  8491. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8492. */
  8493. rotationQuaternion: Quaternion;
  8494. /**
  8495. * Define the current speed of the camera
  8496. */
  8497. speed: number;
  8498. /**
  8499. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8500. * around all axis.
  8501. */
  8502. noRotationConstraint: boolean;
  8503. /**
  8504. * Define the current target of the camera as an object or a position.
  8505. */
  8506. lockedTarget: any;
  8507. /** @hidden */
  8508. _currentTarget: Vector3;
  8509. /** @hidden */
  8510. _initialFocalDistance: number;
  8511. /** @hidden */
  8512. _viewMatrix: Matrix;
  8513. /** @hidden */
  8514. _camMatrix: Matrix;
  8515. /** @hidden */
  8516. _cameraTransformMatrix: Matrix;
  8517. /** @hidden */
  8518. _cameraRotationMatrix: Matrix;
  8519. /** @hidden */
  8520. _referencePoint: Vector3;
  8521. /** @hidden */
  8522. _transformedReferencePoint: Vector3;
  8523. protected _globalCurrentTarget: Vector3;
  8524. protected _globalCurrentUpVector: Vector3;
  8525. /** @hidden */
  8526. _reset: () => void;
  8527. private _defaultUp;
  8528. /**
  8529. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8530. * This is the base of the follow, arc rotate cameras and Free camera
  8531. * @see http://doc.babylonjs.com/features/cameras
  8532. * @param name Defines the name of the camera in the scene
  8533. * @param position Defines the start position of the camera in the scene
  8534. * @param scene Defines the scene the camera belongs to
  8535. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8536. */
  8537. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8538. /**
  8539. * Gets the position in front of the camera at a given distance.
  8540. * @param distance The distance from the camera we want the position to be
  8541. * @returns the position
  8542. */
  8543. getFrontPosition(distance: number): Vector3;
  8544. /** @hidden */
  8545. _getLockedTargetPosition(): Nullable<Vector3>;
  8546. private _storedPosition;
  8547. private _storedRotation;
  8548. private _storedRotationQuaternion;
  8549. /**
  8550. * Store current camera state of the camera (fov, position, rotation, etc..)
  8551. * @returns the camera
  8552. */
  8553. storeState(): Camera;
  8554. /**
  8555. * Restored camera state. You must call storeState() first
  8556. * @returns whether it was successful or not
  8557. * @hidden
  8558. */
  8559. _restoreStateValues(): boolean;
  8560. /** @hidden */
  8561. _initCache(): void;
  8562. /** @hidden */
  8563. _updateCache(ignoreParentClass?: boolean): void;
  8564. /** @hidden */
  8565. _isSynchronizedViewMatrix(): boolean;
  8566. /** @hidden */
  8567. _computeLocalCameraSpeed(): number;
  8568. /**
  8569. * Defines the target the camera should look at.
  8570. * This will automatically adapt alpha beta and radius to fit within the new target.
  8571. * @param target Defines the new target as a Vector or a mesh
  8572. */
  8573. setTarget(target: Vector3): void;
  8574. /**
  8575. * Return the current target position of the camera. This value is expressed in local space.
  8576. * @returns the target position
  8577. */
  8578. getTarget(): Vector3;
  8579. /** @hidden */
  8580. _decideIfNeedsToMove(): boolean;
  8581. /** @hidden */
  8582. _updatePosition(): void;
  8583. /** @hidden */
  8584. _checkInputs(): void;
  8585. protected _updateCameraRotationMatrix(): void;
  8586. /**
  8587. * 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)
  8588. * @returns the current camera
  8589. */
  8590. private _rotateUpVectorWithCameraRotationMatrix;
  8591. private _cachedRotationZ;
  8592. private _cachedQuaternionRotationZ;
  8593. /** @hidden */
  8594. _getViewMatrix(): Matrix;
  8595. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8596. /**
  8597. * @hidden
  8598. */
  8599. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8600. /**
  8601. * @hidden
  8602. */
  8603. _updateRigCameras(): void;
  8604. private _getRigCamPositionAndTarget;
  8605. /**
  8606. * Gets the current object class name.
  8607. * @return the class name
  8608. */
  8609. getClassName(): string;
  8610. }
  8611. }
  8612. declare module BABYLON {
  8613. /**
  8614. * @ignore
  8615. * This is a list of all the different input types that are available in the application.
  8616. * Fo instance: ArcRotateCameraGamepadInput...
  8617. */
  8618. export var CameraInputTypes: {};
  8619. /**
  8620. * This is the contract to implement in order to create a new input class.
  8621. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8622. */
  8623. export interface ICameraInput<TCamera extends Camera> {
  8624. /**
  8625. * Defines the camera the input is attached to.
  8626. */
  8627. camera: Nullable<TCamera>;
  8628. /**
  8629. * Gets the class name of the current intput.
  8630. * @returns the class name
  8631. */
  8632. getClassName(): string;
  8633. /**
  8634. * Get the friendly name associated with the input class.
  8635. * @returns the input friendly name
  8636. */
  8637. getSimpleName(): string;
  8638. /**
  8639. * Attach the input controls to a specific dom element to get the input from.
  8640. * @param element Defines the element the controls should be listened from
  8641. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8642. */
  8643. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8644. /**
  8645. * Detach the current controls from the specified dom element.
  8646. * @param element Defines the element to stop listening the inputs from
  8647. */
  8648. detachControl(element: Nullable<HTMLElement>): void;
  8649. /**
  8650. * Update the current camera state depending on the inputs that have been used this frame.
  8651. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8652. */
  8653. checkInputs?: () => void;
  8654. }
  8655. /**
  8656. * Represents a map of input types to input instance or input index to input instance.
  8657. */
  8658. export interface CameraInputsMap<TCamera extends Camera> {
  8659. /**
  8660. * Accessor to the input by input type.
  8661. */
  8662. [name: string]: ICameraInput<TCamera>;
  8663. /**
  8664. * Accessor to the input by input index.
  8665. */
  8666. [idx: number]: ICameraInput<TCamera>;
  8667. }
  8668. /**
  8669. * This represents the input manager used within a camera.
  8670. * It helps dealing with all the different kind of input attached to a camera.
  8671. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8672. */
  8673. export class CameraInputsManager<TCamera extends Camera> {
  8674. /**
  8675. * Defines the list of inputs attahed to the camera.
  8676. */
  8677. attached: CameraInputsMap<TCamera>;
  8678. /**
  8679. * Defines the dom element the camera is collecting inputs from.
  8680. * This is null if the controls have not been attached.
  8681. */
  8682. attachedElement: Nullable<HTMLElement>;
  8683. /**
  8684. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8685. */
  8686. noPreventDefault: boolean;
  8687. /**
  8688. * Defined the camera the input manager belongs to.
  8689. */
  8690. camera: TCamera;
  8691. /**
  8692. * Update the current camera state depending on the inputs that have been used this frame.
  8693. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8694. */
  8695. checkInputs: () => void;
  8696. /**
  8697. * Instantiate a new Camera Input Manager.
  8698. * @param camera Defines the camera the input manager blongs to
  8699. */
  8700. constructor(camera: TCamera);
  8701. /**
  8702. * Add an input method to a camera
  8703. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8704. * @param input camera input method
  8705. */
  8706. add(input: ICameraInput<TCamera>): void;
  8707. /**
  8708. * Remove a specific input method from a camera
  8709. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8710. * @param inputToRemove camera input method
  8711. */
  8712. remove(inputToRemove: ICameraInput<TCamera>): void;
  8713. /**
  8714. * Remove a specific input type from a camera
  8715. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8716. * @param inputType the type of the input to remove
  8717. */
  8718. removeByType(inputType: string): void;
  8719. private _addCheckInputs;
  8720. /**
  8721. * Attach the input controls to the currently attached dom element to listen the events from.
  8722. * @param input Defines the input to attach
  8723. */
  8724. attachInput(input: ICameraInput<TCamera>): void;
  8725. /**
  8726. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8727. * @param element Defines the dom element to collect the events from
  8728. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8729. */
  8730. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8731. /**
  8732. * Detach the current manager inputs controls from a specific dom element.
  8733. * @param element Defines the dom element to collect the events from
  8734. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8735. */
  8736. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8737. /**
  8738. * Rebuild the dynamic inputCheck function from the current list of
  8739. * defined inputs in the manager.
  8740. */
  8741. rebuildInputCheck(): void;
  8742. /**
  8743. * Remove all attached input methods from a camera
  8744. */
  8745. clear(): void;
  8746. /**
  8747. * Serialize the current input manager attached to a camera.
  8748. * This ensures than once parsed,
  8749. * the input associated to the camera will be identical to the current ones
  8750. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8751. */
  8752. serialize(serializedCamera: any): void;
  8753. /**
  8754. * Parses an input manager serialized JSON to restore the previous list of inputs
  8755. * and states associated to a camera.
  8756. * @param parsedCamera Defines the JSON to parse
  8757. */
  8758. parse(parsedCamera: any): void;
  8759. }
  8760. }
  8761. declare module BABYLON {
  8762. /**
  8763. * Gather the list of keyboard event types as constants.
  8764. */
  8765. export class KeyboardEventTypes {
  8766. /**
  8767. * The keydown event is fired when a key becomes active (pressed).
  8768. */
  8769. static readonly KEYDOWN: number;
  8770. /**
  8771. * The keyup event is fired when a key has been released.
  8772. */
  8773. static readonly KEYUP: number;
  8774. }
  8775. /**
  8776. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8777. */
  8778. export class KeyboardInfo {
  8779. /**
  8780. * Defines the type of event (KeyboardEventTypes)
  8781. */
  8782. type: number;
  8783. /**
  8784. * Defines the related dom event
  8785. */
  8786. event: KeyboardEvent;
  8787. /**
  8788. * Instantiates a new keyboard info.
  8789. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8790. * @param type Defines the type of event (KeyboardEventTypes)
  8791. * @param event Defines the related dom event
  8792. */
  8793. constructor(
  8794. /**
  8795. * Defines the type of event (KeyboardEventTypes)
  8796. */
  8797. type: number,
  8798. /**
  8799. * Defines the related dom event
  8800. */
  8801. event: KeyboardEvent);
  8802. }
  8803. /**
  8804. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8805. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8806. */
  8807. export class KeyboardInfoPre extends KeyboardInfo {
  8808. /**
  8809. * Defines the type of event (KeyboardEventTypes)
  8810. */
  8811. type: number;
  8812. /**
  8813. * Defines the related dom event
  8814. */
  8815. event: KeyboardEvent;
  8816. /**
  8817. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8818. */
  8819. skipOnPointerObservable: boolean;
  8820. /**
  8821. * Instantiates a new keyboard pre info.
  8822. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8823. * @param type Defines the type of event (KeyboardEventTypes)
  8824. * @param event Defines the related dom event
  8825. */
  8826. constructor(
  8827. /**
  8828. * Defines the type of event (KeyboardEventTypes)
  8829. */
  8830. type: number,
  8831. /**
  8832. * Defines the related dom event
  8833. */
  8834. event: KeyboardEvent);
  8835. }
  8836. }
  8837. declare module BABYLON {
  8838. /**
  8839. * Manage the keyboard inputs to control the movement of a free camera.
  8840. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8841. */
  8842. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8843. /**
  8844. * Defines the camera the input is attached to.
  8845. */
  8846. camera: FreeCamera;
  8847. /**
  8848. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8849. */
  8850. keysUp: number[];
  8851. /**
  8852. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8853. */
  8854. keysDown: number[];
  8855. /**
  8856. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8857. */
  8858. keysLeft: number[];
  8859. /**
  8860. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8861. */
  8862. keysRight: number[];
  8863. private _keys;
  8864. private _onCanvasBlurObserver;
  8865. private _onKeyboardObserver;
  8866. private _engine;
  8867. private _scene;
  8868. /**
  8869. * Attach the input controls to a specific dom element to get the input from.
  8870. * @param element Defines the element the controls should be listened from
  8871. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8872. */
  8873. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8874. /**
  8875. * Detach the current controls from the specified dom element.
  8876. * @param element Defines the element to stop listening the inputs from
  8877. */
  8878. detachControl(element: Nullable<HTMLElement>): void;
  8879. /**
  8880. * Update the current camera state depending on the inputs that have been used this frame.
  8881. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8882. */
  8883. checkInputs(): void;
  8884. /**
  8885. * Gets the class name of the current intput.
  8886. * @returns the class name
  8887. */
  8888. getClassName(): string;
  8889. /** @hidden */
  8890. _onLostFocus(): void;
  8891. /**
  8892. * Get the friendly name associated with the input class.
  8893. * @returns the input friendly name
  8894. */
  8895. getSimpleName(): string;
  8896. }
  8897. }
  8898. declare module BABYLON {
  8899. /**
  8900. * Interface describing all the common properties and methods a shadow light needs to implement.
  8901. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8902. * as well as binding the different shadow properties to the effects.
  8903. */
  8904. export interface IShadowLight extends Light {
  8905. /**
  8906. * The light id in the scene (used in scene.findLighById for instance)
  8907. */
  8908. id: string;
  8909. /**
  8910. * The position the shdow will be casted from.
  8911. */
  8912. position: Vector3;
  8913. /**
  8914. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8915. */
  8916. direction: Vector3;
  8917. /**
  8918. * The transformed position. Position of the light in world space taking parenting in account.
  8919. */
  8920. transformedPosition: Vector3;
  8921. /**
  8922. * The transformed direction. Direction of the light in world space taking parenting in account.
  8923. */
  8924. transformedDirection: Vector3;
  8925. /**
  8926. * The friendly name of the light in the scene.
  8927. */
  8928. name: string;
  8929. /**
  8930. * Defines the shadow projection clipping minimum z value.
  8931. */
  8932. shadowMinZ: number;
  8933. /**
  8934. * Defines the shadow projection clipping maximum z value.
  8935. */
  8936. shadowMaxZ: number;
  8937. /**
  8938. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8939. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8940. */
  8941. computeTransformedInformation(): boolean;
  8942. /**
  8943. * Gets the scene the light belongs to.
  8944. * @returns The scene
  8945. */
  8946. getScene(): Scene;
  8947. /**
  8948. * Callback defining a custom Projection Matrix Builder.
  8949. * This can be used to override the default projection matrix computation.
  8950. */
  8951. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8952. /**
  8953. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8954. * @param matrix The materix to updated with the projection information
  8955. * @param viewMatrix The transform matrix of the light
  8956. * @param renderList The list of mesh to render in the map
  8957. * @returns The current light
  8958. */
  8959. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8960. /**
  8961. * Gets the current depth scale used in ESM.
  8962. * @returns The scale
  8963. */
  8964. getDepthScale(): number;
  8965. /**
  8966. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8967. * @returns true if a cube texture needs to be use
  8968. */
  8969. needCube(): boolean;
  8970. /**
  8971. * Detects if the projection matrix requires to be recomputed this frame.
  8972. * @returns true if it requires to be recomputed otherwise, false.
  8973. */
  8974. needProjectionMatrixCompute(): boolean;
  8975. /**
  8976. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8977. */
  8978. forceProjectionMatrixCompute(): void;
  8979. /**
  8980. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8981. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8982. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8983. */
  8984. getShadowDirection(faceIndex?: number): Vector3;
  8985. /**
  8986. * Gets the minZ used for shadow according to both the scene and the light.
  8987. * @param activeCamera The camera we are returning the min for
  8988. * @returns the depth min z
  8989. */
  8990. getDepthMinZ(activeCamera: Camera): number;
  8991. /**
  8992. * Gets the maxZ used for shadow according to both the scene and the light.
  8993. * @param activeCamera The camera we are returning the max for
  8994. * @returns the depth max z
  8995. */
  8996. getDepthMaxZ(activeCamera: Camera): number;
  8997. }
  8998. /**
  8999. * Base implementation IShadowLight
  9000. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9001. */
  9002. export abstract class ShadowLight extends Light implements IShadowLight {
  9003. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9004. protected _position: Vector3;
  9005. protected _setPosition(value: Vector3): void;
  9006. /**
  9007. * Sets the position the shadow will be casted from. Also use as the light position for both
  9008. * point and spot lights.
  9009. */
  9010. /**
  9011. * Sets the position the shadow will be casted from. Also use as the light position for both
  9012. * point and spot lights.
  9013. */
  9014. position: Vector3;
  9015. protected _direction: Vector3;
  9016. protected _setDirection(value: Vector3): void;
  9017. /**
  9018. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9019. * Also use as the light direction on spot and directional lights.
  9020. */
  9021. /**
  9022. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9023. * Also use as the light direction on spot and directional lights.
  9024. */
  9025. direction: Vector3;
  9026. private _shadowMinZ;
  9027. /**
  9028. * Gets the shadow projection clipping minimum z value.
  9029. */
  9030. /**
  9031. * Sets the shadow projection clipping minimum z value.
  9032. */
  9033. shadowMinZ: number;
  9034. private _shadowMaxZ;
  9035. /**
  9036. * Sets the shadow projection clipping maximum z value.
  9037. */
  9038. /**
  9039. * Gets the shadow projection clipping maximum z value.
  9040. */
  9041. shadowMaxZ: number;
  9042. /**
  9043. * Callback defining a custom Projection Matrix Builder.
  9044. * This can be used to override the default projection matrix computation.
  9045. */
  9046. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9047. /**
  9048. * The transformed position. Position of the light in world space taking parenting in account.
  9049. */
  9050. transformedPosition: Vector3;
  9051. /**
  9052. * The transformed direction. Direction of the light in world space taking parenting in account.
  9053. */
  9054. transformedDirection: Vector3;
  9055. private _needProjectionMatrixCompute;
  9056. /**
  9057. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9058. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9059. */
  9060. computeTransformedInformation(): boolean;
  9061. /**
  9062. * Return the depth scale used for the shadow map.
  9063. * @returns the depth scale.
  9064. */
  9065. getDepthScale(): number;
  9066. /**
  9067. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9068. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9069. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9070. */
  9071. getShadowDirection(faceIndex?: number): Vector3;
  9072. /**
  9073. * Returns the ShadowLight absolute position in the World.
  9074. * @returns the position vector in world space
  9075. */
  9076. getAbsolutePosition(): Vector3;
  9077. /**
  9078. * Sets the ShadowLight direction toward the passed target.
  9079. * @param target The point to target in local space
  9080. * @returns the updated ShadowLight direction
  9081. */
  9082. setDirectionToTarget(target: Vector3): Vector3;
  9083. /**
  9084. * Returns the light rotation in euler definition.
  9085. * @returns the x y z rotation in local space.
  9086. */
  9087. getRotation(): Vector3;
  9088. /**
  9089. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9090. * @returns true if a cube texture needs to be use
  9091. */
  9092. needCube(): boolean;
  9093. /**
  9094. * Detects if the projection matrix requires to be recomputed this frame.
  9095. * @returns true if it requires to be recomputed otherwise, false.
  9096. */
  9097. needProjectionMatrixCompute(): boolean;
  9098. /**
  9099. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9100. */
  9101. forceProjectionMatrixCompute(): void;
  9102. /** @hidden */
  9103. _initCache(): void;
  9104. /** @hidden */
  9105. _isSynchronized(): boolean;
  9106. /**
  9107. * Computes the world matrix of the node
  9108. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9109. * @returns the world matrix
  9110. */
  9111. computeWorldMatrix(force?: boolean): Matrix;
  9112. /**
  9113. * Gets the minZ used for shadow according to both the scene and the light.
  9114. * @param activeCamera The camera we are returning the min for
  9115. * @returns the depth min z
  9116. */
  9117. getDepthMinZ(activeCamera: Camera): number;
  9118. /**
  9119. * Gets the maxZ used for shadow according to both the scene and the light.
  9120. * @param activeCamera The camera we are returning the max for
  9121. * @returns the depth max z
  9122. */
  9123. getDepthMaxZ(activeCamera: Camera): number;
  9124. /**
  9125. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9126. * @param matrix The materix to updated with the projection information
  9127. * @param viewMatrix The transform matrix of the light
  9128. * @param renderList The list of mesh to render in the map
  9129. * @returns The current light
  9130. */
  9131. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9132. }
  9133. }
  9134. declare module BABYLON {
  9135. /**
  9136. * "Static Class" containing the most commonly used helper while dealing with material for
  9137. * rendering purpose.
  9138. *
  9139. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9140. *
  9141. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9142. */
  9143. export class MaterialHelper {
  9144. /**
  9145. * Bind the current view position to an effect.
  9146. * @param effect The effect to be bound
  9147. * @param scene The scene the eyes position is used from
  9148. */
  9149. static BindEyePosition(effect: Effect, scene: Scene): void;
  9150. /**
  9151. * Helps preparing the defines values about the UVs in used in the effect.
  9152. * UVs are shared as much as we can accross channels in the shaders.
  9153. * @param texture The texture we are preparing the UVs for
  9154. * @param defines The defines to update
  9155. * @param key The channel key "diffuse", "specular"... used in the shader
  9156. */
  9157. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9158. /**
  9159. * Binds a texture matrix value to its corrsponding uniform
  9160. * @param texture The texture to bind the matrix for
  9161. * @param uniformBuffer The uniform buffer receivin the data
  9162. * @param key The channel key "diffuse", "specular"... used in the shader
  9163. */
  9164. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9165. /**
  9166. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9167. * @param mesh defines the current mesh
  9168. * @param scene defines the current scene
  9169. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9170. * @param pointsCloud defines if point cloud rendering has to be turned on
  9171. * @param fogEnabled defines if fog has to be turned on
  9172. * @param alphaTest defines if alpha testing has to be turned on
  9173. * @param defines defines the current list of defines
  9174. */
  9175. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9176. /**
  9177. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9178. * @param scene defines the current scene
  9179. * @param engine defines the current engine
  9180. * @param defines specifies the list of active defines
  9181. * @param useInstances defines if instances have to be turned on
  9182. * @param useClipPlane defines if clip plane have to be turned on
  9183. */
  9184. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9185. /**
  9186. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9187. * @param mesh The mesh containing the geometry data we will draw
  9188. * @param defines The defines to update
  9189. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9190. * @param useBones Precise whether bones should be used or not (override mesh info)
  9191. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9192. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9193. * @returns false if defines are considered not dirty and have not been checked
  9194. */
  9195. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9196. /**
  9197. * Prepares the defines related to the light information passed in parameter
  9198. * @param scene The scene we are intending to draw
  9199. * @param mesh The mesh the effect is compiling for
  9200. * @param defines The defines to update
  9201. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9202. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9203. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9204. * @returns true if normals will be required for the rest of the effect
  9205. */
  9206. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9207. /**
  9208. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  9209. * that won t be acctive due to defines being turned off.
  9210. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9211. * @param samplersList The samplers list
  9212. * @param defines The defines helping in the list generation
  9213. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9214. */
  9215. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9216. /**
  9217. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9218. * @param defines The defines to update while falling back
  9219. * @param fallbacks The authorized effect fallbacks
  9220. * @param maxSimultaneousLights The maximum number of lights allowed
  9221. * @param rank the current rank of the Effect
  9222. * @returns The newly affected rank
  9223. */
  9224. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9225. /**
  9226. * Prepares the list of attributes required for morph targets according to the effect defines.
  9227. * @param attribs The current list of supported attribs
  9228. * @param mesh The mesh to prepare the morph targets attributes for
  9229. * @param defines The current Defines of the effect
  9230. */
  9231. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9232. /**
  9233. * Prepares the list of attributes required for bones according to the effect defines.
  9234. * @param attribs The current list of supported attribs
  9235. * @param mesh The mesh to prepare the bones attributes for
  9236. * @param defines The current Defines of the effect
  9237. * @param fallbacks The current efffect fallback strategy
  9238. */
  9239. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9240. /**
  9241. * Prepares the list of attributes required for instances according to the effect defines.
  9242. * @param attribs The current list of supported attribs
  9243. * @param defines The current Defines of the effect
  9244. */
  9245. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  9246. /**
  9247. * Binds the light shadow information to the effect for the given mesh.
  9248. * @param light The light containing the generator
  9249. * @param scene The scene the lights belongs to
  9250. * @param mesh The mesh we are binding the information to render
  9251. * @param lightIndex The light index in the effect used to render the mesh
  9252. * @param effect The effect we are binding the data to
  9253. */
  9254. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9255. /**
  9256. * Binds the light information to the effect.
  9257. * @param light The light containing the generator
  9258. * @param effect The effect we are binding the data to
  9259. * @param lightIndex The light index in the effect used to render
  9260. */
  9261. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9262. /**
  9263. * Binds the lights information from the scene to the effect for the given mesh.
  9264. * @param scene The scene the lights belongs to
  9265. * @param mesh The mesh we are binding the information to render
  9266. * @param effect The effect we are binding the data to
  9267. * @param defines The generated defines for the effect
  9268. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9269. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9270. */
  9271. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9272. private static _tempFogColor;
  9273. /**
  9274. * Binds the fog information from the scene to the effect for the given mesh.
  9275. * @param scene The scene the lights belongs to
  9276. * @param mesh The mesh we are binding the information to render
  9277. * @param effect The effect we are binding the data to
  9278. * @param linearSpace Defines if the fog effect is applied in linear space
  9279. */
  9280. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9281. /**
  9282. * Binds the bones information from the mesh to the effect.
  9283. * @param mesh The mesh we are binding the information to render
  9284. * @param effect The effect we are binding the data to
  9285. */
  9286. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9287. /**
  9288. * Binds the morph targets information from the mesh to the effect.
  9289. * @param abstractMesh The mesh we are binding the information to render
  9290. * @param effect The effect we are binding the data to
  9291. */
  9292. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9293. /**
  9294. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9295. * @param defines The generated defines used in the effect
  9296. * @param effect The effect we are binding the data to
  9297. * @param scene The scene we are willing to render with logarithmic scale for
  9298. */
  9299. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9300. /**
  9301. * Binds the clip plane information from the scene to the effect.
  9302. * @param scene The scene the clip plane information are extracted from
  9303. * @param effect The effect we are binding the data to
  9304. */
  9305. static BindClipPlane(effect: Effect, scene: Scene): void;
  9306. }
  9307. }
  9308. declare module BABYLON {
  9309. /** @hidden */
  9310. export var kernelBlurVaryingDeclaration: {
  9311. name: string;
  9312. shader: string;
  9313. };
  9314. }
  9315. declare module BABYLON {
  9316. /** @hidden */
  9317. export var kernelBlurFragment: {
  9318. name: string;
  9319. shader: string;
  9320. };
  9321. }
  9322. declare module BABYLON {
  9323. /** @hidden */
  9324. export var kernelBlurFragment2: {
  9325. name: string;
  9326. shader: string;
  9327. };
  9328. }
  9329. declare module BABYLON {
  9330. /** @hidden */
  9331. export var kernelBlurPixelShader: {
  9332. name: string;
  9333. shader: string;
  9334. };
  9335. }
  9336. declare module BABYLON {
  9337. /** @hidden */
  9338. export var kernelBlurVertex: {
  9339. name: string;
  9340. shader: string;
  9341. };
  9342. }
  9343. declare module BABYLON {
  9344. /** @hidden */
  9345. export var kernelBlurVertexShader: {
  9346. name: string;
  9347. shader: string;
  9348. };
  9349. }
  9350. declare module BABYLON {
  9351. /**
  9352. * The Blur Post Process which blurs an image based on a kernel and direction.
  9353. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  9354. */
  9355. export class BlurPostProcess extends PostProcess {
  9356. /** The direction in which to blur the image. */
  9357. direction: Vector2;
  9358. private blockCompilation;
  9359. protected _kernel: number;
  9360. protected _idealKernel: number;
  9361. protected _packedFloat: boolean;
  9362. private _staticDefines;
  9363. /**
  9364. * Sets the length in pixels of the blur sample region
  9365. */
  9366. /**
  9367. * Gets the length in pixels of the blur sample region
  9368. */
  9369. kernel: number;
  9370. /**
  9371. * Sets wether or not the blur needs to unpack/repack floats
  9372. */
  9373. /**
  9374. * Gets wether or not the blur is unpacking/repacking floats
  9375. */
  9376. packedFloat: boolean;
  9377. /**
  9378. * Creates a new instance BlurPostProcess
  9379. * @param name The name of the effect.
  9380. * @param direction The direction in which to blur the image.
  9381. * @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.
  9382. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  9383. * @param camera The camera to apply the render pass to.
  9384. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  9385. * @param engine The engine which the post process will be applied. (default: current engine)
  9386. * @param reusable If the post process can be reused on the same frame. (default: false)
  9387. * @param textureType Type of textures used when performing the post process. (default: 0)
  9388. * @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)
  9389. */
  9390. constructor(name: string,
  9391. /** The direction in which to blur the image. */
  9392. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  9393. /**
  9394. * Updates the effect with the current post process compile time values and recompiles the shader.
  9395. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  9396. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  9397. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  9398. * @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
  9399. * @param onCompiled Called when the shader has been compiled.
  9400. * @param onError Called if there is an error when compiling a shader.
  9401. */
  9402. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9403. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9404. /**
  9405. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  9406. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  9407. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  9408. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  9409. * The gaps between physical kernels are compensated for in the weighting of the samples
  9410. * @param idealKernel Ideal blur kernel.
  9411. * @return Nearest best kernel.
  9412. */
  9413. protected _nearestBestKernel(idealKernel: number): number;
  9414. /**
  9415. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  9416. * @param x The point on the Gaussian distribution to sample.
  9417. * @return the value of the Gaussian function at x.
  9418. */
  9419. protected _gaussianWeight(x: number): number;
  9420. /**
  9421. * Generates a string that can be used as a floating point number in GLSL.
  9422. * @param x Value to print.
  9423. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  9424. * @return GLSL float string.
  9425. */
  9426. protected _glslFloat(x: number, decimalFigures?: number): string;
  9427. }
  9428. }
  9429. declare module BABYLON {
  9430. /** @hidden */
  9431. export var shadowMapPixelShader: {
  9432. name: string;
  9433. shader: string;
  9434. };
  9435. }
  9436. declare module BABYLON {
  9437. /** @hidden */
  9438. export var bonesDeclaration: {
  9439. name: string;
  9440. shader: string;
  9441. };
  9442. }
  9443. declare module BABYLON {
  9444. /** @hidden */
  9445. export var morphTargetsVertexGlobalDeclaration: {
  9446. name: string;
  9447. shader: string;
  9448. };
  9449. }
  9450. declare module BABYLON {
  9451. /** @hidden */
  9452. export var morphTargetsVertexDeclaration: {
  9453. name: string;
  9454. shader: string;
  9455. };
  9456. }
  9457. declare module BABYLON {
  9458. /** @hidden */
  9459. export var instancesDeclaration: {
  9460. name: string;
  9461. shader: string;
  9462. };
  9463. }
  9464. declare module BABYLON {
  9465. /** @hidden */
  9466. export var helperFunctions: {
  9467. name: string;
  9468. shader: string;
  9469. };
  9470. }
  9471. declare module BABYLON {
  9472. /** @hidden */
  9473. export var morphTargetsVertex: {
  9474. name: string;
  9475. shader: string;
  9476. };
  9477. }
  9478. declare module BABYLON {
  9479. /** @hidden */
  9480. export var instancesVertex: {
  9481. name: string;
  9482. shader: string;
  9483. };
  9484. }
  9485. declare module BABYLON {
  9486. /** @hidden */
  9487. export var bonesVertex: {
  9488. name: string;
  9489. shader: string;
  9490. };
  9491. }
  9492. declare module BABYLON {
  9493. /** @hidden */
  9494. export var shadowMapVertexShader: {
  9495. name: string;
  9496. shader: string;
  9497. };
  9498. }
  9499. declare module BABYLON {
  9500. /** @hidden */
  9501. export var depthBoxBlurPixelShader: {
  9502. name: string;
  9503. shader: string;
  9504. };
  9505. }
  9506. declare module BABYLON {
  9507. /**
  9508. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9509. */
  9510. export interface ICustomShaderOptions {
  9511. /**
  9512. * Gets or sets the custom shader name to use
  9513. */
  9514. shaderName: string;
  9515. /**
  9516. * The list of attribute names used in the shader
  9517. */
  9518. attributes?: string[];
  9519. /**
  9520. * The list of unifrom names used in the shader
  9521. */
  9522. uniforms?: string[];
  9523. /**
  9524. * The list of sampler names used in the shader
  9525. */
  9526. samplers?: string[];
  9527. /**
  9528. * The list of defines used in the shader
  9529. */
  9530. defines?: string[];
  9531. }
  9532. /**
  9533. * Interface to implement to create a shadow generator compatible with BJS.
  9534. */
  9535. export interface IShadowGenerator {
  9536. /**
  9537. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9538. * @returns The render target texture if present otherwise, null
  9539. */
  9540. getShadowMap(): Nullable<RenderTargetTexture>;
  9541. /**
  9542. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9543. * @returns The render target texture if the shadow map is present otherwise, null
  9544. */
  9545. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9546. /**
  9547. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9548. * @param subMesh The submesh we want to render in the shadow map
  9549. * @param useInstances Defines wether will draw in the map using instances
  9550. * @returns true if ready otherwise, false
  9551. */
  9552. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9553. /**
  9554. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9555. * @param defines Defines of the material we want to update
  9556. * @param lightIndex Index of the light in the enabled light list of the material
  9557. */
  9558. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9559. /**
  9560. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9561. * defined in the generator but impacting the effect).
  9562. * It implies the unifroms available on the materials are the standard BJS ones.
  9563. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9564. * @param effect The effect we are binfing the information for
  9565. */
  9566. bindShadowLight(lightIndex: string, effect: Effect): void;
  9567. /**
  9568. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9569. * (eq to shadow prjection matrix * light transform matrix)
  9570. * @returns The transform matrix used to create the shadow map
  9571. */
  9572. getTransformMatrix(): Matrix;
  9573. /**
  9574. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9575. * Cube and 2D textures for instance.
  9576. */
  9577. recreateShadowMap(): void;
  9578. /**
  9579. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9580. * @param onCompiled Callback triggered at the and of the effects compilation
  9581. * @param options Sets of optional options forcing the compilation with different modes
  9582. */
  9583. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9584. useInstances: boolean;
  9585. }>): void;
  9586. /**
  9587. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9588. * @param options Sets of optional options forcing the compilation with different modes
  9589. * @returns A promise that resolves when the compilation completes
  9590. */
  9591. forceCompilationAsync(options?: Partial<{
  9592. useInstances: boolean;
  9593. }>): Promise<void>;
  9594. /**
  9595. * Serializes the shadow generator setup to a json object.
  9596. * @returns The serialized JSON object
  9597. */
  9598. serialize(): any;
  9599. /**
  9600. * Disposes the Shadow map and related Textures and effects.
  9601. */
  9602. dispose(): void;
  9603. }
  9604. /**
  9605. * Default implementation IShadowGenerator.
  9606. * This is the main object responsible of generating shadows in the framework.
  9607. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9608. */
  9609. export class ShadowGenerator implements IShadowGenerator {
  9610. /**
  9611. * Shadow generator mode None: no filtering applied.
  9612. */
  9613. static readonly FILTER_NONE: number;
  9614. /**
  9615. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9616. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9617. */
  9618. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9619. /**
  9620. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9621. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9622. */
  9623. static readonly FILTER_POISSONSAMPLING: number;
  9624. /**
  9625. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9626. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9627. */
  9628. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9629. /**
  9630. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9631. * edge artifacts on steep falloff.
  9632. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9633. */
  9634. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9635. /**
  9636. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9637. * edge artifacts on steep falloff.
  9638. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9639. */
  9640. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9641. /**
  9642. * Shadow generator mode PCF: Percentage Closer Filtering
  9643. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9644. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9645. */
  9646. static readonly FILTER_PCF: number;
  9647. /**
  9648. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9649. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9650. * Contact Hardening
  9651. */
  9652. static readonly FILTER_PCSS: number;
  9653. /**
  9654. * Reserved for PCF and PCSS
  9655. * Highest Quality.
  9656. *
  9657. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9658. *
  9659. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9660. */
  9661. static readonly QUALITY_HIGH: number;
  9662. /**
  9663. * Reserved for PCF and PCSS
  9664. * Good tradeoff for quality/perf cross devices
  9665. *
  9666. * Execute PCF on a 3*3 kernel.
  9667. *
  9668. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9669. */
  9670. static readonly QUALITY_MEDIUM: number;
  9671. /**
  9672. * Reserved for PCF and PCSS
  9673. * The lowest quality but the fastest.
  9674. *
  9675. * Execute PCF on a 1*1 kernel.
  9676. *
  9677. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9678. */
  9679. static readonly QUALITY_LOW: number;
  9680. /** Gets or sets the custom shader name to use */
  9681. customShaderOptions: ICustomShaderOptions;
  9682. /**
  9683. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9684. */
  9685. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9686. /**
  9687. * Observable triggered before a mesh is rendered in the shadow map.
  9688. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9689. */
  9690. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9691. private _bias;
  9692. /**
  9693. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9694. */
  9695. /**
  9696. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9697. */
  9698. bias: number;
  9699. private _normalBias;
  9700. /**
  9701. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9702. */
  9703. /**
  9704. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9705. */
  9706. normalBias: number;
  9707. private _blurBoxOffset;
  9708. /**
  9709. * Gets the blur box offset: offset applied during the blur pass.
  9710. * Only useful if useKernelBlur = false
  9711. */
  9712. /**
  9713. * Sets the blur box offset: offset applied during the blur pass.
  9714. * Only useful if useKernelBlur = false
  9715. */
  9716. blurBoxOffset: number;
  9717. private _blurScale;
  9718. /**
  9719. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9720. * 2 means half of the size.
  9721. */
  9722. /**
  9723. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9724. * 2 means half of the size.
  9725. */
  9726. blurScale: number;
  9727. private _blurKernel;
  9728. /**
  9729. * Gets the blur kernel: kernel size of the blur pass.
  9730. * Only useful if useKernelBlur = true
  9731. */
  9732. /**
  9733. * Sets the blur kernel: kernel size of the blur pass.
  9734. * Only useful if useKernelBlur = true
  9735. */
  9736. blurKernel: number;
  9737. private _useKernelBlur;
  9738. /**
  9739. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9740. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9741. */
  9742. /**
  9743. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9744. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9745. */
  9746. useKernelBlur: boolean;
  9747. private _depthScale;
  9748. /**
  9749. * Gets the depth scale used in ESM mode.
  9750. */
  9751. /**
  9752. * Sets the depth scale used in ESM mode.
  9753. * This can override the scale stored on the light.
  9754. */
  9755. depthScale: number;
  9756. private _filter;
  9757. /**
  9758. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9759. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9760. */
  9761. /**
  9762. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9763. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9764. */
  9765. filter: number;
  9766. /**
  9767. * Gets if the current filter is set to Poisson Sampling.
  9768. */
  9769. /**
  9770. * Sets the current filter to Poisson Sampling.
  9771. */
  9772. usePoissonSampling: boolean;
  9773. /**
  9774. * Gets if the current filter is set to ESM.
  9775. */
  9776. /**
  9777. * Sets the current filter is to ESM.
  9778. */
  9779. useExponentialShadowMap: boolean;
  9780. /**
  9781. * Gets if the current filter is set to filtered ESM.
  9782. */
  9783. /**
  9784. * Gets if the current filter is set to filtered ESM.
  9785. */
  9786. useBlurExponentialShadowMap: boolean;
  9787. /**
  9788. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9789. * exponential to prevent steep falloff artifacts).
  9790. */
  9791. /**
  9792. * Sets the current filter to "close ESM" (using the inverse of the
  9793. * exponential to prevent steep falloff artifacts).
  9794. */
  9795. useCloseExponentialShadowMap: boolean;
  9796. /**
  9797. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9798. * exponential to prevent steep falloff artifacts).
  9799. */
  9800. /**
  9801. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9802. * exponential to prevent steep falloff artifacts).
  9803. */
  9804. useBlurCloseExponentialShadowMap: boolean;
  9805. /**
  9806. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9807. */
  9808. /**
  9809. * Sets the current filter to "PCF" (percentage closer filtering).
  9810. */
  9811. usePercentageCloserFiltering: boolean;
  9812. private _filteringQuality;
  9813. /**
  9814. * Gets the PCF or PCSS Quality.
  9815. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9816. */
  9817. /**
  9818. * Sets the PCF or PCSS Quality.
  9819. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9820. */
  9821. filteringQuality: number;
  9822. /**
  9823. * Gets if the current filter is set to "PCSS" (contact hardening).
  9824. */
  9825. /**
  9826. * Sets the current filter to "PCSS" (contact hardening).
  9827. */
  9828. useContactHardeningShadow: boolean;
  9829. private _contactHardeningLightSizeUVRatio;
  9830. /**
  9831. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9832. * Using a ratio helps keeping shape stability independently of the map size.
  9833. *
  9834. * It does not account for the light projection as it was having too much
  9835. * instability during the light setup or during light position changes.
  9836. *
  9837. * Only valid if useContactHardeningShadow is true.
  9838. */
  9839. /**
  9840. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9841. * Using a ratio helps keeping shape stability independently of the map size.
  9842. *
  9843. * It does not account for the light projection as it was having too much
  9844. * instability during the light setup or during light position changes.
  9845. *
  9846. * Only valid if useContactHardeningShadow is true.
  9847. */
  9848. contactHardeningLightSizeUVRatio: number;
  9849. private _darkness;
  9850. /**
  9851. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9852. * 0 means strongest and 1 would means no shadow.
  9853. * @returns the darkness.
  9854. */
  9855. getDarkness(): number;
  9856. /**
  9857. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9858. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9859. * @returns the shadow generator allowing fluent coding.
  9860. */
  9861. setDarkness(darkness: number): ShadowGenerator;
  9862. private _transparencyShadow;
  9863. /**
  9864. * Sets the ability to have transparent shadow (boolean).
  9865. * @param transparent True if transparent else False
  9866. * @returns the shadow generator allowing fluent coding
  9867. */
  9868. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9869. private _shadowMap;
  9870. private _shadowMap2;
  9871. /**
  9872. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9873. * @returns The render target texture if present otherwise, null
  9874. */
  9875. getShadowMap(): Nullable<RenderTargetTexture>;
  9876. /**
  9877. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9878. * @returns The render target texture if the shadow map is present otherwise, null
  9879. */
  9880. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9881. /**
  9882. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9883. * @param mesh Mesh to add
  9884. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9885. * @returns the Shadow Generator itself
  9886. */
  9887. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9888. /**
  9889. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9890. * @param mesh Mesh to remove
  9891. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9892. * @returns the Shadow Generator itself
  9893. */
  9894. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9895. /**
  9896. * Controls the extent to which the shadows fade out at the edge of the frustum
  9897. * Used only by directionals and spots
  9898. */
  9899. frustumEdgeFalloff: number;
  9900. private _light;
  9901. /**
  9902. * Returns the associated light object.
  9903. * @returns the light generating the shadow
  9904. */
  9905. getLight(): IShadowLight;
  9906. /**
  9907. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9908. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9909. * It might on the other hand introduce peter panning.
  9910. */
  9911. forceBackFacesOnly: boolean;
  9912. private _scene;
  9913. private _lightDirection;
  9914. private _effect;
  9915. private _viewMatrix;
  9916. private _projectionMatrix;
  9917. private _transformMatrix;
  9918. private _cachedPosition;
  9919. private _cachedDirection;
  9920. private _cachedDefines;
  9921. private _currentRenderID;
  9922. private _boxBlurPostprocess;
  9923. private _kernelBlurXPostprocess;
  9924. private _kernelBlurYPostprocess;
  9925. private _blurPostProcesses;
  9926. private _mapSize;
  9927. private _currentFaceIndex;
  9928. private _currentFaceIndexCache;
  9929. private _textureType;
  9930. private _defaultTextureMatrix;
  9931. /** @hidden */
  9932. static _SceneComponentInitialization: (scene: Scene) => void;
  9933. /**
  9934. * Creates a ShadowGenerator object.
  9935. * A ShadowGenerator is the required tool to use the shadows.
  9936. * Each light casting shadows needs to use its own ShadowGenerator.
  9937. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9938. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9939. * @param light The light object generating the shadows.
  9940. * @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.
  9941. */
  9942. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9943. private _initializeGenerator;
  9944. private _initializeShadowMap;
  9945. private _initializeBlurRTTAndPostProcesses;
  9946. private _renderForShadowMap;
  9947. private _renderSubMeshForShadowMap;
  9948. private _applyFilterValues;
  9949. /**
  9950. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9951. * @param onCompiled Callback triggered at the and of the effects compilation
  9952. * @param options Sets of optional options forcing the compilation with different modes
  9953. */
  9954. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9955. useInstances: boolean;
  9956. }>): void;
  9957. /**
  9958. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9959. * @param options Sets of optional options forcing the compilation with different modes
  9960. * @returns A promise that resolves when the compilation completes
  9961. */
  9962. forceCompilationAsync(options?: Partial<{
  9963. useInstances: boolean;
  9964. }>): Promise<void>;
  9965. /**
  9966. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9967. * @param subMesh The submesh we want to render in the shadow map
  9968. * @param useInstances Defines wether will draw in the map using instances
  9969. * @returns true if ready otherwise, false
  9970. */
  9971. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9972. /**
  9973. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9974. * @param defines Defines of the material we want to update
  9975. * @param lightIndex Index of the light in the enabled light list of the material
  9976. */
  9977. prepareDefines(defines: any, lightIndex: number): void;
  9978. /**
  9979. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9980. * defined in the generator but impacting the effect).
  9981. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9982. * @param effect The effect we are binfing the information for
  9983. */
  9984. bindShadowLight(lightIndex: string, effect: Effect): void;
  9985. /**
  9986. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9987. * (eq to shadow prjection matrix * light transform matrix)
  9988. * @returns The transform matrix used to create the shadow map
  9989. */
  9990. getTransformMatrix(): Matrix;
  9991. /**
  9992. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9993. * Cube and 2D textures for instance.
  9994. */
  9995. recreateShadowMap(): void;
  9996. private _disposeBlurPostProcesses;
  9997. private _disposeRTTandPostProcesses;
  9998. /**
  9999. * Disposes the ShadowGenerator.
  10000. * Returns nothing.
  10001. */
  10002. dispose(): void;
  10003. /**
  10004. * Serializes the shadow generator setup to a json object.
  10005. * @returns The serialized JSON object
  10006. */
  10007. serialize(): any;
  10008. /**
  10009. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  10010. * @param parsedShadowGenerator The JSON object to parse
  10011. * @param scene The scene to create the shadow map for
  10012. * @returns The parsed shadow generator
  10013. */
  10014. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  10015. }
  10016. }
  10017. declare module BABYLON {
  10018. /**
  10019. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10020. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10021. * 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.
  10022. */
  10023. export abstract class Light extends Node {
  10024. /**
  10025. * Falloff Default: light is falling off following the material specification:
  10026. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  10027. */
  10028. static readonly FALLOFF_DEFAULT: number;
  10029. /**
  10030. * Falloff Physical: light is falling off following the inverse squared distance law.
  10031. */
  10032. static readonly FALLOFF_PHYSICAL: number;
  10033. /**
  10034. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10035. * to enhance interoperability with other engines.
  10036. */
  10037. static readonly FALLOFF_GLTF: number;
  10038. /**
  10039. * Falloff Standard: light is falling off like in the standard material
  10040. * to enhance interoperability with other materials.
  10041. */
  10042. static readonly FALLOFF_STANDARD: number;
  10043. /**
  10044. * If every light affecting the material is in this lightmapMode,
  10045. * material.lightmapTexture adds or multiplies
  10046. * (depends on material.useLightmapAsShadowmap)
  10047. * after every other light calculations.
  10048. */
  10049. static readonly LIGHTMAP_DEFAULT: number;
  10050. /**
  10051. * material.lightmapTexture as only diffuse lighting from this light
  10052. * adds only specular lighting from this light
  10053. * adds dynamic shadows
  10054. */
  10055. static readonly LIGHTMAP_SPECULAR: number;
  10056. /**
  10057. * material.lightmapTexture as only lighting
  10058. * no light calculation from this light
  10059. * only adds dynamic shadows from this light
  10060. */
  10061. static readonly LIGHTMAP_SHADOWSONLY: number;
  10062. /**
  10063. * Each light type uses the default quantity according to its type:
  10064. * point/spot lights use luminous intensity
  10065. * directional lights use illuminance
  10066. */
  10067. static readonly INTENSITYMODE_AUTOMATIC: number;
  10068. /**
  10069. * lumen (lm)
  10070. */
  10071. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10072. /**
  10073. * candela (lm/sr)
  10074. */
  10075. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10076. /**
  10077. * lux (lm/m^2)
  10078. */
  10079. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10080. /**
  10081. * nit (cd/m^2)
  10082. */
  10083. static readonly INTENSITYMODE_LUMINANCE: number;
  10084. /**
  10085. * Light type const id of the point light.
  10086. */
  10087. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10088. /**
  10089. * Light type const id of the directional light.
  10090. */
  10091. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10092. /**
  10093. * Light type const id of the spot light.
  10094. */
  10095. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10096. /**
  10097. * Light type const id of the hemispheric light.
  10098. */
  10099. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10100. /**
  10101. * Diffuse gives the basic color to an object.
  10102. */
  10103. diffuse: Color3;
  10104. /**
  10105. * Specular produces a highlight color on an object.
  10106. * Note: This is note affecting PBR materials.
  10107. */
  10108. specular: Color3;
  10109. /**
  10110. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10111. * falling off base on range or angle.
  10112. * This can be set to any values in Light.FALLOFF_x.
  10113. *
  10114. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10115. * other types of materials.
  10116. */
  10117. falloffType: number;
  10118. /**
  10119. * Strength of the light.
  10120. * Note: By default it is define in the framework own unit.
  10121. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10122. */
  10123. intensity: number;
  10124. private _range;
  10125. protected _inverseSquaredRange: number;
  10126. /**
  10127. * Defines how far from the source the light is impacting in scene units.
  10128. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10129. */
  10130. /**
  10131. * Defines how far from the source the light is impacting in scene units.
  10132. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10133. */
  10134. range: number;
  10135. /**
  10136. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10137. * of light.
  10138. */
  10139. private _photometricScale;
  10140. private _intensityMode;
  10141. /**
  10142. * Gets the photometric scale used to interpret the intensity.
  10143. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10144. */
  10145. /**
  10146. * Sets the photometric scale used to interpret the intensity.
  10147. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10148. */
  10149. intensityMode: number;
  10150. private _radius;
  10151. /**
  10152. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10153. */
  10154. /**
  10155. * sets the light radius used by PBR Materials to simulate soft area lights.
  10156. */
  10157. radius: number;
  10158. private _renderPriority;
  10159. /**
  10160. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10161. * exceeding the number allowed of the materials.
  10162. */
  10163. renderPriority: number;
  10164. private _shadowEnabled;
  10165. /**
  10166. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10167. * the current shadow generator.
  10168. */
  10169. /**
  10170. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10171. * the current shadow generator.
  10172. */
  10173. shadowEnabled: boolean;
  10174. private _includedOnlyMeshes;
  10175. /**
  10176. * Gets the only meshes impacted by this light.
  10177. */
  10178. /**
  10179. * Sets the only meshes impacted by this light.
  10180. */
  10181. includedOnlyMeshes: AbstractMesh[];
  10182. private _excludedMeshes;
  10183. /**
  10184. * Gets the meshes not impacted by this light.
  10185. */
  10186. /**
  10187. * Sets the meshes not impacted by this light.
  10188. */
  10189. excludedMeshes: AbstractMesh[];
  10190. private _excludeWithLayerMask;
  10191. /**
  10192. * Gets the layer id use to find what meshes are not impacted by the light.
  10193. * Inactive if 0
  10194. */
  10195. /**
  10196. * Sets the layer id use to find what meshes are not impacted by the light.
  10197. * Inactive if 0
  10198. */
  10199. excludeWithLayerMask: number;
  10200. private _includeOnlyWithLayerMask;
  10201. /**
  10202. * Gets the layer id use to find what meshes are impacted by the light.
  10203. * Inactive if 0
  10204. */
  10205. /**
  10206. * Sets the layer id use to find what meshes are impacted by the light.
  10207. * Inactive if 0
  10208. */
  10209. includeOnlyWithLayerMask: number;
  10210. private _lightmapMode;
  10211. /**
  10212. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10213. */
  10214. /**
  10215. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10216. */
  10217. lightmapMode: number;
  10218. /**
  10219. * Shadow generator associted to the light.
  10220. * @hidden Internal use only.
  10221. */
  10222. _shadowGenerator: Nullable<IShadowGenerator>;
  10223. /**
  10224. * @hidden Internal use only.
  10225. */
  10226. _excludedMeshesIds: string[];
  10227. /**
  10228. * @hidden Internal use only.
  10229. */
  10230. _includedOnlyMeshesIds: string[];
  10231. /**
  10232. * The current light unifom buffer.
  10233. * @hidden Internal use only.
  10234. */
  10235. _uniformBuffer: UniformBuffer;
  10236. /**
  10237. * Creates a Light object in the scene.
  10238. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10239. * @param name The firendly name of the light
  10240. * @param scene The scene the light belongs too
  10241. */
  10242. constructor(name: string, scene: Scene);
  10243. protected abstract _buildUniformLayout(): void;
  10244. /**
  10245. * Sets the passed Effect "effect" with the Light information.
  10246. * @param effect The effect to update
  10247. * @param lightIndex The index of the light in the effect to update
  10248. * @returns The light
  10249. */
  10250. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10251. /**
  10252. * Returns the string "Light".
  10253. * @returns the class name
  10254. */
  10255. getClassName(): string;
  10256. /** @hidden */
  10257. readonly _isLight: boolean;
  10258. /**
  10259. * Converts the light information to a readable string for debug purpose.
  10260. * @param fullDetails Supports for multiple levels of logging within scene loading
  10261. * @returns the human readable light info
  10262. */
  10263. toString(fullDetails?: boolean): string;
  10264. /** @hidden */
  10265. protected _syncParentEnabledState(): void;
  10266. /**
  10267. * Set the enabled state of this node.
  10268. * @param value - the new enabled state
  10269. */
  10270. setEnabled(value: boolean): void;
  10271. /**
  10272. * Returns the Light associated shadow generator if any.
  10273. * @return the associated shadow generator.
  10274. */
  10275. getShadowGenerator(): Nullable<IShadowGenerator>;
  10276. /**
  10277. * Returns a Vector3, the absolute light position in the World.
  10278. * @returns the world space position of the light
  10279. */
  10280. getAbsolutePosition(): Vector3;
  10281. /**
  10282. * Specifies if the light will affect the passed mesh.
  10283. * @param mesh The mesh to test against the light
  10284. * @return true the mesh is affected otherwise, false.
  10285. */
  10286. canAffectMesh(mesh: AbstractMesh): boolean;
  10287. /**
  10288. * Sort function to order lights for rendering.
  10289. * @param a First Light object to compare to second.
  10290. * @param b Second Light object to compare first.
  10291. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10292. */
  10293. static CompareLightsPriority(a: Light, b: Light): number;
  10294. /**
  10295. * Releases resources associated with this node.
  10296. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10297. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10298. */
  10299. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10300. /**
  10301. * Returns the light type ID (integer).
  10302. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10303. */
  10304. getTypeID(): number;
  10305. /**
  10306. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10307. * @returns the scaled intensity in intensity mode unit
  10308. */
  10309. getScaledIntensity(): number;
  10310. /**
  10311. * Returns a new Light object, named "name", from the current one.
  10312. * @param name The name of the cloned light
  10313. * @returns the new created light
  10314. */
  10315. clone(name: string): Nullable<Light>;
  10316. /**
  10317. * Serializes the current light into a Serialization object.
  10318. * @returns the serialized object.
  10319. */
  10320. serialize(): any;
  10321. /**
  10322. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10323. * This new light is named "name" and added to the passed scene.
  10324. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10325. * @param name The friendly name of the light
  10326. * @param scene The scene the new light will belong to
  10327. * @returns the constructor function
  10328. */
  10329. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10330. /**
  10331. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10332. * @param parsedLight The JSON representation of the light
  10333. * @param scene The scene to create the parsed light in
  10334. * @returns the created light after parsing
  10335. */
  10336. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10337. private _hookArrayForExcluded;
  10338. private _hookArrayForIncludedOnly;
  10339. private _resyncMeshes;
  10340. /**
  10341. * Forces the meshes to update their light related information in their rendering used effects
  10342. * @hidden Internal Use Only
  10343. */
  10344. _markMeshesAsLightDirty(): void;
  10345. /**
  10346. * Recomputes the cached photometric scale if needed.
  10347. */
  10348. private _computePhotometricScale;
  10349. /**
  10350. * Returns the Photometric Scale according to the light type and intensity mode.
  10351. */
  10352. private _getPhotometricScale;
  10353. /**
  10354. * Reorder the light in the scene according to their defined priority.
  10355. * @hidden Internal Use Only
  10356. */
  10357. _reorderLightsInScene(): void;
  10358. /**
  10359. * Prepares the list of defines specific to the light type.
  10360. * @param defines the list of defines
  10361. * @param lightIndex defines the index of the light for the effect
  10362. */
  10363. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10364. }
  10365. }
  10366. declare module BABYLON {
  10367. /**
  10368. * Interface used to define Action
  10369. */
  10370. export interface IAction {
  10371. /**
  10372. * Trigger for the action
  10373. */
  10374. trigger: number;
  10375. /** Options of the trigger */
  10376. triggerOptions: any;
  10377. /**
  10378. * Gets the trigger parameters
  10379. * @returns the trigger parameters
  10380. */
  10381. getTriggerParameter(): any;
  10382. /**
  10383. * Internal only - executes current action event
  10384. * @hidden
  10385. */
  10386. _executeCurrent(evt?: ActionEvent): void;
  10387. /**
  10388. * Serialize placeholder for child classes
  10389. * @param parent of child
  10390. * @returns the serialized object
  10391. */
  10392. serialize(parent: any): any;
  10393. /**
  10394. * Internal only
  10395. * @hidden
  10396. */
  10397. _prepare(): void;
  10398. /**
  10399. * Internal only - manager for action
  10400. * @hidden
  10401. */
  10402. _actionManager: AbstractActionManager;
  10403. }
  10404. /**
  10405. * The action to be carried out following a trigger
  10406. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10407. */
  10408. export class Action implements IAction {
  10409. /** the trigger, with or without parameters, for the action */
  10410. triggerOptions: any;
  10411. /**
  10412. * Trigger for the action
  10413. */
  10414. trigger: number;
  10415. /**
  10416. * Internal only - manager for action
  10417. * @hidden
  10418. */
  10419. _actionManager: ActionManager;
  10420. private _nextActiveAction;
  10421. private _child;
  10422. private _condition?;
  10423. private _triggerParameter;
  10424. /**
  10425. * An event triggered prior to action being executed.
  10426. */
  10427. onBeforeExecuteObservable: Observable<Action>;
  10428. /**
  10429. * Creates a new Action
  10430. * @param triggerOptions the trigger, with or without parameters, for the action
  10431. * @param condition an optional determinant of action
  10432. */
  10433. constructor(
  10434. /** the trigger, with or without parameters, for the action */
  10435. triggerOptions: any, condition?: Condition);
  10436. /**
  10437. * Internal only
  10438. * @hidden
  10439. */
  10440. _prepare(): void;
  10441. /**
  10442. * Gets the trigger parameters
  10443. * @returns the trigger parameters
  10444. */
  10445. getTriggerParameter(): any;
  10446. /**
  10447. * Internal only - executes current action event
  10448. * @hidden
  10449. */
  10450. _executeCurrent(evt?: ActionEvent): void;
  10451. /**
  10452. * Execute placeholder for child classes
  10453. * @param evt optional action event
  10454. */
  10455. execute(evt?: ActionEvent): void;
  10456. /**
  10457. * Skips to next active action
  10458. */
  10459. skipToNextActiveAction(): void;
  10460. /**
  10461. * Adds action to chain of actions, may be a DoNothingAction
  10462. * @param action defines the next action to execute
  10463. * @returns The action passed in
  10464. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10465. */
  10466. then(action: Action): Action;
  10467. /**
  10468. * Internal only
  10469. * @hidden
  10470. */
  10471. _getProperty(propertyPath: string): string;
  10472. /**
  10473. * Internal only
  10474. * @hidden
  10475. */
  10476. _getEffectiveTarget(target: any, propertyPath: string): any;
  10477. /**
  10478. * Serialize placeholder for child classes
  10479. * @param parent of child
  10480. * @returns the serialized object
  10481. */
  10482. serialize(parent: any): any;
  10483. /**
  10484. * Internal only called by serialize
  10485. * @hidden
  10486. */
  10487. protected _serialize(serializedAction: any, parent?: any): any;
  10488. /**
  10489. * Internal only
  10490. * @hidden
  10491. */
  10492. static _SerializeValueAsString: (value: any) => string;
  10493. /**
  10494. * Internal only
  10495. * @hidden
  10496. */
  10497. static _GetTargetProperty: (target: Scene | Node) => {
  10498. name: string;
  10499. targetType: string;
  10500. value: string;
  10501. };
  10502. }
  10503. }
  10504. declare module BABYLON {
  10505. /**
  10506. * A Condition applied to an Action
  10507. */
  10508. export class Condition {
  10509. /**
  10510. * Internal only - manager for action
  10511. * @hidden
  10512. */
  10513. _actionManager: ActionManager;
  10514. /**
  10515. * Internal only
  10516. * @hidden
  10517. */
  10518. _evaluationId: number;
  10519. /**
  10520. * Internal only
  10521. * @hidden
  10522. */
  10523. _currentResult: boolean;
  10524. /**
  10525. * Creates a new Condition
  10526. * @param actionManager the manager of the action the condition is applied to
  10527. */
  10528. constructor(actionManager: ActionManager);
  10529. /**
  10530. * Check if the current condition is valid
  10531. * @returns a boolean
  10532. */
  10533. isValid(): boolean;
  10534. /**
  10535. * Internal only
  10536. * @hidden
  10537. */
  10538. _getProperty(propertyPath: string): string;
  10539. /**
  10540. * Internal only
  10541. * @hidden
  10542. */
  10543. _getEffectiveTarget(target: any, propertyPath: string): any;
  10544. /**
  10545. * Serialize placeholder for child classes
  10546. * @returns the serialized object
  10547. */
  10548. serialize(): any;
  10549. /**
  10550. * Internal only
  10551. * @hidden
  10552. */
  10553. protected _serialize(serializedCondition: any): any;
  10554. }
  10555. /**
  10556. * Defines specific conditional operators as extensions of Condition
  10557. */
  10558. export class ValueCondition extends Condition {
  10559. /** path to specify the property of the target the conditional operator uses */
  10560. propertyPath: string;
  10561. /** the value compared by the conditional operator against the current value of the property */
  10562. value: any;
  10563. /** the conditional operator, default ValueCondition.IsEqual */
  10564. operator: number;
  10565. /**
  10566. * Internal only
  10567. * @hidden
  10568. */
  10569. private static _IsEqual;
  10570. /**
  10571. * Internal only
  10572. * @hidden
  10573. */
  10574. private static _IsDifferent;
  10575. /**
  10576. * Internal only
  10577. * @hidden
  10578. */
  10579. private static _IsGreater;
  10580. /**
  10581. * Internal only
  10582. * @hidden
  10583. */
  10584. private static _IsLesser;
  10585. /**
  10586. * returns the number for IsEqual
  10587. */
  10588. static readonly IsEqual: number;
  10589. /**
  10590. * Returns the number for IsDifferent
  10591. */
  10592. static readonly IsDifferent: number;
  10593. /**
  10594. * Returns the number for IsGreater
  10595. */
  10596. static readonly IsGreater: number;
  10597. /**
  10598. * Returns the number for IsLesser
  10599. */
  10600. static readonly IsLesser: number;
  10601. /**
  10602. * Internal only The action manager for the condition
  10603. * @hidden
  10604. */
  10605. _actionManager: ActionManager;
  10606. /**
  10607. * Internal only
  10608. * @hidden
  10609. */
  10610. private _target;
  10611. /**
  10612. * Internal only
  10613. * @hidden
  10614. */
  10615. private _effectiveTarget;
  10616. /**
  10617. * Internal only
  10618. * @hidden
  10619. */
  10620. private _property;
  10621. /**
  10622. * Creates a new ValueCondition
  10623. * @param actionManager manager for the action the condition applies to
  10624. * @param target for the action
  10625. * @param propertyPath path to specify the property of the target the conditional operator uses
  10626. * @param value the value compared by the conditional operator against the current value of the property
  10627. * @param operator the conditional operator, default ValueCondition.IsEqual
  10628. */
  10629. constructor(actionManager: ActionManager, target: any,
  10630. /** path to specify the property of the target the conditional operator uses */
  10631. propertyPath: string,
  10632. /** the value compared by the conditional operator against the current value of the property */
  10633. value: any,
  10634. /** the conditional operator, default ValueCondition.IsEqual */
  10635. operator?: number);
  10636. /**
  10637. * Compares the given value with the property value for the specified conditional operator
  10638. * @returns the result of the comparison
  10639. */
  10640. isValid(): boolean;
  10641. /**
  10642. * Serialize the ValueCondition into a JSON compatible object
  10643. * @returns serialization object
  10644. */
  10645. serialize(): any;
  10646. /**
  10647. * Gets the name of the conditional operator for the ValueCondition
  10648. * @param operator the conditional operator
  10649. * @returns the name
  10650. */
  10651. static GetOperatorName(operator: number): string;
  10652. }
  10653. /**
  10654. * Defines a predicate condition as an extension of Condition
  10655. */
  10656. export class PredicateCondition extends Condition {
  10657. /** defines the predicate function used to validate the condition */
  10658. predicate: () => boolean;
  10659. /**
  10660. * Internal only - manager for action
  10661. * @hidden
  10662. */
  10663. _actionManager: ActionManager;
  10664. /**
  10665. * Creates a new PredicateCondition
  10666. * @param actionManager manager for the action the condition applies to
  10667. * @param predicate defines the predicate function used to validate the condition
  10668. */
  10669. constructor(actionManager: ActionManager,
  10670. /** defines the predicate function used to validate the condition */
  10671. predicate: () => boolean);
  10672. /**
  10673. * @returns the validity of the predicate condition
  10674. */
  10675. isValid(): boolean;
  10676. }
  10677. /**
  10678. * Defines a state condition as an extension of Condition
  10679. */
  10680. export class StateCondition extends Condition {
  10681. /** Value to compare with target state */
  10682. value: string;
  10683. /**
  10684. * Internal only - manager for action
  10685. * @hidden
  10686. */
  10687. _actionManager: ActionManager;
  10688. /**
  10689. * Internal only
  10690. * @hidden
  10691. */
  10692. private _target;
  10693. /**
  10694. * Creates a new StateCondition
  10695. * @param actionManager manager for the action the condition applies to
  10696. * @param target of the condition
  10697. * @param value to compare with target state
  10698. */
  10699. constructor(actionManager: ActionManager, target: any,
  10700. /** Value to compare with target state */
  10701. value: string);
  10702. /**
  10703. * Gets a boolean indicating if the current condition is met
  10704. * @returns the validity of the state
  10705. */
  10706. isValid(): boolean;
  10707. /**
  10708. * Serialize the StateCondition into a JSON compatible object
  10709. * @returns serialization object
  10710. */
  10711. serialize(): any;
  10712. }
  10713. }
  10714. declare module BABYLON {
  10715. /**
  10716. * This defines an action responsible to toggle a boolean once triggered.
  10717. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10718. */
  10719. export class SwitchBooleanAction extends Action {
  10720. /**
  10721. * The path to the boolean property in the target object
  10722. */
  10723. propertyPath: string;
  10724. private _target;
  10725. private _effectiveTarget;
  10726. private _property;
  10727. /**
  10728. * Instantiate the action
  10729. * @param triggerOptions defines the trigger options
  10730. * @param target defines the object containing the boolean
  10731. * @param propertyPath defines the path to the boolean property in the target object
  10732. * @param condition defines the trigger related conditions
  10733. */
  10734. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10735. /** @hidden */
  10736. _prepare(): void;
  10737. /**
  10738. * Execute the action toggle the boolean value.
  10739. */
  10740. execute(): void;
  10741. /**
  10742. * Serializes the actions and its related information.
  10743. * @param parent defines the object to serialize in
  10744. * @returns the serialized object
  10745. */
  10746. serialize(parent: any): any;
  10747. }
  10748. /**
  10749. * This defines an action responsible to set a the state field of the target
  10750. * to a desired value once triggered.
  10751. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10752. */
  10753. export class SetStateAction extends Action {
  10754. /**
  10755. * The value to store in the state field.
  10756. */
  10757. value: string;
  10758. private _target;
  10759. /**
  10760. * Instantiate the action
  10761. * @param triggerOptions defines the trigger options
  10762. * @param target defines the object containing the state property
  10763. * @param value defines the value to store in the state field
  10764. * @param condition defines the trigger related conditions
  10765. */
  10766. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10767. /**
  10768. * Execute the action and store the value on the target state property.
  10769. */
  10770. execute(): void;
  10771. /**
  10772. * Serializes the actions and its related information.
  10773. * @param parent defines the object to serialize in
  10774. * @returns the serialized object
  10775. */
  10776. serialize(parent: any): any;
  10777. }
  10778. /**
  10779. * This defines an action responsible to set a property of the target
  10780. * to a desired value once triggered.
  10781. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10782. */
  10783. export class SetValueAction extends Action {
  10784. /**
  10785. * The path of the property to set in the target.
  10786. */
  10787. propertyPath: string;
  10788. /**
  10789. * The value to set in the property
  10790. */
  10791. value: any;
  10792. private _target;
  10793. private _effectiveTarget;
  10794. private _property;
  10795. /**
  10796. * Instantiate the action
  10797. * @param triggerOptions defines the trigger options
  10798. * @param target defines the object containing the property
  10799. * @param propertyPath defines the path of the property to set in the target
  10800. * @param value defines the value to set in the property
  10801. * @param condition defines the trigger related conditions
  10802. */
  10803. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10804. /** @hidden */
  10805. _prepare(): void;
  10806. /**
  10807. * Execute the action and set the targetted property to the desired value.
  10808. */
  10809. execute(): void;
  10810. /**
  10811. * Serializes the actions and its related information.
  10812. * @param parent defines the object to serialize in
  10813. * @returns the serialized object
  10814. */
  10815. serialize(parent: any): any;
  10816. }
  10817. /**
  10818. * This defines an action responsible to increment the target value
  10819. * to a desired value once triggered.
  10820. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10821. */
  10822. export class IncrementValueAction extends Action {
  10823. /**
  10824. * The path of the property to increment in the target.
  10825. */
  10826. propertyPath: string;
  10827. /**
  10828. * The value we should increment the property by.
  10829. */
  10830. value: any;
  10831. private _target;
  10832. private _effectiveTarget;
  10833. private _property;
  10834. /**
  10835. * Instantiate the action
  10836. * @param triggerOptions defines the trigger options
  10837. * @param target defines the object containing the property
  10838. * @param propertyPath defines the path of the property to increment in the target
  10839. * @param value defines the value value we should increment the property by
  10840. * @param condition defines the trigger related conditions
  10841. */
  10842. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10843. /** @hidden */
  10844. _prepare(): void;
  10845. /**
  10846. * Execute the action and increment the target of the value amount.
  10847. */
  10848. execute(): void;
  10849. /**
  10850. * Serializes the actions and its related information.
  10851. * @param parent defines the object to serialize in
  10852. * @returns the serialized object
  10853. */
  10854. serialize(parent: any): any;
  10855. }
  10856. /**
  10857. * This defines an action responsible to start an animation once triggered.
  10858. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10859. */
  10860. export class PlayAnimationAction extends Action {
  10861. /**
  10862. * Where the animation should start (animation frame)
  10863. */
  10864. from: number;
  10865. /**
  10866. * Where the animation should stop (animation frame)
  10867. */
  10868. to: number;
  10869. /**
  10870. * Define if the animation should loop or stop after the first play.
  10871. */
  10872. loop?: boolean;
  10873. private _target;
  10874. /**
  10875. * Instantiate the action
  10876. * @param triggerOptions defines the trigger options
  10877. * @param target defines the target animation or animation name
  10878. * @param from defines from where the animation should start (animation frame)
  10879. * @param end defines where the animation should stop (animation frame)
  10880. * @param loop defines if the animation should loop or stop after the first play
  10881. * @param condition defines the trigger related conditions
  10882. */
  10883. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10884. /** @hidden */
  10885. _prepare(): void;
  10886. /**
  10887. * Execute the action and play the animation.
  10888. */
  10889. execute(): void;
  10890. /**
  10891. * Serializes the actions and its related information.
  10892. * @param parent defines the object to serialize in
  10893. * @returns the serialized object
  10894. */
  10895. serialize(parent: any): any;
  10896. }
  10897. /**
  10898. * This defines an action responsible to stop an animation once triggered.
  10899. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10900. */
  10901. export class StopAnimationAction extends Action {
  10902. private _target;
  10903. /**
  10904. * Instantiate the action
  10905. * @param triggerOptions defines the trigger options
  10906. * @param target defines the target animation or animation name
  10907. * @param condition defines the trigger related conditions
  10908. */
  10909. constructor(triggerOptions: any, target: any, condition?: Condition);
  10910. /** @hidden */
  10911. _prepare(): void;
  10912. /**
  10913. * Execute the action and stop the animation.
  10914. */
  10915. execute(): void;
  10916. /**
  10917. * Serializes the actions and its related information.
  10918. * @param parent defines the object to serialize in
  10919. * @returns the serialized object
  10920. */
  10921. serialize(parent: any): any;
  10922. }
  10923. /**
  10924. * This defines an action responsible that does nothing once triggered.
  10925. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10926. */
  10927. export class DoNothingAction extends Action {
  10928. /**
  10929. * Instantiate the action
  10930. * @param triggerOptions defines the trigger options
  10931. * @param condition defines the trigger related conditions
  10932. */
  10933. constructor(triggerOptions?: any, condition?: Condition);
  10934. /**
  10935. * Execute the action and do nothing.
  10936. */
  10937. execute(): void;
  10938. /**
  10939. * Serializes the actions and its related information.
  10940. * @param parent defines the object to serialize in
  10941. * @returns the serialized object
  10942. */
  10943. serialize(parent: any): any;
  10944. }
  10945. /**
  10946. * This defines an action responsible to trigger several actions once triggered.
  10947. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10948. */
  10949. export class CombineAction extends Action {
  10950. /**
  10951. * The list of aggregated animations to run.
  10952. */
  10953. children: Action[];
  10954. /**
  10955. * Instantiate the action
  10956. * @param triggerOptions defines the trigger options
  10957. * @param children defines the list of aggregated animations to run
  10958. * @param condition defines the trigger related conditions
  10959. */
  10960. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10961. /** @hidden */
  10962. _prepare(): void;
  10963. /**
  10964. * Execute the action and executes all the aggregated actions.
  10965. */
  10966. execute(evt: ActionEvent): void;
  10967. /**
  10968. * Serializes the actions and its related information.
  10969. * @param parent defines the object to serialize in
  10970. * @returns the serialized object
  10971. */
  10972. serialize(parent: any): any;
  10973. }
  10974. /**
  10975. * This defines an action responsible to run code (external event) once triggered.
  10976. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10977. */
  10978. export class ExecuteCodeAction extends Action {
  10979. /**
  10980. * The callback function to run.
  10981. */
  10982. func: (evt: ActionEvent) => void;
  10983. /**
  10984. * Instantiate the action
  10985. * @param triggerOptions defines the trigger options
  10986. * @param func defines the callback function to run
  10987. * @param condition defines the trigger related conditions
  10988. */
  10989. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10990. /**
  10991. * Execute the action and run the attached code.
  10992. */
  10993. execute(evt: ActionEvent): void;
  10994. }
  10995. /**
  10996. * This defines an action responsible to set the parent property of the target once triggered.
  10997. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10998. */
  10999. export class SetParentAction extends Action {
  11000. private _parent;
  11001. private _target;
  11002. /**
  11003. * Instantiate the action
  11004. * @param triggerOptions defines the trigger options
  11005. * @param target defines the target containing the parent property
  11006. * @param parent defines from where the animation should start (animation frame)
  11007. * @param condition defines the trigger related conditions
  11008. */
  11009. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11010. /** @hidden */
  11011. _prepare(): void;
  11012. /**
  11013. * Execute the action and set the parent property.
  11014. */
  11015. execute(): void;
  11016. /**
  11017. * Serializes the actions and its related information.
  11018. * @param parent defines the object to serialize in
  11019. * @returns the serialized object
  11020. */
  11021. serialize(parent: any): any;
  11022. }
  11023. }
  11024. declare module BABYLON {
  11025. /**
  11026. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11027. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11028. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11029. */
  11030. export class ActionManager extends AbstractActionManager {
  11031. /**
  11032. * Nothing
  11033. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11034. */
  11035. static readonly NothingTrigger: number;
  11036. /**
  11037. * On pick
  11038. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11039. */
  11040. static readonly OnPickTrigger: number;
  11041. /**
  11042. * On left pick
  11043. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11044. */
  11045. static readonly OnLeftPickTrigger: number;
  11046. /**
  11047. * On right pick
  11048. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11049. */
  11050. static readonly OnRightPickTrigger: number;
  11051. /**
  11052. * On center pick
  11053. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11054. */
  11055. static readonly OnCenterPickTrigger: number;
  11056. /**
  11057. * On pick down
  11058. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11059. */
  11060. static readonly OnPickDownTrigger: number;
  11061. /**
  11062. * On double pick
  11063. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11064. */
  11065. static readonly OnDoublePickTrigger: number;
  11066. /**
  11067. * On pick up
  11068. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11069. */
  11070. static readonly OnPickUpTrigger: number;
  11071. /**
  11072. * On pick out.
  11073. * This trigger will only be raised if you also declared a OnPickDown
  11074. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11075. */
  11076. static readonly OnPickOutTrigger: number;
  11077. /**
  11078. * On long press
  11079. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11080. */
  11081. static readonly OnLongPressTrigger: number;
  11082. /**
  11083. * On pointer over
  11084. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11085. */
  11086. static readonly OnPointerOverTrigger: number;
  11087. /**
  11088. * On pointer out
  11089. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11090. */
  11091. static readonly OnPointerOutTrigger: number;
  11092. /**
  11093. * On every frame
  11094. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11095. */
  11096. static readonly OnEveryFrameTrigger: number;
  11097. /**
  11098. * On intersection enter
  11099. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11100. */
  11101. static readonly OnIntersectionEnterTrigger: number;
  11102. /**
  11103. * On intersection exit
  11104. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11105. */
  11106. static readonly OnIntersectionExitTrigger: number;
  11107. /**
  11108. * On key down
  11109. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11110. */
  11111. static readonly OnKeyDownTrigger: number;
  11112. /**
  11113. * On key up
  11114. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11115. */
  11116. static readonly OnKeyUpTrigger: number;
  11117. private _scene;
  11118. /**
  11119. * Creates a new action manager
  11120. * @param scene defines the hosting scene
  11121. */
  11122. constructor(scene: Scene);
  11123. /**
  11124. * Releases all associated resources
  11125. */
  11126. dispose(): void;
  11127. /**
  11128. * Gets hosting scene
  11129. * @returns the hosting scene
  11130. */
  11131. getScene(): Scene;
  11132. /**
  11133. * Does this action manager handles actions of any of the given triggers
  11134. * @param triggers defines the triggers to be tested
  11135. * @return a boolean indicating whether one (or more) of the triggers is handled
  11136. */
  11137. hasSpecificTriggers(triggers: number[]): boolean;
  11138. /**
  11139. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11140. * speed.
  11141. * @param triggerA defines the trigger to be tested
  11142. * @param triggerB defines the trigger to be tested
  11143. * @return a boolean indicating whether one (or more) of the triggers is handled
  11144. */
  11145. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11146. /**
  11147. * Does this action manager handles actions of a given trigger
  11148. * @param trigger defines the trigger to be tested
  11149. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11150. * @return whether the trigger is handled
  11151. */
  11152. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11153. /**
  11154. * Does this action manager has pointer triggers
  11155. */
  11156. readonly hasPointerTriggers: boolean;
  11157. /**
  11158. * Does this action manager has pick triggers
  11159. */
  11160. readonly hasPickTriggers: boolean;
  11161. /**
  11162. * Registers an action to this action manager
  11163. * @param action defines the action to be registered
  11164. * @return the action amended (prepared) after registration
  11165. */
  11166. registerAction(action: IAction): Nullable<IAction>;
  11167. /**
  11168. * Unregisters an action to this action manager
  11169. * @param action defines the action to be unregistered
  11170. * @return a boolean indicating whether the action has been unregistered
  11171. */
  11172. unregisterAction(action: IAction): Boolean;
  11173. /**
  11174. * Process a specific trigger
  11175. * @param trigger defines the trigger to process
  11176. * @param evt defines the event details to be processed
  11177. */
  11178. processTrigger(trigger: number, evt?: IActionEvent): void;
  11179. /** @hidden */
  11180. _getEffectiveTarget(target: any, propertyPath: string): any;
  11181. /** @hidden */
  11182. _getProperty(propertyPath: string): string;
  11183. /**
  11184. * Serialize this manager to a JSON object
  11185. * @param name defines the property name to store this manager
  11186. * @returns a JSON representation of this manager
  11187. */
  11188. serialize(name: string): any;
  11189. /**
  11190. * Creates a new ActionManager from a JSON data
  11191. * @param parsedActions defines the JSON data to read from
  11192. * @param object defines the hosting mesh
  11193. * @param scene defines the hosting scene
  11194. */
  11195. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11196. /**
  11197. * Get a trigger name by index
  11198. * @param trigger defines the trigger index
  11199. * @returns a trigger name
  11200. */
  11201. static GetTriggerName(trigger: number): string;
  11202. }
  11203. }
  11204. declare module BABYLON {
  11205. /**
  11206. * Class representing a ray with position and direction
  11207. */
  11208. export class Ray {
  11209. /** origin point */
  11210. origin: Vector3;
  11211. /** direction */
  11212. direction: Vector3;
  11213. /** length of the ray */
  11214. length: number;
  11215. private static readonly TmpVector3;
  11216. private _tmpRay;
  11217. /**
  11218. * Creates a new ray
  11219. * @param origin origin point
  11220. * @param direction direction
  11221. * @param length length of the ray
  11222. */
  11223. constructor(
  11224. /** origin point */
  11225. origin: Vector3,
  11226. /** direction */
  11227. direction: Vector3,
  11228. /** length of the ray */
  11229. length?: number);
  11230. /**
  11231. * Checks if the ray intersects a box
  11232. * @param minimum bound of the box
  11233. * @param maximum bound of the box
  11234. * @param intersectionTreshold extra extend to be added to the box in all direction
  11235. * @returns if the box was hit
  11236. */
  11237. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11238. /**
  11239. * Checks if the ray intersects a box
  11240. * @param box the bounding box to check
  11241. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11242. * @returns if the box was hit
  11243. */
  11244. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11245. /**
  11246. * If the ray hits a sphere
  11247. * @param sphere the bounding sphere to check
  11248. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11249. * @returns true if it hits the sphere
  11250. */
  11251. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11252. /**
  11253. * If the ray hits a triange
  11254. * @param vertex0 triangle vertex
  11255. * @param vertex1 triangle vertex
  11256. * @param vertex2 triangle vertex
  11257. * @returns intersection information if hit
  11258. */
  11259. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11260. /**
  11261. * Checks if ray intersects a plane
  11262. * @param plane the plane to check
  11263. * @returns the distance away it was hit
  11264. */
  11265. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11266. /**
  11267. * Checks if ray intersects a mesh
  11268. * @param mesh the mesh to check
  11269. * @param fastCheck if only the bounding box should checked
  11270. * @returns picking info of the intersecton
  11271. */
  11272. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11273. /**
  11274. * Checks if ray intersects a mesh
  11275. * @param meshes the meshes to check
  11276. * @param fastCheck if only the bounding box should checked
  11277. * @param results array to store result in
  11278. * @returns Array of picking infos
  11279. */
  11280. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11281. private _comparePickingInfo;
  11282. private static smallnum;
  11283. private static rayl;
  11284. /**
  11285. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11286. * @param sega the first point of the segment to test the intersection against
  11287. * @param segb the second point of the segment to test the intersection against
  11288. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11289. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11290. */
  11291. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11292. /**
  11293. * Update the ray from viewport position
  11294. * @param x position
  11295. * @param y y position
  11296. * @param viewportWidth viewport width
  11297. * @param viewportHeight viewport height
  11298. * @param world world matrix
  11299. * @param view view matrix
  11300. * @param projection projection matrix
  11301. * @returns this ray updated
  11302. */
  11303. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11304. /**
  11305. * Creates a ray with origin and direction of 0,0,0
  11306. * @returns the new ray
  11307. */
  11308. static Zero(): Ray;
  11309. /**
  11310. * Creates a new ray from screen space and viewport
  11311. * @param x position
  11312. * @param y y position
  11313. * @param viewportWidth viewport width
  11314. * @param viewportHeight viewport height
  11315. * @param world world matrix
  11316. * @param view view matrix
  11317. * @param projection projection matrix
  11318. * @returns new ray
  11319. */
  11320. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11321. /**
  11322. * 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
  11323. * transformed to the given world matrix.
  11324. * @param origin The origin point
  11325. * @param end The end point
  11326. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11327. * @returns the new ray
  11328. */
  11329. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11330. /**
  11331. * Transforms a ray by a matrix
  11332. * @param ray ray to transform
  11333. * @param matrix matrix to apply
  11334. * @returns the resulting new ray
  11335. */
  11336. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11337. /**
  11338. * Transforms a ray by a matrix
  11339. * @param ray ray to transform
  11340. * @param matrix matrix to apply
  11341. * @param result ray to store result in
  11342. */
  11343. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11344. /**
  11345. * Unproject a ray from screen space to object space
  11346. * @param sourceX defines the screen space x coordinate to use
  11347. * @param sourceY defines the screen space y coordinate to use
  11348. * @param viewportWidth defines the current width of the viewport
  11349. * @param viewportHeight defines the current height of the viewport
  11350. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11351. * @param view defines the view matrix to use
  11352. * @param projection defines the projection matrix to use
  11353. */
  11354. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11355. }
  11356. /**
  11357. * Type used to define predicate used to select faces when a mesh intersection is detected
  11358. */
  11359. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11360. interface Scene {
  11361. /** @hidden */
  11362. _tempPickingRay: Nullable<Ray>;
  11363. /** @hidden */
  11364. _cachedRayForTransform: Ray;
  11365. /** @hidden */
  11366. _pickWithRayInverseMatrix: Matrix;
  11367. /** @hidden */
  11368. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11369. /** @hidden */
  11370. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11371. }
  11372. }
  11373. declare module BABYLON {
  11374. /**
  11375. * Groups all the scene component constants in one place to ease maintenance.
  11376. * @hidden
  11377. */
  11378. export class SceneComponentConstants {
  11379. static readonly NAME_EFFECTLAYER: string;
  11380. static readonly NAME_LAYER: string;
  11381. static readonly NAME_LENSFLARESYSTEM: string;
  11382. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11383. static readonly NAME_PARTICLESYSTEM: string;
  11384. static readonly NAME_GAMEPAD: string;
  11385. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11386. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11387. static readonly NAME_DEPTHRENDERER: string;
  11388. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11389. static readonly NAME_SPRITE: string;
  11390. static readonly NAME_OUTLINERENDERER: string;
  11391. static readonly NAME_PROCEDURALTEXTURE: string;
  11392. static readonly NAME_SHADOWGENERATOR: string;
  11393. static readonly NAME_OCTREE: string;
  11394. static readonly NAME_PHYSICSENGINE: string;
  11395. static readonly NAME_AUDIO: string;
  11396. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11397. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11398. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11399. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11400. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11401. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11402. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11403. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11404. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11405. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11406. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11407. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11408. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11409. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11410. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11411. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11412. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11413. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11414. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11415. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11416. static readonly STEP_AFTERRENDER_AUDIO: number;
  11417. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11418. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11419. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11420. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11421. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11422. static readonly STEP_POINTERMOVE_SPRITE: number;
  11423. static readonly STEP_POINTERDOWN_SPRITE: number;
  11424. static readonly STEP_POINTERUP_SPRITE: number;
  11425. }
  11426. /**
  11427. * This represents a scene component.
  11428. *
  11429. * This is used to decouple the dependency the scene is having on the different workloads like
  11430. * layers, post processes...
  11431. */
  11432. export interface ISceneComponent {
  11433. /**
  11434. * The name of the component. Each component must have a unique name.
  11435. */
  11436. name: string;
  11437. /**
  11438. * The scene the component belongs to.
  11439. */
  11440. scene: Scene;
  11441. /**
  11442. * Register the component to one instance of a scene.
  11443. */
  11444. register(): void;
  11445. /**
  11446. * Rebuilds the elements related to this component in case of
  11447. * context lost for instance.
  11448. */
  11449. rebuild(): void;
  11450. /**
  11451. * Disposes the component and the associated ressources.
  11452. */
  11453. dispose(): void;
  11454. }
  11455. /**
  11456. * This represents a SERIALIZABLE scene component.
  11457. *
  11458. * This extends Scene Component to add Serialization methods on top.
  11459. */
  11460. export interface ISceneSerializableComponent extends ISceneComponent {
  11461. /**
  11462. * Adds all the element from the container to the scene
  11463. * @param container the container holding the elements
  11464. */
  11465. addFromContainer(container: AbstractScene): void;
  11466. /**
  11467. * Removes all the elements in the container from the scene
  11468. * @param container contains the elements to remove
  11469. * @param dispose if the removed element should be disposed (default: false)
  11470. */
  11471. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11472. /**
  11473. * Serializes the component data to the specified json object
  11474. * @param serializationObject The object to serialize to
  11475. */
  11476. serialize(serializationObject: any): void;
  11477. }
  11478. /**
  11479. * Strong typing of a Mesh related stage step action
  11480. */
  11481. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11482. /**
  11483. * Strong typing of a Evaluate Sub Mesh related stage step action
  11484. */
  11485. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11486. /**
  11487. * Strong typing of a Active Mesh related stage step action
  11488. */
  11489. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11490. /**
  11491. * Strong typing of a Camera related stage step action
  11492. */
  11493. export type CameraStageAction = (camera: Camera) => void;
  11494. /**
  11495. * Strong typing of a Render Target related stage step action
  11496. */
  11497. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11498. /**
  11499. * Strong typing of a RenderingGroup related stage step action
  11500. */
  11501. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11502. /**
  11503. * Strong typing of a Mesh Render related stage step action
  11504. */
  11505. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11506. /**
  11507. * Strong typing of a simple stage step action
  11508. */
  11509. export type SimpleStageAction = () => void;
  11510. /**
  11511. * Strong typing of a render target action.
  11512. */
  11513. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11514. /**
  11515. * Strong typing of a pointer move action.
  11516. */
  11517. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11518. /**
  11519. * Strong typing of a pointer up/down action.
  11520. */
  11521. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11522. /**
  11523. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11524. * @hidden
  11525. */
  11526. export class Stage<T extends Function> extends Array<{
  11527. index: number;
  11528. component: ISceneComponent;
  11529. action: T;
  11530. }> {
  11531. /**
  11532. * Hide ctor from the rest of the world.
  11533. * @param items The items to add.
  11534. */
  11535. private constructor();
  11536. /**
  11537. * Creates a new Stage.
  11538. * @returns A new instance of a Stage
  11539. */
  11540. static Create<T extends Function>(): Stage<T>;
  11541. /**
  11542. * Registers a step in an ordered way in the targeted stage.
  11543. * @param index Defines the position to register the step in
  11544. * @param component Defines the component attached to the step
  11545. * @param action Defines the action to launch during the step
  11546. */
  11547. registerStep(index: number, component: ISceneComponent, action: T): void;
  11548. /**
  11549. * Clears all the steps from the stage.
  11550. */
  11551. clear(): void;
  11552. }
  11553. }
  11554. declare module BABYLON {
  11555. interface Scene {
  11556. /** @hidden */
  11557. _pointerOverSprite: Nullable<Sprite>;
  11558. /** @hidden */
  11559. _pickedDownSprite: Nullable<Sprite>;
  11560. /** @hidden */
  11561. _tempSpritePickingRay: Nullable<Ray>;
  11562. /**
  11563. * All of the sprite managers added to this scene
  11564. * @see http://doc.babylonjs.com/babylon101/sprites
  11565. */
  11566. spriteManagers: Array<ISpriteManager>;
  11567. /**
  11568. * An event triggered when sprites rendering is about to start
  11569. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11570. */
  11571. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11572. /**
  11573. * An event triggered when sprites rendering is done
  11574. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11575. */
  11576. onAfterSpritesRenderingObservable: Observable<Scene>;
  11577. /** @hidden */
  11578. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11579. /** Launch a ray to try to pick a sprite in the scene
  11580. * @param x position on screen
  11581. * @param y position on screen
  11582. * @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
  11583. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11584. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11585. * @returns a PickingInfo
  11586. */
  11587. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11588. /** Use the given ray to pick a sprite in the scene
  11589. * @param ray The ray (in world space) to use to pick meshes
  11590. * @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
  11591. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11592. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11593. * @returns a PickingInfo
  11594. */
  11595. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11596. /**
  11597. * Force the sprite under the pointer
  11598. * @param sprite defines the sprite to use
  11599. */
  11600. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11601. /**
  11602. * Gets the sprite under the pointer
  11603. * @returns a Sprite or null if no sprite is under the pointer
  11604. */
  11605. getPointerOverSprite(): Nullable<Sprite>;
  11606. }
  11607. /**
  11608. * Defines the sprite scene component responsible to manage sprites
  11609. * in a given scene.
  11610. */
  11611. export class SpriteSceneComponent implements ISceneComponent {
  11612. /**
  11613. * The component name helpfull to identify the component in the list of scene components.
  11614. */
  11615. readonly name: string;
  11616. /**
  11617. * The scene the component belongs to.
  11618. */
  11619. scene: Scene;
  11620. /** @hidden */
  11621. private _spritePredicate;
  11622. /**
  11623. * Creates a new instance of the component for the given scene
  11624. * @param scene Defines the scene to register the component in
  11625. */
  11626. constructor(scene: Scene);
  11627. /**
  11628. * Registers the component in a given scene
  11629. */
  11630. register(): void;
  11631. /**
  11632. * Rebuilds the elements related to this component in case of
  11633. * context lost for instance.
  11634. */
  11635. rebuild(): void;
  11636. /**
  11637. * Disposes the component and the associated ressources.
  11638. */
  11639. dispose(): void;
  11640. private _pickSpriteButKeepRay;
  11641. private _pointerMove;
  11642. private _pointerDown;
  11643. private _pointerUp;
  11644. }
  11645. }
  11646. declare module BABYLON {
  11647. /** @hidden */
  11648. export var fogFragmentDeclaration: {
  11649. name: string;
  11650. shader: string;
  11651. };
  11652. }
  11653. declare module BABYLON {
  11654. /** @hidden */
  11655. export var fogFragment: {
  11656. name: string;
  11657. shader: string;
  11658. };
  11659. }
  11660. declare module BABYLON {
  11661. /** @hidden */
  11662. export var spritesPixelShader: {
  11663. name: string;
  11664. shader: string;
  11665. };
  11666. }
  11667. declare module BABYLON {
  11668. /** @hidden */
  11669. export var fogVertexDeclaration: {
  11670. name: string;
  11671. shader: string;
  11672. };
  11673. }
  11674. declare module BABYLON {
  11675. /** @hidden */
  11676. export var spritesVertexShader: {
  11677. name: string;
  11678. shader: string;
  11679. };
  11680. }
  11681. declare module BABYLON {
  11682. /**
  11683. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11684. */
  11685. export interface ISpriteManager extends IDisposable {
  11686. /**
  11687. * Restricts the camera to viewing objects with the same layerMask.
  11688. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11689. */
  11690. layerMask: number;
  11691. /**
  11692. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11693. */
  11694. isPickable: boolean;
  11695. /**
  11696. * Specifies the rendering group id for this mesh (0 by default)
  11697. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11698. */
  11699. renderingGroupId: number;
  11700. /**
  11701. * Defines the list of sprites managed by the manager.
  11702. */
  11703. sprites: Array<Sprite>;
  11704. /**
  11705. * Tests the intersection of a sprite with a specific ray.
  11706. * @param ray The ray we are sending to test the collision
  11707. * @param camera The camera space we are sending rays in
  11708. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11709. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11710. * @returns picking info or null.
  11711. */
  11712. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11713. /**
  11714. * Renders the list of sprites on screen.
  11715. */
  11716. render(): void;
  11717. }
  11718. /**
  11719. * Class used to manage multiple sprites on the same spritesheet
  11720. * @see http://doc.babylonjs.com/babylon101/sprites
  11721. */
  11722. export class SpriteManager implements ISpriteManager {
  11723. /** defines the manager's name */
  11724. name: string;
  11725. /** Gets the list of sprites */
  11726. sprites: Sprite[];
  11727. /** Gets or sets the rendering group id (0 by default) */
  11728. renderingGroupId: number;
  11729. /** Gets or sets camera layer mask */
  11730. layerMask: number;
  11731. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11732. fogEnabled: boolean;
  11733. /** Gets or sets a boolean indicating if the sprites are pickable */
  11734. isPickable: boolean;
  11735. /** Defines the default width of a cell in the spritesheet */
  11736. cellWidth: number;
  11737. /** Defines the default height of a cell in the spritesheet */
  11738. cellHeight: number;
  11739. /**
  11740. * An event triggered when the manager is disposed.
  11741. */
  11742. onDisposeObservable: Observable<SpriteManager>;
  11743. private _onDisposeObserver;
  11744. /**
  11745. * Callback called when the manager is disposed
  11746. */
  11747. onDispose: () => void;
  11748. private _capacity;
  11749. private _spriteTexture;
  11750. private _epsilon;
  11751. private _scene;
  11752. private _vertexData;
  11753. private _buffer;
  11754. private _vertexBuffers;
  11755. private _indexBuffer;
  11756. private _effectBase;
  11757. private _effectFog;
  11758. /**
  11759. * Gets or sets the spritesheet texture
  11760. */
  11761. texture: Texture;
  11762. /**
  11763. * Creates a new sprite manager
  11764. * @param name defines the manager's name
  11765. * @param imgUrl defines the sprite sheet url
  11766. * @param capacity defines the maximum allowed number of sprites
  11767. * @param cellSize defines the size of a sprite cell
  11768. * @param scene defines the hosting scene
  11769. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11770. * @param samplingMode defines the smapling mode to use with spritesheet
  11771. */
  11772. constructor(
  11773. /** defines the manager's name */
  11774. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  11775. private _appendSpriteVertex;
  11776. /**
  11777. * Intersects the sprites with a ray
  11778. * @param ray defines the ray to intersect with
  11779. * @param camera defines the current active camera
  11780. * @param predicate defines a predicate used to select candidate sprites
  11781. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11782. * @returns null if no hit or a PickingInfo
  11783. */
  11784. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11785. /**
  11786. * Render all child sprites
  11787. */
  11788. render(): void;
  11789. /**
  11790. * Release associated resources
  11791. */
  11792. dispose(): void;
  11793. }
  11794. }
  11795. declare module BABYLON {
  11796. /**
  11797. * Class used to represent a sprite
  11798. * @see http://doc.babylonjs.com/babylon101/sprites
  11799. */
  11800. export class Sprite {
  11801. /** defines the name */
  11802. name: string;
  11803. /** Gets or sets the current world position */
  11804. position: Vector3;
  11805. /** Gets or sets the main color */
  11806. color: Color4;
  11807. /** Gets or sets the width */
  11808. width: number;
  11809. /** Gets or sets the height */
  11810. height: number;
  11811. /** Gets or sets rotation angle */
  11812. angle: number;
  11813. /** Gets or sets the cell index in the sprite sheet */
  11814. cellIndex: number;
  11815. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11816. invertU: number;
  11817. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11818. invertV: number;
  11819. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11820. disposeWhenFinishedAnimating: boolean;
  11821. /** Gets the list of attached animations */
  11822. animations: Animation[];
  11823. /** Gets or sets a boolean indicating if the sprite can be picked */
  11824. isPickable: boolean;
  11825. /**
  11826. * Gets or sets the associated action manager
  11827. */
  11828. actionManager: Nullable<ActionManager>;
  11829. private _animationStarted;
  11830. private _loopAnimation;
  11831. private _fromIndex;
  11832. private _toIndex;
  11833. private _delay;
  11834. private _direction;
  11835. private _manager;
  11836. private _time;
  11837. private _onAnimationEnd;
  11838. /**
  11839. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11840. */
  11841. isVisible: boolean;
  11842. /**
  11843. * Gets or sets the sprite size
  11844. */
  11845. size: number;
  11846. /**
  11847. * Creates a new Sprite
  11848. * @param name defines the name
  11849. * @param manager defines the manager
  11850. */
  11851. constructor(
  11852. /** defines the name */
  11853. name: string, manager: ISpriteManager);
  11854. /**
  11855. * Starts an animation
  11856. * @param from defines the initial key
  11857. * @param to defines the end key
  11858. * @param loop defines if the animation must loop
  11859. * @param delay defines the start delay (in ms)
  11860. * @param onAnimationEnd defines a callback to call when animation ends
  11861. */
  11862. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11863. /** Stops current animation (if any) */
  11864. stopAnimation(): void;
  11865. /** @hidden */
  11866. _animate(deltaTime: number): void;
  11867. /** Release associated resources */
  11868. dispose(): void;
  11869. }
  11870. }
  11871. declare module BABYLON {
  11872. /**
  11873. * Information about the result of picking within a scene
  11874. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11875. */
  11876. export class PickingInfo {
  11877. /** @hidden */
  11878. _pickingUnavailable: boolean;
  11879. /**
  11880. * If the pick collided with an object
  11881. */
  11882. hit: boolean;
  11883. /**
  11884. * Distance away where the pick collided
  11885. */
  11886. distance: number;
  11887. /**
  11888. * The location of pick collision
  11889. */
  11890. pickedPoint: Nullable<Vector3>;
  11891. /**
  11892. * The mesh corresponding the the pick collision
  11893. */
  11894. pickedMesh: Nullable<AbstractMesh>;
  11895. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  11896. bu: number;
  11897. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  11898. bv: number;
  11899. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11900. faceId: number;
  11901. /** Id of the the submesh that was picked */
  11902. subMeshId: number;
  11903. /** If a sprite was picked, this will be the sprite the pick collided with */
  11904. pickedSprite: Nullable<Sprite>;
  11905. /**
  11906. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11907. */
  11908. originMesh: Nullable<AbstractMesh>;
  11909. /**
  11910. * The ray that was used to perform the picking.
  11911. */
  11912. ray: Nullable<Ray>;
  11913. /**
  11914. * Gets the normal correspodning to the face the pick collided with
  11915. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11916. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11917. * @returns The normal correspodning to the face the pick collided with
  11918. */
  11919. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11920. /**
  11921. * Gets the texture coordinates of where the pick occured
  11922. * @returns the vector containing the coordnates of the texture
  11923. */
  11924. getTextureCoordinates(): Nullable<Vector2>;
  11925. }
  11926. }
  11927. declare module BABYLON {
  11928. /**
  11929. * Gather the list of pointer event types as constants.
  11930. */
  11931. export class PointerEventTypes {
  11932. /**
  11933. * 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.
  11934. */
  11935. static readonly POINTERDOWN: number;
  11936. /**
  11937. * The pointerup event is fired when a pointer is no longer active.
  11938. */
  11939. static readonly POINTERUP: number;
  11940. /**
  11941. * The pointermove event is fired when a pointer changes coordinates.
  11942. */
  11943. static readonly POINTERMOVE: number;
  11944. /**
  11945. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11946. */
  11947. static readonly POINTERWHEEL: number;
  11948. /**
  11949. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11950. */
  11951. static readonly POINTERPICK: number;
  11952. /**
  11953. * The pointertap event is fired when a the object has been touched and released without drag.
  11954. */
  11955. static readonly POINTERTAP: number;
  11956. /**
  11957. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11958. */
  11959. static readonly POINTERDOUBLETAP: number;
  11960. }
  11961. /**
  11962. * Base class of pointer info types.
  11963. */
  11964. export class PointerInfoBase {
  11965. /**
  11966. * Defines the type of event (PointerEventTypes)
  11967. */
  11968. type: number;
  11969. /**
  11970. * Defines the related dom event
  11971. */
  11972. event: PointerEvent | MouseWheelEvent;
  11973. /**
  11974. * Instantiates the base class of pointers info.
  11975. * @param type Defines the type of event (PointerEventTypes)
  11976. * @param event Defines the related dom event
  11977. */
  11978. constructor(
  11979. /**
  11980. * Defines the type of event (PointerEventTypes)
  11981. */
  11982. type: number,
  11983. /**
  11984. * Defines the related dom event
  11985. */
  11986. event: PointerEvent | MouseWheelEvent);
  11987. }
  11988. /**
  11989. * This class is used to store pointer related info for the onPrePointerObservable event.
  11990. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11991. */
  11992. export class PointerInfoPre extends PointerInfoBase {
  11993. /**
  11994. * Ray from a pointer if availible (eg. 6dof controller)
  11995. */
  11996. ray: Nullable<Ray>;
  11997. /**
  11998. * Defines the local position of the pointer on the canvas.
  11999. */
  12000. localPosition: Vector2;
  12001. /**
  12002. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12003. */
  12004. skipOnPointerObservable: boolean;
  12005. /**
  12006. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12007. * @param type Defines the type of event (PointerEventTypes)
  12008. * @param event Defines the related dom event
  12009. * @param localX Defines the local x coordinates of the pointer when the event occured
  12010. * @param localY Defines the local y coordinates of the pointer when the event occured
  12011. */
  12012. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12013. }
  12014. /**
  12015. * This type contains all the data related to a pointer event in Babylon.js.
  12016. * 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.
  12017. */
  12018. export class PointerInfo extends PointerInfoBase {
  12019. /**
  12020. * Defines the picking info associated to the info (if any)\
  12021. */
  12022. pickInfo: Nullable<PickingInfo>;
  12023. /**
  12024. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12025. * @param type Defines the type of event (PointerEventTypes)
  12026. * @param event Defines the related dom event
  12027. * @param pickInfo Defines the picking info associated to the info (if any)\
  12028. */
  12029. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12030. /**
  12031. * Defines the picking info associated to the info (if any)\
  12032. */
  12033. pickInfo: Nullable<PickingInfo>);
  12034. }
  12035. /**
  12036. * Data relating to a touch event on the screen.
  12037. */
  12038. export interface PointerTouch {
  12039. /**
  12040. * X coordinate of touch.
  12041. */
  12042. x: number;
  12043. /**
  12044. * Y coordinate of touch.
  12045. */
  12046. y: number;
  12047. /**
  12048. * Id of touch. Unique for each finger.
  12049. */
  12050. pointerId: number;
  12051. /**
  12052. * Event type passed from DOM.
  12053. */
  12054. type: any;
  12055. }
  12056. }
  12057. declare module BABYLON {
  12058. /**
  12059. * Manage the mouse inputs to control the movement of a free camera.
  12060. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12061. */
  12062. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12063. /**
  12064. * Define if touch is enabled in the mouse input
  12065. */
  12066. touchEnabled: boolean;
  12067. /**
  12068. * Defines the camera the input is attached to.
  12069. */
  12070. camera: FreeCamera;
  12071. /**
  12072. * Defines the buttons associated with the input to handle camera move.
  12073. */
  12074. buttons: number[];
  12075. /**
  12076. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12077. */
  12078. angularSensibility: number;
  12079. private _pointerInput;
  12080. private _onMouseMove;
  12081. private _observer;
  12082. private previousPosition;
  12083. /**
  12084. * Manage the mouse inputs to control the movement of a free camera.
  12085. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12086. * @param touchEnabled Defines if touch is enabled or not
  12087. */
  12088. constructor(
  12089. /**
  12090. * Define if touch is enabled in the mouse input
  12091. */
  12092. touchEnabled?: boolean);
  12093. /**
  12094. * Attach the input controls to a specific dom element to get the input from.
  12095. * @param element Defines the element the controls should be listened from
  12096. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12097. */
  12098. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12099. /**
  12100. * Called on JS contextmenu event.
  12101. * Override this method to provide functionality.
  12102. */
  12103. protected onContextMenu(evt: PointerEvent): void;
  12104. /**
  12105. * Detach the current controls from the specified dom element.
  12106. * @param element Defines the element to stop listening the inputs from
  12107. */
  12108. detachControl(element: Nullable<HTMLElement>): void;
  12109. /**
  12110. * Gets the class name of the current intput.
  12111. * @returns the class name
  12112. */
  12113. getClassName(): string;
  12114. /**
  12115. * Get the friendly name associated with the input class.
  12116. * @returns the input friendly name
  12117. */
  12118. getSimpleName(): string;
  12119. }
  12120. }
  12121. declare module BABYLON {
  12122. /**
  12123. * Manage the touch inputs to control the movement of a free camera.
  12124. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12125. */
  12126. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12127. /**
  12128. * Defines the camera the input is attached to.
  12129. */
  12130. camera: FreeCamera;
  12131. /**
  12132. * Defines the touch sensibility for rotation.
  12133. * The higher the faster.
  12134. */
  12135. touchAngularSensibility: number;
  12136. /**
  12137. * Defines the touch sensibility for move.
  12138. * The higher the faster.
  12139. */
  12140. touchMoveSensibility: number;
  12141. private _offsetX;
  12142. private _offsetY;
  12143. private _pointerPressed;
  12144. private _pointerInput;
  12145. private _observer;
  12146. private _onLostFocus;
  12147. /**
  12148. * Attach the input controls to a specific dom element to get the input from.
  12149. * @param element Defines the element the controls should be listened from
  12150. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12151. */
  12152. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12153. /**
  12154. * Detach the current controls from the specified dom element.
  12155. * @param element Defines the element to stop listening the inputs from
  12156. */
  12157. detachControl(element: Nullable<HTMLElement>): void;
  12158. /**
  12159. * Update the current camera state depending on the inputs that have been used this frame.
  12160. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12161. */
  12162. checkInputs(): void;
  12163. /**
  12164. * Gets the class name of the current intput.
  12165. * @returns the class name
  12166. */
  12167. getClassName(): string;
  12168. /**
  12169. * Get the friendly name associated with the input class.
  12170. * @returns the input friendly name
  12171. */
  12172. getSimpleName(): string;
  12173. }
  12174. }
  12175. declare module BABYLON {
  12176. /**
  12177. * Default Inputs manager for the FreeCamera.
  12178. * It groups all the default supported inputs for ease of use.
  12179. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12180. */
  12181. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12182. /**
  12183. * Instantiates a new FreeCameraInputsManager.
  12184. * @param camera Defines the camera the inputs belong to
  12185. */
  12186. constructor(camera: FreeCamera);
  12187. /**
  12188. * Add keyboard input support to the input manager.
  12189. * @returns the current input manager
  12190. */
  12191. addKeyboard(): FreeCameraInputsManager;
  12192. /**
  12193. * Add mouse input support to the input manager.
  12194. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12195. * @returns the current input manager
  12196. */
  12197. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12198. /**
  12199. * Add touch input support to the input manager.
  12200. * @returns the current input manager
  12201. */
  12202. addTouch(): FreeCameraInputsManager;
  12203. }
  12204. }
  12205. declare module BABYLON {
  12206. /**
  12207. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12208. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12209. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12210. */
  12211. export class FreeCamera extends TargetCamera {
  12212. /**
  12213. * Define the collision ellipsoid of the camera.
  12214. * This is helpful to simulate a camera body like the player body around the camera
  12215. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12216. */
  12217. ellipsoid: Vector3;
  12218. /**
  12219. * Define an offset for the position of the ellipsoid around the camera.
  12220. * This can be helpful to determine the center of the body near the gravity center of the body
  12221. * instead of its head.
  12222. */
  12223. ellipsoidOffset: Vector3;
  12224. /**
  12225. * Enable or disable collisions of the camera with the rest of the scene objects.
  12226. */
  12227. checkCollisions: boolean;
  12228. /**
  12229. * Enable or disable gravity on the camera.
  12230. */
  12231. applyGravity: boolean;
  12232. /**
  12233. * Define the input manager associated to the camera.
  12234. */
  12235. inputs: FreeCameraInputsManager;
  12236. /**
  12237. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12238. * Higher values reduce sensitivity.
  12239. */
  12240. /**
  12241. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12242. * Higher values reduce sensitivity.
  12243. */
  12244. angularSensibility: number;
  12245. /**
  12246. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12247. */
  12248. keysUp: number[];
  12249. /**
  12250. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12251. */
  12252. keysDown: number[];
  12253. /**
  12254. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12255. */
  12256. keysLeft: number[];
  12257. /**
  12258. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12259. */
  12260. keysRight: number[];
  12261. /**
  12262. * Event raised when the camera collide with a mesh in the scene.
  12263. */
  12264. onCollide: (collidedMesh: AbstractMesh) => void;
  12265. private _collider;
  12266. private _needMoveForGravity;
  12267. private _oldPosition;
  12268. private _diffPosition;
  12269. private _newPosition;
  12270. /** @hidden */
  12271. _localDirection: Vector3;
  12272. /** @hidden */
  12273. _transformedDirection: Vector3;
  12274. /**
  12275. * Instantiates a Free Camera.
  12276. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12277. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12278. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12279. * @param name Define the name of the camera in the scene
  12280. * @param position Define the start position of the camera in the scene
  12281. * @param scene Define the scene the camera belongs to
  12282. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12283. */
  12284. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12285. /**
  12286. * Attached controls to the current camera.
  12287. * @param element Defines the element the controls should be listened from
  12288. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12289. */
  12290. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12291. /**
  12292. * Detach the current controls from the camera.
  12293. * The camera will stop reacting to inputs.
  12294. * @param element Defines the element to stop listening the inputs from
  12295. */
  12296. detachControl(element: HTMLElement): void;
  12297. private _collisionMask;
  12298. /**
  12299. * Define a collision mask to limit the list of object the camera can collide with
  12300. */
  12301. collisionMask: number;
  12302. /** @hidden */
  12303. _collideWithWorld(displacement: Vector3): void;
  12304. private _onCollisionPositionChange;
  12305. /** @hidden */
  12306. _checkInputs(): void;
  12307. /** @hidden */
  12308. _decideIfNeedsToMove(): boolean;
  12309. /** @hidden */
  12310. _updatePosition(): void;
  12311. /**
  12312. * Destroy the camera and release the current resources hold by it.
  12313. */
  12314. dispose(): void;
  12315. /**
  12316. * Gets the current object class name.
  12317. * @return the class name
  12318. */
  12319. getClassName(): string;
  12320. }
  12321. }
  12322. declare module BABYLON {
  12323. /**
  12324. * Represents a gamepad control stick position
  12325. */
  12326. export class StickValues {
  12327. /**
  12328. * The x component of the control stick
  12329. */
  12330. x: number;
  12331. /**
  12332. * The y component of the control stick
  12333. */
  12334. y: number;
  12335. /**
  12336. * Initializes the gamepad x and y control stick values
  12337. * @param x The x component of the gamepad control stick value
  12338. * @param y The y component of the gamepad control stick value
  12339. */
  12340. constructor(
  12341. /**
  12342. * The x component of the control stick
  12343. */
  12344. x: number,
  12345. /**
  12346. * The y component of the control stick
  12347. */
  12348. y: number);
  12349. }
  12350. /**
  12351. * An interface which manages callbacks for gamepad button changes
  12352. */
  12353. export interface GamepadButtonChanges {
  12354. /**
  12355. * Called when a gamepad has been changed
  12356. */
  12357. changed: boolean;
  12358. /**
  12359. * Called when a gamepad press event has been triggered
  12360. */
  12361. pressChanged: boolean;
  12362. /**
  12363. * Called when a touch event has been triggered
  12364. */
  12365. touchChanged: boolean;
  12366. /**
  12367. * Called when a value has changed
  12368. */
  12369. valueChanged: boolean;
  12370. }
  12371. /**
  12372. * Represents a gamepad
  12373. */
  12374. export class Gamepad {
  12375. /**
  12376. * The id of the gamepad
  12377. */
  12378. id: string;
  12379. /**
  12380. * The index of the gamepad
  12381. */
  12382. index: number;
  12383. /**
  12384. * The browser gamepad
  12385. */
  12386. browserGamepad: any;
  12387. /**
  12388. * Specifies what type of gamepad this represents
  12389. */
  12390. type: number;
  12391. private _leftStick;
  12392. private _rightStick;
  12393. /** @hidden */
  12394. _isConnected: boolean;
  12395. private _leftStickAxisX;
  12396. private _leftStickAxisY;
  12397. private _rightStickAxisX;
  12398. private _rightStickAxisY;
  12399. /**
  12400. * Triggered when the left control stick has been changed
  12401. */
  12402. private _onleftstickchanged;
  12403. /**
  12404. * Triggered when the right control stick has been changed
  12405. */
  12406. private _onrightstickchanged;
  12407. /**
  12408. * Represents a gamepad controller
  12409. */
  12410. static GAMEPAD: number;
  12411. /**
  12412. * Represents a generic controller
  12413. */
  12414. static GENERIC: number;
  12415. /**
  12416. * Represents an XBox controller
  12417. */
  12418. static XBOX: number;
  12419. /**
  12420. * Represents a pose-enabled controller
  12421. */
  12422. static POSE_ENABLED: number;
  12423. /**
  12424. * Specifies whether the left control stick should be Y-inverted
  12425. */
  12426. protected _invertLeftStickY: boolean;
  12427. /**
  12428. * Specifies if the gamepad has been connected
  12429. */
  12430. readonly isConnected: boolean;
  12431. /**
  12432. * Initializes the gamepad
  12433. * @param id The id of the gamepad
  12434. * @param index The index of the gamepad
  12435. * @param browserGamepad The browser gamepad
  12436. * @param leftStickX The x component of the left joystick
  12437. * @param leftStickY The y component of the left joystick
  12438. * @param rightStickX The x component of the right joystick
  12439. * @param rightStickY The y component of the right joystick
  12440. */
  12441. constructor(
  12442. /**
  12443. * The id of the gamepad
  12444. */
  12445. id: string,
  12446. /**
  12447. * The index of the gamepad
  12448. */
  12449. index: number,
  12450. /**
  12451. * The browser gamepad
  12452. */
  12453. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12454. /**
  12455. * Callback triggered when the left joystick has changed
  12456. * @param callback
  12457. */
  12458. onleftstickchanged(callback: (values: StickValues) => void): void;
  12459. /**
  12460. * Callback triggered when the right joystick has changed
  12461. * @param callback
  12462. */
  12463. onrightstickchanged(callback: (values: StickValues) => void): void;
  12464. /**
  12465. * Gets the left joystick
  12466. */
  12467. /**
  12468. * Sets the left joystick values
  12469. */
  12470. leftStick: StickValues;
  12471. /**
  12472. * Gets the right joystick
  12473. */
  12474. /**
  12475. * Sets the right joystick value
  12476. */
  12477. rightStick: StickValues;
  12478. /**
  12479. * Updates the gamepad joystick positions
  12480. */
  12481. update(): void;
  12482. /**
  12483. * Disposes the gamepad
  12484. */
  12485. dispose(): void;
  12486. }
  12487. /**
  12488. * Represents a generic gamepad
  12489. */
  12490. export class GenericPad extends Gamepad {
  12491. private _buttons;
  12492. private _onbuttondown;
  12493. private _onbuttonup;
  12494. /**
  12495. * Observable triggered when a button has been pressed
  12496. */
  12497. onButtonDownObservable: Observable<number>;
  12498. /**
  12499. * Observable triggered when a button has been released
  12500. */
  12501. onButtonUpObservable: Observable<number>;
  12502. /**
  12503. * Callback triggered when a button has been pressed
  12504. * @param callback Called when a button has been pressed
  12505. */
  12506. onbuttondown(callback: (buttonPressed: number) => void): void;
  12507. /**
  12508. * Callback triggered when a button has been released
  12509. * @param callback Called when a button has been released
  12510. */
  12511. onbuttonup(callback: (buttonReleased: number) => void): void;
  12512. /**
  12513. * Initializes the generic gamepad
  12514. * @param id The id of the generic gamepad
  12515. * @param index The index of the generic gamepad
  12516. * @param browserGamepad The browser gamepad
  12517. */
  12518. constructor(id: string, index: number, browserGamepad: any);
  12519. private _setButtonValue;
  12520. /**
  12521. * Updates the generic gamepad
  12522. */
  12523. update(): void;
  12524. /**
  12525. * Disposes the generic gamepad
  12526. */
  12527. dispose(): void;
  12528. }
  12529. }
  12530. declare module BABYLON {
  12531. /**
  12532. * Defines the types of pose enabled controllers that are supported
  12533. */
  12534. export enum PoseEnabledControllerType {
  12535. /**
  12536. * HTC Vive
  12537. */
  12538. VIVE = 0,
  12539. /**
  12540. * Oculus Rift
  12541. */
  12542. OCULUS = 1,
  12543. /**
  12544. * Windows mixed reality
  12545. */
  12546. WINDOWS = 2,
  12547. /**
  12548. * Samsung gear VR
  12549. */
  12550. GEAR_VR = 3,
  12551. /**
  12552. * Google Daydream
  12553. */
  12554. DAYDREAM = 4,
  12555. /**
  12556. * Generic
  12557. */
  12558. GENERIC = 5
  12559. }
  12560. /**
  12561. * Defines the MutableGamepadButton interface for the state of a gamepad button
  12562. */
  12563. export interface MutableGamepadButton {
  12564. /**
  12565. * Value of the button/trigger
  12566. */
  12567. value: number;
  12568. /**
  12569. * If the button/trigger is currently touched
  12570. */
  12571. touched: boolean;
  12572. /**
  12573. * If the button/trigger is currently pressed
  12574. */
  12575. pressed: boolean;
  12576. }
  12577. /**
  12578. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  12579. * @hidden
  12580. */
  12581. export interface ExtendedGamepadButton extends GamepadButton {
  12582. /**
  12583. * If the button/trigger is currently pressed
  12584. */
  12585. readonly pressed: boolean;
  12586. /**
  12587. * If the button/trigger is currently touched
  12588. */
  12589. readonly touched: boolean;
  12590. /**
  12591. * Value of the button/trigger
  12592. */
  12593. readonly value: number;
  12594. }
  12595. /** @hidden */
  12596. export interface _GamePadFactory {
  12597. /**
  12598. * Returns wether or not the current gamepad can be created for this type of controller.
  12599. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12600. * @returns true if it can be created, otherwise false
  12601. */
  12602. canCreate(gamepadInfo: any): boolean;
  12603. /**
  12604. * Creates a new instance of the Gamepad.
  12605. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12606. * @returns the new gamepad instance
  12607. */
  12608. create(gamepadInfo: any): Gamepad;
  12609. }
  12610. /**
  12611. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12612. */
  12613. export class PoseEnabledControllerHelper {
  12614. /** @hidden */
  12615. static _ControllerFactories: _GamePadFactory[];
  12616. /** @hidden */
  12617. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  12618. /**
  12619. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12620. * @param vrGamepad the gamepad to initialized
  12621. * @returns a vr controller of the type the gamepad identified as
  12622. */
  12623. static InitiateController(vrGamepad: any): Gamepad;
  12624. }
  12625. /**
  12626. * Defines the PoseEnabledController object that contains state of a vr capable controller
  12627. */
  12628. export class PoseEnabledController extends Gamepad implements PoseControlled {
  12629. private _deviceRoomPosition;
  12630. private _deviceRoomRotationQuaternion;
  12631. /**
  12632. * The device position in babylon space
  12633. */
  12634. devicePosition: Vector3;
  12635. /**
  12636. * The device rotation in babylon space
  12637. */
  12638. deviceRotationQuaternion: Quaternion;
  12639. /**
  12640. * The scale factor of the device in babylon space
  12641. */
  12642. deviceScaleFactor: number;
  12643. /**
  12644. * (Likely devicePosition should be used instead) The device position in its room space
  12645. */
  12646. position: Vector3;
  12647. /**
  12648. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  12649. */
  12650. rotationQuaternion: Quaternion;
  12651. /**
  12652. * The type of controller (Eg. Windows mixed reality)
  12653. */
  12654. controllerType: PoseEnabledControllerType;
  12655. protected _calculatedPosition: Vector3;
  12656. private _calculatedRotation;
  12657. /**
  12658. * The raw pose from the device
  12659. */
  12660. rawPose: DevicePose;
  12661. private _trackPosition;
  12662. private _maxRotationDistFromHeadset;
  12663. private _draggedRoomRotation;
  12664. /**
  12665. * @hidden
  12666. */
  12667. _disableTrackPosition(fixedPosition: Vector3): void;
  12668. /**
  12669. * Internal, the mesh attached to the controller
  12670. * @hidden
  12671. */
  12672. _mesh: Nullable<AbstractMesh>;
  12673. private _poseControlledCamera;
  12674. private _leftHandSystemQuaternion;
  12675. /**
  12676. * Internal, matrix used to convert room space to babylon space
  12677. * @hidden
  12678. */
  12679. _deviceToWorld: Matrix;
  12680. /**
  12681. * Node to be used when casting a ray from the controller
  12682. * @hidden
  12683. */
  12684. _pointingPoseNode: Nullable<TransformNode>;
  12685. /**
  12686. * Name of the child mesh that can be used to cast a ray from the controller
  12687. */
  12688. static readonly POINTING_POSE: string;
  12689. /**
  12690. * Creates a new PoseEnabledController from a gamepad
  12691. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  12692. */
  12693. constructor(browserGamepad: any);
  12694. private _workingMatrix;
  12695. /**
  12696. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  12697. */
  12698. update(): void;
  12699. /**
  12700. * Updates only the pose device and mesh without doing any button event checking
  12701. */
  12702. protected _updatePoseAndMesh(): void;
  12703. /**
  12704. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  12705. * @param poseData raw pose fromthe device
  12706. */
  12707. updateFromDevice(poseData: DevicePose): void;
  12708. /**
  12709. * @hidden
  12710. */
  12711. _meshAttachedObservable: Observable<AbstractMesh>;
  12712. /**
  12713. * Attaches a mesh to the controller
  12714. * @param mesh the mesh to be attached
  12715. */
  12716. attachToMesh(mesh: AbstractMesh): void;
  12717. /**
  12718. * Attaches the controllers mesh to a camera
  12719. * @param camera the camera the mesh should be attached to
  12720. */
  12721. attachToPoseControlledCamera(camera: TargetCamera): void;
  12722. /**
  12723. * Disposes of the controller
  12724. */
  12725. dispose(): void;
  12726. /**
  12727. * The mesh that is attached to the controller
  12728. */
  12729. readonly mesh: Nullable<AbstractMesh>;
  12730. /**
  12731. * Gets the ray of the controller in the direction the controller is pointing
  12732. * @param length the length the resulting ray should be
  12733. * @returns a ray in the direction the controller is pointing
  12734. */
  12735. getForwardRay(length?: number): Ray;
  12736. }
  12737. }
  12738. declare module BABYLON {
  12739. /**
  12740. * Defines the WebVRController object that represents controllers tracked in 3D space
  12741. */
  12742. export abstract class WebVRController extends PoseEnabledController {
  12743. /**
  12744. * Internal, the default controller model for the controller
  12745. */
  12746. protected _defaultModel: AbstractMesh;
  12747. /**
  12748. * Fired when the trigger state has changed
  12749. */
  12750. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  12751. /**
  12752. * Fired when the main button state has changed
  12753. */
  12754. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12755. /**
  12756. * Fired when the secondary button state has changed
  12757. */
  12758. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12759. /**
  12760. * Fired when the pad state has changed
  12761. */
  12762. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  12763. /**
  12764. * Fired when controllers stick values have changed
  12765. */
  12766. onPadValuesChangedObservable: Observable<StickValues>;
  12767. /**
  12768. * Array of button availible on the controller
  12769. */
  12770. protected _buttons: Array<MutableGamepadButton>;
  12771. private _onButtonStateChange;
  12772. /**
  12773. * Fired when a controller button's state has changed
  12774. * @param callback the callback containing the button that was modified
  12775. */
  12776. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  12777. /**
  12778. * X and Y axis corrisponding to the controllers joystick
  12779. */
  12780. pad: StickValues;
  12781. /**
  12782. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  12783. */
  12784. hand: string;
  12785. /**
  12786. * The default controller model for the controller
  12787. */
  12788. readonly defaultModel: AbstractMesh;
  12789. /**
  12790. * Creates a new WebVRController from a gamepad
  12791. * @param vrGamepad the gamepad that the WebVRController should be created from
  12792. */
  12793. constructor(vrGamepad: any);
  12794. /**
  12795. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  12796. */
  12797. update(): void;
  12798. /**
  12799. * Function to be called when a button is modified
  12800. */
  12801. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  12802. /**
  12803. * Loads a mesh and attaches it to the controller
  12804. * @param scene the scene the mesh should be added to
  12805. * @param meshLoaded callback for when the mesh has been loaded
  12806. */
  12807. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  12808. private _setButtonValue;
  12809. private _changes;
  12810. private _checkChanges;
  12811. /**
  12812. * Disposes of th webVRCOntroller
  12813. */
  12814. dispose(): void;
  12815. }
  12816. }
  12817. declare module BABYLON {
  12818. /**
  12819. * The HemisphericLight simulates the ambient environment light,
  12820. * so the passed direction is the light reflection direction, not the incoming direction.
  12821. */
  12822. export class HemisphericLight extends Light {
  12823. /**
  12824. * The groundColor is the light in the opposite direction to the one specified during creation.
  12825. * 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.
  12826. */
  12827. groundColor: Color3;
  12828. /**
  12829. * The light reflection direction, not the incoming direction.
  12830. */
  12831. direction: Vector3;
  12832. /**
  12833. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  12834. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  12835. * The HemisphericLight can't cast shadows.
  12836. * Documentation : https://doc.babylonjs.com/babylon101/lights
  12837. * @param name The friendly name of the light
  12838. * @param direction The direction of the light reflection
  12839. * @param scene The scene the light belongs to
  12840. */
  12841. constructor(name: string, direction: Vector3, scene: Scene);
  12842. protected _buildUniformLayout(): void;
  12843. /**
  12844. * Returns the string "HemisphericLight".
  12845. * @return The class name
  12846. */
  12847. getClassName(): string;
  12848. /**
  12849. * Sets the HemisphericLight direction towards the passed target (Vector3).
  12850. * Returns the updated direction.
  12851. * @param target The target the direction should point to
  12852. * @return The computed direction
  12853. */
  12854. setDirectionToTarget(target: Vector3): Vector3;
  12855. /**
  12856. * Returns the shadow generator associated to the light.
  12857. * @returns Always null for hemispheric lights because it does not support shadows.
  12858. */
  12859. getShadowGenerator(): Nullable<IShadowGenerator>;
  12860. /**
  12861. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  12862. * @param effect The effect to update
  12863. * @param lightIndex The index of the light in the effect to update
  12864. * @returns The hemispheric light
  12865. */
  12866. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  12867. /**
  12868. * Computes the world matrix of the node
  12869. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  12870. * @param useWasUpdatedFlag defines a reserved property
  12871. * @returns the world matrix
  12872. */
  12873. computeWorldMatrix(): Matrix;
  12874. /**
  12875. * Returns the integer 3.
  12876. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12877. */
  12878. getTypeID(): number;
  12879. /**
  12880. * Prepares the list of defines specific to the light type.
  12881. * @param defines the list of defines
  12882. * @param lightIndex defines the index of the light for the effect
  12883. */
  12884. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12885. }
  12886. }
  12887. declare module BABYLON {
  12888. /**
  12889. * This represents all the required metrics to create a VR camera.
  12890. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  12891. */
  12892. export class VRCameraMetrics {
  12893. /**
  12894. * Define the horizontal resolution off the screen.
  12895. */
  12896. hResolution: number;
  12897. /**
  12898. * Define the vertical resolution off the screen.
  12899. */
  12900. vResolution: number;
  12901. /**
  12902. * Define the horizontal screen size.
  12903. */
  12904. hScreenSize: number;
  12905. /**
  12906. * Define the vertical screen size.
  12907. */
  12908. vScreenSize: number;
  12909. /**
  12910. * Define the vertical screen center position.
  12911. */
  12912. vScreenCenter: number;
  12913. /**
  12914. * Define the distance of the eyes to the screen.
  12915. */
  12916. eyeToScreenDistance: number;
  12917. /**
  12918. * Define the distance between both lenses
  12919. */
  12920. lensSeparationDistance: number;
  12921. /**
  12922. * Define the distance between both viewer's eyes.
  12923. */
  12924. interpupillaryDistance: number;
  12925. /**
  12926. * Define the distortion factor of the VR postprocess.
  12927. * Please, touch with care.
  12928. */
  12929. distortionK: number[];
  12930. /**
  12931. * Define the chromatic aberration correction factors for the VR post process.
  12932. */
  12933. chromaAbCorrection: number[];
  12934. /**
  12935. * Define the scale factor of the post process.
  12936. * The smaller the better but the slower.
  12937. */
  12938. postProcessScaleFactor: number;
  12939. /**
  12940. * Define an offset for the lens center.
  12941. */
  12942. lensCenterOffset: number;
  12943. /**
  12944. * Define if the current vr camera should compensate the distortion of the lense or not.
  12945. */
  12946. compensateDistortion: boolean;
  12947. /**
  12948. * Defines if multiview should be enabled when rendering (Default: false)
  12949. */
  12950. multiviewEnabled: boolean;
  12951. /**
  12952. * Gets the rendering aspect ratio based on the provided resolutions.
  12953. */
  12954. readonly aspectRatio: number;
  12955. /**
  12956. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  12957. */
  12958. readonly aspectRatioFov: number;
  12959. /**
  12960. * @hidden
  12961. */
  12962. readonly leftHMatrix: Matrix;
  12963. /**
  12964. * @hidden
  12965. */
  12966. readonly rightHMatrix: Matrix;
  12967. /**
  12968. * @hidden
  12969. */
  12970. readonly leftPreViewMatrix: Matrix;
  12971. /**
  12972. * @hidden
  12973. */
  12974. readonly rightPreViewMatrix: Matrix;
  12975. /**
  12976. * Get the default VRMetrics based on the most generic setup.
  12977. * @returns the default vr metrics
  12978. */
  12979. static GetDefault(): VRCameraMetrics;
  12980. }
  12981. }
  12982. declare module BABYLON {
  12983. /** @hidden */
  12984. export var vrDistortionCorrectionPixelShader: {
  12985. name: string;
  12986. shader: string;
  12987. };
  12988. }
  12989. declare module BABYLON {
  12990. /**
  12991. * VRDistortionCorrectionPostProcess used for mobile VR
  12992. */
  12993. export class VRDistortionCorrectionPostProcess extends PostProcess {
  12994. private _isRightEye;
  12995. private _distortionFactors;
  12996. private _postProcessScaleFactor;
  12997. private _lensCenterOffset;
  12998. private _scaleIn;
  12999. private _scaleFactor;
  13000. private _lensCenter;
  13001. /**
  13002. * Initializes the VRDistortionCorrectionPostProcess
  13003. * @param name The name of the effect.
  13004. * @param camera The camera to apply the render pass to.
  13005. * @param isRightEye If this is for the right eye distortion
  13006. * @param vrMetrics All the required metrics for the VR camera
  13007. */
  13008. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  13009. }
  13010. /**
  13011. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  13012. * This will not be used for webXR as it supports displaying texture arrays directly
  13013. */
  13014. export class VRMultiviewToSingleview extends PostProcess {
  13015. /**
  13016. * Initializes a VRMultiviewToSingleview
  13017. * @param name name of the post process
  13018. * @param camera camera to be applied to
  13019. * @param scaleFactor scaling factor to the size of the output texture
  13020. */
  13021. constructor(name: string, camera: Camera, scaleFactor: number);
  13022. }
  13023. }
  13024. declare module BABYLON {
  13025. /**
  13026. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  13027. * IMPORTANT!! The data is right-hand data.
  13028. * @export
  13029. * @interface DevicePose
  13030. */
  13031. export interface DevicePose {
  13032. /**
  13033. * The position of the device, values in array are [x,y,z].
  13034. */
  13035. readonly position: Nullable<Float32Array>;
  13036. /**
  13037. * The linearVelocity of the device, values in array are [x,y,z].
  13038. */
  13039. readonly linearVelocity: Nullable<Float32Array>;
  13040. /**
  13041. * The linearAcceleration of the device, values in array are [x,y,z].
  13042. */
  13043. readonly linearAcceleration: Nullable<Float32Array>;
  13044. /**
  13045. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  13046. */
  13047. readonly orientation: Nullable<Float32Array>;
  13048. /**
  13049. * The angularVelocity of the device, values in array are [x,y,z].
  13050. */
  13051. readonly angularVelocity: Nullable<Float32Array>;
  13052. /**
  13053. * The angularAcceleration of the device, values in array are [x,y,z].
  13054. */
  13055. readonly angularAcceleration: Nullable<Float32Array>;
  13056. }
  13057. /**
  13058. * Interface representing a pose controlled object in Babylon.
  13059. * A pose controlled object has both regular pose values as well as pose values
  13060. * from an external device such as a VR head mounted display
  13061. */
  13062. export interface PoseControlled {
  13063. /**
  13064. * The position of the object in babylon space.
  13065. */
  13066. position: Vector3;
  13067. /**
  13068. * The rotation quaternion of the object in babylon space.
  13069. */
  13070. rotationQuaternion: Quaternion;
  13071. /**
  13072. * The position of the device in babylon space.
  13073. */
  13074. devicePosition?: Vector3;
  13075. /**
  13076. * The rotation quaternion of the device in babylon space.
  13077. */
  13078. deviceRotationQuaternion: Quaternion;
  13079. /**
  13080. * The raw pose coming from the device.
  13081. */
  13082. rawPose: Nullable<DevicePose>;
  13083. /**
  13084. * The scale of the device to be used when translating from device space to babylon space.
  13085. */
  13086. deviceScaleFactor: number;
  13087. /**
  13088. * Updates the poseControlled values based on the input device pose.
  13089. * @param poseData the pose data to update the object with
  13090. */
  13091. updateFromDevice(poseData: DevicePose): void;
  13092. }
  13093. /**
  13094. * Set of options to customize the webVRCamera
  13095. */
  13096. export interface WebVROptions {
  13097. /**
  13098. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  13099. */
  13100. trackPosition?: boolean;
  13101. /**
  13102. * Sets the scale of the vrDevice in babylon space. (default: 1)
  13103. */
  13104. positionScale?: number;
  13105. /**
  13106. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  13107. */
  13108. displayName?: string;
  13109. /**
  13110. * Should the native controller meshes be initialized. (default: true)
  13111. */
  13112. controllerMeshes?: boolean;
  13113. /**
  13114. * Creating a default HemiLight only on controllers. (default: true)
  13115. */
  13116. defaultLightingOnControllers?: boolean;
  13117. /**
  13118. * If you don't want to use the default VR button of the helper. (default: false)
  13119. */
  13120. useCustomVRButton?: boolean;
  13121. /**
  13122. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  13123. */
  13124. customVRButton?: HTMLButtonElement;
  13125. /**
  13126. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  13127. */
  13128. rayLength?: number;
  13129. /**
  13130. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  13131. */
  13132. defaultHeight?: number;
  13133. /**
  13134. * If multiview should be used if availible (default: false)
  13135. */
  13136. useMultiview?: boolean;
  13137. }
  13138. /**
  13139. * This represents a WebVR camera.
  13140. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  13141. * @example http://doc.babylonjs.com/how_to/webvr_camera
  13142. */
  13143. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  13144. private webVROptions;
  13145. /**
  13146. * @hidden
  13147. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  13148. */
  13149. _vrDevice: any;
  13150. /**
  13151. * The rawPose of the vrDevice.
  13152. */
  13153. rawPose: Nullable<DevicePose>;
  13154. private _onVREnabled;
  13155. private _specsVersion;
  13156. private _attached;
  13157. private _frameData;
  13158. protected _descendants: Array<Node>;
  13159. private _deviceRoomPosition;
  13160. /** @hidden */
  13161. _deviceRoomRotationQuaternion: Quaternion;
  13162. private _standingMatrix;
  13163. /**
  13164. * Represents device position in babylon space.
  13165. */
  13166. devicePosition: Vector3;
  13167. /**
  13168. * Represents device rotation in babylon space.
  13169. */
  13170. deviceRotationQuaternion: Quaternion;
  13171. /**
  13172. * The scale of the device to be used when translating from device space to babylon space.
  13173. */
  13174. deviceScaleFactor: number;
  13175. private _deviceToWorld;
  13176. private _worldToDevice;
  13177. /**
  13178. * References to the webVR controllers for the vrDevice.
  13179. */
  13180. controllers: Array<WebVRController>;
  13181. /**
  13182. * Emits an event when a controller is attached.
  13183. */
  13184. onControllersAttachedObservable: Observable<WebVRController[]>;
  13185. /**
  13186. * Emits an event when a controller's mesh has been loaded;
  13187. */
  13188. onControllerMeshLoadedObservable: Observable<WebVRController>;
  13189. /**
  13190. * Emits an event when the HMD's pose has been updated.
  13191. */
  13192. onPoseUpdatedFromDeviceObservable: Observable<any>;
  13193. private _poseSet;
  13194. /**
  13195. * If the rig cameras be used as parent instead of this camera.
  13196. */
  13197. rigParenting: boolean;
  13198. private _lightOnControllers;
  13199. private _defaultHeight?;
  13200. /**
  13201. * Instantiates a WebVRFreeCamera.
  13202. * @param name The name of the WebVRFreeCamera
  13203. * @param position The starting anchor position for the camera
  13204. * @param scene The scene the camera belongs to
  13205. * @param webVROptions a set of customizable options for the webVRCamera
  13206. */
  13207. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  13208. /**
  13209. * Gets the device distance from the ground in meters.
  13210. * @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.
  13211. */
  13212. deviceDistanceToRoomGround(): number;
  13213. /**
  13214. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13215. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  13216. */
  13217. useStandingMatrix(callback?: (bool: boolean) => void): void;
  13218. /**
  13219. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13220. * @returns A promise with a boolean set to if the standing matrix is supported.
  13221. */
  13222. useStandingMatrixAsync(): Promise<boolean>;
  13223. /**
  13224. * Disposes the camera
  13225. */
  13226. dispose(): void;
  13227. /**
  13228. * Gets a vrController by name.
  13229. * @param name The name of the controller to retreive
  13230. * @returns the controller matching the name specified or null if not found
  13231. */
  13232. getControllerByName(name: string): Nullable<WebVRController>;
  13233. private _leftController;
  13234. /**
  13235. * The controller corrisponding to the users left hand.
  13236. */
  13237. readonly leftController: Nullable<WebVRController>;
  13238. private _rightController;
  13239. /**
  13240. * The controller corrisponding to the users right hand.
  13241. */
  13242. readonly rightController: Nullable<WebVRController>;
  13243. /**
  13244. * Casts a ray forward from the vrCamera's gaze.
  13245. * @param length Length of the ray (default: 100)
  13246. * @returns the ray corrisponding to the gaze
  13247. */
  13248. getForwardRay(length?: number): Ray;
  13249. /**
  13250. * @hidden
  13251. * Updates the camera based on device's frame data
  13252. */
  13253. _checkInputs(): void;
  13254. /**
  13255. * Updates the poseControlled values based on the input device pose.
  13256. * @param poseData Pose coming from the device
  13257. */
  13258. updateFromDevice(poseData: DevicePose): void;
  13259. private _htmlElementAttached;
  13260. private _detachIfAttached;
  13261. /**
  13262. * WebVR's attach control will start broadcasting frames to the device.
  13263. * Note that in certain browsers (chrome for example) this function must be called
  13264. * within a user-interaction callback. Example:
  13265. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  13266. *
  13267. * @param element html element to attach the vrDevice to
  13268. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  13269. */
  13270. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  13271. /**
  13272. * Detaches the camera from the html element and disables VR
  13273. *
  13274. * @param element html element to detach from
  13275. */
  13276. detachControl(element: HTMLElement): void;
  13277. /**
  13278. * @returns the name of this class
  13279. */
  13280. getClassName(): string;
  13281. /**
  13282. * Calls resetPose on the vrDisplay
  13283. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  13284. */
  13285. resetToCurrentRotation(): void;
  13286. /**
  13287. * @hidden
  13288. * Updates the rig cameras (left and right eye)
  13289. */
  13290. _updateRigCameras(): void;
  13291. private _workingVector;
  13292. private _oneVector;
  13293. private _workingMatrix;
  13294. private updateCacheCalled;
  13295. private _correctPositionIfNotTrackPosition;
  13296. /**
  13297. * @hidden
  13298. * Updates the cached values of the camera
  13299. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  13300. */
  13301. _updateCache(ignoreParentClass?: boolean): void;
  13302. /**
  13303. * @hidden
  13304. * Get current device position in babylon world
  13305. */
  13306. _computeDevicePosition(): void;
  13307. /**
  13308. * Updates the current device position and rotation in the babylon world
  13309. */
  13310. update(): void;
  13311. /**
  13312. * @hidden
  13313. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  13314. * @returns an identity matrix
  13315. */
  13316. _getViewMatrix(): Matrix;
  13317. private _tmpMatrix;
  13318. /**
  13319. * This function is called by the two RIG cameras.
  13320. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  13321. * @hidden
  13322. */
  13323. _getWebVRViewMatrix(): Matrix;
  13324. /** @hidden */
  13325. _getWebVRProjectionMatrix(): Matrix;
  13326. private _onGamepadConnectedObserver;
  13327. private _onGamepadDisconnectedObserver;
  13328. private _updateCacheWhenTrackingDisabledObserver;
  13329. /**
  13330. * Initializes the controllers and their meshes
  13331. */
  13332. initControllers(): void;
  13333. }
  13334. }
  13335. declare module BABYLON {
  13336. /**
  13337. * Size options for a post process
  13338. */
  13339. export type PostProcessOptions = {
  13340. width: number;
  13341. height: number;
  13342. };
  13343. /**
  13344. * PostProcess can be used to apply a shader to a texture after it has been rendered
  13345. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13346. */
  13347. export class PostProcess {
  13348. /** Name of the PostProcess. */
  13349. name: string;
  13350. /**
  13351. * Gets or sets the unique id of the post process
  13352. */
  13353. uniqueId: number;
  13354. /**
  13355. * Width of the texture to apply the post process on
  13356. */
  13357. width: number;
  13358. /**
  13359. * Height of the texture to apply the post process on
  13360. */
  13361. height: number;
  13362. /**
  13363. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  13364. * @hidden
  13365. */
  13366. _outputTexture: Nullable<InternalTexture>;
  13367. /**
  13368. * Sampling mode used by the shader
  13369. * See https://doc.babylonjs.com/classes/3.1/texture
  13370. */
  13371. renderTargetSamplingMode: number;
  13372. /**
  13373. * Clear color to use when screen clearing
  13374. */
  13375. clearColor: Color4;
  13376. /**
  13377. * If the buffer needs to be cleared before applying the post process. (default: true)
  13378. * Should be set to false if shader will overwrite all previous pixels.
  13379. */
  13380. autoClear: boolean;
  13381. /**
  13382. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  13383. */
  13384. alphaMode: number;
  13385. /**
  13386. * Sets the setAlphaBlendConstants of the babylon engine
  13387. */
  13388. alphaConstants: Color4;
  13389. /**
  13390. * Animations to be used for the post processing
  13391. */
  13392. animations: Animation[];
  13393. /**
  13394. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  13395. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  13396. */
  13397. enablePixelPerfectMode: boolean;
  13398. /**
  13399. * Force the postprocess to be applied without taking in account viewport
  13400. */
  13401. forceFullscreenViewport: boolean;
  13402. /**
  13403. * List of inspectable custom properties (used by the Inspector)
  13404. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13405. */
  13406. inspectableCustomProperties: IInspectable[];
  13407. /**
  13408. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  13409. *
  13410. * | Value | Type | Description |
  13411. * | ----- | ----------------------------------- | ----------- |
  13412. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  13413. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  13414. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  13415. *
  13416. */
  13417. scaleMode: number;
  13418. /**
  13419. * Force textures to be a power of two (default: false)
  13420. */
  13421. alwaysForcePOT: boolean;
  13422. private _samples;
  13423. /**
  13424. * Number of sample textures (default: 1)
  13425. */
  13426. samples: number;
  13427. /**
  13428. * Modify the scale of the post process to be the same as the viewport (default: false)
  13429. */
  13430. adaptScaleToCurrentViewport: boolean;
  13431. private _camera;
  13432. private _scene;
  13433. private _engine;
  13434. private _options;
  13435. private _reusable;
  13436. private _textureType;
  13437. /**
  13438. * Smart array of input and output textures for the post process.
  13439. * @hidden
  13440. */
  13441. _textures: SmartArray<InternalTexture>;
  13442. /**
  13443. * The index in _textures that corresponds to the output texture.
  13444. * @hidden
  13445. */
  13446. _currentRenderTextureInd: number;
  13447. private _effect;
  13448. private _samplers;
  13449. private _fragmentUrl;
  13450. private _vertexUrl;
  13451. private _parameters;
  13452. private _scaleRatio;
  13453. protected _indexParameters: any;
  13454. private _shareOutputWithPostProcess;
  13455. private _texelSize;
  13456. private _forcedOutputTexture;
  13457. /**
  13458. * Returns the fragment url or shader name used in the post process.
  13459. * @returns the fragment url or name in the shader store.
  13460. */
  13461. getEffectName(): string;
  13462. /**
  13463. * An event triggered when the postprocess is activated.
  13464. */
  13465. onActivateObservable: Observable<Camera>;
  13466. private _onActivateObserver;
  13467. /**
  13468. * A function that is added to the onActivateObservable
  13469. */
  13470. onActivate: Nullable<(camera: Camera) => void>;
  13471. /**
  13472. * An event triggered when the postprocess changes its size.
  13473. */
  13474. onSizeChangedObservable: Observable<PostProcess>;
  13475. private _onSizeChangedObserver;
  13476. /**
  13477. * A function that is added to the onSizeChangedObservable
  13478. */
  13479. onSizeChanged: (postProcess: PostProcess) => void;
  13480. /**
  13481. * An event triggered when the postprocess applies its effect.
  13482. */
  13483. onApplyObservable: Observable<Effect>;
  13484. private _onApplyObserver;
  13485. /**
  13486. * A function that is added to the onApplyObservable
  13487. */
  13488. onApply: (effect: Effect) => void;
  13489. /**
  13490. * An event triggered before rendering the postprocess
  13491. */
  13492. onBeforeRenderObservable: Observable<Effect>;
  13493. private _onBeforeRenderObserver;
  13494. /**
  13495. * A function that is added to the onBeforeRenderObservable
  13496. */
  13497. onBeforeRender: (effect: Effect) => void;
  13498. /**
  13499. * An event triggered after rendering the postprocess
  13500. */
  13501. onAfterRenderObservable: Observable<Effect>;
  13502. private _onAfterRenderObserver;
  13503. /**
  13504. * A function that is added to the onAfterRenderObservable
  13505. */
  13506. onAfterRender: (efect: Effect) => void;
  13507. /**
  13508. * 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
  13509. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  13510. */
  13511. inputTexture: InternalTexture;
  13512. /**
  13513. * Gets the camera which post process is applied to.
  13514. * @returns The camera the post process is applied to.
  13515. */
  13516. getCamera(): Camera;
  13517. /**
  13518. * Gets the texel size of the postprocess.
  13519. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  13520. */
  13521. readonly texelSize: Vector2;
  13522. /**
  13523. * Creates a new instance PostProcess
  13524. * @param name The name of the PostProcess.
  13525. * @param fragmentUrl The url of the fragment shader to be used.
  13526. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  13527. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  13528. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  13529. * @param camera The camera to apply the render pass to.
  13530. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  13531. * @param engine The engine which the post process will be applied. (default: current engine)
  13532. * @param reusable If the post process can be reused on the same frame. (default: false)
  13533. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  13534. * @param textureType Type of textures used when performing the post process. (default: 0)
  13535. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  13536. * @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
  13537. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  13538. */
  13539. constructor(
  13540. /** Name of the PostProcess. */
  13541. 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);
  13542. /**
  13543. * Gets a string idenfifying the name of the class
  13544. * @returns "PostProcess" string
  13545. */
  13546. getClassName(): string;
  13547. /**
  13548. * Gets the engine which this post process belongs to.
  13549. * @returns The engine the post process was enabled with.
  13550. */
  13551. getEngine(): Engine;
  13552. /**
  13553. * The effect that is created when initializing the post process.
  13554. * @returns The created effect corrisponding the the postprocess.
  13555. */
  13556. getEffect(): Effect;
  13557. /**
  13558. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  13559. * @param postProcess The post process to share the output with.
  13560. * @returns This post process.
  13561. */
  13562. shareOutputWith(postProcess: PostProcess): PostProcess;
  13563. /**
  13564. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  13565. * This should be called if the post process that shares output with this post process is disabled/disposed.
  13566. */
  13567. useOwnOutput(): void;
  13568. /**
  13569. * Updates the effect with the current post process compile time values and recompiles the shader.
  13570. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  13571. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  13572. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  13573. * @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
  13574. * @param onCompiled Called when the shader has been compiled.
  13575. * @param onError Called if there is an error when compiling a shader.
  13576. */
  13577. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  13578. /**
  13579. * The post process is reusable if it can be used multiple times within one frame.
  13580. * @returns If the post process is reusable
  13581. */
  13582. isReusable(): boolean;
  13583. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  13584. markTextureDirty(): void;
  13585. /**
  13586. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  13587. * 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.
  13588. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  13589. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  13590. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  13591. * @returns The target texture that was bound to be written to.
  13592. */
  13593. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  13594. /**
  13595. * If the post process is supported.
  13596. */
  13597. readonly isSupported: boolean;
  13598. /**
  13599. * The aspect ratio of the output texture.
  13600. */
  13601. readonly aspectRatio: number;
  13602. /**
  13603. * Get a value indicating if the post-process is ready to be used
  13604. * @returns true if the post-process is ready (shader is compiled)
  13605. */
  13606. isReady(): boolean;
  13607. /**
  13608. * Binds all textures and uniforms to the shader, this will be run on every pass.
  13609. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  13610. */
  13611. apply(): Nullable<Effect>;
  13612. private _disposeTextures;
  13613. /**
  13614. * Disposes the post process.
  13615. * @param camera The camera to dispose the post process on.
  13616. */
  13617. dispose(camera?: Camera): void;
  13618. }
  13619. }
  13620. declare module BABYLON {
  13621. /**
  13622. * PostProcessManager is used to manage one or more post processes or post process pipelines
  13623. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13624. */
  13625. export class PostProcessManager {
  13626. private _scene;
  13627. private _indexBuffer;
  13628. private _vertexBuffers;
  13629. /**
  13630. * Creates a new instance PostProcess
  13631. * @param scene The scene that the post process is associated with.
  13632. */
  13633. constructor(scene: Scene);
  13634. private _prepareBuffers;
  13635. private _buildIndexBuffer;
  13636. /**
  13637. * Rebuilds the vertex buffers of the manager.
  13638. * @hidden
  13639. */
  13640. _rebuild(): void;
  13641. /**
  13642. * Prepares a frame to be run through a post process.
  13643. * @param sourceTexture The input texture to the post procesess. (default: null)
  13644. * @param postProcesses An array of post processes to be run. (default: null)
  13645. * @returns True if the post processes were able to be run.
  13646. * @hidden
  13647. */
  13648. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  13649. /**
  13650. * Manually render a set of post processes to a texture.
  13651. * @param postProcesses An array of post processes to be run.
  13652. * @param targetTexture The target texture to render to.
  13653. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  13654. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  13655. * @param lodLevel defines which lod of the texture to render to
  13656. */
  13657. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  13658. /**
  13659. * Finalize the result of the output of the postprocesses.
  13660. * @param doNotPresent If true the result will not be displayed to the screen.
  13661. * @param targetTexture The target texture to render to.
  13662. * @param faceIndex The index of the face to bind the target texture to.
  13663. * @param postProcesses The array of post processes to render.
  13664. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  13665. * @hidden
  13666. */
  13667. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  13668. /**
  13669. * Disposes of the post process manager.
  13670. */
  13671. dispose(): void;
  13672. }
  13673. }
  13674. declare module BABYLON {
  13675. interface AbstractScene {
  13676. /**
  13677. * The list of layers (background and foreground) of the scene
  13678. */
  13679. layers: Array<Layer>;
  13680. }
  13681. /**
  13682. * Defines the layer scene component responsible to manage any layers
  13683. * in a given scene.
  13684. */
  13685. export class LayerSceneComponent implements ISceneComponent {
  13686. /**
  13687. * The component name helpfull to identify the component in the list of scene components.
  13688. */
  13689. readonly name: string;
  13690. /**
  13691. * The scene the component belongs to.
  13692. */
  13693. scene: Scene;
  13694. private _engine;
  13695. /**
  13696. * Creates a new instance of the component for the given scene
  13697. * @param scene Defines the scene to register the component in
  13698. */
  13699. constructor(scene: Scene);
  13700. /**
  13701. * Registers the component in a given scene
  13702. */
  13703. register(): void;
  13704. /**
  13705. * Rebuilds the elements related to this component in case of
  13706. * context lost for instance.
  13707. */
  13708. rebuild(): void;
  13709. /**
  13710. * Disposes the component and the associated ressources.
  13711. */
  13712. dispose(): void;
  13713. private _draw;
  13714. private _drawCameraPredicate;
  13715. private _drawCameraBackground;
  13716. private _drawCameraForeground;
  13717. private _drawRenderTargetPredicate;
  13718. private _drawRenderTargetBackground;
  13719. private _drawRenderTargetForeground;
  13720. }
  13721. }
  13722. declare module BABYLON {
  13723. /** @hidden */
  13724. export var layerPixelShader: {
  13725. name: string;
  13726. shader: string;
  13727. };
  13728. }
  13729. declare module BABYLON {
  13730. /** @hidden */
  13731. export var layerVertexShader: {
  13732. name: string;
  13733. shader: string;
  13734. };
  13735. }
  13736. declare module BABYLON {
  13737. /**
  13738. * This represents a full screen 2d layer.
  13739. * This can be useful to display a picture in the background of your scene for instance.
  13740. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13741. */
  13742. export class Layer {
  13743. /**
  13744. * Define the name of the layer.
  13745. */
  13746. name: string;
  13747. /**
  13748. * Define the texture the layer should display.
  13749. */
  13750. texture: Nullable<Texture>;
  13751. /**
  13752. * Is the layer in background or foreground.
  13753. */
  13754. isBackground: boolean;
  13755. /**
  13756. * Define the color of the layer (instead of texture).
  13757. */
  13758. color: Color4;
  13759. /**
  13760. * Define the scale of the layer in order to zoom in out of the texture.
  13761. */
  13762. scale: Vector2;
  13763. /**
  13764. * Define an offset for the layer in order to shift the texture.
  13765. */
  13766. offset: Vector2;
  13767. /**
  13768. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  13769. */
  13770. alphaBlendingMode: number;
  13771. /**
  13772. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  13773. * Alpha test will not mix with the background color in case of transparency.
  13774. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  13775. */
  13776. alphaTest: boolean;
  13777. /**
  13778. * Define a mask to restrict the layer to only some of the scene cameras.
  13779. */
  13780. layerMask: number;
  13781. /**
  13782. * Define the list of render target the layer is visible into.
  13783. */
  13784. renderTargetTextures: RenderTargetTexture[];
  13785. /**
  13786. * Define if the layer is only used in renderTarget or if it also
  13787. * renders in the main frame buffer of the canvas.
  13788. */
  13789. renderOnlyInRenderTargetTextures: boolean;
  13790. private _scene;
  13791. private _vertexBuffers;
  13792. private _indexBuffer;
  13793. private _effect;
  13794. private _alphaTestEffect;
  13795. /**
  13796. * An event triggered when the layer is disposed.
  13797. */
  13798. onDisposeObservable: Observable<Layer>;
  13799. private _onDisposeObserver;
  13800. /**
  13801. * Back compatibility with callback before the onDisposeObservable existed.
  13802. * The set callback will be triggered when the layer has been disposed.
  13803. */
  13804. onDispose: () => void;
  13805. /**
  13806. * An event triggered before rendering the scene
  13807. */
  13808. onBeforeRenderObservable: Observable<Layer>;
  13809. private _onBeforeRenderObserver;
  13810. /**
  13811. * Back compatibility with callback before the onBeforeRenderObservable existed.
  13812. * The set callback will be triggered just before rendering the layer.
  13813. */
  13814. onBeforeRender: () => void;
  13815. /**
  13816. * An event triggered after rendering the scene
  13817. */
  13818. onAfterRenderObservable: Observable<Layer>;
  13819. private _onAfterRenderObserver;
  13820. /**
  13821. * Back compatibility with callback before the onAfterRenderObservable existed.
  13822. * The set callback will be triggered just after rendering the layer.
  13823. */
  13824. onAfterRender: () => void;
  13825. /**
  13826. * Instantiates a new layer.
  13827. * This represents a full screen 2d layer.
  13828. * This can be useful to display a picture in the background of your scene for instance.
  13829. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13830. * @param name Define the name of the layer in the scene
  13831. * @param imgUrl Define the url of the texture to display in the layer
  13832. * @param scene Define the scene the layer belongs to
  13833. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  13834. * @param color Defines a color for the layer
  13835. */
  13836. constructor(
  13837. /**
  13838. * Define the name of the layer.
  13839. */
  13840. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  13841. private _createIndexBuffer;
  13842. /** @hidden */
  13843. _rebuild(): void;
  13844. /**
  13845. * Renders the layer in the scene.
  13846. */
  13847. render(): void;
  13848. /**
  13849. * Disposes and releases the associated ressources.
  13850. */
  13851. dispose(): void;
  13852. }
  13853. }
  13854. declare module BABYLON {
  13855. interface AbstractScene {
  13856. /**
  13857. * The list of procedural textures added to the scene
  13858. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13859. */
  13860. proceduralTextures: Array<ProceduralTexture>;
  13861. }
  13862. /**
  13863. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  13864. * in a given scene.
  13865. */
  13866. export class ProceduralTextureSceneComponent implements ISceneComponent {
  13867. /**
  13868. * The component name helpfull to identify the component in the list of scene components.
  13869. */
  13870. readonly name: string;
  13871. /**
  13872. * The scene the component belongs to.
  13873. */
  13874. scene: Scene;
  13875. /**
  13876. * Creates a new instance of the component for the given scene
  13877. * @param scene Defines the scene to register the component in
  13878. */
  13879. constructor(scene: Scene);
  13880. /**
  13881. * Registers the component in a given scene
  13882. */
  13883. register(): void;
  13884. /**
  13885. * Rebuilds the elements related to this component in case of
  13886. * context lost for instance.
  13887. */
  13888. rebuild(): void;
  13889. /**
  13890. * Disposes the component and the associated ressources.
  13891. */
  13892. dispose(): void;
  13893. private _beforeClear;
  13894. }
  13895. }
  13896. declare module BABYLON {
  13897. /** @hidden */
  13898. export var proceduralVertexShader: {
  13899. name: string;
  13900. shader: string;
  13901. };
  13902. }
  13903. declare module BABYLON {
  13904. /**
  13905. * 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 calmpler' images.
  13906. * This is the base class of any Procedural texture and contains most of the shareable code.
  13907. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13908. */
  13909. export class ProceduralTexture extends Texture {
  13910. isCube: boolean;
  13911. /**
  13912. * Define if the texture is enabled or not (disabled texture will not render)
  13913. */
  13914. isEnabled: boolean;
  13915. /**
  13916. * Define if the texture must be cleared before rendering (default is true)
  13917. */
  13918. autoClear: boolean;
  13919. /**
  13920. * Callback called when the texture is generated
  13921. */
  13922. onGenerated: () => void;
  13923. /**
  13924. * Event raised when the texture is generated
  13925. */
  13926. onGeneratedObservable: Observable<ProceduralTexture>;
  13927. /** @hidden */
  13928. _generateMipMaps: boolean;
  13929. /** @hidden **/
  13930. _effect: Effect;
  13931. /** @hidden */
  13932. _textures: {
  13933. [key: string]: Texture;
  13934. };
  13935. private _size;
  13936. private _currentRefreshId;
  13937. private _refreshRate;
  13938. private _vertexBuffers;
  13939. private _indexBuffer;
  13940. private _uniforms;
  13941. private _samplers;
  13942. private _fragment;
  13943. private _floats;
  13944. private _ints;
  13945. private _floatsArrays;
  13946. private _colors3;
  13947. private _colors4;
  13948. private _vectors2;
  13949. private _vectors3;
  13950. private _matrices;
  13951. private _fallbackTexture;
  13952. private _fallbackTextureUsed;
  13953. private _engine;
  13954. private _cachedDefines;
  13955. private _contentUpdateId;
  13956. private _contentData;
  13957. /**
  13958. * Instantiates a new procedural texture.
  13959. * 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.
  13960. * This is the base class of any Procedural texture and contains most of the shareable code.
  13961. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13962. * @param name Define the name of the texture
  13963. * @param size Define the size of the texture to create
  13964. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  13965. * @param scene Define the scene the texture belongs to
  13966. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  13967. * @param generateMipMaps Define if the texture should creates mip maps or not
  13968. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  13969. */
  13970. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  13971. /**
  13972. * The effect that is created when initializing the post process.
  13973. * @returns The created effect corrisponding the the postprocess.
  13974. */
  13975. getEffect(): Effect;
  13976. /**
  13977. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  13978. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  13979. */
  13980. getContent(): Nullable<ArrayBufferView>;
  13981. private _createIndexBuffer;
  13982. /** @hidden */
  13983. _rebuild(): void;
  13984. /**
  13985. * Resets the texture in order to recreate its associated resources.
  13986. * This can be called in case of context loss
  13987. */
  13988. reset(): void;
  13989. protected _getDefines(): string;
  13990. /**
  13991. * Is the texture ready to be used ? (rendered at least once)
  13992. * @returns true if ready, otherwise, false.
  13993. */
  13994. isReady(): boolean;
  13995. /**
  13996. * Resets the refresh counter of the texture and start bak from scratch.
  13997. * Could be useful to regenerate the texture if it is setup to render only once.
  13998. */
  13999. resetRefreshCounter(): void;
  14000. /**
  14001. * Set the fragment shader to use in order to render the texture.
  14002. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  14003. */
  14004. setFragment(fragment: any): void;
  14005. /**
  14006. * Define the refresh rate of the texture or the rendering frequency.
  14007. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14008. */
  14009. refreshRate: number;
  14010. /** @hidden */
  14011. _shouldRender(): boolean;
  14012. /**
  14013. * Get the size the texture is rendering at.
  14014. * @returns the size (texture is always squared)
  14015. */
  14016. getRenderSize(): number;
  14017. /**
  14018. * Resize the texture to new value.
  14019. * @param size Define the new size the texture should have
  14020. * @param generateMipMaps Define whether the new texture should create mip maps
  14021. */
  14022. resize(size: number, generateMipMaps: boolean): void;
  14023. private _checkUniform;
  14024. /**
  14025. * Set a texture in the shader program used to render.
  14026. * @param name Define the name of the uniform samplers as defined in the shader
  14027. * @param texture Define the texture to bind to this sampler
  14028. * @return the texture itself allowing "fluent" like uniform updates
  14029. */
  14030. setTexture(name: string, texture: Texture): ProceduralTexture;
  14031. /**
  14032. * Set a float in the shader.
  14033. * @param name Define the name of the uniform as defined in the shader
  14034. * @param value Define the value to give to the uniform
  14035. * @return the texture itself allowing "fluent" like uniform updates
  14036. */
  14037. setFloat(name: string, value: number): ProceduralTexture;
  14038. /**
  14039. * Set a int in the shader.
  14040. * @param name Define the name of the uniform as defined in the shader
  14041. * @param value Define the value to give to the uniform
  14042. * @return the texture itself allowing "fluent" like uniform updates
  14043. */
  14044. setInt(name: string, value: number): ProceduralTexture;
  14045. /**
  14046. * Set an array of floats in the shader.
  14047. * @param name Define the name of the uniform as defined in the shader
  14048. * @param value Define the value to give to the uniform
  14049. * @return the texture itself allowing "fluent" like uniform updates
  14050. */
  14051. setFloats(name: string, value: number[]): ProceduralTexture;
  14052. /**
  14053. * Set a vec3 in the shader from a Color3.
  14054. * @param name Define the name of the uniform as defined in the shader
  14055. * @param value Define the value to give to the uniform
  14056. * @return the texture itself allowing "fluent" like uniform updates
  14057. */
  14058. setColor3(name: string, value: Color3): ProceduralTexture;
  14059. /**
  14060. * Set a vec4 in the shader from a Color4.
  14061. * @param name Define the name of the uniform as defined in the shader
  14062. * @param value Define the value to give to the uniform
  14063. * @return the texture itself allowing "fluent" like uniform updates
  14064. */
  14065. setColor4(name: string, value: Color4): ProceduralTexture;
  14066. /**
  14067. * Set a vec2 in the shader from a Vector2.
  14068. * @param name Define the name of the uniform as defined in the shader
  14069. * @param value Define the value to give to the uniform
  14070. * @return the texture itself allowing "fluent" like uniform updates
  14071. */
  14072. setVector2(name: string, value: Vector2): ProceduralTexture;
  14073. /**
  14074. * Set a vec3 in the shader from a Vector3.
  14075. * @param name Define the name of the uniform as defined in the shader
  14076. * @param value Define the value to give to the uniform
  14077. * @return the texture itself allowing "fluent" like uniform updates
  14078. */
  14079. setVector3(name: string, value: Vector3): ProceduralTexture;
  14080. /**
  14081. * Set a mat4 in the shader from a MAtrix.
  14082. * @param name Define the name of the uniform as defined in the shader
  14083. * @param value Define the value to give to the uniform
  14084. * @return the texture itself allowing "fluent" like uniform updates
  14085. */
  14086. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14087. /**
  14088. * Render the texture to its associated render target.
  14089. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14090. */
  14091. render(useCameraPostProcess?: boolean): void;
  14092. /**
  14093. * Clone the texture.
  14094. * @returns the cloned texture
  14095. */
  14096. clone(): ProceduralTexture;
  14097. /**
  14098. * Dispose the texture and release its asoociated resources.
  14099. */
  14100. dispose(): void;
  14101. }
  14102. }
  14103. declare module BABYLON {
  14104. /**
  14105. * This represents the base class for particle system in Babylon.
  14106. * 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.
  14107. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14108. * @example https://doc.babylonjs.com/babylon101/particles
  14109. */
  14110. export class BaseParticleSystem {
  14111. /**
  14112. * Source color is added to the destination color without alpha affecting the result
  14113. */
  14114. static BLENDMODE_ONEONE: number;
  14115. /**
  14116. * Blend current color and particle color using particle’s alpha
  14117. */
  14118. static BLENDMODE_STANDARD: number;
  14119. /**
  14120. * Add current color and particle color multiplied by particle’s alpha
  14121. */
  14122. static BLENDMODE_ADD: number;
  14123. /**
  14124. * Multiply current color with particle color
  14125. */
  14126. static BLENDMODE_MULTIPLY: number;
  14127. /**
  14128. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14129. */
  14130. static BLENDMODE_MULTIPLYADD: number;
  14131. /**
  14132. * List of animations used by the particle system.
  14133. */
  14134. animations: Animation[];
  14135. /**
  14136. * The id of the Particle system.
  14137. */
  14138. id: string;
  14139. /**
  14140. * The friendly name of the Particle system.
  14141. */
  14142. name: string;
  14143. /**
  14144. * The rendering group used by the Particle system to chose when to render.
  14145. */
  14146. renderingGroupId: number;
  14147. /**
  14148. * The emitter represents the Mesh or position we are attaching the particle system to.
  14149. */
  14150. emitter: Nullable<AbstractMesh | Vector3>;
  14151. /**
  14152. * The maximum number of particles to emit per frame
  14153. */
  14154. emitRate: number;
  14155. /**
  14156. * If you want to launch only a few particles at once, that can be done, as well.
  14157. */
  14158. manualEmitCount: number;
  14159. /**
  14160. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14161. */
  14162. updateSpeed: number;
  14163. /**
  14164. * The amount of time the particle system is running (depends of the overall update speed).
  14165. */
  14166. targetStopDuration: number;
  14167. /**
  14168. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14169. */
  14170. disposeOnStop: boolean;
  14171. /**
  14172. * Minimum power of emitting particles.
  14173. */
  14174. minEmitPower: number;
  14175. /**
  14176. * Maximum power of emitting particles.
  14177. */
  14178. maxEmitPower: number;
  14179. /**
  14180. * Minimum life time of emitting particles.
  14181. */
  14182. minLifeTime: number;
  14183. /**
  14184. * Maximum life time of emitting particles.
  14185. */
  14186. maxLifeTime: number;
  14187. /**
  14188. * Minimum Size of emitting particles.
  14189. */
  14190. minSize: number;
  14191. /**
  14192. * Maximum Size of emitting particles.
  14193. */
  14194. maxSize: number;
  14195. /**
  14196. * Minimum scale of emitting particles on X axis.
  14197. */
  14198. minScaleX: number;
  14199. /**
  14200. * Maximum scale of emitting particles on X axis.
  14201. */
  14202. maxScaleX: number;
  14203. /**
  14204. * Minimum scale of emitting particles on Y axis.
  14205. */
  14206. minScaleY: number;
  14207. /**
  14208. * Maximum scale of emitting particles on Y axis.
  14209. */
  14210. maxScaleY: number;
  14211. /**
  14212. * Gets or sets the minimal initial rotation in radians.
  14213. */
  14214. minInitialRotation: number;
  14215. /**
  14216. * Gets or sets the maximal initial rotation in radians.
  14217. */
  14218. maxInitialRotation: number;
  14219. /**
  14220. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14221. */
  14222. minAngularSpeed: number;
  14223. /**
  14224. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14225. */
  14226. maxAngularSpeed: number;
  14227. /**
  14228. * The texture used to render each particle. (this can be a spritesheet)
  14229. */
  14230. particleTexture: Nullable<Texture>;
  14231. /**
  14232. * The layer mask we are rendering the particles through.
  14233. */
  14234. layerMask: number;
  14235. /**
  14236. * This can help using your own shader to render the particle system.
  14237. * The according effect will be created
  14238. */
  14239. customShader: any;
  14240. /**
  14241. * By default particle system starts as soon as they are created. This prevents the
  14242. * automatic start to happen and let you decide when to start emitting particles.
  14243. */
  14244. preventAutoStart: boolean;
  14245. private _noiseTexture;
  14246. /**
  14247. * Gets or sets a texture used to add random noise to particle positions
  14248. */
  14249. noiseTexture: Nullable<ProceduralTexture>;
  14250. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14251. noiseStrength: Vector3;
  14252. /**
  14253. * Callback triggered when the particle animation is ending.
  14254. */
  14255. onAnimationEnd: Nullable<() => void>;
  14256. /**
  14257. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14258. */
  14259. blendMode: number;
  14260. /**
  14261. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14262. * to override the particles.
  14263. */
  14264. forceDepthWrite: boolean;
  14265. /** 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 */
  14266. preWarmCycles: number;
  14267. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14268. preWarmStepOffset: number;
  14269. /**
  14270. * 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)
  14271. */
  14272. spriteCellChangeSpeed: number;
  14273. /**
  14274. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14275. */
  14276. startSpriteCellID: number;
  14277. /**
  14278. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14279. */
  14280. endSpriteCellID: number;
  14281. /**
  14282. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14283. */
  14284. spriteCellWidth: number;
  14285. /**
  14286. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14287. */
  14288. spriteCellHeight: number;
  14289. /**
  14290. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14291. */
  14292. spriteRandomStartCell: boolean;
  14293. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14294. translationPivot: Vector2;
  14295. /** @hidden */
  14296. protected _isAnimationSheetEnabled: boolean;
  14297. /**
  14298. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14299. */
  14300. beginAnimationOnStart: boolean;
  14301. /**
  14302. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14303. */
  14304. beginAnimationFrom: number;
  14305. /**
  14306. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14307. */
  14308. beginAnimationTo: number;
  14309. /**
  14310. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14311. */
  14312. beginAnimationLoop: boolean;
  14313. /**
  14314. * Gets or sets a world offset applied to all particles
  14315. */
  14316. worldOffset: Vector3;
  14317. /**
  14318. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14319. */
  14320. isAnimationSheetEnabled: boolean;
  14321. /**
  14322. * Get hosting scene
  14323. * @returns the scene
  14324. */
  14325. getScene(): Scene;
  14326. /**
  14327. * You can use gravity if you want to give an orientation to your particles.
  14328. */
  14329. gravity: Vector3;
  14330. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14331. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14332. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14333. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14334. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14335. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14336. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14337. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14338. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14339. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14340. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14341. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14342. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14343. /**
  14344. * Defines the delay in milliseconds before starting the system (0 by default)
  14345. */
  14346. startDelay: number;
  14347. /**
  14348. * Gets the current list of drag gradients.
  14349. * You must use addDragGradient and removeDragGradient to udpate this list
  14350. * @returns the list of drag gradients
  14351. */
  14352. getDragGradients(): Nullable<Array<FactorGradient>>;
  14353. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14354. limitVelocityDamping: number;
  14355. /**
  14356. * Gets the current list of limit velocity gradients.
  14357. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14358. * @returns the list of limit velocity gradients
  14359. */
  14360. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14361. /**
  14362. * Gets the current list of color gradients.
  14363. * You must use addColorGradient and removeColorGradient to udpate this list
  14364. * @returns the list of color gradients
  14365. */
  14366. getColorGradients(): Nullable<Array<ColorGradient>>;
  14367. /**
  14368. * Gets the current list of size gradients.
  14369. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14370. * @returns the list of size gradients
  14371. */
  14372. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14373. /**
  14374. * Gets the current list of color remap gradients.
  14375. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14376. * @returns the list of color remap gradients
  14377. */
  14378. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14379. /**
  14380. * Gets the current list of alpha remap gradients.
  14381. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14382. * @returns the list of alpha remap gradients
  14383. */
  14384. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14385. /**
  14386. * Gets the current list of life time gradients.
  14387. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14388. * @returns the list of life time gradients
  14389. */
  14390. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14391. /**
  14392. * Gets the current list of angular speed gradients.
  14393. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14394. * @returns the list of angular speed gradients
  14395. */
  14396. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14397. /**
  14398. * Gets the current list of velocity gradients.
  14399. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14400. * @returns the list of velocity gradients
  14401. */
  14402. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14403. /**
  14404. * Gets the current list of start size gradients.
  14405. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14406. * @returns the list of start size gradients
  14407. */
  14408. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14409. /**
  14410. * Gets the current list of emit rate gradients.
  14411. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14412. * @returns the list of emit rate gradients
  14413. */
  14414. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14415. /**
  14416. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14417. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14418. */
  14419. direction1: Vector3;
  14420. /**
  14421. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14422. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14423. */
  14424. direction2: Vector3;
  14425. /**
  14426. * 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.
  14427. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14428. */
  14429. minEmitBox: Vector3;
  14430. /**
  14431. * 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.
  14432. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14433. */
  14434. maxEmitBox: Vector3;
  14435. /**
  14436. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14437. */
  14438. color1: Color4;
  14439. /**
  14440. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14441. */
  14442. color2: Color4;
  14443. /**
  14444. * Color the particle will have at the end of its lifetime
  14445. */
  14446. colorDead: Color4;
  14447. /**
  14448. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  14449. */
  14450. textureMask: Color4;
  14451. /**
  14452. * The particle emitter type defines the emitter used by the particle system.
  14453. * It can be for example box, sphere, or cone...
  14454. */
  14455. particleEmitterType: IParticleEmitterType;
  14456. /** @hidden */
  14457. _isSubEmitter: boolean;
  14458. /**
  14459. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14460. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14461. */
  14462. billboardMode: number;
  14463. protected _isBillboardBased: boolean;
  14464. /**
  14465. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14466. */
  14467. isBillboardBased: boolean;
  14468. /**
  14469. * The scene the particle system belongs to.
  14470. */
  14471. protected _scene: Scene;
  14472. /**
  14473. * Local cache of defines for image processing.
  14474. */
  14475. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  14476. /**
  14477. * Default configuration related to image processing available in the standard Material.
  14478. */
  14479. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14480. /**
  14481. * Gets the image processing configuration used either in this material.
  14482. */
  14483. /**
  14484. * Sets the Default image processing configuration used either in the this material.
  14485. *
  14486. * If sets to null, the scene one is in use.
  14487. */
  14488. imageProcessingConfiguration: ImageProcessingConfiguration;
  14489. /**
  14490. * Attaches a new image processing configuration to the Standard Material.
  14491. * @param configuration
  14492. */
  14493. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14494. /** @hidden */
  14495. protected _reset(): void;
  14496. /** @hidden */
  14497. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  14498. /**
  14499. * Instantiates a particle system.
  14500. * 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.
  14501. * @param name The name of the particle system
  14502. */
  14503. constructor(name: string);
  14504. /**
  14505. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14506. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14507. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14508. * @returns the emitter
  14509. */
  14510. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14511. /**
  14512. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14513. * @param radius The radius of the hemisphere to emit from
  14514. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14515. * @returns the emitter
  14516. */
  14517. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  14518. /**
  14519. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14520. * @param radius The radius of the sphere to emit from
  14521. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14522. * @returns the emitter
  14523. */
  14524. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  14525. /**
  14526. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14527. * @param radius The radius of the sphere to emit from
  14528. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14529. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14530. * @returns the emitter
  14531. */
  14532. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  14533. /**
  14534. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14535. * @param radius The radius of the emission cylinder
  14536. * @param height The height of the emission cylinder
  14537. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14538. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14539. * @returns the emitter
  14540. */
  14541. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  14542. /**
  14543. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14544. * @param radius The radius of the cylinder to emit from
  14545. * @param height The height of the emission cylinder
  14546. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14547. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14548. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14549. * @returns the emitter
  14550. */
  14551. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  14552. /**
  14553. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14554. * @param radius The radius of the cone to emit from
  14555. * @param angle The base angle of the cone
  14556. * @returns the emitter
  14557. */
  14558. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  14559. /**
  14560. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14561. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14562. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14563. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14564. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14565. * @returns the emitter
  14566. */
  14567. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14568. }
  14569. }
  14570. declare module BABYLON {
  14571. /**
  14572. * Type of sub emitter
  14573. */
  14574. export enum SubEmitterType {
  14575. /**
  14576. * Attached to the particle over it's lifetime
  14577. */
  14578. ATTACHED = 0,
  14579. /**
  14580. * Created when the particle dies
  14581. */
  14582. END = 1
  14583. }
  14584. /**
  14585. * Sub emitter class used to emit particles from an existing particle
  14586. */
  14587. export class SubEmitter {
  14588. /**
  14589. * the particle system to be used by the sub emitter
  14590. */
  14591. particleSystem: ParticleSystem;
  14592. /**
  14593. * Type of the submitter (Default: END)
  14594. */
  14595. type: SubEmitterType;
  14596. /**
  14597. * 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)
  14598. * Note: This only is supported when using an emitter of type Mesh
  14599. */
  14600. inheritDirection: boolean;
  14601. /**
  14602. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  14603. */
  14604. inheritedVelocityAmount: number;
  14605. /**
  14606. * Creates a sub emitter
  14607. * @param particleSystem the particle system to be used by the sub emitter
  14608. */
  14609. constructor(
  14610. /**
  14611. * the particle system to be used by the sub emitter
  14612. */
  14613. particleSystem: ParticleSystem);
  14614. /**
  14615. * Clones the sub emitter
  14616. * @returns the cloned sub emitter
  14617. */
  14618. clone(): SubEmitter;
  14619. /**
  14620. * Serialize current object to a JSON object
  14621. * @returns the serialized object
  14622. */
  14623. serialize(): any;
  14624. /** @hidden */
  14625. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  14626. /**
  14627. * Creates a new SubEmitter from a serialized JSON version
  14628. * @param serializationObject defines the JSON object to read from
  14629. * @param scene defines the hosting scene
  14630. * @param rootUrl defines the rootUrl for data loading
  14631. * @returns a new SubEmitter
  14632. */
  14633. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  14634. /** Release associated resources */
  14635. dispose(): void;
  14636. }
  14637. }
  14638. declare module BABYLON {
  14639. /** @hidden */
  14640. export var clipPlaneFragmentDeclaration: {
  14641. name: string;
  14642. shader: string;
  14643. };
  14644. }
  14645. declare module BABYLON {
  14646. /** @hidden */
  14647. export var imageProcessingDeclaration: {
  14648. name: string;
  14649. shader: string;
  14650. };
  14651. }
  14652. declare module BABYLON {
  14653. /** @hidden */
  14654. export var imageProcessingFunctions: {
  14655. name: string;
  14656. shader: string;
  14657. };
  14658. }
  14659. declare module BABYLON {
  14660. /** @hidden */
  14661. export var clipPlaneFragment: {
  14662. name: string;
  14663. shader: string;
  14664. };
  14665. }
  14666. declare module BABYLON {
  14667. /** @hidden */
  14668. export var particlesPixelShader: {
  14669. name: string;
  14670. shader: string;
  14671. };
  14672. }
  14673. declare module BABYLON {
  14674. /** @hidden */
  14675. export var clipPlaneVertexDeclaration: {
  14676. name: string;
  14677. shader: string;
  14678. };
  14679. }
  14680. declare module BABYLON {
  14681. /** @hidden */
  14682. export var clipPlaneVertex: {
  14683. name: string;
  14684. shader: string;
  14685. };
  14686. }
  14687. declare module BABYLON {
  14688. /** @hidden */
  14689. export var particlesVertexShader: {
  14690. name: string;
  14691. shader: string;
  14692. };
  14693. }
  14694. declare module BABYLON {
  14695. /**
  14696. * This represents a particle system in Babylon.
  14697. * 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.
  14698. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14699. * @example https://doc.babylonjs.com/babylon101/particles
  14700. */
  14701. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  14702. /**
  14703. * Billboard mode will only apply to Y axis
  14704. */
  14705. static readonly BILLBOARDMODE_Y: number;
  14706. /**
  14707. * Billboard mode will apply to all axes
  14708. */
  14709. static readonly BILLBOARDMODE_ALL: number;
  14710. /**
  14711. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  14712. */
  14713. static readonly BILLBOARDMODE_STRETCHED: number;
  14714. /**
  14715. * This function can be defined to provide custom update for active particles.
  14716. * This function will be called instead of regular update (age, position, color, etc.).
  14717. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  14718. */
  14719. updateFunction: (particles: Particle[]) => void;
  14720. private _emitterWorldMatrix;
  14721. /**
  14722. * This function can be defined to specify initial direction for every new particle.
  14723. * It by default use the emitterType defined function
  14724. */
  14725. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  14726. /**
  14727. * This function can be defined to specify initial position for every new particle.
  14728. * It by default use the emitterType defined function
  14729. */
  14730. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  14731. /**
  14732. * @hidden
  14733. */
  14734. _inheritedVelocityOffset: Vector3;
  14735. /**
  14736. * An event triggered when the system is disposed
  14737. */
  14738. onDisposeObservable: Observable<ParticleSystem>;
  14739. private _onDisposeObserver;
  14740. /**
  14741. * Sets a callback that will be triggered when the system is disposed
  14742. */
  14743. onDispose: () => void;
  14744. private _particles;
  14745. private _epsilon;
  14746. private _capacity;
  14747. private _stockParticles;
  14748. private _newPartsExcess;
  14749. private _vertexData;
  14750. private _vertexBuffer;
  14751. private _vertexBuffers;
  14752. private _spriteBuffer;
  14753. private _indexBuffer;
  14754. private _effect;
  14755. private _customEffect;
  14756. private _cachedDefines;
  14757. private _scaledColorStep;
  14758. private _colorDiff;
  14759. private _scaledDirection;
  14760. private _scaledGravity;
  14761. private _currentRenderId;
  14762. private _alive;
  14763. private _useInstancing;
  14764. private _started;
  14765. private _stopped;
  14766. private _actualFrame;
  14767. private _scaledUpdateSpeed;
  14768. private _vertexBufferSize;
  14769. /** @hidden */
  14770. _currentEmitRateGradient: Nullable<FactorGradient>;
  14771. /** @hidden */
  14772. _currentEmitRate1: number;
  14773. /** @hidden */
  14774. _currentEmitRate2: number;
  14775. /** @hidden */
  14776. _currentStartSizeGradient: Nullable<FactorGradient>;
  14777. /** @hidden */
  14778. _currentStartSize1: number;
  14779. /** @hidden */
  14780. _currentStartSize2: number;
  14781. private readonly _rawTextureWidth;
  14782. private _rampGradientsTexture;
  14783. private _useRampGradients;
  14784. /** Gets or sets a boolean indicating that ramp gradients must be used
  14785. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14786. */
  14787. useRampGradients: boolean;
  14788. /**
  14789. * 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.
  14790. * 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: [])
  14791. */
  14792. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  14793. private _subEmitters;
  14794. /**
  14795. * @hidden
  14796. * If the particle systems emitter should be disposed when the particle system is disposed
  14797. */
  14798. _disposeEmitterOnDispose: boolean;
  14799. /**
  14800. * The current active Sub-systems, this property is used by the root particle system only.
  14801. */
  14802. activeSubSystems: Array<ParticleSystem>;
  14803. private _rootParticleSystem;
  14804. /**
  14805. * Gets the current list of active particles
  14806. */
  14807. readonly particles: Particle[];
  14808. /**
  14809. * Returns the string "ParticleSystem"
  14810. * @returns a string containing the class name
  14811. */
  14812. getClassName(): string;
  14813. /**
  14814. * Instantiates a particle system.
  14815. * 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.
  14816. * @param name The name of the particle system
  14817. * @param capacity The max number of particles alive at the same time
  14818. * @param scene The scene the particle system belongs to
  14819. * @param customEffect a custom effect used to change the way particles are rendered by default
  14820. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  14821. * @param epsilon Offset used to render the particles
  14822. */
  14823. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  14824. private _addFactorGradient;
  14825. private _removeFactorGradient;
  14826. /**
  14827. * Adds a new life time gradient
  14828. * @param gradient defines the gradient to use (between 0 and 1)
  14829. * @param factor defines the life time factor to affect to the specified gradient
  14830. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14831. * @returns the current particle system
  14832. */
  14833. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14834. /**
  14835. * Remove a specific life time gradient
  14836. * @param gradient defines the gradient to remove
  14837. * @returns the current particle system
  14838. */
  14839. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14840. /**
  14841. * Adds a new size gradient
  14842. * @param gradient defines the gradient to use (between 0 and 1)
  14843. * @param factor defines the size factor to affect to the specified gradient
  14844. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14845. * @returns the current particle system
  14846. */
  14847. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14848. /**
  14849. * Remove a specific size gradient
  14850. * @param gradient defines the gradient to remove
  14851. * @returns the current particle system
  14852. */
  14853. removeSizeGradient(gradient: number): IParticleSystem;
  14854. /**
  14855. * Adds a new color remap gradient
  14856. * @param gradient defines the gradient to use (between 0 and 1)
  14857. * @param min defines the color remap minimal range
  14858. * @param max defines the color remap maximal range
  14859. * @returns the current particle system
  14860. */
  14861. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14862. /**
  14863. * Remove a specific color remap gradient
  14864. * @param gradient defines the gradient to remove
  14865. * @returns the current particle system
  14866. */
  14867. removeColorRemapGradient(gradient: number): IParticleSystem;
  14868. /**
  14869. * Adds a new alpha remap gradient
  14870. * @param gradient defines the gradient to use (between 0 and 1)
  14871. * @param min defines the alpha remap minimal range
  14872. * @param max defines the alpha remap maximal range
  14873. * @returns the current particle system
  14874. */
  14875. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14876. /**
  14877. * Remove a specific alpha remap gradient
  14878. * @param gradient defines the gradient to remove
  14879. * @returns the current particle system
  14880. */
  14881. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  14882. /**
  14883. * Adds a new angular speed gradient
  14884. * @param gradient defines the gradient to use (between 0 and 1)
  14885. * @param factor defines the angular speed to affect to the specified gradient
  14886. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14887. * @returns the current particle system
  14888. */
  14889. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14890. /**
  14891. * Remove a specific angular speed gradient
  14892. * @param gradient defines the gradient to remove
  14893. * @returns the current particle system
  14894. */
  14895. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14896. /**
  14897. * Adds a new velocity gradient
  14898. * @param gradient defines the gradient to use (between 0 and 1)
  14899. * @param factor defines the velocity to affect to the specified gradient
  14900. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14901. * @returns the current particle system
  14902. */
  14903. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14904. /**
  14905. * Remove a specific velocity gradient
  14906. * @param gradient defines the gradient to remove
  14907. * @returns the current particle system
  14908. */
  14909. removeVelocityGradient(gradient: number): IParticleSystem;
  14910. /**
  14911. * Adds a new limit velocity gradient
  14912. * @param gradient defines the gradient to use (between 0 and 1)
  14913. * @param factor defines the limit velocity value to affect to the specified gradient
  14914. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14915. * @returns the current particle system
  14916. */
  14917. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14918. /**
  14919. * Remove a specific limit velocity gradient
  14920. * @param gradient defines the gradient to remove
  14921. * @returns the current particle system
  14922. */
  14923. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14924. /**
  14925. * Adds a new drag gradient
  14926. * @param gradient defines the gradient to use (between 0 and 1)
  14927. * @param factor defines the drag value to affect to the specified gradient
  14928. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14929. * @returns the current particle system
  14930. */
  14931. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14932. /**
  14933. * Remove a specific drag gradient
  14934. * @param gradient defines the gradient to remove
  14935. * @returns the current particle system
  14936. */
  14937. removeDragGradient(gradient: number): IParticleSystem;
  14938. /**
  14939. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14940. * @param gradient defines the gradient to use (between 0 and 1)
  14941. * @param factor defines the emit rate value to affect to the specified gradient
  14942. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14943. * @returns the current particle system
  14944. */
  14945. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14946. /**
  14947. * Remove a specific emit rate gradient
  14948. * @param gradient defines the gradient to remove
  14949. * @returns the current particle system
  14950. */
  14951. removeEmitRateGradient(gradient: number): IParticleSystem;
  14952. /**
  14953. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14954. * @param gradient defines the gradient to use (between 0 and 1)
  14955. * @param factor defines the start size value to affect to the specified gradient
  14956. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14957. * @returns the current particle system
  14958. */
  14959. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14960. /**
  14961. * Remove a specific start size gradient
  14962. * @param gradient defines the gradient to remove
  14963. * @returns the current particle system
  14964. */
  14965. removeStartSizeGradient(gradient: number): IParticleSystem;
  14966. private _createRampGradientTexture;
  14967. /**
  14968. * Gets the current list of ramp gradients.
  14969. * You must use addRampGradient and removeRampGradient to udpate this list
  14970. * @returns the list of ramp gradients
  14971. */
  14972. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14973. /**
  14974. * Adds a new ramp gradient used to remap particle colors
  14975. * @param gradient defines the gradient to use (between 0 and 1)
  14976. * @param color defines the color to affect to the specified gradient
  14977. * @returns the current particle system
  14978. */
  14979. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  14980. /**
  14981. * Remove a specific ramp gradient
  14982. * @param gradient defines the gradient to remove
  14983. * @returns the current particle system
  14984. */
  14985. removeRampGradient(gradient: number): ParticleSystem;
  14986. /**
  14987. * Adds a new color gradient
  14988. * @param gradient defines the gradient to use (between 0 and 1)
  14989. * @param color1 defines the color to affect to the specified gradient
  14990. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14991. * @returns this particle system
  14992. */
  14993. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14994. /**
  14995. * Remove a specific color gradient
  14996. * @param gradient defines the gradient to remove
  14997. * @returns this particle system
  14998. */
  14999. removeColorGradient(gradient: number): IParticleSystem;
  15000. private _fetchR;
  15001. protected _reset(): void;
  15002. private _resetEffect;
  15003. private _createVertexBuffers;
  15004. private _createIndexBuffer;
  15005. /**
  15006. * Gets the maximum number of particles active at the same time.
  15007. * @returns The max number of active particles.
  15008. */
  15009. getCapacity(): number;
  15010. /**
  15011. * Gets whether there are still active particles in the system.
  15012. * @returns True if it is alive, otherwise false.
  15013. */
  15014. isAlive(): boolean;
  15015. /**
  15016. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15017. * @returns True if it has been started, otherwise false.
  15018. */
  15019. isStarted(): boolean;
  15020. private _prepareSubEmitterInternalArray;
  15021. /**
  15022. * Starts the particle system and begins to emit
  15023. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15024. */
  15025. start(delay?: number): void;
  15026. /**
  15027. * Stops the particle system.
  15028. * @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.
  15029. */
  15030. stop(stopSubEmitters?: boolean): void;
  15031. /**
  15032. * Remove all active particles
  15033. */
  15034. reset(): void;
  15035. /**
  15036. * @hidden (for internal use only)
  15037. */
  15038. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15039. /**
  15040. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15041. * Its lifetime will start back at 0.
  15042. */
  15043. recycleParticle: (particle: Particle) => void;
  15044. private _stopSubEmitters;
  15045. private _createParticle;
  15046. private _removeFromRoot;
  15047. private _emitFromParticle;
  15048. private _update;
  15049. /** @hidden */
  15050. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15051. /** @hidden */
  15052. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15053. /** @hidden */
  15054. private _getEffect;
  15055. /**
  15056. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15057. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15058. */
  15059. animate(preWarmOnly?: boolean): void;
  15060. private _appendParticleVertices;
  15061. /**
  15062. * Rebuilds the particle system.
  15063. */
  15064. rebuild(): void;
  15065. /**
  15066. * Is this system ready to be used/rendered
  15067. * @return true if the system is ready
  15068. */
  15069. isReady(): boolean;
  15070. private _render;
  15071. /**
  15072. * Renders the particle system in its current state.
  15073. * @returns the current number of particles
  15074. */
  15075. render(): number;
  15076. /**
  15077. * Disposes the particle system and free the associated resources
  15078. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15079. */
  15080. dispose(disposeTexture?: boolean): void;
  15081. /**
  15082. * Clones the particle system.
  15083. * @param name The name of the cloned object
  15084. * @param newEmitter The new emitter to use
  15085. * @returns the cloned particle system
  15086. */
  15087. clone(name: string, newEmitter: any): ParticleSystem;
  15088. /**
  15089. * Serializes the particle system to a JSON object.
  15090. * @returns the JSON object
  15091. */
  15092. serialize(): any;
  15093. /** @hidden */
  15094. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  15095. /** @hidden */
  15096. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  15097. /**
  15098. * Parses a JSON object to create a particle system.
  15099. * @param parsedParticleSystem The JSON object to parse
  15100. * @param scene The scene to create the particle system in
  15101. * @param rootUrl The root url to use to load external dependencies like texture
  15102. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15103. * @returns the Parsed particle system
  15104. */
  15105. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15106. }
  15107. }
  15108. declare module BABYLON {
  15109. /**
  15110. * A particle represents one of the element emitted by a particle system.
  15111. * This is mainly define by its coordinates, direction, velocity and age.
  15112. */
  15113. export class Particle {
  15114. /**
  15115. * The particle system the particle belongs to.
  15116. */
  15117. particleSystem: ParticleSystem;
  15118. private static _Count;
  15119. /**
  15120. * Unique ID of the particle
  15121. */
  15122. id: number;
  15123. /**
  15124. * The world position of the particle in the scene.
  15125. */
  15126. position: Vector3;
  15127. /**
  15128. * The world direction of the particle in the scene.
  15129. */
  15130. direction: Vector3;
  15131. /**
  15132. * The color of the particle.
  15133. */
  15134. color: Color4;
  15135. /**
  15136. * The color change of the particle per step.
  15137. */
  15138. colorStep: Color4;
  15139. /**
  15140. * Defines how long will the life of the particle be.
  15141. */
  15142. lifeTime: number;
  15143. /**
  15144. * The current age of the particle.
  15145. */
  15146. age: number;
  15147. /**
  15148. * The current size of the particle.
  15149. */
  15150. size: number;
  15151. /**
  15152. * The current scale of the particle.
  15153. */
  15154. scale: Vector2;
  15155. /**
  15156. * The current angle of the particle.
  15157. */
  15158. angle: number;
  15159. /**
  15160. * Defines how fast is the angle changing.
  15161. */
  15162. angularSpeed: number;
  15163. /**
  15164. * Defines the cell index used by the particle to be rendered from a sprite.
  15165. */
  15166. cellIndex: number;
  15167. /**
  15168. * The information required to support color remapping
  15169. */
  15170. remapData: Vector4;
  15171. /** @hidden */
  15172. _randomCellOffset?: number;
  15173. /** @hidden */
  15174. _initialDirection: Nullable<Vector3>;
  15175. /** @hidden */
  15176. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15177. /** @hidden */
  15178. _initialStartSpriteCellID: number;
  15179. /** @hidden */
  15180. _initialEndSpriteCellID: number;
  15181. /** @hidden */
  15182. _currentColorGradient: Nullable<ColorGradient>;
  15183. /** @hidden */
  15184. _currentColor1: Color4;
  15185. /** @hidden */
  15186. _currentColor2: Color4;
  15187. /** @hidden */
  15188. _currentSizeGradient: Nullable<FactorGradient>;
  15189. /** @hidden */
  15190. _currentSize1: number;
  15191. /** @hidden */
  15192. _currentSize2: number;
  15193. /** @hidden */
  15194. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15195. /** @hidden */
  15196. _currentAngularSpeed1: number;
  15197. /** @hidden */
  15198. _currentAngularSpeed2: number;
  15199. /** @hidden */
  15200. _currentVelocityGradient: Nullable<FactorGradient>;
  15201. /** @hidden */
  15202. _currentVelocity1: number;
  15203. /** @hidden */
  15204. _currentVelocity2: number;
  15205. /** @hidden */
  15206. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  15207. /** @hidden */
  15208. _currentLimitVelocity1: number;
  15209. /** @hidden */
  15210. _currentLimitVelocity2: number;
  15211. /** @hidden */
  15212. _currentDragGradient: Nullable<FactorGradient>;
  15213. /** @hidden */
  15214. _currentDrag1: number;
  15215. /** @hidden */
  15216. _currentDrag2: number;
  15217. /** @hidden */
  15218. _randomNoiseCoordinates1: Vector3;
  15219. /** @hidden */
  15220. _randomNoiseCoordinates2: Vector3;
  15221. /**
  15222. * Creates a new instance Particle
  15223. * @param particleSystem the particle system the particle belongs to
  15224. */
  15225. constructor(
  15226. /**
  15227. * The particle system the particle belongs to.
  15228. */
  15229. particleSystem: ParticleSystem);
  15230. private updateCellInfoFromSystem;
  15231. /**
  15232. * Defines how the sprite cell index is updated for the particle
  15233. */
  15234. updateCellIndex(): void;
  15235. /** @hidden */
  15236. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15237. /** @hidden */
  15238. _inheritParticleInfoToSubEmitters(): void;
  15239. /** @hidden */
  15240. _reset(): void;
  15241. /**
  15242. * Copy the properties of particle to another one.
  15243. * @param other the particle to copy the information to.
  15244. */
  15245. copyTo(other: Particle): void;
  15246. }
  15247. }
  15248. declare module BABYLON {
  15249. /**
  15250. * Particle emitter represents a volume emitting particles.
  15251. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15252. */
  15253. export interface IParticleEmitterType {
  15254. /**
  15255. * Called by the particle System when the direction is computed for the created particle.
  15256. * @param worldMatrix is the world matrix of the particle system
  15257. * @param directionToUpdate is the direction vector to update with the result
  15258. * @param particle is the particle we are computed the direction for
  15259. */
  15260. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15261. /**
  15262. * Called by the particle System when the position is computed for the created particle.
  15263. * @param worldMatrix is the world matrix of the particle system
  15264. * @param positionToUpdate is the position vector to update with the result
  15265. * @param particle is the particle we are computed the position for
  15266. */
  15267. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15268. /**
  15269. * Clones the current emitter and returns a copy of it
  15270. * @returns the new emitter
  15271. */
  15272. clone(): IParticleEmitterType;
  15273. /**
  15274. * Called by the GPUParticleSystem to setup the update shader
  15275. * @param effect defines the update shader
  15276. */
  15277. applyToShader(effect: Effect): void;
  15278. /**
  15279. * Returns a string to use to update the GPU particles update shader
  15280. * @returns the effect defines string
  15281. */
  15282. getEffectDefines(): string;
  15283. /**
  15284. * Returns a string representing the class name
  15285. * @returns a string containing the class name
  15286. */
  15287. getClassName(): string;
  15288. /**
  15289. * Serializes the particle system to a JSON object.
  15290. * @returns the JSON object
  15291. */
  15292. serialize(): any;
  15293. /**
  15294. * Parse properties from a JSON object
  15295. * @param serializationObject defines the JSON object
  15296. */
  15297. parse(serializationObject: any): void;
  15298. }
  15299. }
  15300. declare module BABYLON {
  15301. /**
  15302. * Particle emitter emitting particles from the inside of a box.
  15303. * It emits the particles randomly between 2 given directions.
  15304. */
  15305. export class BoxParticleEmitter implements IParticleEmitterType {
  15306. /**
  15307. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15308. */
  15309. direction1: Vector3;
  15310. /**
  15311. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15312. */
  15313. direction2: Vector3;
  15314. /**
  15315. * 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.
  15316. */
  15317. minEmitBox: Vector3;
  15318. /**
  15319. * 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.
  15320. */
  15321. maxEmitBox: Vector3;
  15322. /**
  15323. * Creates a new instance BoxParticleEmitter
  15324. */
  15325. constructor();
  15326. /**
  15327. * Called by the particle System when the direction is computed for the created particle.
  15328. * @param worldMatrix is the world matrix of the particle system
  15329. * @param directionToUpdate is the direction vector to update with the result
  15330. * @param particle is the particle we are computed the direction for
  15331. */
  15332. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15333. /**
  15334. * Called by the particle System when the position is computed for the created particle.
  15335. * @param worldMatrix is the world matrix of the particle system
  15336. * @param positionToUpdate is the position vector to update with the result
  15337. * @param particle is the particle we are computed the position for
  15338. */
  15339. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15340. /**
  15341. * Clones the current emitter and returns a copy of it
  15342. * @returns the new emitter
  15343. */
  15344. clone(): BoxParticleEmitter;
  15345. /**
  15346. * Called by the GPUParticleSystem to setup the update shader
  15347. * @param effect defines the update shader
  15348. */
  15349. applyToShader(effect: Effect): void;
  15350. /**
  15351. * Returns a string to use to update the GPU particles update shader
  15352. * @returns a string containng the defines string
  15353. */
  15354. getEffectDefines(): string;
  15355. /**
  15356. * Returns the string "BoxParticleEmitter"
  15357. * @returns a string containing the class name
  15358. */
  15359. getClassName(): string;
  15360. /**
  15361. * Serializes the particle system to a JSON object.
  15362. * @returns the JSON object
  15363. */
  15364. serialize(): any;
  15365. /**
  15366. * Parse properties from a JSON object
  15367. * @param serializationObject defines the JSON object
  15368. */
  15369. parse(serializationObject: any): void;
  15370. }
  15371. }
  15372. declare module BABYLON {
  15373. /**
  15374. * Particle emitter emitting particles from the inside of a cone.
  15375. * It emits the particles alongside the cone volume from the base to the particle.
  15376. * The emission direction might be randomized.
  15377. */
  15378. export class ConeParticleEmitter implements IParticleEmitterType {
  15379. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15380. directionRandomizer: number;
  15381. private _radius;
  15382. private _angle;
  15383. private _height;
  15384. /**
  15385. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  15386. */
  15387. radiusRange: number;
  15388. /**
  15389. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  15390. */
  15391. heightRange: number;
  15392. /**
  15393. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  15394. */
  15395. emitFromSpawnPointOnly: boolean;
  15396. /**
  15397. * Gets or sets the radius of the emission cone
  15398. */
  15399. radius: number;
  15400. /**
  15401. * Gets or sets the angle of the emission cone
  15402. */
  15403. angle: number;
  15404. private _buildHeight;
  15405. /**
  15406. * Creates a new instance ConeParticleEmitter
  15407. * @param radius the radius of the emission cone (1 by default)
  15408. * @param angle the cone base angle (PI by default)
  15409. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  15410. */
  15411. constructor(radius?: number, angle?: number,
  15412. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15413. directionRandomizer?: number);
  15414. /**
  15415. * Called by the particle System when the direction is computed for the created particle.
  15416. * @param worldMatrix is the world matrix of the particle system
  15417. * @param directionToUpdate is the direction vector to update with the result
  15418. * @param particle is the particle we are computed the direction for
  15419. */
  15420. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15421. /**
  15422. * Called by the particle System when the position is computed for the created particle.
  15423. * @param worldMatrix is the world matrix of the particle system
  15424. * @param positionToUpdate is the position vector to update with the result
  15425. * @param particle is the particle we are computed the position for
  15426. */
  15427. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15428. /**
  15429. * Clones the current emitter and returns a copy of it
  15430. * @returns the new emitter
  15431. */
  15432. clone(): ConeParticleEmitter;
  15433. /**
  15434. * Called by the GPUParticleSystem to setup the update shader
  15435. * @param effect defines the update shader
  15436. */
  15437. applyToShader(effect: Effect): void;
  15438. /**
  15439. * Returns a string to use to update the GPU particles update shader
  15440. * @returns a string containng the defines string
  15441. */
  15442. getEffectDefines(): string;
  15443. /**
  15444. * Returns the string "ConeParticleEmitter"
  15445. * @returns a string containing the class name
  15446. */
  15447. getClassName(): string;
  15448. /**
  15449. * Serializes the particle system to a JSON object.
  15450. * @returns the JSON object
  15451. */
  15452. serialize(): any;
  15453. /**
  15454. * Parse properties from a JSON object
  15455. * @param serializationObject defines the JSON object
  15456. */
  15457. parse(serializationObject: any): void;
  15458. }
  15459. }
  15460. declare module BABYLON {
  15461. /**
  15462. * Particle emitter emitting particles from the inside of a cylinder.
  15463. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  15464. */
  15465. export class CylinderParticleEmitter implements IParticleEmitterType {
  15466. /**
  15467. * The radius of the emission cylinder.
  15468. */
  15469. radius: number;
  15470. /**
  15471. * The height of the emission cylinder.
  15472. */
  15473. height: number;
  15474. /**
  15475. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15476. */
  15477. radiusRange: number;
  15478. /**
  15479. * How much to randomize the particle direction [0-1].
  15480. */
  15481. directionRandomizer: number;
  15482. /**
  15483. * Creates a new instance CylinderParticleEmitter
  15484. * @param radius the radius of the emission cylinder (1 by default)
  15485. * @param height the height of the emission cylinder (1 by default)
  15486. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15487. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15488. */
  15489. constructor(
  15490. /**
  15491. * The radius of the emission cylinder.
  15492. */
  15493. radius?: number,
  15494. /**
  15495. * The height of the emission cylinder.
  15496. */
  15497. height?: number,
  15498. /**
  15499. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15500. */
  15501. radiusRange?: number,
  15502. /**
  15503. * How much to randomize the particle direction [0-1].
  15504. */
  15505. directionRandomizer?: number);
  15506. /**
  15507. * Called by the particle System when the direction is computed for the created particle.
  15508. * @param worldMatrix is the world matrix of the particle system
  15509. * @param directionToUpdate is the direction vector to update with the result
  15510. * @param particle is the particle we are computed the direction for
  15511. */
  15512. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15513. /**
  15514. * Called by the particle System when the position is computed for the created particle.
  15515. * @param worldMatrix is the world matrix of the particle system
  15516. * @param positionToUpdate is the position vector to update with the result
  15517. * @param particle is the particle we are computed the position for
  15518. */
  15519. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15520. /**
  15521. * Clones the current emitter and returns a copy of it
  15522. * @returns the new emitter
  15523. */
  15524. clone(): CylinderParticleEmitter;
  15525. /**
  15526. * Called by the GPUParticleSystem to setup the update shader
  15527. * @param effect defines the update shader
  15528. */
  15529. applyToShader(effect: Effect): void;
  15530. /**
  15531. * Returns a string to use to update the GPU particles update shader
  15532. * @returns a string containng the defines string
  15533. */
  15534. getEffectDefines(): string;
  15535. /**
  15536. * Returns the string "CylinderParticleEmitter"
  15537. * @returns a string containing the class name
  15538. */
  15539. getClassName(): string;
  15540. /**
  15541. * Serializes the particle system to a JSON object.
  15542. * @returns the JSON object
  15543. */
  15544. serialize(): any;
  15545. /**
  15546. * Parse properties from a JSON object
  15547. * @param serializationObject defines the JSON object
  15548. */
  15549. parse(serializationObject: any): void;
  15550. }
  15551. /**
  15552. * Particle emitter emitting particles from the inside of a cylinder.
  15553. * It emits the particles randomly between two vectors.
  15554. */
  15555. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  15556. /**
  15557. * The min limit of the emission direction.
  15558. */
  15559. direction1: Vector3;
  15560. /**
  15561. * The max limit of the emission direction.
  15562. */
  15563. direction2: Vector3;
  15564. /**
  15565. * Creates a new instance CylinderDirectedParticleEmitter
  15566. * @param radius the radius of the emission cylinder (1 by default)
  15567. * @param height the height of the emission cylinder (1 by default)
  15568. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15569. * @param direction1 the min limit of the emission direction (up vector by default)
  15570. * @param direction2 the max limit of the emission direction (up vector by default)
  15571. */
  15572. constructor(radius?: number, height?: number, radiusRange?: number,
  15573. /**
  15574. * The min limit of the emission direction.
  15575. */
  15576. direction1?: Vector3,
  15577. /**
  15578. * The max limit of the emission direction.
  15579. */
  15580. direction2?: Vector3);
  15581. /**
  15582. * Called by the particle System when the direction is computed for the created particle.
  15583. * @param worldMatrix is the world matrix of the particle system
  15584. * @param directionToUpdate is the direction vector to update with the result
  15585. * @param particle is the particle we are computed the direction for
  15586. */
  15587. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15588. /**
  15589. * Clones the current emitter and returns a copy of it
  15590. * @returns the new emitter
  15591. */
  15592. clone(): CylinderDirectedParticleEmitter;
  15593. /**
  15594. * Called by the GPUParticleSystem to setup the update shader
  15595. * @param effect defines the update shader
  15596. */
  15597. applyToShader(effect: Effect): void;
  15598. /**
  15599. * Returns a string to use to update the GPU particles update shader
  15600. * @returns a string containng the defines string
  15601. */
  15602. getEffectDefines(): string;
  15603. /**
  15604. * Returns the string "CylinderDirectedParticleEmitter"
  15605. * @returns a string containing the class name
  15606. */
  15607. getClassName(): string;
  15608. /**
  15609. * Serializes the particle system to a JSON object.
  15610. * @returns the JSON object
  15611. */
  15612. serialize(): any;
  15613. /**
  15614. * Parse properties from a JSON object
  15615. * @param serializationObject defines the JSON object
  15616. */
  15617. parse(serializationObject: any): void;
  15618. }
  15619. }
  15620. declare module BABYLON {
  15621. /**
  15622. * Particle emitter emitting particles from the inside of a hemisphere.
  15623. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  15624. */
  15625. export class HemisphericParticleEmitter implements IParticleEmitterType {
  15626. /**
  15627. * The radius of the emission hemisphere.
  15628. */
  15629. radius: number;
  15630. /**
  15631. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15632. */
  15633. radiusRange: number;
  15634. /**
  15635. * How much to randomize the particle direction [0-1].
  15636. */
  15637. directionRandomizer: number;
  15638. /**
  15639. * Creates a new instance HemisphericParticleEmitter
  15640. * @param radius the radius of the emission hemisphere (1 by default)
  15641. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15642. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15643. */
  15644. constructor(
  15645. /**
  15646. * The radius of the emission hemisphere.
  15647. */
  15648. radius?: number,
  15649. /**
  15650. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15651. */
  15652. radiusRange?: number,
  15653. /**
  15654. * How much to randomize the particle direction [0-1].
  15655. */
  15656. directionRandomizer?: number);
  15657. /**
  15658. * Called by the particle System when the direction is computed for the created particle.
  15659. * @param worldMatrix is the world matrix of the particle system
  15660. * @param directionToUpdate is the direction vector to update with the result
  15661. * @param particle is the particle we are computed the direction for
  15662. */
  15663. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15664. /**
  15665. * Called by the particle System when the position is computed for the created particle.
  15666. * @param worldMatrix is the world matrix of the particle system
  15667. * @param positionToUpdate is the position vector to update with the result
  15668. * @param particle is the particle we are computed the position for
  15669. */
  15670. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15671. /**
  15672. * Clones the current emitter and returns a copy of it
  15673. * @returns the new emitter
  15674. */
  15675. clone(): HemisphericParticleEmitter;
  15676. /**
  15677. * Called by the GPUParticleSystem to setup the update shader
  15678. * @param effect defines the update shader
  15679. */
  15680. applyToShader(effect: Effect): void;
  15681. /**
  15682. * Returns a string to use to update the GPU particles update shader
  15683. * @returns a string containng the defines string
  15684. */
  15685. getEffectDefines(): string;
  15686. /**
  15687. * Returns the string "HemisphericParticleEmitter"
  15688. * @returns a string containing the class name
  15689. */
  15690. getClassName(): string;
  15691. /**
  15692. * Serializes the particle system to a JSON object.
  15693. * @returns the JSON object
  15694. */
  15695. serialize(): any;
  15696. /**
  15697. * Parse properties from a JSON object
  15698. * @param serializationObject defines the JSON object
  15699. */
  15700. parse(serializationObject: any): void;
  15701. }
  15702. }
  15703. declare module BABYLON {
  15704. /**
  15705. * Particle emitter emitting particles from a point.
  15706. * It emits the particles randomly between 2 given directions.
  15707. */
  15708. export class PointParticleEmitter implements IParticleEmitterType {
  15709. /**
  15710. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15711. */
  15712. direction1: Vector3;
  15713. /**
  15714. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15715. */
  15716. direction2: Vector3;
  15717. /**
  15718. * Creates a new instance PointParticleEmitter
  15719. */
  15720. constructor();
  15721. /**
  15722. * Called by the particle System when the direction is computed for the created particle.
  15723. * @param worldMatrix is the world matrix of the particle system
  15724. * @param directionToUpdate is the direction vector to update with the result
  15725. * @param particle is the particle we are computed the direction for
  15726. */
  15727. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15728. /**
  15729. * Called by the particle System when the position is computed for the created particle.
  15730. * @param worldMatrix is the world matrix of the particle system
  15731. * @param positionToUpdate is the position vector to update with the result
  15732. * @param particle is the particle we are computed the position for
  15733. */
  15734. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15735. /**
  15736. * Clones the current emitter and returns a copy of it
  15737. * @returns the new emitter
  15738. */
  15739. clone(): PointParticleEmitter;
  15740. /**
  15741. * Called by the GPUParticleSystem to setup the update shader
  15742. * @param effect defines the update shader
  15743. */
  15744. applyToShader(effect: Effect): void;
  15745. /**
  15746. * Returns a string to use to update the GPU particles update shader
  15747. * @returns a string containng the defines string
  15748. */
  15749. getEffectDefines(): string;
  15750. /**
  15751. * Returns the string "PointParticleEmitter"
  15752. * @returns a string containing the class name
  15753. */
  15754. getClassName(): string;
  15755. /**
  15756. * Serializes the particle system to a JSON object.
  15757. * @returns the JSON object
  15758. */
  15759. serialize(): any;
  15760. /**
  15761. * Parse properties from a JSON object
  15762. * @param serializationObject defines the JSON object
  15763. */
  15764. parse(serializationObject: any): void;
  15765. }
  15766. }
  15767. declare module BABYLON {
  15768. /**
  15769. * Particle emitter emitting particles from the inside of a sphere.
  15770. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  15771. */
  15772. export class SphereParticleEmitter implements IParticleEmitterType {
  15773. /**
  15774. * The radius of the emission sphere.
  15775. */
  15776. radius: number;
  15777. /**
  15778. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15779. */
  15780. radiusRange: number;
  15781. /**
  15782. * How much to randomize the particle direction [0-1].
  15783. */
  15784. directionRandomizer: number;
  15785. /**
  15786. * Creates a new instance SphereParticleEmitter
  15787. * @param radius the radius of the emission sphere (1 by default)
  15788. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15789. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15790. */
  15791. constructor(
  15792. /**
  15793. * The radius of the emission sphere.
  15794. */
  15795. radius?: number,
  15796. /**
  15797. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15798. */
  15799. radiusRange?: number,
  15800. /**
  15801. * How much to randomize the particle direction [0-1].
  15802. */
  15803. directionRandomizer?: number);
  15804. /**
  15805. * Called by the particle System when the direction is computed for the created particle.
  15806. * @param worldMatrix is the world matrix of the particle system
  15807. * @param directionToUpdate is the direction vector to update with the result
  15808. * @param particle is the particle we are computed the direction for
  15809. */
  15810. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15811. /**
  15812. * Called by the particle System when the position is computed for the created particle.
  15813. * @param worldMatrix is the world matrix of the particle system
  15814. * @param positionToUpdate is the position vector to update with the result
  15815. * @param particle is the particle we are computed the position for
  15816. */
  15817. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15818. /**
  15819. * Clones the current emitter and returns a copy of it
  15820. * @returns the new emitter
  15821. */
  15822. clone(): SphereParticleEmitter;
  15823. /**
  15824. * Called by the GPUParticleSystem to setup the update shader
  15825. * @param effect defines the update shader
  15826. */
  15827. applyToShader(effect: Effect): void;
  15828. /**
  15829. * Returns a string to use to update the GPU particles update shader
  15830. * @returns a string containng the defines string
  15831. */
  15832. getEffectDefines(): string;
  15833. /**
  15834. * Returns the string "SphereParticleEmitter"
  15835. * @returns a string containing the class name
  15836. */
  15837. getClassName(): string;
  15838. /**
  15839. * Serializes the particle system to a JSON object.
  15840. * @returns the JSON object
  15841. */
  15842. serialize(): any;
  15843. /**
  15844. * Parse properties from a JSON object
  15845. * @param serializationObject defines the JSON object
  15846. */
  15847. parse(serializationObject: any): void;
  15848. }
  15849. /**
  15850. * Particle emitter emitting particles from the inside of a sphere.
  15851. * It emits the particles randomly between two vectors.
  15852. */
  15853. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  15854. /**
  15855. * The min limit of the emission direction.
  15856. */
  15857. direction1: Vector3;
  15858. /**
  15859. * The max limit of the emission direction.
  15860. */
  15861. direction2: Vector3;
  15862. /**
  15863. * Creates a new instance SphereDirectedParticleEmitter
  15864. * @param radius the radius of the emission sphere (1 by default)
  15865. * @param direction1 the min limit of the emission direction (up vector by default)
  15866. * @param direction2 the max limit of the emission direction (up vector by default)
  15867. */
  15868. constructor(radius?: number,
  15869. /**
  15870. * The min limit of the emission direction.
  15871. */
  15872. direction1?: Vector3,
  15873. /**
  15874. * The max limit of the emission direction.
  15875. */
  15876. direction2?: Vector3);
  15877. /**
  15878. * Called by the particle System when the direction is computed for the created particle.
  15879. * @param worldMatrix is the world matrix of the particle system
  15880. * @param directionToUpdate is the direction vector to update with the result
  15881. * @param particle is the particle we are computed the direction for
  15882. */
  15883. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15884. /**
  15885. * Clones the current emitter and returns a copy of it
  15886. * @returns the new emitter
  15887. */
  15888. clone(): SphereDirectedParticleEmitter;
  15889. /**
  15890. * Called by the GPUParticleSystem to setup the update shader
  15891. * @param effect defines the update shader
  15892. */
  15893. applyToShader(effect: Effect): void;
  15894. /**
  15895. * Returns a string to use to update the GPU particles update shader
  15896. * @returns a string containng the defines string
  15897. */
  15898. getEffectDefines(): string;
  15899. /**
  15900. * Returns the string "SphereDirectedParticleEmitter"
  15901. * @returns a string containing the class name
  15902. */
  15903. getClassName(): string;
  15904. /**
  15905. * Serializes the particle system to a JSON object.
  15906. * @returns the JSON object
  15907. */
  15908. serialize(): any;
  15909. /**
  15910. * Parse properties from a JSON object
  15911. * @param serializationObject defines the JSON object
  15912. */
  15913. parse(serializationObject: any): void;
  15914. }
  15915. }
  15916. declare module BABYLON {
  15917. /**
  15918. * Interface representing a particle system in Babylon.js.
  15919. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  15920. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  15921. */
  15922. export interface IParticleSystem {
  15923. /**
  15924. * List of animations used by the particle system.
  15925. */
  15926. animations: Animation[];
  15927. /**
  15928. * The id of the Particle system.
  15929. */
  15930. id: string;
  15931. /**
  15932. * The name of the Particle system.
  15933. */
  15934. name: string;
  15935. /**
  15936. * The emitter represents the Mesh or position we are attaching the particle system to.
  15937. */
  15938. emitter: Nullable<AbstractMesh | Vector3>;
  15939. /**
  15940. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  15941. */
  15942. isBillboardBased: boolean;
  15943. /**
  15944. * The rendering group used by the Particle system to chose when to render.
  15945. */
  15946. renderingGroupId: number;
  15947. /**
  15948. * The layer mask we are rendering the particles through.
  15949. */
  15950. layerMask: number;
  15951. /**
  15952. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  15953. */
  15954. updateSpeed: number;
  15955. /**
  15956. * The amount of time the particle system is running (depends of the overall update speed).
  15957. */
  15958. targetStopDuration: number;
  15959. /**
  15960. * The texture used to render each particle. (this can be a spritesheet)
  15961. */
  15962. particleTexture: Nullable<Texture>;
  15963. /**
  15964. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  15965. */
  15966. blendMode: number;
  15967. /**
  15968. * Minimum life time of emitting particles.
  15969. */
  15970. minLifeTime: number;
  15971. /**
  15972. * Maximum life time of emitting particles.
  15973. */
  15974. maxLifeTime: number;
  15975. /**
  15976. * Minimum Size of emitting particles.
  15977. */
  15978. minSize: number;
  15979. /**
  15980. * Maximum Size of emitting particles.
  15981. */
  15982. maxSize: number;
  15983. /**
  15984. * Minimum scale of emitting particles on X axis.
  15985. */
  15986. minScaleX: number;
  15987. /**
  15988. * Maximum scale of emitting particles on X axis.
  15989. */
  15990. maxScaleX: number;
  15991. /**
  15992. * Minimum scale of emitting particles on Y axis.
  15993. */
  15994. minScaleY: number;
  15995. /**
  15996. * Maximum scale of emitting particles on Y axis.
  15997. */
  15998. maxScaleY: number;
  15999. /**
  16000. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16001. */
  16002. color1: Color4;
  16003. /**
  16004. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16005. */
  16006. color2: Color4;
  16007. /**
  16008. * Color the particle will have at the end of its lifetime.
  16009. */
  16010. colorDead: Color4;
  16011. /**
  16012. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  16013. */
  16014. emitRate: number;
  16015. /**
  16016. * You can use gravity if you want to give an orientation to your particles.
  16017. */
  16018. gravity: Vector3;
  16019. /**
  16020. * Minimum power of emitting particles.
  16021. */
  16022. minEmitPower: number;
  16023. /**
  16024. * Maximum power of emitting particles.
  16025. */
  16026. maxEmitPower: number;
  16027. /**
  16028. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16029. */
  16030. minAngularSpeed: number;
  16031. /**
  16032. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16033. */
  16034. maxAngularSpeed: number;
  16035. /**
  16036. * Gets or sets the minimal initial rotation in radians.
  16037. */
  16038. minInitialRotation: number;
  16039. /**
  16040. * Gets or sets the maximal initial rotation in radians.
  16041. */
  16042. maxInitialRotation: number;
  16043. /**
  16044. * The particle emitter type defines the emitter used by the particle system.
  16045. * It can be for example box, sphere, or cone...
  16046. */
  16047. particleEmitterType: Nullable<IParticleEmitterType>;
  16048. /**
  16049. * Defines the delay in milliseconds before starting the system (0 by default)
  16050. */
  16051. startDelay: number;
  16052. /**
  16053. * 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
  16054. */
  16055. preWarmCycles: number;
  16056. /**
  16057. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  16058. */
  16059. preWarmStepOffset: number;
  16060. /**
  16061. * 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)
  16062. */
  16063. spriteCellChangeSpeed: number;
  16064. /**
  16065. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16066. */
  16067. startSpriteCellID: number;
  16068. /**
  16069. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16070. */
  16071. endSpriteCellID: number;
  16072. /**
  16073. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16074. */
  16075. spriteCellWidth: number;
  16076. /**
  16077. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16078. */
  16079. spriteCellHeight: number;
  16080. /**
  16081. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16082. */
  16083. spriteRandomStartCell: boolean;
  16084. /**
  16085. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  16086. */
  16087. isAnimationSheetEnabled: boolean;
  16088. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16089. translationPivot: Vector2;
  16090. /**
  16091. * Gets or sets a texture used to add random noise to particle positions
  16092. */
  16093. noiseTexture: Nullable<BaseTexture>;
  16094. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16095. noiseStrength: Vector3;
  16096. /**
  16097. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16098. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16099. */
  16100. billboardMode: number;
  16101. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16102. limitVelocityDamping: number;
  16103. /**
  16104. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16105. */
  16106. beginAnimationOnStart: boolean;
  16107. /**
  16108. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16109. */
  16110. beginAnimationFrom: number;
  16111. /**
  16112. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16113. */
  16114. beginAnimationTo: number;
  16115. /**
  16116. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16117. */
  16118. beginAnimationLoop: boolean;
  16119. /**
  16120. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16121. */
  16122. disposeOnStop: boolean;
  16123. /**
  16124. * Gets the maximum number of particles active at the same time.
  16125. * @returns The max number of active particles.
  16126. */
  16127. getCapacity(): number;
  16128. /**
  16129. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16130. * @returns True if it has been started, otherwise false.
  16131. */
  16132. isStarted(): boolean;
  16133. /**
  16134. * Animates the particle system for this frame.
  16135. */
  16136. animate(): void;
  16137. /**
  16138. * Renders the particle system in its current state.
  16139. * @returns the current number of particles
  16140. */
  16141. render(): number;
  16142. /**
  16143. * Dispose the particle system and frees its associated resources.
  16144. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16145. */
  16146. dispose(disposeTexture?: boolean): void;
  16147. /**
  16148. * Clones the particle system.
  16149. * @param name The name of the cloned object
  16150. * @param newEmitter The new emitter to use
  16151. * @returns the cloned particle system
  16152. */
  16153. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16154. /**
  16155. * Serializes the particle system to a JSON object.
  16156. * @returns the JSON object
  16157. */
  16158. serialize(): any;
  16159. /**
  16160. * Rebuild the particle system
  16161. */
  16162. rebuild(): void;
  16163. /**
  16164. * Starts the particle system and begins to emit
  16165. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16166. */
  16167. start(delay?: number): void;
  16168. /**
  16169. * Stops the particle system.
  16170. */
  16171. stop(): void;
  16172. /**
  16173. * Remove all active particles
  16174. */
  16175. reset(): void;
  16176. /**
  16177. * Is this system ready to be used/rendered
  16178. * @return true if the system is ready
  16179. */
  16180. isReady(): boolean;
  16181. /**
  16182. * Adds a new color gradient
  16183. * @param gradient defines the gradient to use (between 0 and 1)
  16184. * @param color1 defines the color to affect to the specified gradient
  16185. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16186. * @returns the current particle system
  16187. */
  16188. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16189. /**
  16190. * Remove a specific color gradient
  16191. * @param gradient defines the gradient to remove
  16192. * @returns the current particle system
  16193. */
  16194. removeColorGradient(gradient: number): IParticleSystem;
  16195. /**
  16196. * Adds a new size gradient
  16197. * @param gradient defines the gradient to use (between 0 and 1)
  16198. * @param factor defines the size factor to affect to the specified gradient
  16199. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16200. * @returns the current particle system
  16201. */
  16202. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16203. /**
  16204. * Remove a specific size gradient
  16205. * @param gradient defines the gradient to remove
  16206. * @returns the current particle system
  16207. */
  16208. removeSizeGradient(gradient: number): IParticleSystem;
  16209. /**
  16210. * Gets the current list of color gradients.
  16211. * You must use addColorGradient and removeColorGradient to udpate this list
  16212. * @returns the list of color gradients
  16213. */
  16214. getColorGradients(): Nullable<Array<ColorGradient>>;
  16215. /**
  16216. * Gets the current list of size gradients.
  16217. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16218. * @returns the list of size gradients
  16219. */
  16220. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16221. /**
  16222. * Gets the current list of angular speed gradients.
  16223. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16224. * @returns the list of angular speed gradients
  16225. */
  16226. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16227. /**
  16228. * Adds a new angular speed gradient
  16229. * @param gradient defines the gradient to use (between 0 and 1)
  16230. * @param factor defines the angular speed to affect to the specified gradient
  16231. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16232. * @returns the current particle system
  16233. */
  16234. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16235. /**
  16236. * Remove a specific angular speed gradient
  16237. * @param gradient defines the gradient to remove
  16238. * @returns the current particle system
  16239. */
  16240. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16241. /**
  16242. * Gets the current list of velocity gradients.
  16243. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16244. * @returns the list of velocity gradients
  16245. */
  16246. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16247. /**
  16248. * Adds a new velocity gradient
  16249. * @param gradient defines the gradient to use (between 0 and 1)
  16250. * @param factor defines the velocity to affect to the specified gradient
  16251. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16252. * @returns the current particle system
  16253. */
  16254. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16255. /**
  16256. * Remove a specific velocity gradient
  16257. * @param gradient defines the gradient to remove
  16258. * @returns the current particle system
  16259. */
  16260. removeVelocityGradient(gradient: number): IParticleSystem;
  16261. /**
  16262. * Gets the current list of limit velocity gradients.
  16263. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16264. * @returns the list of limit velocity gradients
  16265. */
  16266. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16267. /**
  16268. * Adds a new limit velocity gradient
  16269. * @param gradient defines the gradient to use (between 0 and 1)
  16270. * @param factor defines the limit velocity to affect to the specified gradient
  16271. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16272. * @returns the current particle system
  16273. */
  16274. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16275. /**
  16276. * Remove a specific limit velocity gradient
  16277. * @param gradient defines the gradient to remove
  16278. * @returns the current particle system
  16279. */
  16280. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16281. /**
  16282. * Adds a new drag gradient
  16283. * @param gradient defines the gradient to use (between 0 and 1)
  16284. * @param factor defines the drag to affect to the specified gradient
  16285. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16286. * @returns the current particle system
  16287. */
  16288. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16289. /**
  16290. * Remove a specific drag gradient
  16291. * @param gradient defines the gradient to remove
  16292. * @returns the current particle system
  16293. */
  16294. removeDragGradient(gradient: number): IParticleSystem;
  16295. /**
  16296. * Gets the current list of drag gradients.
  16297. * You must use addDragGradient and removeDragGradient to udpate this list
  16298. * @returns the list of drag gradients
  16299. */
  16300. getDragGradients(): Nullable<Array<FactorGradient>>;
  16301. /**
  16302. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16303. * @param gradient defines the gradient to use (between 0 and 1)
  16304. * @param factor defines the emit rate to affect to the specified gradient
  16305. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16306. * @returns the current particle system
  16307. */
  16308. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16309. /**
  16310. * Remove a specific emit rate gradient
  16311. * @param gradient defines the gradient to remove
  16312. * @returns the current particle system
  16313. */
  16314. removeEmitRateGradient(gradient: number): IParticleSystem;
  16315. /**
  16316. * Gets the current list of emit rate gradients.
  16317. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16318. * @returns the list of emit rate gradients
  16319. */
  16320. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16321. /**
  16322. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16323. * @param gradient defines the gradient to use (between 0 and 1)
  16324. * @param factor defines the start size to affect to the specified gradient
  16325. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16326. * @returns the current particle system
  16327. */
  16328. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16329. /**
  16330. * Remove a specific start size gradient
  16331. * @param gradient defines the gradient to remove
  16332. * @returns the current particle system
  16333. */
  16334. removeStartSizeGradient(gradient: number): IParticleSystem;
  16335. /**
  16336. * Gets the current list of start size gradients.
  16337. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16338. * @returns the list of start size gradients
  16339. */
  16340. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16341. /**
  16342. * Adds a new life time gradient
  16343. * @param gradient defines the gradient to use (between 0 and 1)
  16344. * @param factor defines the life time factor to affect to the specified gradient
  16345. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16346. * @returns the current particle system
  16347. */
  16348. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16349. /**
  16350. * Remove a specific life time gradient
  16351. * @param gradient defines the gradient to remove
  16352. * @returns the current particle system
  16353. */
  16354. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16355. /**
  16356. * Gets the current list of life time gradients.
  16357. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16358. * @returns the list of life time gradients
  16359. */
  16360. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16361. /**
  16362. * Gets the current list of color gradients.
  16363. * You must use addColorGradient and removeColorGradient to udpate this list
  16364. * @returns the list of color gradients
  16365. */
  16366. getColorGradients(): Nullable<Array<ColorGradient>>;
  16367. /**
  16368. * Adds a new ramp gradient used to remap particle colors
  16369. * @param gradient defines the gradient to use (between 0 and 1)
  16370. * @param color defines the color to affect to the specified gradient
  16371. * @returns the current particle system
  16372. */
  16373. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  16374. /**
  16375. * Gets the current list of ramp gradients.
  16376. * You must use addRampGradient and removeRampGradient to udpate this list
  16377. * @returns the list of ramp gradients
  16378. */
  16379. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16380. /** Gets or sets a boolean indicating that ramp gradients must be used
  16381. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16382. */
  16383. useRampGradients: boolean;
  16384. /**
  16385. * Adds a new color remap gradient
  16386. * @param gradient defines the gradient to use (between 0 and 1)
  16387. * @param min defines the color remap minimal range
  16388. * @param max defines the color remap maximal range
  16389. * @returns the current particle system
  16390. */
  16391. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16392. /**
  16393. * Gets the current list of color remap gradients.
  16394. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16395. * @returns the list of color remap gradients
  16396. */
  16397. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16398. /**
  16399. * Adds a new alpha remap gradient
  16400. * @param gradient defines the gradient to use (between 0 and 1)
  16401. * @param min defines the alpha remap minimal range
  16402. * @param max defines the alpha remap maximal range
  16403. * @returns the current particle system
  16404. */
  16405. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16406. /**
  16407. * Gets the current list of alpha remap gradients.
  16408. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16409. * @returns the list of alpha remap gradients
  16410. */
  16411. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16412. /**
  16413. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16414. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16415. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16416. * @returns the emitter
  16417. */
  16418. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16419. /**
  16420. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16421. * @param radius The radius of the hemisphere to emit from
  16422. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16423. * @returns the emitter
  16424. */
  16425. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  16426. /**
  16427. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16428. * @param radius The radius of the sphere to emit from
  16429. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16430. * @returns the emitter
  16431. */
  16432. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  16433. /**
  16434. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16435. * @param radius The radius of the sphere to emit from
  16436. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16437. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16438. * @returns the emitter
  16439. */
  16440. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16441. /**
  16442. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16443. * @param radius The radius of the emission cylinder
  16444. * @param height The height of the emission cylinder
  16445. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16446. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16447. * @returns the emitter
  16448. */
  16449. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  16450. /**
  16451. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16452. * @param radius The radius of the cylinder to emit from
  16453. * @param height The height of the emission cylinder
  16454. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16455. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16456. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16457. * @returns the emitter
  16458. */
  16459. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16460. /**
  16461. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16462. * @param radius The radius of the cone to emit from
  16463. * @param angle The base angle of the cone
  16464. * @returns the emitter
  16465. */
  16466. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  16467. /**
  16468. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16469. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16470. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16471. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16472. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16473. * @returns the emitter
  16474. */
  16475. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16476. /**
  16477. * Get hosting scene
  16478. * @returns the scene
  16479. */
  16480. getScene(): Scene;
  16481. }
  16482. }
  16483. declare module BABYLON {
  16484. /**
  16485. * Creates an instance based on a source mesh.
  16486. */
  16487. export class InstancedMesh extends AbstractMesh {
  16488. private _sourceMesh;
  16489. private _currentLOD;
  16490. /** @hidden */
  16491. _indexInSourceMeshInstanceArray: number;
  16492. constructor(name: string, source: Mesh);
  16493. /**
  16494. * Returns the string "InstancedMesh".
  16495. */
  16496. getClassName(): string;
  16497. /**
  16498. * If the source mesh receives shadows
  16499. */
  16500. readonly receiveShadows: boolean;
  16501. /**
  16502. * The material of the source mesh
  16503. */
  16504. readonly material: Nullable<Material>;
  16505. /**
  16506. * Visibility of the source mesh
  16507. */
  16508. readonly visibility: number;
  16509. /**
  16510. * Skeleton of the source mesh
  16511. */
  16512. readonly skeleton: Nullable<Skeleton>;
  16513. /**
  16514. * Rendering ground id of the source mesh
  16515. */
  16516. renderingGroupId: number;
  16517. /**
  16518. * Returns the total number of vertices (integer).
  16519. */
  16520. getTotalVertices(): number;
  16521. /**
  16522. * Returns a positive integer : the total number of indices in this mesh geometry.
  16523. * @returns the numner of indices or zero if the mesh has no geometry.
  16524. */
  16525. getTotalIndices(): number;
  16526. /**
  16527. * The source mesh of the instance
  16528. */
  16529. readonly sourceMesh: Mesh;
  16530. /**
  16531. * Is this node ready to be used/rendered
  16532. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16533. * @return {boolean} is it ready
  16534. */
  16535. isReady(completeCheck?: boolean): boolean;
  16536. /**
  16537. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16538. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16539. * @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.
  16540. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16541. */
  16542. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16543. /**
  16544. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16545. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16546. * The `data` are either a numeric array either a Float32Array.
  16547. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16548. * 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).
  16549. * Note that a new underlying VertexBuffer object is created each call.
  16550. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16551. *
  16552. * Possible `kind` values :
  16553. * - VertexBuffer.PositionKind
  16554. * - VertexBuffer.UVKind
  16555. * - VertexBuffer.UV2Kind
  16556. * - VertexBuffer.UV3Kind
  16557. * - VertexBuffer.UV4Kind
  16558. * - VertexBuffer.UV5Kind
  16559. * - VertexBuffer.UV6Kind
  16560. * - VertexBuffer.ColorKind
  16561. * - VertexBuffer.MatricesIndicesKind
  16562. * - VertexBuffer.MatricesIndicesExtraKind
  16563. * - VertexBuffer.MatricesWeightsKind
  16564. * - VertexBuffer.MatricesWeightsExtraKind
  16565. *
  16566. * Returns the Mesh.
  16567. */
  16568. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  16569. /**
  16570. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16571. * If the mesh has no geometry, it is simply returned as it is.
  16572. * The `data` are either a numeric array either a Float32Array.
  16573. * No new underlying VertexBuffer object is created.
  16574. * 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.
  16575. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16576. *
  16577. * Possible `kind` values :
  16578. * - VertexBuffer.PositionKind
  16579. * - VertexBuffer.UVKind
  16580. * - VertexBuffer.UV2Kind
  16581. * - VertexBuffer.UV3Kind
  16582. * - VertexBuffer.UV4Kind
  16583. * - VertexBuffer.UV5Kind
  16584. * - VertexBuffer.UV6Kind
  16585. * - VertexBuffer.ColorKind
  16586. * - VertexBuffer.MatricesIndicesKind
  16587. * - VertexBuffer.MatricesIndicesExtraKind
  16588. * - VertexBuffer.MatricesWeightsKind
  16589. * - VertexBuffer.MatricesWeightsExtraKind
  16590. *
  16591. * Returns the Mesh.
  16592. */
  16593. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16594. /**
  16595. * Sets the mesh indices.
  16596. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16597. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16598. * This method creates a new index buffer each call.
  16599. * Returns the Mesh.
  16600. */
  16601. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16602. /**
  16603. * Boolean : True if the mesh owns the requested kind of data.
  16604. */
  16605. isVerticesDataPresent(kind: string): boolean;
  16606. /**
  16607. * Returns an array of indices (IndicesArray).
  16608. */
  16609. getIndices(): Nullable<IndicesArray>;
  16610. readonly _positions: Nullable<Vector3[]>;
  16611. /**
  16612. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16613. * This means the mesh underlying bounding box and sphere are recomputed.
  16614. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16615. * @returns the current mesh
  16616. */
  16617. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16618. /** @hidden */
  16619. _preActivate(): InstancedMesh;
  16620. /** @hidden */
  16621. _activate(renderId: number): InstancedMesh;
  16622. /**
  16623. * Returns the current associated LOD AbstractMesh.
  16624. */
  16625. getLOD(camera: Camera): AbstractMesh;
  16626. /** @hidden */
  16627. _syncSubMeshes(): InstancedMesh;
  16628. /** @hidden */
  16629. _generatePointsArray(): boolean;
  16630. /**
  16631. * Creates a new InstancedMesh from the current mesh.
  16632. * - name (string) : the cloned mesh name
  16633. * - newParent (optional Node) : the optional Node to parent the clone to.
  16634. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16635. *
  16636. * Returns the clone.
  16637. */
  16638. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  16639. /**
  16640. * Disposes the InstancedMesh.
  16641. * Returns nothing.
  16642. */
  16643. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16644. }
  16645. }
  16646. declare module BABYLON {
  16647. /**
  16648. * Defines the options associated with the creation of a shader material.
  16649. */
  16650. export interface IShaderMaterialOptions {
  16651. /**
  16652. * Does the material work in alpha blend mode
  16653. */
  16654. needAlphaBlending: boolean;
  16655. /**
  16656. * Does the material work in alpha test mode
  16657. */
  16658. needAlphaTesting: boolean;
  16659. /**
  16660. * The list of attribute names used in the shader
  16661. */
  16662. attributes: string[];
  16663. /**
  16664. * The list of unifrom names used in the shader
  16665. */
  16666. uniforms: string[];
  16667. /**
  16668. * The list of UBO names used in the shader
  16669. */
  16670. uniformBuffers: string[];
  16671. /**
  16672. * The list of sampler names used in the shader
  16673. */
  16674. samplers: string[];
  16675. /**
  16676. * The list of defines used in the shader
  16677. */
  16678. defines: string[];
  16679. }
  16680. /**
  16681. * 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.
  16682. *
  16683. * This returned material effects how the mesh will look based on the code in the shaders.
  16684. *
  16685. * @see http://doc.babylonjs.com/how_to/shader_material
  16686. */
  16687. export class ShaderMaterial extends Material {
  16688. private _shaderPath;
  16689. private _options;
  16690. private _textures;
  16691. private _textureArrays;
  16692. private _floats;
  16693. private _ints;
  16694. private _floatsArrays;
  16695. private _colors3;
  16696. private _colors3Arrays;
  16697. private _colors4;
  16698. private _vectors2;
  16699. private _vectors3;
  16700. private _vectors4;
  16701. private _matrices;
  16702. private _matrices3x3;
  16703. private _matrices2x2;
  16704. private _vectors2Arrays;
  16705. private _vectors3Arrays;
  16706. private _cachedWorldViewMatrix;
  16707. private _renderId;
  16708. /**
  16709. * Instantiate a new shader material.
  16710. * 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.
  16711. * This returned material effects how the mesh will look based on the code in the shaders.
  16712. * @see http://doc.babylonjs.com/how_to/shader_material
  16713. * @param name Define the name of the material in the scene
  16714. * @param scene Define the scene the material belongs to
  16715. * @param shaderPath Defines the route to the shader code in one of three ways:
  16716. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16717. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  16718. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16719. * @param options Define the options used to create the shader
  16720. */
  16721. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16722. /**
  16723. * Gets the options used to compile the shader.
  16724. * They can be modified to trigger a new compilation
  16725. */
  16726. readonly options: IShaderMaterialOptions;
  16727. /**
  16728. * Gets the current class name of the material e.g. "ShaderMaterial"
  16729. * Mainly use in serialization.
  16730. * @returns the class name
  16731. */
  16732. getClassName(): string;
  16733. /**
  16734. * Specifies if the material will require alpha blending
  16735. * @returns a boolean specifying if alpha blending is needed
  16736. */
  16737. needAlphaBlending(): boolean;
  16738. /**
  16739. * Specifies if this material should be rendered in alpha test mode
  16740. * @returns a boolean specifying if an alpha test is needed.
  16741. */
  16742. needAlphaTesting(): boolean;
  16743. private _checkUniform;
  16744. /**
  16745. * Set a texture in the shader.
  16746. * @param name Define the name of the uniform samplers as defined in the shader
  16747. * @param texture Define the texture to bind to this sampler
  16748. * @return the material itself allowing "fluent" like uniform updates
  16749. */
  16750. setTexture(name: string, texture: Texture): ShaderMaterial;
  16751. /**
  16752. * Set a texture array in the shader.
  16753. * @param name Define the name of the uniform sampler array as defined in the shader
  16754. * @param textures Define the list of textures to bind to this sampler
  16755. * @return the material itself allowing "fluent" like uniform updates
  16756. */
  16757. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  16758. /**
  16759. * Set a float in the shader.
  16760. * @param name Define the name of the uniform as defined in the shader
  16761. * @param value Define the value to give to the uniform
  16762. * @return the material itself allowing "fluent" like uniform updates
  16763. */
  16764. setFloat(name: string, value: number): ShaderMaterial;
  16765. /**
  16766. * Set a int in the shader.
  16767. * @param name Define the name of the uniform as defined in the shader
  16768. * @param value Define the value to give to the uniform
  16769. * @return the material itself allowing "fluent" like uniform updates
  16770. */
  16771. setInt(name: string, value: number): ShaderMaterial;
  16772. /**
  16773. * Set an array of floats in the shader.
  16774. * @param name Define the name of the uniform as defined in the shader
  16775. * @param value Define the value to give to the uniform
  16776. * @return the material itself allowing "fluent" like uniform updates
  16777. */
  16778. setFloats(name: string, value: number[]): ShaderMaterial;
  16779. /**
  16780. * Set a vec3 in the shader from a Color3.
  16781. * @param name Define the name of the uniform as defined in the shader
  16782. * @param value Define the value to give to the uniform
  16783. * @return the material itself allowing "fluent" like uniform updates
  16784. */
  16785. setColor3(name: string, value: Color3): ShaderMaterial;
  16786. /**
  16787. * Set a vec3 array in the shader from a Color3 array.
  16788. * @param name Define the name of the uniform as defined in the shader
  16789. * @param value Define the value to give to the uniform
  16790. * @return the material itself allowing "fluent" like uniform updates
  16791. */
  16792. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16793. /**
  16794. * Set a vec4 in the shader from a Color4.
  16795. * @param name Define the name of the uniform as defined in the shader
  16796. * @param value Define the value to give to the uniform
  16797. * @return the material itself allowing "fluent" like uniform updates
  16798. */
  16799. setColor4(name: string, value: Color4): ShaderMaterial;
  16800. /**
  16801. * Set a vec2 in the shader from a Vector2.
  16802. * @param name Define the name of the uniform as defined in the shader
  16803. * @param value Define the value to give to the uniform
  16804. * @return the material itself allowing "fluent" like uniform updates
  16805. */
  16806. setVector2(name: string, value: Vector2): ShaderMaterial;
  16807. /**
  16808. * Set a vec3 in the shader from a Vector3.
  16809. * @param name Define the name of the uniform as defined in the shader
  16810. * @param value Define the value to give to the uniform
  16811. * @return the material itself allowing "fluent" like uniform updates
  16812. */
  16813. setVector3(name: string, value: Vector3): ShaderMaterial;
  16814. /**
  16815. * Set a vec4 in the shader from a Vector4.
  16816. * @param name Define the name of the uniform as defined in the shader
  16817. * @param value Define the value to give to the uniform
  16818. * @return the material itself allowing "fluent" like uniform updates
  16819. */
  16820. setVector4(name: string, value: Vector4): ShaderMaterial;
  16821. /**
  16822. * Set a mat4 in the shader from a Matrix.
  16823. * @param name Define the name of the uniform as defined in the shader
  16824. * @param value Define the value to give to the uniform
  16825. * @return the material itself allowing "fluent" like uniform updates
  16826. */
  16827. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16828. /**
  16829. * Set a mat3 in the shader from a Float32Array.
  16830. * @param name Define the name of the uniform as defined in the shader
  16831. * @param value Define the value to give to the uniform
  16832. * @return the material itself allowing "fluent" like uniform updates
  16833. */
  16834. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16835. /**
  16836. * Set a mat2 in the shader from a Float32Array.
  16837. * @param name Define the name of the uniform as defined in the shader
  16838. * @param value Define the value to give to the uniform
  16839. * @return the material itself allowing "fluent" like uniform updates
  16840. */
  16841. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  16842. /**
  16843. * Set a vec2 array in the shader from a number array.
  16844. * @param name Define the name of the uniform as defined in the shader
  16845. * @param value Define the value to give to the uniform
  16846. * @return the material itself allowing "fluent" like uniform updates
  16847. */
  16848. setArray2(name: string, value: number[]): ShaderMaterial;
  16849. /**
  16850. * Set a vec3 array in the shader from a number array.
  16851. * @param name Define the name of the uniform as defined in the shader
  16852. * @param value Define the value to give to the uniform
  16853. * @return the material itself allowing "fluent" like uniform updates
  16854. */
  16855. setArray3(name: string, value: number[]): ShaderMaterial;
  16856. private _checkCache;
  16857. /**
  16858. * Specifies that the submesh is ready to be used
  16859. * @param mesh defines the mesh to check
  16860. * @param subMesh defines which submesh to check
  16861. * @param useInstances specifies that instances should be used
  16862. * @returns a boolean indicating that the submesh is ready or not
  16863. */
  16864. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  16865. /**
  16866. * Checks if the material is ready to render the requested mesh
  16867. * @param mesh Define the mesh to render
  16868. * @param useInstances Define whether or not the material is used with instances
  16869. * @returns true if ready, otherwise false
  16870. */
  16871. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16872. /**
  16873. * Binds the world matrix to the material
  16874. * @param world defines the world transformation matrix
  16875. */
  16876. bindOnlyWorldMatrix(world: Matrix): void;
  16877. /**
  16878. * Binds the material to the mesh
  16879. * @param world defines the world transformation matrix
  16880. * @param mesh defines the mesh to bind the material to
  16881. */
  16882. bind(world: Matrix, mesh?: Mesh): void;
  16883. /**
  16884. * Gets the active textures from the material
  16885. * @returns an array of textures
  16886. */
  16887. getActiveTextures(): BaseTexture[];
  16888. /**
  16889. * Specifies if the material uses a texture
  16890. * @param texture defines the texture to check against the material
  16891. * @returns a boolean specifying if the material uses the texture
  16892. */
  16893. hasTexture(texture: BaseTexture): boolean;
  16894. /**
  16895. * Makes a duplicate of the material, and gives it a new name
  16896. * @param name defines the new name for the duplicated material
  16897. * @returns the cloned material
  16898. */
  16899. clone(name: string): ShaderMaterial;
  16900. /**
  16901. * Disposes the material
  16902. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16903. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16904. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16905. */
  16906. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16907. /**
  16908. * Serializes this material in a JSON representation
  16909. * @returns the serialized material object
  16910. */
  16911. serialize(): any;
  16912. /**
  16913. * Creates a shader material from parsed shader material data
  16914. * @param source defines the JSON represnetation of the material
  16915. * @param scene defines the hosting scene
  16916. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16917. * @returns a new material
  16918. */
  16919. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16920. }
  16921. }
  16922. declare module BABYLON {
  16923. /** @hidden */
  16924. export var colorPixelShader: {
  16925. name: string;
  16926. shader: string;
  16927. };
  16928. }
  16929. declare module BABYLON {
  16930. /** @hidden */
  16931. export var colorVertexShader: {
  16932. name: string;
  16933. shader: string;
  16934. };
  16935. }
  16936. declare module BABYLON {
  16937. /**
  16938. * Line mesh
  16939. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16940. */
  16941. export class LinesMesh extends Mesh {
  16942. /**
  16943. * If vertex color should be applied to the mesh
  16944. */
  16945. useVertexColor?: boolean | undefined;
  16946. /**
  16947. * If vertex alpha should be applied to the mesh
  16948. */
  16949. useVertexAlpha?: boolean | undefined;
  16950. /**
  16951. * Color of the line (Default: White)
  16952. */
  16953. color: Color3;
  16954. /**
  16955. * Alpha of the line (Default: 1)
  16956. */
  16957. alpha: number;
  16958. /**
  16959. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16960. * This margin is expressed in world space coordinates, so its value may vary.
  16961. * Default value is 0.1
  16962. */
  16963. intersectionThreshold: number;
  16964. private _colorShader;
  16965. /**
  16966. * Creates a new LinesMesh
  16967. * @param name defines the name
  16968. * @param scene defines the hosting scene
  16969. * @param parent defines the parent mesh if any
  16970. * @param source defines the optional source LinesMesh used to clone data from
  16971. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16972. * When false, achieved by calling a clone(), also passing False.
  16973. * This will make creation of children, recursive.
  16974. * @param useVertexColor defines if this LinesMesh supports vertex color
  16975. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16976. */
  16977. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  16978. /**
  16979. * If vertex color should be applied to the mesh
  16980. */
  16981. useVertexColor?: boolean | undefined,
  16982. /**
  16983. * If vertex alpha should be applied to the mesh
  16984. */
  16985. useVertexAlpha?: boolean | undefined);
  16986. private _addClipPlaneDefine;
  16987. private _removeClipPlaneDefine;
  16988. isReady(): boolean;
  16989. /**
  16990. * Returns the string "LineMesh"
  16991. */
  16992. getClassName(): string;
  16993. /**
  16994. * @hidden
  16995. */
  16996. /**
  16997. * @hidden
  16998. */
  16999. material: Material;
  17000. /**
  17001. * @hidden
  17002. */
  17003. readonly checkCollisions: boolean;
  17004. /** @hidden */
  17005. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  17006. /** @hidden */
  17007. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  17008. /**
  17009. * Disposes of the line mesh
  17010. * @param doNotRecurse If children should be disposed
  17011. */
  17012. dispose(doNotRecurse?: boolean): void;
  17013. /**
  17014. * Returns a new LineMesh object cloned from the current one.
  17015. */
  17016. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  17017. /**
  17018. * Creates a new InstancedLinesMesh object from the mesh model.
  17019. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  17020. * @param name defines the name of the new instance
  17021. * @returns a new InstancedLinesMesh
  17022. */
  17023. createInstance(name: string): InstancedLinesMesh;
  17024. }
  17025. /**
  17026. * Creates an instance based on a source LinesMesh
  17027. */
  17028. export class InstancedLinesMesh extends InstancedMesh {
  17029. /**
  17030. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17031. * This margin is expressed in world space coordinates, so its value may vary.
  17032. * Initilized with the intersectionThreshold value of the source LinesMesh
  17033. */
  17034. intersectionThreshold: number;
  17035. constructor(name: string, source: LinesMesh);
  17036. /**
  17037. * Returns the string "InstancedLinesMesh".
  17038. */
  17039. getClassName(): string;
  17040. }
  17041. }
  17042. declare module BABYLON {
  17043. /** @hidden */
  17044. export var linePixelShader: {
  17045. name: string;
  17046. shader: string;
  17047. };
  17048. }
  17049. declare module BABYLON {
  17050. /** @hidden */
  17051. export var lineVertexShader: {
  17052. name: string;
  17053. shader: string;
  17054. };
  17055. }
  17056. declare module BABYLON {
  17057. interface AbstractMesh {
  17058. /**
  17059. * Disables the mesh edge rendering mode
  17060. * @returns the currentAbstractMesh
  17061. */
  17062. disableEdgesRendering(): AbstractMesh;
  17063. /**
  17064. * Enables the edge rendering mode on the mesh.
  17065. * This mode makes the mesh edges visible
  17066. * @param epsilon defines the maximal distance between two angles to detect a face
  17067. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17068. * @returns the currentAbstractMesh
  17069. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17070. */
  17071. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17072. /**
  17073. * Gets the edgesRenderer associated with the mesh
  17074. */
  17075. edgesRenderer: Nullable<EdgesRenderer>;
  17076. }
  17077. interface LinesMesh {
  17078. /**
  17079. * Enables the edge rendering mode on the mesh.
  17080. * This mode makes the mesh edges visible
  17081. * @param epsilon defines the maximal distance between two angles to detect a face
  17082. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17083. * @returns the currentAbstractMesh
  17084. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17085. */
  17086. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17087. }
  17088. interface InstancedLinesMesh {
  17089. /**
  17090. * Enables the edge rendering mode on the mesh.
  17091. * This mode makes the mesh edges visible
  17092. * @param epsilon defines the maximal distance between two angles to detect a face
  17093. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17094. * @returns the current InstancedLinesMesh
  17095. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17096. */
  17097. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17098. }
  17099. /**
  17100. * Defines the minimum contract an Edges renderer should follow.
  17101. */
  17102. export interface IEdgesRenderer extends IDisposable {
  17103. /**
  17104. * Gets or sets a boolean indicating if the edgesRenderer is active
  17105. */
  17106. isEnabled: boolean;
  17107. /**
  17108. * Renders the edges of the attached mesh,
  17109. */
  17110. render(): void;
  17111. /**
  17112. * Checks wether or not the edges renderer is ready to render.
  17113. * @return true if ready, otherwise false.
  17114. */
  17115. isReady(): boolean;
  17116. }
  17117. /**
  17118. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17119. */
  17120. export class EdgesRenderer implements IEdgesRenderer {
  17121. /**
  17122. * Define the size of the edges with an orthographic camera
  17123. */
  17124. edgesWidthScalerForOrthographic: number;
  17125. /**
  17126. * Define the size of the edges with a perspective camera
  17127. */
  17128. edgesWidthScalerForPerspective: number;
  17129. protected _source: AbstractMesh;
  17130. protected _linesPositions: number[];
  17131. protected _linesNormals: number[];
  17132. protected _linesIndices: number[];
  17133. protected _epsilon: number;
  17134. protected _indicesCount: number;
  17135. protected _lineShader: ShaderMaterial;
  17136. protected _ib: WebGLBuffer;
  17137. protected _buffers: {
  17138. [key: string]: Nullable<VertexBuffer>;
  17139. };
  17140. protected _checkVerticesInsteadOfIndices: boolean;
  17141. private _meshRebuildObserver;
  17142. private _meshDisposeObserver;
  17143. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17144. isEnabled: boolean;
  17145. /**
  17146. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17147. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17148. * @param source Mesh used to create edges
  17149. * @param epsilon sum of angles in adjacency to check for edge
  17150. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17151. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17152. */
  17153. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17154. protected _prepareRessources(): void;
  17155. /** @hidden */
  17156. _rebuild(): void;
  17157. /**
  17158. * Releases the required resources for the edges renderer
  17159. */
  17160. dispose(): void;
  17161. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17162. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17163. /**
  17164. * Checks if the pair of p0 and p1 is en edge
  17165. * @param faceIndex
  17166. * @param edge
  17167. * @param faceNormals
  17168. * @param p0
  17169. * @param p1
  17170. * @private
  17171. */
  17172. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17173. /**
  17174. * push line into the position, normal and index buffer
  17175. * @protected
  17176. */
  17177. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17178. /**
  17179. * Generates lines edges from adjacencjes
  17180. * @private
  17181. */
  17182. _generateEdgesLines(): void;
  17183. /**
  17184. * Checks wether or not the edges renderer is ready to render.
  17185. * @return true if ready, otherwise false.
  17186. */
  17187. isReady(): boolean;
  17188. /**
  17189. * Renders the edges of the attached mesh,
  17190. */
  17191. render(): void;
  17192. }
  17193. /**
  17194. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17195. */
  17196. export class LineEdgesRenderer extends EdgesRenderer {
  17197. /**
  17198. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17199. * @param source LineMesh used to generate edges
  17200. * @param epsilon not important (specified angle for edge detection)
  17201. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17202. */
  17203. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17204. /**
  17205. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17206. */
  17207. _generateEdgesLines(): void;
  17208. }
  17209. }
  17210. declare module BABYLON {
  17211. /**
  17212. * This represents the object necessary to create a rendering group.
  17213. * This is exclusively used and created by the rendering manager.
  17214. * To modify the behavior, you use the available helpers in your scene or meshes.
  17215. * @hidden
  17216. */
  17217. export class RenderingGroup {
  17218. index: number;
  17219. private _scene;
  17220. private _opaqueSubMeshes;
  17221. private _transparentSubMeshes;
  17222. private _alphaTestSubMeshes;
  17223. private _depthOnlySubMeshes;
  17224. private _particleSystems;
  17225. private _spriteManagers;
  17226. private _opaqueSortCompareFn;
  17227. private _alphaTestSortCompareFn;
  17228. private _transparentSortCompareFn;
  17229. private _renderOpaque;
  17230. private _renderAlphaTest;
  17231. private _renderTransparent;
  17232. private _edgesRenderers;
  17233. onBeforeTransparentRendering: () => void;
  17234. /**
  17235. * Set the opaque sort comparison function.
  17236. * If null the sub meshes will be render in the order they were created
  17237. */
  17238. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17239. /**
  17240. * Set the alpha test sort comparison function.
  17241. * If null the sub meshes will be render in the order they were created
  17242. */
  17243. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17244. /**
  17245. * Set the transparent sort comparison function.
  17246. * If null the sub meshes will be render in the order they were created
  17247. */
  17248. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17249. /**
  17250. * Creates a new rendering group.
  17251. * @param index The rendering group index
  17252. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17253. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17254. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17255. */
  17256. 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>);
  17257. /**
  17258. * Render all the sub meshes contained in the group.
  17259. * @param customRenderFunction Used to override the default render behaviour of the group.
  17260. * @returns true if rendered some submeshes.
  17261. */
  17262. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17263. /**
  17264. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17265. * @param subMeshes The submeshes to render
  17266. */
  17267. private renderOpaqueSorted;
  17268. /**
  17269. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17270. * @param subMeshes The submeshes to render
  17271. */
  17272. private renderAlphaTestSorted;
  17273. /**
  17274. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17275. * @param subMeshes The submeshes to render
  17276. */
  17277. private renderTransparentSorted;
  17278. /**
  17279. * Renders the submeshes in a specified order.
  17280. * @param subMeshes The submeshes to sort before render
  17281. * @param sortCompareFn The comparison function use to sort
  17282. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17283. * @param transparent Specifies to activate blending if true
  17284. */
  17285. private static renderSorted;
  17286. /**
  17287. * Renders the submeshes in the order they were dispatched (no sort applied).
  17288. * @param subMeshes The submeshes to render
  17289. */
  17290. private static renderUnsorted;
  17291. /**
  17292. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17293. * are rendered back to front if in the same alpha index.
  17294. *
  17295. * @param a The first submesh
  17296. * @param b The second submesh
  17297. * @returns The result of the comparison
  17298. */
  17299. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17300. /**
  17301. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17302. * are rendered back to front.
  17303. *
  17304. * @param a The first submesh
  17305. * @param b The second submesh
  17306. * @returns The result of the comparison
  17307. */
  17308. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17309. /**
  17310. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17311. * are rendered front to back (prevent overdraw).
  17312. *
  17313. * @param a The first submesh
  17314. * @param b The second submesh
  17315. * @returns The result of the comparison
  17316. */
  17317. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17318. /**
  17319. * Resets the different lists of submeshes to prepare a new frame.
  17320. */
  17321. prepare(): void;
  17322. dispose(): void;
  17323. /**
  17324. * Inserts the submesh in its correct queue depending on its material.
  17325. * @param subMesh The submesh to dispatch
  17326. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17327. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17328. */
  17329. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17330. dispatchSprites(spriteManager: ISpriteManager): void;
  17331. dispatchParticles(particleSystem: IParticleSystem): void;
  17332. private _renderParticles;
  17333. private _renderSprites;
  17334. }
  17335. }
  17336. declare module BABYLON {
  17337. /**
  17338. * Interface describing the different options available in the rendering manager
  17339. * regarding Auto Clear between groups.
  17340. */
  17341. export interface IRenderingManagerAutoClearSetup {
  17342. /**
  17343. * Defines whether or not autoclear is enable.
  17344. */
  17345. autoClear: boolean;
  17346. /**
  17347. * Defines whether or not to autoclear the depth buffer.
  17348. */
  17349. depth: boolean;
  17350. /**
  17351. * Defines whether or not to autoclear the stencil buffer.
  17352. */
  17353. stencil: boolean;
  17354. }
  17355. /**
  17356. * This class is used by the onRenderingGroupObservable
  17357. */
  17358. export class RenderingGroupInfo {
  17359. /**
  17360. * The Scene that being rendered
  17361. */
  17362. scene: Scene;
  17363. /**
  17364. * The camera currently used for the rendering pass
  17365. */
  17366. camera: Nullable<Camera>;
  17367. /**
  17368. * The ID of the renderingGroup being processed
  17369. */
  17370. renderingGroupId: number;
  17371. }
  17372. /**
  17373. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17374. * It is enable to manage the different groups as well as the different necessary sort functions.
  17375. * This should not be used directly aside of the few static configurations
  17376. */
  17377. export class RenderingManager {
  17378. /**
  17379. * The max id used for rendering groups (not included)
  17380. */
  17381. static MAX_RENDERINGGROUPS: number;
  17382. /**
  17383. * The min id used for rendering groups (included)
  17384. */
  17385. static MIN_RENDERINGGROUPS: number;
  17386. /**
  17387. * Used to globally prevent autoclearing scenes.
  17388. */
  17389. static AUTOCLEAR: boolean;
  17390. /**
  17391. * @hidden
  17392. */
  17393. _useSceneAutoClearSetup: boolean;
  17394. private _scene;
  17395. private _renderingGroups;
  17396. private _depthStencilBufferAlreadyCleaned;
  17397. private _autoClearDepthStencil;
  17398. private _customOpaqueSortCompareFn;
  17399. private _customAlphaTestSortCompareFn;
  17400. private _customTransparentSortCompareFn;
  17401. private _renderingGroupInfo;
  17402. /**
  17403. * Instantiates a new rendering group for a particular scene
  17404. * @param scene Defines the scene the groups belongs to
  17405. */
  17406. constructor(scene: Scene);
  17407. private _clearDepthStencilBuffer;
  17408. /**
  17409. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17410. * @hidden
  17411. */
  17412. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17413. /**
  17414. * Resets the different information of the group to prepare a new frame
  17415. * @hidden
  17416. */
  17417. reset(): void;
  17418. /**
  17419. * Dispose and release the group and its associated resources.
  17420. * @hidden
  17421. */
  17422. dispose(): void;
  17423. /**
  17424. * Clear the info related to rendering groups preventing retention points during dispose.
  17425. */
  17426. freeRenderingGroups(): void;
  17427. private _prepareRenderingGroup;
  17428. /**
  17429. * Add a sprite manager to the rendering manager in order to render it this frame.
  17430. * @param spriteManager Define the sprite manager to render
  17431. */
  17432. dispatchSprites(spriteManager: ISpriteManager): void;
  17433. /**
  17434. * Add a particle system to the rendering manager in order to render it this frame.
  17435. * @param particleSystem Define the particle system to render
  17436. */
  17437. dispatchParticles(particleSystem: IParticleSystem): void;
  17438. /**
  17439. * Add a submesh to the manager in order to render it this frame
  17440. * @param subMesh The submesh to dispatch
  17441. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17442. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17443. */
  17444. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17445. /**
  17446. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17447. * This allowed control for front to back rendering or reversly depending of the special needs.
  17448. *
  17449. * @param renderingGroupId The rendering group id corresponding to its index
  17450. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17451. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17452. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17453. */
  17454. 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;
  17455. /**
  17456. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17457. *
  17458. * @param renderingGroupId The rendering group id corresponding to its index
  17459. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17460. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17461. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17462. */
  17463. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17464. /**
  17465. * Gets the current auto clear configuration for one rendering group of the rendering
  17466. * manager.
  17467. * @param index the rendering group index to get the information for
  17468. * @returns The auto clear setup for the requested rendering group
  17469. */
  17470. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17471. }
  17472. }
  17473. declare module BABYLON {
  17474. /**
  17475. * This Helps creating a texture that will be created from a camera in your scene.
  17476. * It is basically a dynamic texture that could be used to create special effects for instance.
  17477. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  17478. */
  17479. export class RenderTargetTexture extends Texture {
  17480. isCube: boolean;
  17481. /**
  17482. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  17483. */
  17484. static readonly REFRESHRATE_RENDER_ONCE: number;
  17485. /**
  17486. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  17487. */
  17488. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  17489. /**
  17490. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  17491. * the central point of your effect and can save a lot of performances.
  17492. */
  17493. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  17494. /**
  17495. * Use this predicate to dynamically define the list of mesh you want to render.
  17496. * If set, the renderList property will be overwritten.
  17497. */
  17498. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  17499. private _renderList;
  17500. /**
  17501. * Use this list to define the list of mesh you want to render.
  17502. */
  17503. renderList: Nullable<Array<AbstractMesh>>;
  17504. private _hookArray;
  17505. /**
  17506. * Define if particles should be rendered in your texture.
  17507. */
  17508. renderParticles: boolean;
  17509. /**
  17510. * Define if sprites should be rendered in your texture.
  17511. */
  17512. renderSprites: boolean;
  17513. /**
  17514. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  17515. */
  17516. coordinatesMode: number;
  17517. /**
  17518. * Define the camera used to render the texture.
  17519. */
  17520. activeCamera: Nullable<Camera>;
  17521. /**
  17522. * Override the render function of the texture with your own one.
  17523. */
  17524. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  17525. /**
  17526. * Define if camera post processes should be use while rendering the texture.
  17527. */
  17528. useCameraPostProcesses: boolean;
  17529. /**
  17530. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  17531. */
  17532. ignoreCameraViewport: boolean;
  17533. private _postProcessManager;
  17534. private _postProcesses;
  17535. private _resizeObserver;
  17536. /**
  17537. * An event triggered when the texture is unbind.
  17538. */
  17539. onBeforeBindObservable: Observable<RenderTargetTexture>;
  17540. /**
  17541. * An event triggered when the texture is unbind.
  17542. */
  17543. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  17544. private _onAfterUnbindObserver;
  17545. /**
  17546. * Set a after unbind callback in the texture.
  17547. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  17548. */
  17549. onAfterUnbind: () => void;
  17550. /**
  17551. * An event triggered before rendering the texture
  17552. */
  17553. onBeforeRenderObservable: Observable<number>;
  17554. private _onBeforeRenderObserver;
  17555. /**
  17556. * Set a before render callback in the texture.
  17557. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  17558. */
  17559. onBeforeRender: (faceIndex: number) => void;
  17560. /**
  17561. * An event triggered after rendering the texture
  17562. */
  17563. onAfterRenderObservable: Observable<number>;
  17564. private _onAfterRenderObserver;
  17565. /**
  17566. * Set a after render callback in the texture.
  17567. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  17568. */
  17569. onAfterRender: (faceIndex: number) => void;
  17570. /**
  17571. * An event triggered after the texture clear
  17572. */
  17573. onClearObservable: Observable<Engine>;
  17574. private _onClearObserver;
  17575. /**
  17576. * Set a clear callback in the texture.
  17577. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  17578. */
  17579. onClear: (Engine: Engine) => void;
  17580. /**
  17581. * Define the clear color of the Render Target if it should be different from the scene.
  17582. */
  17583. clearColor: Color4;
  17584. protected _size: number | {
  17585. width: number;
  17586. height: number;
  17587. };
  17588. protected _initialSizeParameter: number | {
  17589. width: number;
  17590. height: number;
  17591. } | {
  17592. ratio: number;
  17593. };
  17594. protected _sizeRatio: Nullable<number>;
  17595. /** @hidden */
  17596. _generateMipMaps: boolean;
  17597. protected _renderingManager: RenderingManager;
  17598. /** @hidden */
  17599. _waitingRenderList: string[];
  17600. protected _doNotChangeAspectRatio: boolean;
  17601. protected _currentRefreshId: number;
  17602. protected _refreshRate: number;
  17603. protected _textureMatrix: Matrix;
  17604. protected _samples: number;
  17605. protected _renderTargetOptions: RenderTargetCreationOptions;
  17606. /**
  17607. * Gets render target creation options that were used.
  17608. */
  17609. readonly renderTargetOptions: RenderTargetCreationOptions;
  17610. protected _engine: Engine;
  17611. protected _onRatioRescale(): void;
  17612. /**
  17613. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  17614. * It must define where the camera used to render the texture is set
  17615. */
  17616. boundingBoxPosition: Vector3;
  17617. private _boundingBoxSize;
  17618. /**
  17619. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  17620. * When defined, the cubemap will switch to local mode
  17621. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  17622. * @example https://www.babylonjs-playground.com/#RNASML
  17623. */
  17624. boundingBoxSize: Vector3;
  17625. /**
  17626. * In case the RTT has been created with a depth texture, get the associated
  17627. * depth texture.
  17628. * Otherwise, return null.
  17629. */
  17630. depthStencilTexture: Nullable<InternalTexture>;
  17631. /**
  17632. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  17633. * or used a shadow, depth texture...
  17634. * @param name The friendly name of the texture
  17635. * @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)
  17636. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  17637. * @param generateMipMaps True if mip maps need to be generated after render.
  17638. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  17639. * @param type The type of the buffer in the RTT (int, half float, float...)
  17640. * @param isCube True if a cube texture needs to be created
  17641. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  17642. * @param generateDepthBuffer True to generate a depth buffer
  17643. * @param generateStencilBuffer True to generate a stencil buffer
  17644. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  17645. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  17646. * @param delayAllocation if the texture allocation should be delayed (default: false)
  17647. */
  17648. constructor(name: string, size: number | {
  17649. width: number;
  17650. height: number;
  17651. } | {
  17652. ratio: number;
  17653. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  17654. /**
  17655. * Creates a depth stencil texture.
  17656. * This is only available in WebGL 2 or with the depth texture extension available.
  17657. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  17658. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  17659. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  17660. */
  17661. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  17662. private _processSizeParameter;
  17663. /**
  17664. * Define the number of samples to use in case of MSAA.
  17665. * It defaults to one meaning no MSAA has been enabled.
  17666. */
  17667. samples: number;
  17668. /**
  17669. * Resets the refresh counter of the texture and start bak from scratch.
  17670. * Could be useful to regenerate the texture if it is setup to render only once.
  17671. */
  17672. resetRefreshCounter(): void;
  17673. /**
  17674. * Define the refresh rate of the texture or the rendering frequency.
  17675. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  17676. */
  17677. refreshRate: number;
  17678. /**
  17679. * Adds a post process to the render target rendering passes.
  17680. * @param postProcess define the post process to add
  17681. */
  17682. addPostProcess(postProcess: PostProcess): void;
  17683. /**
  17684. * Clear all the post processes attached to the render target
  17685. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  17686. */
  17687. clearPostProcesses(dispose?: boolean): void;
  17688. /**
  17689. * Remove one of the post process from the list of attached post processes to the texture
  17690. * @param postProcess define the post process to remove from the list
  17691. */
  17692. removePostProcess(postProcess: PostProcess): void;
  17693. /** @hidden */
  17694. _shouldRender(): boolean;
  17695. /**
  17696. * Gets the actual render size of the texture.
  17697. * @returns the width of the render size
  17698. */
  17699. getRenderSize(): number;
  17700. /**
  17701. * Gets the actual render width of the texture.
  17702. * @returns the width of the render size
  17703. */
  17704. getRenderWidth(): number;
  17705. /**
  17706. * Gets the actual render height of the texture.
  17707. * @returns the height of the render size
  17708. */
  17709. getRenderHeight(): number;
  17710. /**
  17711. * Get if the texture can be rescaled or not.
  17712. */
  17713. readonly canRescale: boolean;
  17714. /**
  17715. * Resize the texture using a ratio.
  17716. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  17717. */
  17718. scale(ratio: number): void;
  17719. /**
  17720. * Get the texture reflection matrix used to rotate/transform the reflection.
  17721. * @returns the reflection matrix
  17722. */
  17723. getReflectionTextureMatrix(): Matrix;
  17724. /**
  17725. * Resize the texture to a new desired size.
  17726. * Be carrefull as it will recreate all the data in the new texture.
  17727. * @param size Define the new size. It can be:
  17728. * - a number for squared texture,
  17729. * - an object containing { width: number, height: number }
  17730. * - or an object containing a ratio { ratio: number }
  17731. */
  17732. resize(size: number | {
  17733. width: number;
  17734. height: number;
  17735. } | {
  17736. ratio: number;
  17737. }): void;
  17738. /**
  17739. * Renders all the objects from the render list into the texture.
  17740. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  17741. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  17742. */
  17743. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  17744. private _bestReflectionRenderTargetDimension;
  17745. /**
  17746. * @hidden
  17747. * @param faceIndex face index to bind to if this is a cubetexture
  17748. */
  17749. _bindFrameBuffer(faceIndex?: number): void;
  17750. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  17751. private renderToTarget;
  17752. /**
  17753. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17754. * This allowed control for front to back rendering or reversly depending of the special needs.
  17755. *
  17756. * @param renderingGroupId The rendering group id corresponding to its index
  17757. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17758. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17759. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17760. */
  17761. 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;
  17762. /**
  17763. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17764. *
  17765. * @param renderingGroupId The rendering group id corresponding to its index
  17766. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17767. */
  17768. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  17769. /**
  17770. * Clones the texture.
  17771. * @returns the cloned texture
  17772. */
  17773. clone(): RenderTargetTexture;
  17774. /**
  17775. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  17776. * @returns The JSON representation of the texture
  17777. */
  17778. serialize(): any;
  17779. /**
  17780. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  17781. */
  17782. disposeFramebufferObjects(): void;
  17783. /**
  17784. * Dispose the texture and release its associated resources.
  17785. */
  17786. dispose(): void;
  17787. /** @hidden */
  17788. _rebuild(): void;
  17789. /**
  17790. * Clear the info related to rendering groups preventing retention point in material dispose.
  17791. */
  17792. freeRenderingGroups(): void;
  17793. /**
  17794. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  17795. * @returns the view count
  17796. */
  17797. getViewCount(): number;
  17798. }
  17799. /**
  17800. * Renders to multiple views with a single draw call
  17801. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  17802. */
  17803. export class MultiviewRenderTarget extends RenderTargetTexture {
  17804. /**
  17805. * Creates a multiview render target
  17806. * @param scene scene used with the render target
  17807. * @param size the size of the render target (used for each view)
  17808. */
  17809. constructor(scene: Scene, size?: number | {
  17810. width: number;
  17811. height: number;
  17812. } | {
  17813. ratio: number;
  17814. });
  17815. /**
  17816. * @hidden
  17817. * @param faceIndex the face index, if its a cube texture
  17818. */
  17819. _bindFrameBuffer(faceIndex?: number): void;
  17820. /**
  17821. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  17822. * @returns the view count
  17823. */
  17824. getViewCount(): number;
  17825. }
  17826. }
  17827. declare module BABYLON {
  17828. /**
  17829. * Mirror texture can be used to simulate the view from a mirror in a scene.
  17830. * It will dynamically be rendered every frame to adapt to the camera point of view.
  17831. * You can then easily use it as a reflectionTexture on a flat surface.
  17832. * In case the surface is not a plane, please consider relying on reflection probes.
  17833. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17834. */
  17835. export class MirrorTexture extends RenderTargetTexture {
  17836. private scene;
  17837. /**
  17838. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  17839. * It is possible to directly set the mirrorPlane by directly using a 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.
  17840. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17841. */
  17842. mirrorPlane: Plane;
  17843. /**
  17844. * Define the blur ratio used to blur the reflection if needed.
  17845. */
  17846. blurRatio: number;
  17847. /**
  17848. * Define the adaptive blur kernel used to blur the reflection if needed.
  17849. * This will autocompute the closest best match for the `blurKernel`
  17850. */
  17851. adaptiveBlurKernel: number;
  17852. /**
  17853. * Define the blur kernel used to blur the reflection if needed.
  17854. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17855. */
  17856. blurKernel: number;
  17857. /**
  17858. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  17859. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17860. */
  17861. blurKernelX: number;
  17862. /**
  17863. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  17864. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17865. */
  17866. blurKernelY: number;
  17867. private _autoComputeBlurKernel;
  17868. protected _onRatioRescale(): void;
  17869. private _updateGammaSpace;
  17870. private _imageProcessingConfigChangeObserver;
  17871. private _transformMatrix;
  17872. private _mirrorMatrix;
  17873. private _savedViewMatrix;
  17874. private _blurX;
  17875. private _blurY;
  17876. private _adaptiveBlurKernel;
  17877. private _blurKernelX;
  17878. private _blurKernelY;
  17879. private _blurRatio;
  17880. /**
  17881. * Instantiates a Mirror Texture.
  17882. * Mirror texture can be used to simulate the view from a mirror in a scene.
  17883. * It will dynamically be rendered every frame to adapt to the camera point of view.
  17884. * You can then easily use it as a reflectionTexture on a flat surface.
  17885. * In case the surface is not a plane, please consider relying on reflection probes.
  17886. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17887. * @param name
  17888. * @param size
  17889. * @param scene
  17890. * @param generateMipMaps
  17891. * @param type
  17892. * @param samplingMode
  17893. * @param generateDepthBuffer
  17894. */
  17895. constructor(name: string, size: number | {
  17896. width: number;
  17897. height: number;
  17898. } | {
  17899. ratio: number;
  17900. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  17901. private _preparePostProcesses;
  17902. /**
  17903. * Clone the mirror texture.
  17904. * @returns the cloned texture
  17905. */
  17906. clone(): MirrorTexture;
  17907. /**
  17908. * Serialize the texture to a JSON representation you could use in Parse later on
  17909. * @returns the serialized JSON representation
  17910. */
  17911. serialize(): any;
  17912. /**
  17913. * Dispose the texture and release its associated resources.
  17914. */
  17915. dispose(): void;
  17916. }
  17917. }
  17918. declare module BABYLON {
  17919. /**
  17920. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  17921. * @see http://doc.babylonjs.com/babylon101/materials#texture
  17922. */
  17923. export class Texture extends BaseTexture {
  17924. /** @hidden */
  17925. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  17926. /** @hidden */
  17927. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  17928. /** @hidden */
  17929. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  17930. /** nearest is mag = nearest and min = nearest and mip = linear */
  17931. static readonly NEAREST_SAMPLINGMODE: number;
  17932. /** nearest is mag = nearest and min = nearest and mip = linear */
  17933. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  17934. /** Bilinear is mag = linear and min = linear and mip = nearest */
  17935. static readonly BILINEAR_SAMPLINGMODE: number;
  17936. /** Bilinear is mag = linear and min = linear and mip = nearest */
  17937. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  17938. /** Trilinear is mag = linear and min = linear and mip = linear */
  17939. static readonly TRILINEAR_SAMPLINGMODE: number;
  17940. /** Trilinear is mag = linear and min = linear and mip = linear */
  17941. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  17942. /** mag = nearest and min = nearest and mip = nearest */
  17943. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  17944. /** mag = nearest and min = linear and mip = nearest */
  17945. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  17946. /** mag = nearest and min = linear and mip = linear */
  17947. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  17948. /** mag = nearest and min = linear and mip = none */
  17949. static readonly NEAREST_LINEAR: number;
  17950. /** mag = nearest and min = nearest and mip = none */
  17951. static readonly NEAREST_NEAREST: number;
  17952. /** mag = linear and min = nearest and mip = nearest */
  17953. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  17954. /** mag = linear and min = nearest and mip = linear */
  17955. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  17956. /** mag = linear and min = linear and mip = none */
  17957. static readonly LINEAR_LINEAR: number;
  17958. /** mag = linear and min = nearest and mip = none */
  17959. static readonly LINEAR_NEAREST: number;
  17960. /** Explicit coordinates mode */
  17961. static readonly EXPLICIT_MODE: number;
  17962. /** Spherical coordinates mode */
  17963. static readonly SPHERICAL_MODE: number;
  17964. /** Planar coordinates mode */
  17965. static readonly PLANAR_MODE: number;
  17966. /** Cubic coordinates mode */
  17967. static readonly CUBIC_MODE: number;
  17968. /** Projection coordinates mode */
  17969. static readonly PROJECTION_MODE: number;
  17970. /** Inverse Cubic coordinates mode */
  17971. static readonly SKYBOX_MODE: number;
  17972. /** Inverse Cubic coordinates mode */
  17973. static readonly INVCUBIC_MODE: number;
  17974. /** Equirectangular coordinates mode */
  17975. static readonly EQUIRECTANGULAR_MODE: number;
  17976. /** Equirectangular Fixed coordinates mode */
  17977. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  17978. /** Equirectangular Fixed Mirrored coordinates mode */
  17979. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  17980. /** Texture is not repeating outside of 0..1 UVs */
  17981. static readonly CLAMP_ADDRESSMODE: number;
  17982. /** Texture is repeating outside of 0..1 UVs */
  17983. static readonly WRAP_ADDRESSMODE: number;
  17984. /** Texture is repeating and mirrored */
  17985. static readonly MIRROR_ADDRESSMODE: number;
  17986. /**
  17987. * 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
  17988. */
  17989. static UseSerializedUrlIfAny: boolean;
  17990. /**
  17991. * Define the url of the texture.
  17992. */
  17993. url: Nullable<string>;
  17994. /**
  17995. * Define an offset on the texture to offset the u coordinates of the UVs
  17996. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  17997. */
  17998. uOffset: number;
  17999. /**
  18000. * Define an offset on the texture to offset the v coordinates of the UVs
  18001. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18002. */
  18003. vOffset: number;
  18004. /**
  18005. * Define an offset on the texture to scale the u coordinates of the UVs
  18006. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18007. */
  18008. uScale: number;
  18009. /**
  18010. * Define an offset on the texture to scale the v coordinates of the UVs
  18011. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18012. */
  18013. vScale: number;
  18014. /**
  18015. * Define an offset on the texture to rotate around the u coordinates of the UVs
  18016. * @see http://doc.babylonjs.com/how_to/more_materials
  18017. */
  18018. uAng: number;
  18019. /**
  18020. * Define an offset on the texture to rotate around the v coordinates of the UVs
  18021. * @see http://doc.babylonjs.com/how_to/more_materials
  18022. */
  18023. vAng: number;
  18024. /**
  18025. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  18026. * @see http://doc.babylonjs.com/how_to/more_materials
  18027. */
  18028. wAng: number;
  18029. /**
  18030. * Defines the center of rotation (U)
  18031. */
  18032. uRotationCenter: number;
  18033. /**
  18034. * Defines the center of rotation (V)
  18035. */
  18036. vRotationCenter: number;
  18037. /**
  18038. * Defines the center of rotation (W)
  18039. */
  18040. wRotationCenter: number;
  18041. /**
  18042. * Are mip maps generated for this texture or not.
  18043. */
  18044. readonly noMipmap: boolean;
  18045. /**
  18046. * List of inspectable custom properties (used by the Inspector)
  18047. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18048. */
  18049. inspectableCustomProperties: IInspectable[];
  18050. private _noMipmap;
  18051. /** @hidden */
  18052. _invertY: boolean;
  18053. private _rowGenerationMatrix;
  18054. private _cachedTextureMatrix;
  18055. private _projectionModeMatrix;
  18056. private _t0;
  18057. private _t1;
  18058. private _t2;
  18059. private _cachedUOffset;
  18060. private _cachedVOffset;
  18061. private _cachedUScale;
  18062. private _cachedVScale;
  18063. private _cachedUAng;
  18064. private _cachedVAng;
  18065. private _cachedWAng;
  18066. private _cachedProjectionMatrixId;
  18067. private _cachedCoordinatesMode;
  18068. /** @hidden */
  18069. protected _initialSamplingMode: number;
  18070. /** @hidden */
  18071. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  18072. private _deleteBuffer;
  18073. protected _format: Nullable<number>;
  18074. private _delayedOnLoad;
  18075. private _delayedOnError;
  18076. /**
  18077. * Observable triggered once the texture has been loaded.
  18078. */
  18079. onLoadObservable: Observable<Texture>;
  18080. protected _isBlocking: boolean;
  18081. /**
  18082. * Is the texture preventing material to render while loading.
  18083. * If false, a default texture will be used instead of the loading one during the preparation step.
  18084. */
  18085. isBlocking: boolean;
  18086. /**
  18087. * Get the current sampling mode associated with the texture.
  18088. */
  18089. readonly samplingMode: number;
  18090. /**
  18091. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  18092. */
  18093. readonly invertY: boolean;
  18094. /**
  18095. * Instantiates a new texture.
  18096. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18097. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18098. * @param url define the url of the picture to load as a texture
  18099. * @param scene define the scene the texture will belong to
  18100. * @param noMipmap define if the texture will require mip maps or not
  18101. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18102. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18103. * @param onLoad define a callback triggered when the texture has been loaded
  18104. * @param onError define a callback triggered when an error occurred during the loading session
  18105. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18106. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18107. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18108. */
  18109. 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);
  18110. /**
  18111. * Update the url (and optional buffer) of this texture if url was null during construction.
  18112. * @param url the url of the texture
  18113. * @param buffer the buffer of the texture (defaults to null)
  18114. * @param onLoad callback called when the texture is loaded (defaults to null)
  18115. */
  18116. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  18117. /**
  18118. * Finish the loading sequence of a texture flagged as delayed load.
  18119. * @hidden
  18120. */
  18121. delayLoad(): void;
  18122. private _prepareRowForTextureGeneration;
  18123. /**
  18124. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  18125. * @returns the transform matrix of the texture.
  18126. */
  18127. getTextureMatrix(): Matrix;
  18128. /**
  18129. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  18130. * @returns The reflection texture transform
  18131. */
  18132. getReflectionTextureMatrix(): Matrix;
  18133. /**
  18134. * Clones the texture.
  18135. * @returns the cloned texture
  18136. */
  18137. clone(): Texture;
  18138. /**
  18139. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18140. * @returns The JSON representation of the texture
  18141. */
  18142. serialize(): any;
  18143. /**
  18144. * Get the current class name of the texture useful for serialization or dynamic coding.
  18145. * @returns "Texture"
  18146. */
  18147. getClassName(): string;
  18148. /**
  18149. * Dispose the texture and release its associated resources.
  18150. */
  18151. dispose(): void;
  18152. /**
  18153. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  18154. * @param parsedTexture Define the JSON representation of the texture
  18155. * @param scene Define the scene the parsed texture should be instantiated in
  18156. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  18157. * @returns The parsed texture if successful
  18158. */
  18159. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  18160. /**
  18161. * Creates a texture from its base 64 representation.
  18162. * @param data Define the base64 payload without the data: prefix
  18163. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18164. * @param scene Define the scene the texture should belong to
  18165. * @param noMipmap Forces the texture to not create mip map information if true
  18166. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18167. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18168. * @param onLoad define a callback triggered when the texture has been loaded
  18169. * @param onError define a callback triggered when an error occurred during the loading session
  18170. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18171. * @returns the created texture
  18172. */
  18173. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  18174. /**
  18175. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  18176. * @param data Define the base64 payload without the data: prefix
  18177. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18178. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18179. * @param scene Define the scene the texture should belong to
  18180. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18181. * @param noMipmap Forces the texture to not create mip map information if true
  18182. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18183. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18184. * @param onLoad define a callback triggered when the texture has been loaded
  18185. * @param onError define a callback triggered when an error occurred during the loading session
  18186. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18187. * @returns the created texture
  18188. */
  18189. 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;
  18190. }
  18191. }
  18192. declare module BABYLON {
  18193. /**
  18194. * Raw texture can help creating a texture directly from an array of data.
  18195. * This can be super useful if you either get the data from an uncompressed source or
  18196. * if you wish to create your texture pixel by pixel.
  18197. */
  18198. export class RawTexture extends Texture {
  18199. /**
  18200. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18201. */
  18202. format: number;
  18203. private _engine;
  18204. /**
  18205. * Instantiates a new RawTexture.
  18206. * Raw texture can help creating a texture directly from an array of data.
  18207. * This can be super useful if you either get the data from an uncompressed source or
  18208. * if you wish to create your texture pixel by pixel.
  18209. * @param data define the array of data to use to create the texture
  18210. * @param width define the width of the texture
  18211. * @param height define the height of the texture
  18212. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18213. * @param scene define the scene the texture belongs to
  18214. * @param generateMipMaps define whether mip maps should be generated or not
  18215. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18216. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18217. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18218. */
  18219. constructor(data: ArrayBufferView, width: number, height: number,
  18220. /**
  18221. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18222. */
  18223. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  18224. /**
  18225. * Updates the texture underlying data.
  18226. * @param data Define the new data of the texture
  18227. */
  18228. update(data: ArrayBufferView): void;
  18229. /**
  18230. * Creates a luminance texture from some data.
  18231. * @param data Define the texture data
  18232. * @param width Define the width of the texture
  18233. * @param height Define the height of the texture
  18234. * @param scene Define the scene the texture belongs to
  18235. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18236. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18237. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18238. * @returns the luminance texture
  18239. */
  18240. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18241. /**
  18242. * Creates a luminance alpha texture from some data.
  18243. * @param data Define the texture data
  18244. * @param width Define the width of the texture
  18245. * @param height Define the height of the texture
  18246. * @param scene Define the scene the texture belongs to
  18247. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18248. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18249. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18250. * @returns the luminance alpha texture
  18251. */
  18252. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18253. /**
  18254. * Creates an alpha texture from some data.
  18255. * @param data Define the texture data
  18256. * @param width Define the width of the texture
  18257. * @param height Define the height of the texture
  18258. * @param scene Define the scene the texture belongs to
  18259. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18260. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18261. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18262. * @returns the alpha texture
  18263. */
  18264. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18265. /**
  18266. * Creates a RGB texture from some data.
  18267. * @param data Define the texture data
  18268. * @param width Define the width of the texture
  18269. * @param height Define the height of the texture
  18270. * @param scene Define the scene the texture belongs to
  18271. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18272. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18273. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18274. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18275. * @returns the RGB alpha texture
  18276. */
  18277. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18278. /**
  18279. * Creates a RGBA texture from some data.
  18280. * @param data Define the texture data
  18281. * @param width Define the width of the texture
  18282. * @param height Define the height of the texture
  18283. * @param scene Define the scene the texture belongs to
  18284. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18285. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18286. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18287. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18288. * @returns the RGBA texture
  18289. */
  18290. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18291. /**
  18292. * Creates a R texture from some data.
  18293. * @param data Define the texture data
  18294. * @param width Define the width of the texture
  18295. * @param height Define the height of the texture
  18296. * @param scene Define the scene the texture belongs to
  18297. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18298. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18299. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18300. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18301. * @returns the R texture
  18302. */
  18303. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18304. }
  18305. }
  18306. declare module BABYLON {
  18307. /**
  18308. * Defines a runtime animation
  18309. */
  18310. export class RuntimeAnimation {
  18311. private _events;
  18312. /**
  18313. * The current frame of the runtime animation
  18314. */
  18315. private _currentFrame;
  18316. /**
  18317. * The animation used by the runtime animation
  18318. */
  18319. private _animation;
  18320. /**
  18321. * The target of the runtime animation
  18322. */
  18323. private _target;
  18324. /**
  18325. * The initiating animatable
  18326. */
  18327. private _host;
  18328. /**
  18329. * The original value of the runtime animation
  18330. */
  18331. private _originalValue;
  18332. /**
  18333. * The original blend value of the runtime animation
  18334. */
  18335. private _originalBlendValue;
  18336. /**
  18337. * The offsets cache of the runtime animation
  18338. */
  18339. private _offsetsCache;
  18340. /**
  18341. * The high limits cache of the runtime animation
  18342. */
  18343. private _highLimitsCache;
  18344. /**
  18345. * Specifies if the runtime animation has been stopped
  18346. */
  18347. private _stopped;
  18348. /**
  18349. * The blending factor of the runtime animation
  18350. */
  18351. private _blendingFactor;
  18352. /**
  18353. * The BabylonJS scene
  18354. */
  18355. private _scene;
  18356. /**
  18357. * The current value of the runtime animation
  18358. */
  18359. private _currentValue;
  18360. /** @hidden */
  18361. _workValue: any;
  18362. /**
  18363. * The active target of the runtime animation
  18364. */
  18365. private _activeTarget;
  18366. /**
  18367. * The target path of the runtime animation
  18368. */
  18369. private _targetPath;
  18370. /**
  18371. * The weight of the runtime animation
  18372. */
  18373. private _weight;
  18374. /**
  18375. * The ratio offset of the runtime animation
  18376. */
  18377. private _ratioOffset;
  18378. /**
  18379. * The previous delay of the runtime animation
  18380. */
  18381. private _previousDelay;
  18382. /**
  18383. * The previous ratio of the runtime animation
  18384. */
  18385. private _previousRatio;
  18386. /**
  18387. * Gets the current frame of the runtime animation
  18388. */
  18389. readonly currentFrame: number;
  18390. /**
  18391. * Gets the weight of the runtime animation
  18392. */
  18393. readonly weight: number;
  18394. /**
  18395. * Gets the current value of the runtime animation
  18396. */
  18397. readonly currentValue: any;
  18398. /**
  18399. * Gets the target path of the runtime animation
  18400. */
  18401. readonly targetPath: string;
  18402. /**
  18403. * Gets the actual target of the runtime animation
  18404. */
  18405. readonly target: any;
  18406. /**
  18407. * Create a new RuntimeAnimation object
  18408. * @param target defines the target of the animation
  18409. * @param animation defines the source animation object
  18410. * @param scene defines the hosting scene
  18411. * @param host defines the initiating Animatable
  18412. */
  18413. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  18414. /**
  18415. * Gets the animation from the runtime animation
  18416. */
  18417. readonly animation: Animation;
  18418. /**
  18419. * Resets the runtime animation to the beginning
  18420. * @param restoreOriginal defines whether to restore the target property to the original value
  18421. */
  18422. reset(restoreOriginal?: boolean): void;
  18423. /**
  18424. * Specifies if the runtime animation is stopped
  18425. * @returns Boolean specifying if the runtime animation is stopped
  18426. */
  18427. isStopped(): boolean;
  18428. /**
  18429. * Disposes of the runtime animation
  18430. */
  18431. dispose(): void;
  18432. /**
  18433. * Interpolates the animation from the current frame
  18434. * @param currentFrame The frame to interpolate the animation to
  18435. * @param repeatCount The number of times that the animation should loop
  18436. * @param loopMode The type of looping mode to use
  18437. * @param offsetValue Animation offset value
  18438. * @param highLimitValue The high limit value
  18439. * @returns The interpolated value
  18440. */
  18441. private _interpolate;
  18442. /**
  18443. * Apply the interpolated value to the target
  18444. * @param currentValue defines the value computed by the animation
  18445. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  18446. */
  18447. setValue(currentValue: any, weight?: number): void;
  18448. private _setValue;
  18449. /**
  18450. * Gets the loop pmode of the runtime animation
  18451. * @returns Loop Mode
  18452. */
  18453. private _getCorrectLoopMode;
  18454. /**
  18455. * Move the current animation to a given frame
  18456. * @param frame defines the frame to move to
  18457. */
  18458. goToFrame(frame: number): void;
  18459. /**
  18460. * @hidden Internal use only
  18461. */
  18462. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  18463. /**
  18464. * Execute the current animation
  18465. * @param delay defines the delay to add to the current frame
  18466. * @param from defines the lower bound of the animation range
  18467. * @param to defines the upper bound of the animation range
  18468. * @param loop defines if the current animation must loop
  18469. * @param speedRatio defines the current speed ratio
  18470. * @param weight defines the weight of the animation (default is -1 so no weight)
  18471. * @param onLoop optional callback called when animation loops
  18472. * @returns a boolean indicating if the animation is running
  18473. */
  18474. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  18475. }
  18476. }
  18477. declare module BABYLON {
  18478. /**
  18479. * Class used to store an actual running animation
  18480. */
  18481. export class Animatable {
  18482. /** defines the target object */
  18483. target: any;
  18484. /** defines the starting frame number (default is 0) */
  18485. fromFrame: number;
  18486. /** defines the ending frame number (default is 100) */
  18487. toFrame: number;
  18488. /** defines if the animation must loop (default is false) */
  18489. loopAnimation: boolean;
  18490. /** defines a callback to call when animation ends if it is not looping */
  18491. onAnimationEnd?: (() => void) | null | undefined;
  18492. /** defines a callback to call when animation loops */
  18493. onAnimationLoop?: (() => void) | null | undefined;
  18494. private _localDelayOffset;
  18495. private _pausedDelay;
  18496. private _runtimeAnimations;
  18497. private _paused;
  18498. private _scene;
  18499. private _speedRatio;
  18500. private _weight;
  18501. private _syncRoot;
  18502. /**
  18503. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  18504. * This will only apply for non looping animation (default is true)
  18505. */
  18506. disposeOnEnd: boolean;
  18507. /**
  18508. * Gets a boolean indicating if the animation has started
  18509. */
  18510. animationStarted: boolean;
  18511. /**
  18512. * Observer raised when the animation ends
  18513. */
  18514. onAnimationEndObservable: Observable<Animatable>;
  18515. /**
  18516. * Observer raised when the animation loops
  18517. */
  18518. onAnimationLoopObservable: Observable<Animatable>;
  18519. /**
  18520. * Gets the root Animatable used to synchronize and normalize animations
  18521. */
  18522. readonly syncRoot: Animatable;
  18523. /**
  18524. * Gets the current frame of the first RuntimeAnimation
  18525. * Used to synchronize Animatables
  18526. */
  18527. readonly masterFrame: number;
  18528. /**
  18529. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  18530. */
  18531. weight: number;
  18532. /**
  18533. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  18534. */
  18535. speedRatio: number;
  18536. /**
  18537. * Creates a new Animatable
  18538. * @param scene defines the hosting scene
  18539. * @param target defines the target object
  18540. * @param fromFrame defines the starting frame number (default is 0)
  18541. * @param toFrame defines the ending frame number (default is 100)
  18542. * @param loopAnimation defines if the animation must loop (default is false)
  18543. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  18544. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  18545. * @param animations defines a group of animation to add to the new Animatable
  18546. * @param onAnimationLoop defines a callback to call when animation loops
  18547. */
  18548. constructor(scene: Scene,
  18549. /** defines the target object */
  18550. target: any,
  18551. /** defines the starting frame number (default is 0) */
  18552. fromFrame?: number,
  18553. /** defines the ending frame number (default is 100) */
  18554. toFrame?: number,
  18555. /** defines if the animation must loop (default is false) */
  18556. loopAnimation?: boolean, speedRatio?: number,
  18557. /** defines a callback to call when animation ends if it is not looping */
  18558. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  18559. /** defines a callback to call when animation loops */
  18560. onAnimationLoop?: (() => void) | null | undefined);
  18561. /**
  18562. * Synchronize and normalize current Animatable with a source Animatable
  18563. * This is useful when using animation weights and when animations are not of the same length
  18564. * @param root defines the root Animatable to synchronize with
  18565. * @returns the current Animatable
  18566. */
  18567. syncWith(root: Animatable): Animatable;
  18568. /**
  18569. * Gets the list of runtime animations
  18570. * @returns an array of RuntimeAnimation
  18571. */
  18572. getAnimations(): RuntimeAnimation[];
  18573. /**
  18574. * Adds more animations to the current animatable
  18575. * @param target defines the target of the animations
  18576. * @param animations defines the new animations to add
  18577. */
  18578. appendAnimations(target: any, animations: Animation[]): void;
  18579. /**
  18580. * Gets the source animation for a specific property
  18581. * @param property defines the propertyu to look for
  18582. * @returns null or the source animation for the given property
  18583. */
  18584. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  18585. /**
  18586. * Gets the runtime animation for a specific property
  18587. * @param property defines the propertyu to look for
  18588. * @returns null or the runtime animation for the given property
  18589. */
  18590. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  18591. /**
  18592. * Resets the animatable to its original state
  18593. */
  18594. reset(): void;
  18595. /**
  18596. * Allows the animatable to blend with current running animations
  18597. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18598. * @param blendingSpeed defines the blending speed to use
  18599. */
  18600. enableBlending(blendingSpeed: number): void;
  18601. /**
  18602. * Disable animation blending
  18603. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18604. */
  18605. disableBlending(): void;
  18606. /**
  18607. * Jump directly to a given frame
  18608. * @param frame defines the frame to jump to
  18609. */
  18610. goToFrame(frame: number): void;
  18611. /**
  18612. * Pause the animation
  18613. */
  18614. pause(): void;
  18615. /**
  18616. * Restart the animation
  18617. */
  18618. restart(): void;
  18619. private _raiseOnAnimationEnd;
  18620. /**
  18621. * Stop and delete the current animation
  18622. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  18623. * @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)
  18624. */
  18625. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  18626. /**
  18627. * Wait asynchronously for the animation to end
  18628. * @returns a promise which will be fullfilled when the animation ends
  18629. */
  18630. waitAsync(): Promise<Animatable>;
  18631. /** @hidden */
  18632. _animate(delay: number): boolean;
  18633. }
  18634. interface Scene {
  18635. /** @hidden */
  18636. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  18637. /** @hidden */
  18638. _processLateAnimationBindingsForMatrices(holder: {
  18639. totalWeight: number;
  18640. animations: RuntimeAnimation[];
  18641. originalValue: Matrix;
  18642. }): any;
  18643. /** @hidden */
  18644. _processLateAnimationBindingsForQuaternions(holder: {
  18645. totalWeight: number;
  18646. animations: RuntimeAnimation[];
  18647. originalValue: Quaternion;
  18648. }, refQuaternion: Quaternion): Quaternion;
  18649. /** @hidden */
  18650. _processLateAnimationBindings(): void;
  18651. /**
  18652. * Will start the animation sequence of a given target
  18653. * @param target defines the target
  18654. * @param from defines from which frame should animation start
  18655. * @param to defines until which frame should animation run.
  18656. * @param weight defines the weight to apply to the animation (1.0 by default)
  18657. * @param loop defines if the animation loops
  18658. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18659. * @param onAnimationEnd defines the function to be executed when the animation ends
  18660. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18661. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18662. * @param onAnimationLoop defines the callback to call when an animation loops
  18663. * @returns the animatable object created for this animation
  18664. */
  18665. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18666. /**
  18667. * Will start the animation sequence of a given target
  18668. * @param target defines the target
  18669. * @param from defines from which frame should animation start
  18670. * @param to defines until which frame should animation run.
  18671. * @param loop defines if the animation loops
  18672. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18673. * @param onAnimationEnd defines the function to be executed when the animation ends
  18674. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18675. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18676. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  18677. * @param onAnimationLoop defines the callback to call when an animation loops
  18678. * @returns the animatable object created for this animation
  18679. */
  18680. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18681. /**
  18682. * Will start the animation sequence of a given target and its hierarchy
  18683. * @param target defines the target
  18684. * @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.
  18685. * @param from defines from which frame should animation start
  18686. * @param to defines until which frame should animation run.
  18687. * @param loop defines if the animation loops
  18688. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18689. * @param onAnimationEnd defines the function to be executed when the animation ends
  18690. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18691. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18692. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18693. * @param onAnimationLoop defines the callback to call when an animation loops
  18694. * @returns the list of created animatables
  18695. */
  18696. 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[];
  18697. /**
  18698. * Begin a new animation on a given node
  18699. * @param target defines the target where the animation will take place
  18700. * @param animations defines the list of animations to start
  18701. * @param from defines the initial value
  18702. * @param to defines the final value
  18703. * @param loop defines if you want animation to loop (off by default)
  18704. * @param speedRatio defines the speed ratio to apply to all animations
  18705. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18706. * @param onAnimationLoop defines the callback to call when an animation loops
  18707. * @returns the list of created animatables
  18708. */
  18709. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  18710. /**
  18711. * Begin a new animation on a given node and its hierarchy
  18712. * @param target defines the root node where the animation will take place
  18713. * @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.
  18714. * @param animations defines the list of animations to start
  18715. * @param from defines the initial value
  18716. * @param to defines the final value
  18717. * @param loop defines if you want animation to loop (off by default)
  18718. * @param speedRatio defines the speed ratio to apply to all animations
  18719. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18720. * @param onAnimationLoop defines the callback to call when an animation loops
  18721. * @returns the list of animatables created for all nodes
  18722. */
  18723. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  18724. /**
  18725. * Gets the animatable associated with a specific target
  18726. * @param target defines the target of the animatable
  18727. * @returns the required animatable if found
  18728. */
  18729. getAnimatableByTarget(target: any): Nullable<Animatable>;
  18730. /**
  18731. * Gets all animatables associated with a given target
  18732. * @param target defines the target to look animatables for
  18733. * @returns an array of Animatables
  18734. */
  18735. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  18736. /**
  18737. * Will stop the animation of the given target
  18738. * @param target - the target
  18739. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  18740. * @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)
  18741. */
  18742. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  18743. /**
  18744. * Stops and removes all animations that have been applied to the scene
  18745. */
  18746. stopAllAnimations(): void;
  18747. }
  18748. interface Bone {
  18749. /**
  18750. * Copy an animation range from another bone
  18751. * @param source defines the source bone
  18752. * @param rangeName defines the range name to copy
  18753. * @param frameOffset defines the frame offset
  18754. * @param rescaleAsRequired defines if rescaling must be applied if required
  18755. * @param skelDimensionsRatio defines the scaling ratio
  18756. * @returns true if operation was successful
  18757. */
  18758. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  18759. }
  18760. }
  18761. declare module BABYLON {
  18762. /**
  18763. * Class used to handle skinning animations
  18764. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  18765. */
  18766. export class Skeleton implements IAnimatable {
  18767. /** defines the skeleton name */
  18768. name: string;
  18769. /** defines the skeleton Id */
  18770. id: string;
  18771. /**
  18772. * Defines the list of child bones
  18773. */
  18774. bones: Bone[];
  18775. /**
  18776. * Defines an estimate of the dimension of the skeleton at rest
  18777. */
  18778. dimensionsAtRest: Vector3;
  18779. /**
  18780. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  18781. */
  18782. needInitialSkinMatrix: boolean;
  18783. /**
  18784. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  18785. */
  18786. overrideMesh: Nullable<AbstractMesh>;
  18787. /**
  18788. * Gets the list of animations attached to this skeleton
  18789. */
  18790. animations: Array<Animation>;
  18791. private _scene;
  18792. private _isDirty;
  18793. private _transformMatrices;
  18794. private _transformMatrixTexture;
  18795. private _meshesWithPoseMatrix;
  18796. private _animatables;
  18797. private _identity;
  18798. private _synchronizedWithMesh;
  18799. private _ranges;
  18800. private _lastAbsoluteTransformsUpdateId;
  18801. private _canUseTextureForBones;
  18802. private _uniqueId;
  18803. /** @hidden */
  18804. _numBonesWithLinkedTransformNode: number;
  18805. /**
  18806. * Specifies if the skeleton should be serialized
  18807. */
  18808. doNotSerialize: boolean;
  18809. private _useTextureToStoreBoneMatrices;
  18810. /**
  18811. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  18812. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  18813. */
  18814. useTextureToStoreBoneMatrices: boolean;
  18815. private _animationPropertiesOverride;
  18816. /**
  18817. * Gets or sets the animation properties override
  18818. */
  18819. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  18820. /**
  18821. * List of inspectable custom properties (used by the Inspector)
  18822. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18823. */
  18824. inspectableCustomProperties: IInspectable[];
  18825. /**
  18826. * An observable triggered before computing the skeleton's matrices
  18827. */
  18828. onBeforeComputeObservable: Observable<Skeleton>;
  18829. /**
  18830. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  18831. */
  18832. readonly isUsingTextureForMatrices: boolean;
  18833. /**
  18834. * Gets the unique ID of this skeleton
  18835. */
  18836. readonly uniqueId: number;
  18837. /**
  18838. * Creates a new skeleton
  18839. * @param name defines the skeleton name
  18840. * @param id defines the skeleton Id
  18841. * @param scene defines the hosting scene
  18842. */
  18843. constructor(
  18844. /** defines the skeleton name */
  18845. name: string,
  18846. /** defines the skeleton Id */
  18847. id: string, scene: Scene);
  18848. /**
  18849. * Gets the current object class name.
  18850. * @return the class name
  18851. */
  18852. getClassName(): string;
  18853. /**
  18854. * Returns an array containing the root bones
  18855. * @returns an array containing the root bones
  18856. */
  18857. getChildren(): Array<Bone>;
  18858. /**
  18859. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  18860. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  18861. * @returns a Float32Array containing matrices data
  18862. */
  18863. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  18864. /**
  18865. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  18866. * @returns a raw texture containing the data
  18867. */
  18868. getTransformMatrixTexture(): Nullable<RawTexture>;
  18869. /**
  18870. * Gets the current hosting scene
  18871. * @returns a scene object
  18872. */
  18873. getScene(): Scene;
  18874. /**
  18875. * Gets a string representing the current skeleton data
  18876. * @param fullDetails defines a boolean indicating if we want a verbose version
  18877. * @returns a string representing the current skeleton data
  18878. */
  18879. toString(fullDetails?: boolean): string;
  18880. /**
  18881. * Get bone's index searching by name
  18882. * @param name defines bone's name to search for
  18883. * @return the indice of the bone. Returns -1 if not found
  18884. */
  18885. getBoneIndexByName(name: string): number;
  18886. /**
  18887. * Creater a new animation range
  18888. * @param name defines the name of the range
  18889. * @param from defines the start key
  18890. * @param to defines the end key
  18891. */
  18892. createAnimationRange(name: string, from: number, to: number): void;
  18893. /**
  18894. * Delete a specific animation range
  18895. * @param name defines the name of the range
  18896. * @param deleteFrames defines if frames must be removed as well
  18897. */
  18898. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  18899. /**
  18900. * Gets a specific animation range
  18901. * @param name defines the name of the range to look for
  18902. * @returns the requested animation range or null if not found
  18903. */
  18904. getAnimationRange(name: string): Nullable<AnimationRange>;
  18905. /**
  18906. * Gets the list of all animation ranges defined on this skeleton
  18907. * @returns an array
  18908. */
  18909. getAnimationRanges(): Nullable<AnimationRange>[];
  18910. /**
  18911. * Copy animation range from a source skeleton.
  18912. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  18913. * @param source defines the source skeleton
  18914. * @param name defines the name of the range to copy
  18915. * @param rescaleAsRequired defines if rescaling must be applied if required
  18916. * @returns true if operation was successful
  18917. */
  18918. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  18919. /**
  18920. * Forces the skeleton to go to rest pose
  18921. */
  18922. returnToRest(): void;
  18923. private _getHighestAnimationFrame;
  18924. /**
  18925. * Begin a specific animation range
  18926. * @param name defines the name of the range to start
  18927. * @param loop defines if looping must be turned on (false by default)
  18928. * @param speedRatio defines the speed ratio to apply (1 by default)
  18929. * @param onAnimationEnd defines a callback which will be called when animation will end
  18930. * @returns a new animatable
  18931. */
  18932. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  18933. /** @hidden */
  18934. _markAsDirty(): void;
  18935. /** @hidden */
  18936. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  18937. /** @hidden */
  18938. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  18939. private _computeTransformMatrices;
  18940. /**
  18941. * Build all resources required to render a skeleton
  18942. */
  18943. prepare(): void;
  18944. /**
  18945. * Gets the list of animatables currently running for this skeleton
  18946. * @returns an array of animatables
  18947. */
  18948. getAnimatables(): IAnimatable[];
  18949. /**
  18950. * Clone the current skeleton
  18951. * @param name defines the name of the new skeleton
  18952. * @param id defines the id of the enw skeleton
  18953. * @returns the new skeleton
  18954. */
  18955. clone(name: string, id: string): Skeleton;
  18956. /**
  18957. * Enable animation blending for this skeleton
  18958. * @param blendingSpeed defines the blending speed to apply
  18959. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18960. */
  18961. enableBlending(blendingSpeed?: number): void;
  18962. /**
  18963. * Releases all resources associated with the current skeleton
  18964. */
  18965. dispose(): void;
  18966. /**
  18967. * Serialize the skeleton in a JSON object
  18968. * @returns a JSON object
  18969. */
  18970. serialize(): any;
  18971. /**
  18972. * Creates a new skeleton from serialized data
  18973. * @param parsedSkeleton defines the serialized data
  18974. * @param scene defines the hosting scene
  18975. * @returns a new skeleton
  18976. */
  18977. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  18978. /**
  18979. * Compute all node absolute transforms
  18980. * @param forceUpdate defines if computation must be done even if cache is up to date
  18981. */
  18982. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  18983. /**
  18984. * Gets the root pose matrix
  18985. * @returns a matrix
  18986. */
  18987. getPoseMatrix(): Nullable<Matrix>;
  18988. /**
  18989. * Sorts bones per internal index
  18990. */
  18991. sortBones(): void;
  18992. private _sortBones;
  18993. }
  18994. }
  18995. declare module BABYLON {
  18996. /**
  18997. * Defines a target to use with MorphTargetManager
  18998. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  18999. */
  19000. export class MorphTarget implements IAnimatable {
  19001. /** defines the name of the target */
  19002. name: string;
  19003. /**
  19004. * Gets or sets the list of animations
  19005. */
  19006. animations: Animation[];
  19007. private _scene;
  19008. private _positions;
  19009. private _normals;
  19010. private _tangents;
  19011. private _influence;
  19012. /**
  19013. * Observable raised when the influence changes
  19014. */
  19015. onInfluenceChanged: Observable<boolean>;
  19016. /** @hidden */
  19017. _onDataLayoutChanged: Observable<void>;
  19018. /**
  19019. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  19020. */
  19021. influence: number;
  19022. /**
  19023. * Gets or sets the id of the morph Target
  19024. */
  19025. id: string;
  19026. private _animationPropertiesOverride;
  19027. /**
  19028. * Gets or sets the animation properties override
  19029. */
  19030. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19031. /**
  19032. * Creates a new MorphTarget
  19033. * @param name defines the name of the target
  19034. * @param influence defines the influence to use
  19035. * @param scene defines the scene the morphtarget belongs to
  19036. */
  19037. constructor(
  19038. /** defines the name of the target */
  19039. name: string, influence?: number, scene?: Nullable<Scene>);
  19040. /**
  19041. * Gets a boolean defining if the target contains position data
  19042. */
  19043. readonly hasPositions: boolean;
  19044. /**
  19045. * Gets a boolean defining if the target contains normal data
  19046. */
  19047. readonly hasNormals: boolean;
  19048. /**
  19049. * Gets a boolean defining if the target contains tangent data
  19050. */
  19051. readonly hasTangents: boolean;
  19052. /**
  19053. * Affects position data to this target
  19054. * @param data defines the position data to use
  19055. */
  19056. setPositions(data: Nullable<FloatArray>): void;
  19057. /**
  19058. * Gets the position data stored in this target
  19059. * @returns a FloatArray containing the position data (or null if not present)
  19060. */
  19061. getPositions(): Nullable<FloatArray>;
  19062. /**
  19063. * Affects normal data to this target
  19064. * @param data defines the normal data to use
  19065. */
  19066. setNormals(data: Nullable<FloatArray>): void;
  19067. /**
  19068. * Gets the normal data stored in this target
  19069. * @returns a FloatArray containing the normal data (or null if not present)
  19070. */
  19071. getNormals(): Nullable<FloatArray>;
  19072. /**
  19073. * Affects tangent data to this target
  19074. * @param data defines the tangent data to use
  19075. */
  19076. setTangents(data: Nullable<FloatArray>): void;
  19077. /**
  19078. * Gets the tangent data stored in this target
  19079. * @returns a FloatArray containing the tangent data (or null if not present)
  19080. */
  19081. getTangents(): Nullable<FloatArray>;
  19082. /**
  19083. * Serializes the current target into a Serialization object
  19084. * @returns the serialized object
  19085. */
  19086. serialize(): any;
  19087. /**
  19088. * Returns the string "MorphTarget"
  19089. * @returns "MorphTarget"
  19090. */
  19091. getClassName(): string;
  19092. /**
  19093. * Creates a new target from serialized data
  19094. * @param serializationObject defines the serialized data to use
  19095. * @returns a new MorphTarget
  19096. */
  19097. static Parse(serializationObject: any): MorphTarget;
  19098. /**
  19099. * Creates a MorphTarget from mesh data
  19100. * @param mesh defines the source mesh
  19101. * @param name defines the name to use for the new target
  19102. * @param influence defines the influence to attach to the target
  19103. * @returns a new MorphTarget
  19104. */
  19105. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  19106. }
  19107. }
  19108. declare module BABYLON {
  19109. /**
  19110. * This class is used to deform meshes using morphing between different targets
  19111. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19112. */
  19113. export class MorphTargetManager {
  19114. private _targets;
  19115. private _targetInfluenceChangedObservers;
  19116. private _targetDataLayoutChangedObservers;
  19117. private _activeTargets;
  19118. private _scene;
  19119. private _influences;
  19120. private _supportsNormals;
  19121. private _supportsTangents;
  19122. private _vertexCount;
  19123. private _uniqueId;
  19124. private _tempInfluences;
  19125. /**
  19126. * Creates a new MorphTargetManager
  19127. * @param scene defines the current scene
  19128. */
  19129. constructor(scene?: Nullable<Scene>);
  19130. /**
  19131. * Gets the unique ID of this manager
  19132. */
  19133. readonly uniqueId: number;
  19134. /**
  19135. * Gets the number of vertices handled by this manager
  19136. */
  19137. readonly vertexCount: number;
  19138. /**
  19139. * Gets a boolean indicating if this manager supports morphing of normals
  19140. */
  19141. readonly supportsNormals: boolean;
  19142. /**
  19143. * Gets a boolean indicating if this manager supports morphing of tangents
  19144. */
  19145. readonly supportsTangents: boolean;
  19146. /**
  19147. * Gets the number of targets stored in this manager
  19148. */
  19149. readonly numTargets: number;
  19150. /**
  19151. * Gets the number of influencers (ie. the number of targets with influences > 0)
  19152. */
  19153. readonly numInfluencers: number;
  19154. /**
  19155. * Gets the list of influences (one per target)
  19156. */
  19157. readonly influences: Float32Array;
  19158. /**
  19159. * Gets the active target at specified index. An active target is a target with an influence > 0
  19160. * @param index defines the index to check
  19161. * @returns the requested target
  19162. */
  19163. getActiveTarget(index: number): MorphTarget;
  19164. /**
  19165. * Gets the target at specified index
  19166. * @param index defines the index to check
  19167. * @returns the requested target
  19168. */
  19169. getTarget(index: number): MorphTarget;
  19170. /**
  19171. * Add a new target to this manager
  19172. * @param target defines the target to add
  19173. */
  19174. addTarget(target: MorphTarget): void;
  19175. /**
  19176. * Removes a target from the manager
  19177. * @param target defines the target to remove
  19178. */
  19179. removeTarget(target: MorphTarget): void;
  19180. /**
  19181. * Serializes the current manager into a Serialization object
  19182. * @returns the serialized object
  19183. */
  19184. serialize(): any;
  19185. private _syncActiveTargets;
  19186. /**
  19187. * Syncrhonize the targets with all the meshes using this morph target manager
  19188. */
  19189. synchronize(): void;
  19190. /**
  19191. * Creates a new MorphTargetManager from serialized data
  19192. * @param serializationObject defines the serialized data
  19193. * @param scene defines the hosting scene
  19194. * @returns the new MorphTargetManager
  19195. */
  19196. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  19197. }
  19198. }
  19199. declare module BABYLON {
  19200. /**
  19201. * Mesh representing the gorund
  19202. */
  19203. export class GroundMesh extends Mesh {
  19204. /** If octree should be generated */
  19205. generateOctree: boolean;
  19206. private _heightQuads;
  19207. /** @hidden */
  19208. _subdivisionsX: number;
  19209. /** @hidden */
  19210. _subdivisionsY: number;
  19211. /** @hidden */
  19212. _width: number;
  19213. /** @hidden */
  19214. _height: number;
  19215. /** @hidden */
  19216. _minX: number;
  19217. /** @hidden */
  19218. _maxX: number;
  19219. /** @hidden */
  19220. _minZ: number;
  19221. /** @hidden */
  19222. _maxZ: number;
  19223. constructor(name: string, scene: Scene);
  19224. /**
  19225. * "GroundMesh"
  19226. * @returns "GroundMesh"
  19227. */
  19228. getClassName(): string;
  19229. /**
  19230. * The minimum of x and y subdivisions
  19231. */
  19232. readonly subdivisions: number;
  19233. /**
  19234. * X subdivisions
  19235. */
  19236. readonly subdivisionsX: number;
  19237. /**
  19238. * Y subdivisions
  19239. */
  19240. readonly subdivisionsY: number;
  19241. /**
  19242. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  19243. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  19244. * @param chunksCount the number of subdivisions for x and y
  19245. * @param octreeBlocksSize (Default: 32)
  19246. */
  19247. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  19248. /**
  19249. * Returns a height (y) value in the Worl system :
  19250. * the ground altitude at the coordinates (x, z) expressed in the World system.
  19251. * @param x x coordinate
  19252. * @param z z coordinate
  19253. * @returns the ground y position if (x, z) are outside the ground surface.
  19254. */
  19255. getHeightAtCoordinates(x: number, z: number): number;
  19256. /**
  19257. * Returns a normalized vector (Vector3) orthogonal to the ground
  19258. * at the ground coordinates (x, z) expressed in the World system.
  19259. * @param x x coordinate
  19260. * @param z z coordinate
  19261. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  19262. */
  19263. getNormalAtCoordinates(x: number, z: number): Vector3;
  19264. /**
  19265. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  19266. * at the ground coordinates (x, z) expressed in the World system.
  19267. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  19268. * @param x x coordinate
  19269. * @param z z coordinate
  19270. * @param ref vector to store the result
  19271. * @returns the GroundMesh.
  19272. */
  19273. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  19274. /**
  19275. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  19276. * if the ground has been updated.
  19277. * This can be used in the render loop.
  19278. * @returns the GroundMesh.
  19279. */
  19280. updateCoordinateHeights(): GroundMesh;
  19281. private _getFacetAt;
  19282. private _initHeightQuads;
  19283. private _computeHeightQuads;
  19284. /**
  19285. * Serializes this ground mesh
  19286. * @param serializationObject object to write serialization to
  19287. */
  19288. serialize(serializationObject: any): void;
  19289. /**
  19290. * Parses a serialized ground mesh
  19291. * @param parsedMesh the serialized mesh
  19292. * @param scene the scene to create the ground mesh in
  19293. * @returns the created ground mesh
  19294. */
  19295. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  19296. }
  19297. }
  19298. declare module BABYLON {
  19299. /**
  19300. * Interface for Physics-Joint data
  19301. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19302. */
  19303. export interface PhysicsJointData {
  19304. /**
  19305. * The main pivot of the joint
  19306. */
  19307. mainPivot?: Vector3;
  19308. /**
  19309. * The connected pivot of the joint
  19310. */
  19311. connectedPivot?: Vector3;
  19312. /**
  19313. * The main axis of the joint
  19314. */
  19315. mainAxis?: Vector3;
  19316. /**
  19317. * The connected axis of the joint
  19318. */
  19319. connectedAxis?: Vector3;
  19320. /**
  19321. * The collision of the joint
  19322. */
  19323. collision?: boolean;
  19324. /**
  19325. * Native Oimo/Cannon/Energy data
  19326. */
  19327. nativeParams?: any;
  19328. }
  19329. /**
  19330. * This is a holder class for the physics joint created by the physics plugin
  19331. * It holds a set of functions to control the underlying joint
  19332. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19333. */
  19334. export class PhysicsJoint {
  19335. /**
  19336. * The type of the physics joint
  19337. */
  19338. type: number;
  19339. /**
  19340. * The data for the physics joint
  19341. */
  19342. jointData: PhysicsJointData;
  19343. private _physicsJoint;
  19344. protected _physicsPlugin: IPhysicsEnginePlugin;
  19345. /**
  19346. * Initializes the physics joint
  19347. * @param type The type of the physics joint
  19348. * @param jointData The data for the physics joint
  19349. */
  19350. constructor(
  19351. /**
  19352. * The type of the physics joint
  19353. */
  19354. type: number,
  19355. /**
  19356. * The data for the physics joint
  19357. */
  19358. jointData: PhysicsJointData);
  19359. /**
  19360. * Gets the physics joint
  19361. */
  19362. /**
  19363. * Sets the physics joint
  19364. */
  19365. physicsJoint: any;
  19366. /**
  19367. * Sets the physics plugin
  19368. */
  19369. physicsPlugin: IPhysicsEnginePlugin;
  19370. /**
  19371. * Execute a function that is physics-plugin specific.
  19372. * @param {Function} func the function that will be executed.
  19373. * It accepts two parameters: the physics world and the physics joint
  19374. */
  19375. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  19376. /**
  19377. * Distance-Joint type
  19378. */
  19379. static DistanceJoint: number;
  19380. /**
  19381. * Hinge-Joint type
  19382. */
  19383. static HingeJoint: number;
  19384. /**
  19385. * Ball-and-Socket joint type
  19386. */
  19387. static BallAndSocketJoint: number;
  19388. /**
  19389. * Wheel-Joint type
  19390. */
  19391. static WheelJoint: number;
  19392. /**
  19393. * Slider-Joint type
  19394. */
  19395. static SliderJoint: number;
  19396. /**
  19397. * Prismatic-Joint type
  19398. */
  19399. static PrismaticJoint: number;
  19400. /**
  19401. * Universal-Joint type
  19402. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  19403. */
  19404. static UniversalJoint: number;
  19405. /**
  19406. * Hinge-Joint 2 type
  19407. */
  19408. static Hinge2Joint: number;
  19409. /**
  19410. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  19411. */
  19412. static PointToPointJoint: number;
  19413. /**
  19414. * Spring-Joint type
  19415. */
  19416. static SpringJoint: number;
  19417. /**
  19418. * Lock-Joint type
  19419. */
  19420. static LockJoint: number;
  19421. }
  19422. /**
  19423. * A class representing a physics distance joint
  19424. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19425. */
  19426. export class DistanceJoint extends PhysicsJoint {
  19427. /**
  19428. *
  19429. * @param jointData The data for the Distance-Joint
  19430. */
  19431. constructor(jointData: DistanceJointData);
  19432. /**
  19433. * Update the predefined distance.
  19434. * @param maxDistance The maximum preferred distance
  19435. * @param minDistance The minimum preferred distance
  19436. */
  19437. updateDistance(maxDistance: number, minDistance?: number): void;
  19438. }
  19439. /**
  19440. * Represents a Motor-Enabled Joint
  19441. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19442. */
  19443. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  19444. /**
  19445. * Initializes the Motor-Enabled Joint
  19446. * @param type The type of the joint
  19447. * @param jointData The physica joint data for the joint
  19448. */
  19449. constructor(type: number, jointData: PhysicsJointData);
  19450. /**
  19451. * Set the motor values.
  19452. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19453. * @param force the force to apply
  19454. * @param maxForce max force for this motor.
  19455. */
  19456. setMotor(force?: number, maxForce?: number): void;
  19457. /**
  19458. * Set the motor's limits.
  19459. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19460. * @param upperLimit The upper limit of the motor
  19461. * @param lowerLimit The lower limit of the motor
  19462. */
  19463. setLimit(upperLimit: number, lowerLimit?: number): void;
  19464. }
  19465. /**
  19466. * This class represents a single physics Hinge-Joint
  19467. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19468. */
  19469. export class HingeJoint extends MotorEnabledJoint {
  19470. /**
  19471. * Initializes the Hinge-Joint
  19472. * @param jointData The joint data for the Hinge-Joint
  19473. */
  19474. constructor(jointData: PhysicsJointData);
  19475. /**
  19476. * Set the motor values.
  19477. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19478. * @param {number} force the force to apply
  19479. * @param {number} maxForce max force for this motor.
  19480. */
  19481. setMotor(force?: number, maxForce?: number): void;
  19482. /**
  19483. * Set the motor's limits.
  19484. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19485. * @param upperLimit The upper limit of the motor
  19486. * @param lowerLimit The lower limit of the motor
  19487. */
  19488. setLimit(upperLimit: number, lowerLimit?: number): void;
  19489. }
  19490. /**
  19491. * This class represents a dual hinge physics joint (same as wheel joint)
  19492. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19493. */
  19494. export class Hinge2Joint extends MotorEnabledJoint {
  19495. /**
  19496. * Initializes the Hinge2-Joint
  19497. * @param jointData The joint data for the Hinge2-Joint
  19498. */
  19499. constructor(jointData: PhysicsJointData);
  19500. /**
  19501. * Set the motor values.
  19502. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19503. * @param {number} targetSpeed the speed the motor is to reach
  19504. * @param {number} maxForce max force for this motor.
  19505. * @param {motorIndex} the motor's index, 0 or 1.
  19506. */
  19507. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  19508. /**
  19509. * Set the motor limits.
  19510. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19511. * @param {number} upperLimit the upper limit
  19512. * @param {number} lowerLimit lower limit
  19513. * @param {motorIndex} the motor's index, 0 or 1.
  19514. */
  19515. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19516. }
  19517. /**
  19518. * Interface for a motor enabled joint
  19519. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19520. */
  19521. export interface IMotorEnabledJoint {
  19522. /**
  19523. * Physics joint
  19524. */
  19525. physicsJoint: any;
  19526. /**
  19527. * Sets the motor of the motor-enabled joint
  19528. * @param force The force of the motor
  19529. * @param maxForce The maximum force of the motor
  19530. * @param motorIndex The index of the motor
  19531. */
  19532. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  19533. /**
  19534. * Sets the limit of the motor
  19535. * @param upperLimit The upper limit of the motor
  19536. * @param lowerLimit The lower limit of the motor
  19537. * @param motorIndex The index of the motor
  19538. */
  19539. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19540. }
  19541. /**
  19542. * Joint data for a Distance-Joint
  19543. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19544. */
  19545. export interface DistanceJointData extends PhysicsJointData {
  19546. /**
  19547. * Max distance the 2 joint objects can be apart
  19548. */
  19549. maxDistance: number;
  19550. }
  19551. /**
  19552. * Joint data from a spring joint
  19553. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19554. */
  19555. export interface SpringJointData extends PhysicsJointData {
  19556. /**
  19557. * Length of the spring
  19558. */
  19559. length: number;
  19560. /**
  19561. * Stiffness of the spring
  19562. */
  19563. stiffness: number;
  19564. /**
  19565. * Damping of the spring
  19566. */
  19567. damping: number;
  19568. /** this callback will be called when applying the force to the impostors. */
  19569. forceApplicationCallback: () => void;
  19570. }
  19571. }
  19572. declare module BABYLON {
  19573. /**
  19574. * Holds the data for the raycast result
  19575. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19576. */
  19577. export class PhysicsRaycastResult {
  19578. private _hasHit;
  19579. private _hitDistance;
  19580. private _hitNormalWorld;
  19581. private _hitPointWorld;
  19582. private _rayFromWorld;
  19583. private _rayToWorld;
  19584. /**
  19585. * Gets if there was a hit
  19586. */
  19587. readonly hasHit: boolean;
  19588. /**
  19589. * Gets the distance from the hit
  19590. */
  19591. readonly hitDistance: number;
  19592. /**
  19593. * Gets the hit normal/direction in the world
  19594. */
  19595. readonly hitNormalWorld: Vector3;
  19596. /**
  19597. * Gets the hit point in the world
  19598. */
  19599. readonly hitPointWorld: Vector3;
  19600. /**
  19601. * Gets the ray "start point" of the ray in the world
  19602. */
  19603. readonly rayFromWorld: Vector3;
  19604. /**
  19605. * Gets the ray "end point" of the ray in the world
  19606. */
  19607. readonly rayToWorld: Vector3;
  19608. /**
  19609. * Sets the hit data (normal & point in world space)
  19610. * @param hitNormalWorld defines the normal in world space
  19611. * @param hitPointWorld defines the point in world space
  19612. */
  19613. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  19614. /**
  19615. * Sets the distance from the start point to the hit point
  19616. * @param distance
  19617. */
  19618. setHitDistance(distance: number): void;
  19619. /**
  19620. * Calculates the distance manually
  19621. */
  19622. calculateHitDistance(): void;
  19623. /**
  19624. * Resets all the values to default
  19625. * @param from The from point on world space
  19626. * @param to The to point on world space
  19627. */
  19628. reset(from?: Vector3, to?: Vector3): void;
  19629. }
  19630. /**
  19631. * Interface for the size containing width and height
  19632. */
  19633. interface IXYZ {
  19634. /**
  19635. * X
  19636. */
  19637. x: number;
  19638. /**
  19639. * Y
  19640. */
  19641. y: number;
  19642. /**
  19643. * Z
  19644. */
  19645. z: number;
  19646. }
  19647. }
  19648. declare module BABYLON {
  19649. /**
  19650. * Interface used to describe a physics joint
  19651. */
  19652. export interface PhysicsImpostorJoint {
  19653. /** Defines the main impostor to which the joint is linked */
  19654. mainImpostor: PhysicsImpostor;
  19655. /** Defines the impostor that is connected to the main impostor using this joint */
  19656. connectedImpostor: PhysicsImpostor;
  19657. /** Defines the joint itself */
  19658. joint: PhysicsJoint;
  19659. }
  19660. /** @hidden */
  19661. export interface IPhysicsEnginePlugin {
  19662. world: any;
  19663. name: string;
  19664. setGravity(gravity: Vector3): void;
  19665. setTimeStep(timeStep: number): void;
  19666. getTimeStep(): number;
  19667. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  19668. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19669. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19670. generatePhysicsBody(impostor: PhysicsImpostor): void;
  19671. removePhysicsBody(impostor: PhysicsImpostor): void;
  19672. generateJoint(joint: PhysicsImpostorJoint): void;
  19673. removeJoint(joint: PhysicsImpostorJoint): void;
  19674. isSupported(): boolean;
  19675. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  19676. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  19677. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19678. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19679. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19680. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19681. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  19682. getBodyMass(impostor: PhysicsImpostor): number;
  19683. getBodyFriction(impostor: PhysicsImpostor): number;
  19684. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  19685. getBodyRestitution(impostor: PhysicsImpostor): number;
  19686. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  19687. getBodyPressure?(impostor: PhysicsImpostor): number;
  19688. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  19689. getBodyStiffness?(impostor: PhysicsImpostor): number;
  19690. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  19691. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  19692. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  19693. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  19694. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  19695. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  19696. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  19697. sleepBody(impostor: PhysicsImpostor): void;
  19698. wakeUpBody(impostor: PhysicsImpostor): void;
  19699. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  19700. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  19701. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  19702. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19703. getRadius(impostor: PhysicsImpostor): number;
  19704. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  19705. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  19706. dispose(): void;
  19707. }
  19708. /**
  19709. * Interface used to define a physics engine
  19710. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  19711. */
  19712. export interface IPhysicsEngine {
  19713. /**
  19714. * Gets the gravity vector used by the simulation
  19715. */
  19716. gravity: Vector3;
  19717. /**
  19718. * Sets the gravity vector used by the simulation
  19719. * @param gravity defines the gravity vector to use
  19720. */
  19721. setGravity(gravity: Vector3): void;
  19722. /**
  19723. * Set the time step of the physics engine.
  19724. * Default is 1/60.
  19725. * To slow it down, enter 1/600 for example.
  19726. * To speed it up, 1/30
  19727. * @param newTimeStep the new timestep to apply to this world.
  19728. */
  19729. setTimeStep(newTimeStep: number): void;
  19730. /**
  19731. * Get the time step of the physics engine.
  19732. * @returns the current time step
  19733. */
  19734. getTimeStep(): number;
  19735. /**
  19736. * Release all resources
  19737. */
  19738. dispose(): void;
  19739. /**
  19740. * Gets the name of the current physics plugin
  19741. * @returns the name of the plugin
  19742. */
  19743. getPhysicsPluginName(): string;
  19744. /**
  19745. * Adding a new impostor for the impostor tracking.
  19746. * This will be done by the impostor itself.
  19747. * @param impostor the impostor to add
  19748. */
  19749. addImpostor(impostor: PhysicsImpostor): void;
  19750. /**
  19751. * Remove an impostor from the engine.
  19752. * This impostor and its mesh will not longer be updated by the physics engine.
  19753. * @param impostor the impostor to remove
  19754. */
  19755. removeImpostor(impostor: PhysicsImpostor): void;
  19756. /**
  19757. * Add a joint to the physics engine
  19758. * @param mainImpostor defines the main impostor to which the joint is added.
  19759. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  19760. * @param joint defines the joint that will connect both impostors.
  19761. */
  19762. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19763. /**
  19764. * Removes a joint from the simulation
  19765. * @param mainImpostor defines the impostor used with the joint
  19766. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  19767. * @param joint defines the joint to remove
  19768. */
  19769. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19770. /**
  19771. * Gets the current plugin used to run the simulation
  19772. * @returns current plugin
  19773. */
  19774. getPhysicsPlugin(): IPhysicsEnginePlugin;
  19775. /**
  19776. * Gets the list of physic impostors
  19777. * @returns an array of PhysicsImpostor
  19778. */
  19779. getImpostors(): Array<PhysicsImpostor>;
  19780. /**
  19781. * Gets the impostor for a physics enabled object
  19782. * @param object defines the object impersonated by the impostor
  19783. * @returns the PhysicsImpostor or null if not found
  19784. */
  19785. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  19786. /**
  19787. * Gets the impostor for a physics body object
  19788. * @param body defines physics body used by the impostor
  19789. * @returns the PhysicsImpostor or null if not found
  19790. */
  19791. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  19792. /**
  19793. * Does a raycast in the physics world
  19794. * @param from when should the ray start?
  19795. * @param to when should the ray end?
  19796. * @returns PhysicsRaycastResult
  19797. */
  19798. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  19799. /**
  19800. * Called by the scene. No need to call it.
  19801. * @param delta defines the timespam between frames
  19802. */
  19803. _step(delta: number): void;
  19804. }
  19805. }
  19806. declare module BABYLON {
  19807. /**
  19808. * The interface for the physics imposter parameters
  19809. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19810. */
  19811. export interface PhysicsImpostorParameters {
  19812. /**
  19813. * The mass of the physics imposter
  19814. */
  19815. mass: number;
  19816. /**
  19817. * The friction of the physics imposter
  19818. */
  19819. friction?: number;
  19820. /**
  19821. * The coefficient of restitution of the physics imposter
  19822. */
  19823. restitution?: number;
  19824. /**
  19825. * The native options of the physics imposter
  19826. */
  19827. nativeOptions?: any;
  19828. /**
  19829. * Specifies if the parent should be ignored
  19830. */
  19831. ignoreParent?: boolean;
  19832. /**
  19833. * Specifies if bi-directional transformations should be disabled
  19834. */
  19835. disableBidirectionalTransformation?: boolean;
  19836. /**
  19837. * The pressure inside the physics imposter, soft object only
  19838. */
  19839. pressure?: number;
  19840. /**
  19841. * The stiffness the physics imposter, soft object only
  19842. */
  19843. stiffness?: number;
  19844. /**
  19845. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  19846. */
  19847. velocityIterations?: number;
  19848. /**
  19849. * The number of iterations used in maintaining consistent vertex positions, soft object only
  19850. */
  19851. positionIterations?: number;
  19852. /**
  19853. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  19854. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  19855. * Add to fix multiple points
  19856. */
  19857. fixedPoints?: number;
  19858. /**
  19859. * The collision margin around a soft object
  19860. */
  19861. margin?: number;
  19862. /**
  19863. * The collision margin around a soft object
  19864. */
  19865. damping?: number;
  19866. /**
  19867. * The path for a rope based on an extrusion
  19868. */
  19869. path?: any;
  19870. /**
  19871. * The shape of an extrusion used for a rope based on an extrusion
  19872. */
  19873. shape?: any;
  19874. }
  19875. /**
  19876. * Interface for a physics-enabled object
  19877. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19878. */
  19879. export interface IPhysicsEnabledObject {
  19880. /**
  19881. * The position of the physics-enabled object
  19882. */
  19883. position: Vector3;
  19884. /**
  19885. * The rotation of the physics-enabled object
  19886. */
  19887. rotationQuaternion: Nullable<Quaternion>;
  19888. /**
  19889. * The scale of the physics-enabled object
  19890. */
  19891. scaling: Vector3;
  19892. /**
  19893. * The rotation of the physics-enabled object
  19894. */
  19895. rotation?: Vector3;
  19896. /**
  19897. * The parent of the physics-enabled object
  19898. */
  19899. parent?: any;
  19900. /**
  19901. * The bounding info of the physics-enabled object
  19902. * @returns The bounding info of the physics-enabled object
  19903. */
  19904. getBoundingInfo(): BoundingInfo;
  19905. /**
  19906. * Computes the world matrix
  19907. * @param force Specifies if the world matrix should be computed by force
  19908. * @returns A world matrix
  19909. */
  19910. computeWorldMatrix(force: boolean): Matrix;
  19911. /**
  19912. * Gets the world matrix
  19913. * @returns A world matrix
  19914. */
  19915. getWorldMatrix?(): Matrix;
  19916. /**
  19917. * Gets the child meshes
  19918. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  19919. * @returns An array of abstract meshes
  19920. */
  19921. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  19922. /**
  19923. * Gets the vertex data
  19924. * @param kind The type of vertex data
  19925. * @returns A nullable array of numbers, or a float32 array
  19926. */
  19927. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  19928. /**
  19929. * Gets the indices from the mesh
  19930. * @returns A nullable array of index arrays
  19931. */
  19932. getIndices?(): Nullable<IndicesArray>;
  19933. /**
  19934. * Gets the scene from the mesh
  19935. * @returns the indices array or null
  19936. */
  19937. getScene?(): Scene;
  19938. /**
  19939. * Gets the absolute position from the mesh
  19940. * @returns the absolute position
  19941. */
  19942. getAbsolutePosition(): Vector3;
  19943. /**
  19944. * Gets the absolute pivot point from the mesh
  19945. * @returns the absolute pivot point
  19946. */
  19947. getAbsolutePivotPoint(): Vector3;
  19948. /**
  19949. * Rotates the mesh
  19950. * @param axis The axis of rotation
  19951. * @param amount The amount of rotation
  19952. * @param space The space of the rotation
  19953. * @returns The rotation transform node
  19954. */
  19955. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  19956. /**
  19957. * Translates the mesh
  19958. * @param axis The axis of translation
  19959. * @param distance The distance of translation
  19960. * @param space The space of the translation
  19961. * @returns The transform node
  19962. */
  19963. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  19964. /**
  19965. * Sets the absolute position of the mesh
  19966. * @param absolutePosition The absolute position of the mesh
  19967. * @returns The transform node
  19968. */
  19969. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  19970. /**
  19971. * Gets the class name of the mesh
  19972. * @returns The class name
  19973. */
  19974. getClassName(): string;
  19975. }
  19976. /**
  19977. * Represents a physics imposter
  19978. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19979. */
  19980. export class PhysicsImpostor {
  19981. /**
  19982. * The physics-enabled object used as the physics imposter
  19983. */
  19984. object: IPhysicsEnabledObject;
  19985. /**
  19986. * The type of the physics imposter
  19987. */
  19988. type: number;
  19989. private _options;
  19990. private _scene?;
  19991. /**
  19992. * The default object size of the imposter
  19993. */
  19994. static DEFAULT_OBJECT_SIZE: Vector3;
  19995. /**
  19996. * The identity quaternion of the imposter
  19997. */
  19998. static IDENTITY_QUATERNION: Quaternion;
  19999. /** @hidden */
  20000. _pluginData: any;
  20001. private _physicsEngine;
  20002. private _physicsBody;
  20003. private _bodyUpdateRequired;
  20004. private _onBeforePhysicsStepCallbacks;
  20005. private _onAfterPhysicsStepCallbacks;
  20006. /** @hidden */
  20007. _onPhysicsCollideCallbacks: Array<{
  20008. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  20009. otherImpostors: Array<PhysicsImpostor>;
  20010. }>;
  20011. private _deltaPosition;
  20012. private _deltaRotation;
  20013. private _deltaRotationConjugated;
  20014. /** hidden */
  20015. _isFromLine: boolean;
  20016. private _parent;
  20017. private _isDisposed;
  20018. private static _tmpVecs;
  20019. private static _tmpQuat;
  20020. /**
  20021. * Specifies if the physics imposter is disposed
  20022. */
  20023. readonly isDisposed: boolean;
  20024. /**
  20025. * Gets the mass of the physics imposter
  20026. */
  20027. mass: number;
  20028. /**
  20029. * Gets the coefficient of friction
  20030. */
  20031. /**
  20032. * Sets the coefficient of friction
  20033. */
  20034. friction: number;
  20035. /**
  20036. * Gets the coefficient of restitution
  20037. */
  20038. /**
  20039. * Sets the coefficient of restitution
  20040. */
  20041. restitution: number;
  20042. /**
  20043. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  20044. */
  20045. /**
  20046. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  20047. */
  20048. pressure: number;
  20049. /**
  20050. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  20051. */
  20052. /**
  20053. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  20054. */
  20055. stiffness: number;
  20056. /**
  20057. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  20058. */
  20059. /**
  20060. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  20061. */
  20062. velocityIterations: number;
  20063. /**
  20064. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  20065. */
  20066. /**
  20067. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  20068. */
  20069. positionIterations: number;
  20070. /**
  20071. * The unique id of the physics imposter
  20072. * set by the physics engine when adding this impostor to the array
  20073. */
  20074. uniqueId: number;
  20075. /**
  20076. * @hidden
  20077. */
  20078. soft: boolean;
  20079. /**
  20080. * @hidden
  20081. */
  20082. segments: number;
  20083. private _joints;
  20084. /**
  20085. * Initializes the physics imposter
  20086. * @param object The physics-enabled object used as the physics imposter
  20087. * @param type The type of the physics imposter
  20088. * @param _options The options for the physics imposter
  20089. * @param _scene The Babylon scene
  20090. */
  20091. constructor(
  20092. /**
  20093. * The physics-enabled object used as the physics imposter
  20094. */
  20095. object: IPhysicsEnabledObject,
  20096. /**
  20097. * The type of the physics imposter
  20098. */
  20099. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  20100. /**
  20101. * This function will completly initialize this impostor.
  20102. * It will create a new body - but only if this mesh has no parent.
  20103. * If it has, this impostor will not be used other than to define the impostor
  20104. * of the child mesh.
  20105. * @hidden
  20106. */
  20107. _init(): void;
  20108. private _getPhysicsParent;
  20109. /**
  20110. * Should a new body be generated.
  20111. * @returns boolean specifying if body initialization is required
  20112. */
  20113. isBodyInitRequired(): boolean;
  20114. /**
  20115. * Sets the updated scaling
  20116. * @param updated Specifies if the scaling is updated
  20117. */
  20118. setScalingUpdated(): void;
  20119. /**
  20120. * Force a regeneration of this or the parent's impostor's body.
  20121. * Use under cautious - This will remove all joints already implemented.
  20122. */
  20123. forceUpdate(): void;
  20124. /**
  20125. * Gets the body that holds this impostor. Either its own, or its parent.
  20126. */
  20127. /**
  20128. * Set the physics body. Used mainly by the physics engine/plugin
  20129. */
  20130. physicsBody: any;
  20131. /**
  20132. * Get the parent of the physics imposter
  20133. * @returns Physics imposter or null
  20134. */
  20135. /**
  20136. * Sets the parent of the physics imposter
  20137. */
  20138. parent: Nullable<PhysicsImpostor>;
  20139. /**
  20140. * Resets the update flags
  20141. */
  20142. resetUpdateFlags(): void;
  20143. /**
  20144. * Gets the object extend size
  20145. * @returns the object extend size
  20146. */
  20147. getObjectExtendSize(): Vector3;
  20148. /**
  20149. * Gets the object center
  20150. * @returns The object center
  20151. */
  20152. getObjectCenter(): Vector3;
  20153. /**
  20154. * Get a specific parametes from the options parameter
  20155. * @param paramName The object parameter name
  20156. * @returns The object parameter
  20157. */
  20158. getParam(paramName: string): any;
  20159. /**
  20160. * Sets a specific parameter in the options given to the physics plugin
  20161. * @param paramName The parameter name
  20162. * @param value The value of the parameter
  20163. */
  20164. setParam(paramName: string, value: number): void;
  20165. /**
  20166. * Specifically change the body's mass option. Won't recreate the physics body object
  20167. * @param mass The mass of the physics imposter
  20168. */
  20169. setMass(mass: number): void;
  20170. /**
  20171. * Gets the linear velocity
  20172. * @returns linear velocity or null
  20173. */
  20174. getLinearVelocity(): Nullable<Vector3>;
  20175. /**
  20176. * Sets the linear velocity
  20177. * @param velocity linear velocity or null
  20178. */
  20179. setLinearVelocity(velocity: Nullable<Vector3>): void;
  20180. /**
  20181. * Gets the angular velocity
  20182. * @returns angular velocity or null
  20183. */
  20184. getAngularVelocity(): Nullable<Vector3>;
  20185. /**
  20186. * Sets the angular velocity
  20187. * @param velocity The velocity or null
  20188. */
  20189. setAngularVelocity(velocity: Nullable<Vector3>): void;
  20190. /**
  20191. * Execute a function with the physics plugin native code
  20192. * Provide a function the will have two variables - the world object and the physics body object
  20193. * @param func The function to execute with the physics plugin native code
  20194. */
  20195. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  20196. /**
  20197. * Register a function that will be executed before the physics world is stepping forward
  20198. * @param func The function to execute before the physics world is stepped forward
  20199. */
  20200. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20201. /**
  20202. * Unregister a function that will be executed before the physics world is stepping forward
  20203. * @param func The function to execute before the physics world is stepped forward
  20204. */
  20205. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20206. /**
  20207. * Register a function that will be executed after the physics step
  20208. * @param func The function to execute after physics step
  20209. */
  20210. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20211. /**
  20212. * Unregisters a function that will be executed after the physics step
  20213. * @param func The function to execute after physics step
  20214. */
  20215. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20216. /**
  20217. * register a function that will be executed when this impostor collides against a different body
  20218. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  20219. * @param func Callback that is executed on collision
  20220. */
  20221. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  20222. /**
  20223. * Unregisters the physics imposter on contact
  20224. * @param collideAgainst The physics object to collide against
  20225. * @param func Callback to execute on collision
  20226. */
  20227. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  20228. private _tmpQuat;
  20229. private _tmpQuat2;
  20230. /**
  20231. * Get the parent rotation
  20232. * @returns The parent rotation
  20233. */
  20234. getParentsRotation(): Quaternion;
  20235. /**
  20236. * this function is executed by the physics engine.
  20237. */
  20238. beforeStep: () => void;
  20239. /**
  20240. * this function is executed by the physics engine
  20241. */
  20242. afterStep: () => void;
  20243. /**
  20244. * Legacy collision detection event support
  20245. */
  20246. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  20247. /**
  20248. * event and body object due to cannon's event-based architecture.
  20249. */
  20250. onCollide: (e: {
  20251. body: any;
  20252. }) => void;
  20253. /**
  20254. * Apply a force
  20255. * @param force The force to apply
  20256. * @param contactPoint The contact point for the force
  20257. * @returns The physics imposter
  20258. */
  20259. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20260. /**
  20261. * Apply an impulse
  20262. * @param force The impulse force
  20263. * @param contactPoint The contact point for the impulse force
  20264. * @returns The physics imposter
  20265. */
  20266. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20267. /**
  20268. * A help function to create a joint
  20269. * @param otherImpostor A physics imposter used to create a joint
  20270. * @param jointType The type of joint
  20271. * @param jointData The data for the joint
  20272. * @returns The physics imposter
  20273. */
  20274. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  20275. /**
  20276. * Add a joint to this impostor with a different impostor
  20277. * @param otherImpostor A physics imposter used to add a joint
  20278. * @param joint The joint to add
  20279. * @returns The physics imposter
  20280. */
  20281. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  20282. /**
  20283. * Add an anchor to a cloth impostor
  20284. * @param otherImpostor rigid impostor to anchor to
  20285. * @param width ratio across width from 0 to 1
  20286. * @param height ratio up height from 0 to 1
  20287. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  20288. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  20289. * @returns impostor the soft imposter
  20290. */
  20291. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  20292. /**
  20293. * Add a hook to a rope impostor
  20294. * @param otherImpostor rigid impostor to anchor to
  20295. * @param length ratio across rope from 0 to 1
  20296. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  20297. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  20298. * @returns impostor the rope imposter
  20299. */
  20300. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  20301. /**
  20302. * Will keep this body still, in a sleep mode.
  20303. * @returns the physics imposter
  20304. */
  20305. sleep(): PhysicsImpostor;
  20306. /**
  20307. * Wake the body up.
  20308. * @returns The physics imposter
  20309. */
  20310. wakeUp(): PhysicsImpostor;
  20311. /**
  20312. * Clones the physics imposter
  20313. * @param newObject The physics imposter clones to this physics-enabled object
  20314. * @returns A nullable physics imposter
  20315. */
  20316. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20317. /**
  20318. * Disposes the physics imposter
  20319. */
  20320. dispose(): void;
  20321. /**
  20322. * Sets the delta position
  20323. * @param position The delta position amount
  20324. */
  20325. setDeltaPosition(position: Vector3): void;
  20326. /**
  20327. * Sets the delta rotation
  20328. * @param rotation The delta rotation amount
  20329. */
  20330. setDeltaRotation(rotation: Quaternion): void;
  20331. /**
  20332. * Gets the box size of the physics imposter and stores the result in the input parameter
  20333. * @param result Stores the box size
  20334. * @returns The physics imposter
  20335. */
  20336. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  20337. /**
  20338. * Gets the radius of the physics imposter
  20339. * @returns Radius of the physics imposter
  20340. */
  20341. getRadius(): number;
  20342. /**
  20343. * Sync a bone with this impostor
  20344. * @param bone The bone to sync to the impostor.
  20345. * @param boneMesh The mesh that the bone is influencing.
  20346. * @param jointPivot The pivot of the joint / bone in local space.
  20347. * @param distToJoint Optional distance from the impostor to the joint.
  20348. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20349. */
  20350. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  20351. /**
  20352. * Sync impostor to a bone
  20353. * @param bone The bone that the impostor will be synced to.
  20354. * @param boneMesh The mesh that the bone is influencing.
  20355. * @param jointPivot The pivot of the joint / bone in local space.
  20356. * @param distToJoint Optional distance from the impostor to the joint.
  20357. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20358. * @param boneAxis Optional vector3 axis the bone is aligned with
  20359. */
  20360. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  20361. /**
  20362. * No-Imposter type
  20363. */
  20364. static NoImpostor: number;
  20365. /**
  20366. * Sphere-Imposter type
  20367. */
  20368. static SphereImpostor: number;
  20369. /**
  20370. * Box-Imposter type
  20371. */
  20372. static BoxImpostor: number;
  20373. /**
  20374. * Plane-Imposter type
  20375. */
  20376. static PlaneImpostor: number;
  20377. /**
  20378. * Mesh-imposter type
  20379. */
  20380. static MeshImpostor: number;
  20381. /**
  20382. * Cylinder-Imposter type
  20383. */
  20384. static CylinderImpostor: number;
  20385. /**
  20386. * Particle-Imposter type
  20387. */
  20388. static ParticleImpostor: number;
  20389. /**
  20390. * Heightmap-Imposter type
  20391. */
  20392. static HeightmapImpostor: number;
  20393. /**
  20394. * ConvexHull-Impostor type (Ammo.js plugin only)
  20395. */
  20396. static ConvexHullImpostor: number;
  20397. /**
  20398. * Rope-Imposter type
  20399. */
  20400. static RopeImpostor: number;
  20401. /**
  20402. * Cloth-Imposter type
  20403. */
  20404. static ClothImpostor: number;
  20405. /**
  20406. * Softbody-Imposter type
  20407. */
  20408. static SoftbodyImpostor: number;
  20409. }
  20410. }
  20411. declare module BABYLON {
  20412. /**
  20413. * Class used to represent a specific level of detail of a mesh
  20414. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20415. */
  20416. export class MeshLODLevel {
  20417. /** Defines the distance where this level should star being displayed */
  20418. distance: number;
  20419. /** Defines the mesh to use to render this level */
  20420. mesh: Nullable<Mesh>;
  20421. /**
  20422. * Creates a new LOD level
  20423. * @param distance defines the distance where this level should star being displayed
  20424. * @param mesh defines the mesh to use to render this level
  20425. */
  20426. constructor(
  20427. /** Defines the distance where this level should star being displayed */
  20428. distance: number,
  20429. /** Defines the mesh to use to render this level */
  20430. mesh: Nullable<Mesh>);
  20431. }
  20432. /**
  20433. * @hidden
  20434. **/
  20435. export class _CreationDataStorage {
  20436. closePath?: boolean;
  20437. closeArray?: boolean;
  20438. idx: number[];
  20439. dashSize: number;
  20440. gapSize: number;
  20441. path3D: Path3D;
  20442. pathArray: Vector3[][];
  20443. arc: number;
  20444. radius: number;
  20445. cap: number;
  20446. tessellation: number;
  20447. }
  20448. /**
  20449. * @hidden
  20450. **/
  20451. class _InstanceDataStorage {
  20452. visibleInstances: any;
  20453. renderIdForInstances: number[];
  20454. batchCache: _InstancesBatch;
  20455. instancesBufferSize: number;
  20456. instancesBuffer: Nullable<Buffer>;
  20457. instancesData: Float32Array;
  20458. overridenInstanceCount: number;
  20459. }
  20460. /**
  20461. * @hidden
  20462. **/
  20463. export class _InstancesBatch {
  20464. mustReturn: boolean;
  20465. visibleInstances: Nullable<InstancedMesh[]>[];
  20466. renderSelf: boolean[];
  20467. }
  20468. /**
  20469. * Class used to represent renderable models
  20470. */
  20471. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  20472. /**
  20473. * Mesh side orientation : usually the external or front surface
  20474. */
  20475. static readonly FRONTSIDE: number;
  20476. /**
  20477. * Mesh side orientation : usually the internal or back surface
  20478. */
  20479. static readonly BACKSIDE: number;
  20480. /**
  20481. * Mesh side orientation : both internal and external or front and back surfaces
  20482. */
  20483. static readonly DOUBLESIDE: number;
  20484. /**
  20485. * Mesh side orientation : by default, `FRONTSIDE`
  20486. */
  20487. static readonly DEFAULTSIDE: number;
  20488. /**
  20489. * Mesh cap setting : no cap
  20490. */
  20491. static readonly NO_CAP: number;
  20492. /**
  20493. * Mesh cap setting : one cap at the beginning of the mesh
  20494. */
  20495. static readonly CAP_START: number;
  20496. /**
  20497. * Mesh cap setting : one cap at the end of the mesh
  20498. */
  20499. static readonly CAP_END: number;
  20500. /**
  20501. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  20502. */
  20503. static readonly CAP_ALL: number;
  20504. /**
  20505. * Gets the default side orientation.
  20506. * @param orientation the orientation to value to attempt to get
  20507. * @returns the default orientation
  20508. * @hidden
  20509. */
  20510. static _GetDefaultSideOrientation(orientation?: number): number;
  20511. private _onBeforeRenderObservable;
  20512. private _onBeforeBindObservable;
  20513. private _onAfterRenderObservable;
  20514. private _onBeforeDrawObservable;
  20515. /**
  20516. * An event triggered before rendering the mesh
  20517. */
  20518. readonly onBeforeRenderObservable: Observable<Mesh>;
  20519. /**
  20520. * An event triggered before binding the mesh
  20521. */
  20522. readonly onBeforeBindObservable: Observable<Mesh>;
  20523. /**
  20524. * An event triggered after rendering the mesh
  20525. */
  20526. readonly onAfterRenderObservable: Observable<Mesh>;
  20527. /**
  20528. * An event triggered before drawing the mesh
  20529. */
  20530. readonly onBeforeDrawObservable: Observable<Mesh>;
  20531. private _onBeforeDrawObserver;
  20532. /**
  20533. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  20534. */
  20535. onBeforeDraw: () => void;
  20536. /**
  20537. * Gets the delay loading state of the mesh (when delay loading is turned on)
  20538. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  20539. */
  20540. delayLoadState: number;
  20541. /**
  20542. * Gets the list of instances created from this mesh
  20543. * it is not supposed to be modified manually.
  20544. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  20545. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20546. */
  20547. instances: InstancedMesh[];
  20548. /**
  20549. * Gets the file containing delay loading data for this mesh
  20550. */
  20551. delayLoadingFile: string;
  20552. /** @hidden */
  20553. _binaryInfo: any;
  20554. private _LODLevels;
  20555. /**
  20556. * User defined function used to change how LOD level selection is done
  20557. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20558. */
  20559. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  20560. private _morphTargetManager;
  20561. /**
  20562. * Gets or sets the morph target manager
  20563. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  20564. */
  20565. morphTargetManager: Nullable<MorphTargetManager>;
  20566. /** @hidden */
  20567. _creationDataStorage: Nullable<_CreationDataStorage>;
  20568. /** @hidden */
  20569. _geometry: Nullable<Geometry>;
  20570. /** @hidden */
  20571. _delayInfo: Array<string>;
  20572. /** @hidden */
  20573. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  20574. /** @hidden */
  20575. _instanceDataStorage: _InstanceDataStorage;
  20576. private _effectiveMaterial;
  20577. /** @hidden */
  20578. _shouldGenerateFlatShading: boolean;
  20579. private _preActivateId;
  20580. /** @hidden */
  20581. _originalBuilderSideOrientation: number;
  20582. /**
  20583. * Use this property to change the original side orientation defined at construction time
  20584. */
  20585. overrideMaterialSideOrientation: Nullable<number>;
  20586. private _areNormalsFrozen;
  20587. private _sourcePositions;
  20588. private _sourceNormals;
  20589. private _source;
  20590. private meshMap;
  20591. /**
  20592. * Gets the source mesh (the one used to clone this one from)
  20593. */
  20594. readonly source: Nullable<Mesh>;
  20595. /**
  20596. * Gets or sets a boolean indicating that this mesh does not use index buffer
  20597. */
  20598. isUnIndexed: boolean;
  20599. /**
  20600. * @constructor
  20601. * @param name The value used by scene.getMeshByName() to do a lookup.
  20602. * @param scene The scene to add this mesh to.
  20603. * @param parent The parent of this mesh, if it has one
  20604. * @param source An optional Mesh from which geometry is shared, cloned.
  20605. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  20606. * When false, achieved by calling a clone(), also passing False.
  20607. * This will make creation of children, recursive.
  20608. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  20609. */
  20610. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  20611. /**
  20612. * Gets the class name
  20613. * @returns the string "Mesh".
  20614. */
  20615. getClassName(): string;
  20616. /** @hidden */
  20617. readonly _isMesh: boolean;
  20618. /**
  20619. * Returns a description of this mesh
  20620. * @param fullDetails define if full details about this mesh must be used
  20621. * @returns a descriptive string representing this mesh
  20622. */
  20623. toString(fullDetails?: boolean): string;
  20624. /** @hidden */
  20625. _unBindEffect(): void;
  20626. /**
  20627. * Gets a boolean indicating if this mesh has LOD
  20628. */
  20629. readonly hasLODLevels: boolean;
  20630. /**
  20631. * Gets the list of MeshLODLevel associated with the current mesh
  20632. * @returns an array of MeshLODLevel
  20633. */
  20634. getLODLevels(): MeshLODLevel[];
  20635. private _sortLODLevels;
  20636. /**
  20637. * Add a mesh as LOD level triggered at the given distance.
  20638. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20639. * @param distance The distance from the center of the object to show this level
  20640. * @param mesh The mesh to be added as LOD level (can be null)
  20641. * @return This mesh (for chaining)
  20642. */
  20643. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  20644. /**
  20645. * Returns the LOD level mesh at the passed distance or null if not found.
  20646. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20647. * @param distance The distance from the center of the object to show this level
  20648. * @returns a Mesh or `null`
  20649. */
  20650. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  20651. /**
  20652. * Remove a mesh from the LOD array
  20653. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20654. * @param mesh defines the mesh to be removed
  20655. * @return This mesh (for chaining)
  20656. */
  20657. removeLODLevel(mesh: Mesh): Mesh;
  20658. /**
  20659. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  20660. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20661. * @param camera defines the camera to use to compute distance
  20662. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  20663. * @return This mesh (for chaining)
  20664. */
  20665. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  20666. /**
  20667. * Gets the mesh internal Geometry object
  20668. */
  20669. readonly geometry: Nullable<Geometry>;
  20670. /**
  20671. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  20672. * @returns the total number of vertices
  20673. */
  20674. getTotalVertices(): number;
  20675. /**
  20676. * Returns the content of an associated vertex buffer
  20677. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20678. * - VertexBuffer.PositionKind
  20679. * - VertexBuffer.UVKind
  20680. * - VertexBuffer.UV2Kind
  20681. * - VertexBuffer.UV3Kind
  20682. * - VertexBuffer.UV4Kind
  20683. * - VertexBuffer.UV5Kind
  20684. * - VertexBuffer.UV6Kind
  20685. * - VertexBuffer.ColorKind
  20686. * - VertexBuffer.MatricesIndicesKind
  20687. * - VertexBuffer.MatricesIndicesExtraKind
  20688. * - VertexBuffer.MatricesWeightsKind
  20689. * - VertexBuffer.MatricesWeightsExtraKind
  20690. * @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
  20691. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  20692. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  20693. */
  20694. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20695. /**
  20696. * Returns the mesh VertexBuffer object from the requested `kind`
  20697. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20698. * - VertexBuffer.PositionKind
  20699. * - VertexBuffer.UVKind
  20700. * - VertexBuffer.UV2Kind
  20701. * - VertexBuffer.UV3Kind
  20702. * - VertexBuffer.UV4Kind
  20703. * - VertexBuffer.UV5Kind
  20704. * - VertexBuffer.UV6Kind
  20705. * - VertexBuffer.ColorKind
  20706. * - VertexBuffer.MatricesIndicesKind
  20707. * - VertexBuffer.MatricesIndicesExtraKind
  20708. * - VertexBuffer.MatricesWeightsKind
  20709. * - VertexBuffer.MatricesWeightsExtraKind
  20710. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  20711. */
  20712. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20713. /**
  20714. * Tests if a specific vertex buffer is associated with this mesh
  20715. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  20716. * - VertexBuffer.PositionKind
  20717. * - VertexBuffer.UVKind
  20718. * - VertexBuffer.UV2Kind
  20719. * - VertexBuffer.UV3Kind
  20720. * - VertexBuffer.UV4Kind
  20721. * - VertexBuffer.UV5Kind
  20722. * - VertexBuffer.UV6Kind
  20723. * - VertexBuffer.ColorKind
  20724. * - VertexBuffer.MatricesIndicesKind
  20725. * - VertexBuffer.MatricesIndicesExtraKind
  20726. * - VertexBuffer.MatricesWeightsKind
  20727. * - VertexBuffer.MatricesWeightsExtraKind
  20728. * @returns a boolean
  20729. */
  20730. isVerticesDataPresent(kind: string): boolean;
  20731. /**
  20732. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  20733. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  20734. * - VertexBuffer.PositionKind
  20735. * - VertexBuffer.UVKind
  20736. * - VertexBuffer.UV2Kind
  20737. * - VertexBuffer.UV3Kind
  20738. * - VertexBuffer.UV4Kind
  20739. * - VertexBuffer.UV5Kind
  20740. * - VertexBuffer.UV6Kind
  20741. * - VertexBuffer.ColorKind
  20742. * - VertexBuffer.MatricesIndicesKind
  20743. * - VertexBuffer.MatricesIndicesExtraKind
  20744. * - VertexBuffer.MatricesWeightsKind
  20745. * - VertexBuffer.MatricesWeightsExtraKind
  20746. * @returns a boolean
  20747. */
  20748. isVertexBufferUpdatable(kind: string): boolean;
  20749. /**
  20750. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  20751. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20752. * - VertexBuffer.PositionKind
  20753. * - VertexBuffer.UVKind
  20754. * - VertexBuffer.UV2Kind
  20755. * - VertexBuffer.UV3Kind
  20756. * - VertexBuffer.UV4Kind
  20757. * - VertexBuffer.UV5Kind
  20758. * - VertexBuffer.UV6Kind
  20759. * - VertexBuffer.ColorKind
  20760. * - VertexBuffer.MatricesIndicesKind
  20761. * - VertexBuffer.MatricesIndicesExtraKind
  20762. * - VertexBuffer.MatricesWeightsKind
  20763. * - VertexBuffer.MatricesWeightsExtraKind
  20764. * @returns an array of strings
  20765. */
  20766. getVerticesDataKinds(): string[];
  20767. /**
  20768. * Returns a positive integer : the total number of indices in this mesh geometry.
  20769. * @returns the numner of indices or zero if the mesh has no geometry.
  20770. */
  20771. getTotalIndices(): number;
  20772. /**
  20773. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  20774. * @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.
  20775. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20776. * @returns the indices array or an empty array if the mesh has no geometry
  20777. */
  20778. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  20779. readonly isBlocked: boolean;
  20780. /**
  20781. * Determine if the current mesh is ready to be rendered
  20782. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  20783. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  20784. * @returns true if all associated assets are ready (material, textures, shaders)
  20785. */
  20786. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  20787. /**
  20788. * 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.
  20789. */
  20790. readonly areNormalsFrozen: boolean;
  20791. /**
  20792. * 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.
  20793. * @returns the current mesh
  20794. */
  20795. freezeNormals(): Mesh;
  20796. /**
  20797. * 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
  20798. * @returns the current mesh
  20799. */
  20800. unfreezeNormals(): Mesh;
  20801. /**
  20802. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  20803. */
  20804. overridenInstanceCount: number;
  20805. /** @hidden */
  20806. _preActivate(): Mesh;
  20807. /** @hidden */
  20808. _preActivateForIntermediateRendering(renderId: number): Mesh;
  20809. /** @hidden */
  20810. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  20811. /**
  20812. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  20813. * This means the mesh underlying bounding box and sphere are recomputed.
  20814. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  20815. * @returns the current mesh
  20816. */
  20817. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  20818. /** @hidden */
  20819. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  20820. /**
  20821. * This function will subdivide the mesh into multiple submeshes
  20822. * @param count defines the expected number of submeshes
  20823. */
  20824. subdivide(count: number): void;
  20825. /**
  20826. * Copy a FloatArray into a specific associated vertex buffer
  20827. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20828. * - VertexBuffer.PositionKind
  20829. * - VertexBuffer.UVKind
  20830. * - VertexBuffer.UV2Kind
  20831. * - VertexBuffer.UV3Kind
  20832. * - VertexBuffer.UV4Kind
  20833. * - VertexBuffer.UV5Kind
  20834. * - VertexBuffer.UV6Kind
  20835. * - VertexBuffer.ColorKind
  20836. * - VertexBuffer.MatricesIndicesKind
  20837. * - VertexBuffer.MatricesIndicesExtraKind
  20838. * - VertexBuffer.MatricesWeightsKind
  20839. * - VertexBuffer.MatricesWeightsExtraKind
  20840. * @param data defines the data source
  20841. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  20842. * @param stride defines the data stride size (can be null)
  20843. * @returns the current mesh
  20844. */
  20845. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  20846. /**
  20847. * Flags an associated vertex buffer as updatable
  20848. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  20849. * - VertexBuffer.PositionKind
  20850. * - VertexBuffer.UVKind
  20851. * - VertexBuffer.UV2Kind
  20852. * - VertexBuffer.UV3Kind
  20853. * - VertexBuffer.UV4Kind
  20854. * - VertexBuffer.UV5Kind
  20855. * - VertexBuffer.UV6Kind
  20856. * - VertexBuffer.ColorKind
  20857. * - VertexBuffer.MatricesIndicesKind
  20858. * - VertexBuffer.MatricesIndicesExtraKind
  20859. * - VertexBuffer.MatricesWeightsKind
  20860. * - VertexBuffer.MatricesWeightsExtraKind
  20861. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  20862. */
  20863. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  20864. /**
  20865. * Sets the mesh global Vertex Buffer
  20866. * @param buffer defines the buffer to use
  20867. * @returns the current mesh
  20868. */
  20869. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  20870. /**
  20871. * Update a specific associated vertex buffer
  20872. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20873. * - VertexBuffer.PositionKind
  20874. * - VertexBuffer.UVKind
  20875. * - VertexBuffer.UV2Kind
  20876. * - VertexBuffer.UV3Kind
  20877. * - VertexBuffer.UV4Kind
  20878. * - VertexBuffer.UV5Kind
  20879. * - VertexBuffer.UV6Kind
  20880. * - VertexBuffer.ColorKind
  20881. * - VertexBuffer.MatricesIndicesKind
  20882. * - VertexBuffer.MatricesIndicesExtraKind
  20883. * - VertexBuffer.MatricesWeightsKind
  20884. * - VertexBuffer.MatricesWeightsExtraKind
  20885. * @param data defines the data source
  20886. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  20887. * @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)
  20888. * @returns the current mesh
  20889. */
  20890. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  20891. /**
  20892. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  20893. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  20894. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  20895. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  20896. * @returns the current mesh
  20897. */
  20898. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  20899. /**
  20900. * Creates a un-shared specific occurence of the geometry for the mesh.
  20901. * @returns the current mesh
  20902. */
  20903. makeGeometryUnique(): Mesh;
  20904. /**
  20905. * Set the index buffer of this mesh
  20906. * @param indices defines the source data
  20907. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  20908. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  20909. * @returns the current mesh
  20910. */
  20911. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  20912. /**
  20913. * Update the current index buffer
  20914. * @param indices defines the source data
  20915. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  20916. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  20917. * @returns the current mesh
  20918. */
  20919. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  20920. /**
  20921. * Invert the geometry to move from a right handed system to a left handed one.
  20922. * @returns the current mesh
  20923. */
  20924. toLeftHanded(): Mesh;
  20925. /** @hidden */
  20926. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  20927. /** @hidden */
  20928. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  20929. /**
  20930. * Registers for this mesh a javascript function called just before the rendering process
  20931. * @param func defines the function to call before rendering this mesh
  20932. * @returns the current mesh
  20933. */
  20934. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20935. /**
  20936. * Disposes a previously registered javascript function called before the rendering
  20937. * @param func defines the function to remove
  20938. * @returns the current mesh
  20939. */
  20940. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20941. /**
  20942. * Registers for this mesh a javascript function called just after the rendering is complete
  20943. * @param func defines the function to call after rendering this mesh
  20944. * @returns the current mesh
  20945. */
  20946. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20947. /**
  20948. * Disposes a previously registered javascript function called after the rendering.
  20949. * @param func defines the function to remove
  20950. * @returns the current mesh
  20951. */
  20952. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20953. /** @hidden */
  20954. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  20955. /** @hidden */
  20956. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  20957. /** @hidden */
  20958. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  20959. /**
  20960. * 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
  20961. * @param subMesh defines the subMesh to render
  20962. * @param enableAlphaMode defines if alpha mode can be changed
  20963. * @returns the current mesh
  20964. */
  20965. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  20966. private _onBeforeDraw;
  20967. /**
  20968. * Renormalize the mesh and patch it up if there are no weights
  20969. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  20970. * However in the case of zero weights then we set just a single influence to 1.
  20971. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  20972. */
  20973. cleanMatrixWeights(): void;
  20974. private normalizeSkinFourWeights;
  20975. private normalizeSkinWeightsAndExtra;
  20976. /**
  20977. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  20978. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  20979. * the user know there was an issue with importing the mesh
  20980. * @returns a validation object with skinned, valid and report string
  20981. */
  20982. validateSkinning(): {
  20983. skinned: boolean;
  20984. valid: boolean;
  20985. report: string;
  20986. };
  20987. /** @hidden */
  20988. _checkDelayState(): Mesh;
  20989. private _queueLoad;
  20990. /**
  20991. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  20992. * A mesh is in the frustum if its bounding box intersects the frustum
  20993. * @param frustumPlanes defines the frustum to test
  20994. * @returns true if the mesh is in the frustum planes
  20995. */
  20996. isInFrustum(frustumPlanes: Plane[]): boolean;
  20997. /**
  20998. * Sets the mesh material by the material or multiMaterial `id` property
  20999. * @param id is a string identifying the material or the multiMaterial
  21000. * @returns the current mesh
  21001. */
  21002. setMaterialByID(id: string): Mesh;
  21003. /**
  21004. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  21005. * @returns an array of IAnimatable
  21006. */
  21007. getAnimatables(): IAnimatable[];
  21008. /**
  21009. * Modifies the mesh geometry according to the passed transformation matrix.
  21010. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  21011. * The mesh normals are modified using the same transformation.
  21012. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21013. * @param transform defines the transform matrix to use
  21014. * @see http://doc.babylonjs.com/resources/baking_transformations
  21015. * @returns the current mesh
  21016. */
  21017. bakeTransformIntoVertices(transform: Matrix): Mesh;
  21018. /**
  21019. * Modifies the mesh geometry according to its own current World Matrix.
  21020. * The mesh World Matrix is then reset.
  21021. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  21022. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21023. * @see http://doc.babylonjs.com/resources/baking_transformations
  21024. * @returns the current mesh
  21025. */
  21026. bakeCurrentTransformIntoVertices(): Mesh;
  21027. /** @hidden */
  21028. readonly _positions: Nullable<Vector3[]>;
  21029. /** @hidden */
  21030. _resetPointsArrayCache(): Mesh;
  21031. /** @hidden */
  21032. _generatePointsArray(): boolean;
  21033. /**
  21034. * Returns a new Mesh object generated from the current mesh properties.
  21035. * This method must not get confused with createInstance()
  21036. * @param name is a string, the name given to the new mesh
  21037. * @param newParent can be any Node object (default `null`)
  21038. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  21039. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  21040. * @returns a new mesh
  21041. */
  21042. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  21043. /**
  21044. * Releases resources associated with this mesh.
  21045. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  21046. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  21047. */
  21048. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  21049. /**
  21050. * Modifies the mesh geometry according to a displacement map.
  21051. * 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.
  21052. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21053. * @param url is a string, the URL from the image file is to be downloaded.
  21054. * @param minHeight is the lower limit of the displacement.
  21055. * @param maxHeight is the upper limit of the displacement.
  21056. * @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.
  21057. * @param uvOffset is an optional vector2 used to offset UV.
  21058. * @param uvScale is an optional vector2 used to scale UV.
  21059. * @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.
  21060. * @returns the Mesh.
  21061. */
  21062. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21063. /**
  21064. * Modifies the mesh geometry according to a displacementMap buffer.
  21065. * 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.
  21066. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21067. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  21068. * @param heightMapWidth is the width of the buffer image.
  21069. * @param heightMapHeight is the height of the buffer image.
  21070. * @param minHeight is the lower limit of the displacement.
  21071. * @param maxHeight is the upper limit of the displacement.
  21072. * @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.
  21073. * @param uvOffset is an optional vector2 used to offset UV.
  21074. * @param uvScale is an optional vector2 used to scale UV.
  21075. * @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.
  21076. * @returns the Mesh.
  21077. */
  21078. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21079. /**
  21080. * Modify the mesh to get a flat shading rendering.
  21081. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  21082. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  21083. * @returns current mesh
  21084. */
  21085. convertToFlatShadedMesh(): Mesh;
  21086. /**
  21087. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  21088. * In other words, more vertices, no more indices and a single bigger VBO.
  21089. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  21090. * @returns current mesh
  21091. */
  21092. convertToUnIndexedMesh(): Mesh;
  21093. /**
  21094. * Inverses facet orientations.
  21095. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21096. * @param flipNormals will also inverts the normals
  21097. * @returns current mesh
  21098. */
  21099. flipFaces(flipNormals?: boolean): Mesh;
  21100. /**
  21101. * Increase the number of facets and hence vertices in a mesh
  21102. * Vertex normals are interpolated from existing vertex normals
  21103. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21104. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  21105. */
  21106. increaseVertices(numberPerEdge: number): void;
  21107. /**
  21108. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  21109. * This will undo any application of covertToFlatShadedMesh
  21110. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21111. */
  21112. forceSharedVertices(): void;
  21113. /** @hidden */
  21114. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  21115. /** @hidden */
  21116. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  21117. /**
  21118. * Creates a new InstancedMesh object from the mesh model.
  21119. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  21120. * @param name defines the name of the new instance
  21121. * @returns a new InstancedMesh
  21122. */
  21123. createInstance(name: string): InstancedMesh;
  21124. /**
  21125. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  21126. * After this call, all the mesh instances have the same submeshes than the current mesh.
  21127. * @returns the current mesh
  21128. */
  21129. synchronizeInstances(): Mesh;
  21130. /**
  21131. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  21132. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  21133. * This should be used together with the simplification to avoid disappearing triangles.
  21134. * @param successCallback an optional success callback to be called after the optimization finished.
  21135. * @returns the current mesh
  21136. */
  21137. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  21138. /**
  21139. * Serialize current mesh
  21140. * @param serializationObject defines the object which will receive the serialization data
  21141. */
  21142. serialize(serializationObject: any): void;
  21143. /** @hidden */
  21144. _syncGeometryWithMorphTargetManager(): void;
  21145. /** @hidden */
  21146. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  21147. /**
  21148. * Returns a new Mesh object parsed from the source provided.
  21149. * @param parsedMesh is the source
  21150. * @param scene defines the hosting scene
  21151. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  21152. * @returns a new Mesh
  21153. */
  21154. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  21155. /**
  21156. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  21157. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21158. * @param name defines the name of the mesh to create
  21159. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  21160. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  21161. * @param closePath creates a seam between the first and the last points of each path of the path array
  21162. * @param offset is taken in account only if the `pathArray` is containing a single path
  21163. * @param scene defines the hosting scene
  21164. * @param updatable defines if the mesh must be flagged as updatable
  21165. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21166. * @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)
  21167. * @returns a new Mesh
  21168. */
  21169. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21170. /**
  21171. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  21172. * @param name defines the name of the mesh to create
  21173. * @param radius sets the radius size (float) of the polygon (default 0.5)
  21174. * @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
  21175. * @param scene defines the hosting scene
  21176. * @param updatable defines if the mesh must be flagged as updatable
  21177. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21178. * @returns a new Mesh
  21179. */
  21180. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21181. /**
  21182. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  21183. * @param name defines the name of the mesh to create
  21184. * @param size sets the size (float) of each box side (default 1)
  21185. * @param scene defines the hosting scene
  21186. * @param updatable defines if the mesh must be flagged as updatable
  21187. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21188. * @returns a new Mesh
  21189. */
  21190. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21191. /**
  21192. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  21193. * @param name defines the name of the mesh to create
  21194. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21195. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21196. * @param scene defines the hosting scene
  21197. * @param updatable defines if the mesh must be flagged as updatable
  21198. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21199. * @returns a new Mesh
  21200. */
  21201. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21202. /**
  21203. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  21204. * @param name defines the name of the mesh to create
  21205. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  21206. * @param diameterTop set the top cap diameter (floats, default 1)
  21207. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  21208. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  21209. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  21210. * @param scene defines the hosting scene
  21211. * @param updatable defines if the mesh must be flagged as updatable
  21212. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21213. * @returns a new Mesh
  21214. */
  21215. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  21216. /**
  21217. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  21218. * @param name defines the name of the mesh to create
  21219. * @param diameter sets the diameter size (float) of the torus (default 1)
  21220. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  21221. * @param tessellation sets the number of torus sides (postive integer, default 16)
  21222. * @param scene defines the hosting scene
  21223. * @param updatable defines if the mesh must be flagged as updatable
  21224. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21225. * @returns a new Mesh
  21226. */
  21227. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21228. /**
  21229. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  21230. * @param name defines the name of the mesh to create
  21231. * @param radius sets the global radius size (float) of the torus knot (default 2)
  21232. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  21233. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  21234. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  21235. * @param p the number of windings on X axis (positive integers, default 2)
  21236. * @param q the number of windings on Y axis (positive integers, default 3)
  21237. * @param scene defines the hosting scene
  21238. * @param updatable defines if the mesh must be flagged as updatable
  21239. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21240. * @returns a new Mesh
  21241. */
  21242. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21243. /**
  21244. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  21245. * @param name defines the name of the mesh to create
  21246. * @param points is an array successive Vector3
  21247. * @param scene defines the hosting scene
  21248. * @param updatable defines if the mesh must be flagged as updatable
  21249. * @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).
  21250. * @returns a new Mesh
  21251. */
  21252. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  21253. /**
  21254. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  21255. * @param name defines the name of the mesh to create
  21256. * @param points is an array successive Vector3
  21257. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  21258. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  21259. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  21260. * @param scene defines the hosting scene
  21261. * @param updatable defines if the mesh must be flagged as updatable
  21262. * @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)
  21263. * @returns a new Mesh
  21264. */
  21265. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  21266. /**
  21267. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  21268. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  21269. * 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.
  21270. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21271. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21272. * Remember you can only change the shape positions, not their number when updating a polygon.
  21273. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  21274. * @param name defines the name of the mesh to create
  21275. * @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
  21276. * @param scene defines the hosting scene
  21277. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21278. * @param updatable defines if the mesh must be flagged as updatable
  21279. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21280. * @param earcutInjection can be used to inject your own earcut reference
  21281. * @returns a new Mesh
  21282. */
  21283. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21284. /**
  21285. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  21286. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  21287. * @param name defines the name of the mesh to create
  21288. * @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
  21289. * @param depth defines the height of extrusion
  21290. * @param scene defines the hosting scene
  21291. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21292. * @param updatable defines if the mesh must be flagged as updatable
  21293. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21294. * @param earcutInjection can be used to inject your own earcut reference
  21295. * @returns a new Mesh
  21296. */
  21297. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21298. /**
  21299. * Creates an extruded shape mesh.
  21300. * 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
  21301. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21302. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21303. * @param name defines the name of the mesh to create
  21304. * @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
  21305. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21306. * @param scale is the value to scale the shape
  21307. * @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
  21308. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  21309. * @param scene defines the hosting scene
  21310. * @param updatable defines if the mesh must be flagged as updatable
  21311. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21312. * @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)
  21313. * @returns a new Mesh
  21314. */
  21315. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21316. /**
  21317. * Creates an custom extruded shape mesh.
  21318. * The custom extrusion is a parametric shape.
  21319. * It has no predefined shape. Its final shape will depend on the input parameters.
  21320. * Please consider using the same method from the MeshBuilder class instead
  21321. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21322. * @param name defines the name of the mesh to create
  21323. * @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
  21324. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21325. * @param scaleFunction is a custom Javascript function called on each path point
  21326. * @param rotationFunction is a custom Javascript function called on each path point
  21327. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  21328. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  21329. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  21330. * @param scene defines the hosting scene
  21331. * @param updatable defines if the mesh must be flagged as updatable
  21332. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21333. * @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)
  21334. * @returns a new Mesh
  21335. */
  21336. 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;
  21337. /**
  21338. * Creates lathe mesh.
  21339. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  21340. * Please consider using the same method from the MeshBuilder class instead
  21341. * @param name defines the name of the mesh to create
  21342. * @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
  21343. * @param radius is the radius value of the lathe
  21344. * @param tessellation is the side number of the lathe.
  21345. * @param scene defines the hosting scene
  21346. * @param updatable defines if the mesh must be flagged as updatable
  21347. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21348. * @returns a new Mesh
  21349. */
  21350. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21351. /**
  21352. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  21353. * @param name defines the name of the mesh to create
  21354. * @param size sets the size (float) of both sides of the plane at once (default 1)
  21355. * @param scene defines the hosting scene
  21356. * @param updatable defines if the mesh must be flagged as updatable
  21357. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21358. * @returns a new Mesh
  21359. */
  21360. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21361. /**
  21362. * Creates a ground mesh.
  21363. * Please consider using the same method from the MeshBuilder class instead
  21364. * @param name defines the name of the mesh to create
  21365. * @param width set the width of the ground
  21366. * @param height set the height of the ground
  21367. * @param subdivisions sets the number of subdivisions per side
  21368. * @param scene defines the hosting scene
  21369. * @param updatable defines if the mesh must be flagged as updatable
  21370. * @returns a new Mesh
  21371. */
  21372. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  21373. /**
  21374. * Creates a tiled ground mesh.
  21375. * Please consider using the same method from the MeshBuilder class instead
  21376. * @param name defines the name of the mesh to create
  21377. * @param xmin set the ground minimum X coordinate
  21378. * @param zmin set the ground minimum Y coordinate
  21379. * @param xmax set the ground maximum X coordinate
  21380. * @param zmax set the ground maximum Z coordinate
  21381. * @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
  21382. * @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
  21383. * @param scene defines the hosting scene
  21384. * @param updatable defines if the mesh must be flagged as updatable
  21385. * @returns a new Mesh
  21386. */
  21387. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  21388. w: number;
  21389. h: number;
  21390. }, precision: {
  21391. w: number;
  21392. h: number;
  21393. }, scene: Scene, updatable?: boolean): Mesh;
  21394. /**
  21395. * Creates a ground mesh from a height map.
  21396. * Please consider using the same method from the MeshBuilder class instead
  21397. * @see http://doc.babylonjs.com/babylon101/height_map
  21398. * @param name defines the name of the mesh to create
  21399. * @param url sets the URL of the height map image resource
  21400. * @param width set the ground width size
  21401. * @param height set the ground height size
  21402. * @param subdivisions sets the number of subdivision per side
  21403. * @param minHeight is the minimum altitude on the ground
  21404. * @param maxHeight is the maximum altitude on the ground
  21405. * @param scene defines the hosting scene
  21406. * @param updatable defines if the mesh must be flagged as updatable
  21407. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  21408. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  21409. * @returns a new Mesh
  21410. */
  21411. 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;
  21412. /**
  21413. * Creates a tube mesh.
  21414. * The tube is a parametric shape.
  21415. * It has no predefined shape. Its final shape will depend on the input parameters.
  21416. * Please consider using the same method from the MeshBuilder class instead
  21417. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21418. * @param name defines the name of the mesh to create
  21419. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  21420. * @param radius sets the tube radius size
  21421. * @param tessellation is the number of sides on the tubular surface
  21422. * @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
  21423. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  21424. * @param scene defines the hosting scene
  21425. * @param updatable defines if the mesh must be flagged as updatable
  21426. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21427. * @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)
  21428. * @returns a new Mesh
  21429. */
  21430. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  21431. (i: number, distance: number): number;
  21432. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21433. /**
  21434. * Creates a polyhedron mesh.
  21435. * Please consider using the same method from the MeshBuilder class instead.
  21436. * * 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
  21437. * * The parameter `size` (positive float, default 1) sets the polygon size
  21438. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  21439. * * 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`
  21440. * * 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
  21441. * * 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)`)
  21442. * * 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
  21443. * * 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
  21444. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21445. * * 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
  21446. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21447. * @param name defines the name of the mesh to create
  21448. * @param options defines the options used to create the mesh
  21449. * @param scene defines the hosting scene
  21450. * @returns a new Mesh
  21451. */
  21452. static CreatePolyhedron(name: string, options: {
  21453. type?: number;
  21454. size?: number;
  21455. sizeX?: number;
  21456. sizeY?: number;
  21457. sizeZ?: number;
  21458. custom?: any;
  21459. faceUV?: Vector4[];
  21460. faceColors?: Color4[];
  21461. updatable?: boolean;
  21462. sideOrientation?: number;
  21463. }, scene: Scene): Mesh;
  21464. /**
  21465. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  21466. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  21467. * * 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`)
  21468. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  21469. * * 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
  21470. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21471. * * 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
  21472. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21473. * @param name defines the name of the mesh
  21474. * @param options defines the options used to create the mesh
  21475. * @param scene defines the hosting scene
  21476. * @returns a new Mesh
  21477. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  21478. */
  21479. static CreateIcoSphere(name: string, options: {
  21480. radius?: number;
  21481. flat?: boolean;
  21482. subdivisions?: number;
  21483. sideOrientation?: number;
  21484. updatable?: boolean;
  21485. }, scene: Scene): Mesh;
  21486. /**
  21487. * Creates a decal mesh.
  21488. * Please consider using the same method from the MeshBuilder class instead.
  21489. * A decal is a mesh usually applied as a model onto the surface of another mesh
  21490. * @param name defines the name of the mesh
  21491. * @param sourceMesh defines the mesh receiving the decal
  21492. * @param position sets the position of the decal in world coordinates
  21493. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  21494. * @param size sets the decal scaling
  21495. * @param angle sets the angle to rotate the decal
  21496. * @returns a new Mesh
  21497. */
  21498. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  21499. /**
  21500. * Prepare internal position array for software CPU skinning
  21501. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  21502. */
  21503. setPositionsForCPUSkinning(): Float32Array;
  21504. /**
  21505. * Prepare internal normal array for software CPU skinning
  21506. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  21507. */
  21508. setNormalsForCPUSkinning(): Float32Array;
  21509. /**
  21510. * Updates the vertex buffer by applying transformation from the bones
  21511. * @param skeleton defines the skeleton to apply to current mesh
  21512. * @returns the current mesh
  21513. */
  21514. applySkeleton(skeleton: Skeleton): Mesh;
  21515. /**
  21516. * 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
  21517. * @param meshes defines the list of meshes to scan
  21518. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  21519. */
  21520. static MinMax(meshes: AbstractMesh[]): {
  21521. min: Vector3;
  21522. max: Vector3;
  21523. };
  21524. /**
  21525. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  21526. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  21527. * @returns a vector3
  21528. */
  21529. static Center(meshesOrMinMaxVector: {
  21530. min: Vector3;
  21531. max: Vector3;
  21532. } | AbstractMesh[]): Vector3;
  21533. /**
  21534. * Merge the array of meshes into a single mesh for performance reasons.
  21535. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  21536. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  21537. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  21538. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  21539. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  21540. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  21541. * @returns a new mesh
  21542. */
  21543. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  21544. /** @hidden */
  21545. addInstance(instance: InstancedMesh): void;
  21546. /** @hidden */
  21547. removeInstance(instance: InstancedMesh): void;
  21548. }
  21549. }
  21550. declare module BABYLON {
  21551. /**
  21552. * Base class for the main features of a material in Babylon.js
  21553. */
  21554. export class Material implements IAnimatable {
  21555. /**
  21556. * Returns the triangle fill mode
  21557. */
  21558. static readonly TriangleFillMode: number;
  21559. /**
  21560. * Returns the wireframe mode
  21561. */
  21562. static readonly WireFrameFillMode: number;
  21563. /**
  21564. * Returns the point fill mode
  21565. */
  21566. static readonly PointFillMode: number;
  21567. /**
  21568. * Returns the point list draw mode
  21569. */
  21570. static readonly PointListDrawMode: number;
  21571. /**
  21572. * Returns the line list draw mode
  21573. */
  21574. static readonly LineListDrawMode: number;
  21575. /**
  21576. * Returns the line loop draw mode
  21577. */
  21578. static readonly LineLoopDrawMode: number;
  21579. /**
  21580. * Returns the line strip draw mode
  21581. */
  21582. static readonly LineStripDrawMode: number;
  21583. /**
  21584. * Returns the triangle strip draw mode
  21585. */
  21586. static readonly TriangleStripDrawMode: number;
  21587. /**
  21588. * Returns the triangle fan draw mode
  21589. */
  21590. static readonly TriangleFanDrawMode: number;
  21591. /**
  21592. * Stores the clock-wise side orientation
  21593. */
  21594. static readonly ClockWiseSideOrientation: number;
  21595. /**
  21596. * Stores the counter clock-wise side orientation
  21597. */
  21598. static readonly CounterClockWiseSideOrientation: number;
  21599. /**
  21600. * The dirty texture flag value
  21601. */
  21602. static readonly TextureDirtyFlag: number;
  21603. /**
  21604. * The dirty light flag value
  21605. */
  21606. static readonly LightDirtyFlag: number;
  21607. /**
  21608. * The dirty fresnel flag value
  21609. */
  21610. static readonly FresnelDirtyFlag: number;
  21611. /**
  21612. * The dirty attribute flag value
  21613. */
  21614. static readonly AttributesDirtyFlag: number;
  21615. /**
  21616. * The dirty misc flag value
  21617. */
  21618. static readonly MiscDirtyFlag: number;
  21619. /**
  21620. * The all dirty flag value
  21621. */
  21622. static readonly AllDirtyFlag: number;
  21623. /**
  21624. * The ID of the material
  21625. */
  21626. id: string;
  21627. /**
  21628. * Gets or sets the unique id of the material
  21629. */
  21630. uniqueId: number;
  21631. /**
  21632. * The name of the material
  21633. */
  21634. name: string;
  21635. /**
  21636. * Gets or sets user defined metadata
  21637. */
  21638. metadata: any;
  21639. /**
  21640. * For internal use only. Please do not use.
  21641. */
  21642. reservedDataStore: any;
  21643. /**
  21644. * Specifies if the ready state should be checked on each call
  21645. */
  21646. checkReadyOnEveryCall: boolean;
  21647. /**
  21648. * Specifies if the ready state should be checked once
  21649. */
  21650. checkReadyOnlyOnce: boolean;
  21651. /**
  21652. * The state of the material
  21653. */
  21654. state: string;
  21655. /**
  21656. * The alpha value of the material
  21657. */
  21658. protected _alpha: number;
  21659. /**
  21660. * List of inspectable custom properties (used by the Inspector)
  21661. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21662. */
  21663. inspectableCustomProperties: IInspectable[];
  21664. /**
  21665. * Sets the alpha value of the material
  21666. */
  21667. /**
  21668. * Gets the alpha value of the material
  21669. */
  21670. alpha: number;
  21671. /**
  21672. * Specifies if back face culling is enabled
  21673. */
  21674. protected _backFaceCulling: boolean;
  21675. /**
  21676. * Sets the back-face culling state
  21677. */
  21678. /**
  21679. * Gets the back-face culling state
  21680. */
  21681. backFaceCulling: boolean;
  21682. /**
  21683. * Stores the value for side orientation
  21684. */
  21685. sideOrientation: number;
  21686. /**
  21687. * Callback triggered when the material is compiled
  21688. */
  21689. onCompiled: (effect: Effect) => void;
  21690. /**
  21691. * Callback triggered when an error occurs
  21692. */
  21693. onError: (effect: Effect, errors: string) => void;
  21694. /**
  21695. * Callback triggered to get the render target textures
  21696. */
  21697. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  21698. /**
  21699. * Gets a boolean indicating that current material needs to register RTT
  21700. */
  21701. readonly hasRenderTargetTextures: boolean;
  21702. /**
  21703. * Specifies if the material should be serialized
  21704. */
  21705. doNotSerialize: boolean;
  21706. /**
  21707. * @hidden
  21708. */
  21709. _storeEffectOnSubMeshes: boolean;
  21710. /**
  21711. * Stores the animations for the material
  21712. */
  21713. animations: Array<Animation>;
  21714. /**
  21715. * An event triggered when the material is disposed
  21716. */
  21717. onDisposeObservable: Observable<Material>;
  21718. /**
  21719. * An observer which watches for dispose events
  21720. */
  21721. private _onDisposeObserver;
  21722. private _onUnBindObservable;
  21723. /**
  21724. * Called during a dispose event
  21725. */
  21726. onDispose: () => void;
  21727. private _onBindObservable;
  21728. /**
  21729. * An event triggered when the material is bound
  21730. */
  21731. readonly onBindObservable: Observable<AbstractMesh>;
  21732. /**
  21733. * An observer which watches for bind events
  21734. */
  21735. private _onBindObserver;
  21736. /**
  21737. * Called during a bind event
  21738. */
  21739. onBind: (Mesh: AbstractMesh) => void;
  21740. /**
  21741. * An event triggered when the material is unbound
  21742. */
  21743. readonly onUnBindObservable: Observable<Material>;
  21744. /**
  21745. * Stores the value of the alpha mode
  21746. */
  21747. private _alphaMode;
  21748. /**
  21749. * Sets the value of the alpha mode.
  21750. *
  21751. * | Value | Type | Description |
  21752. * | --- | --- | --- |
  21753. * | 0 | ALPHA_DISABLE | |
  21754. * | 1 | ALPHA_ADD | |
  21755. * | 2 | ALPHA_COMBINE | |
  21756. * | 3 | ALPHA_SUBTRACT | |
  21757. * | 4 | ALPHA_MULTIPLY | |
  21758. * | 5 | ALPHA_MAXIMIZED | |
  21759. * | 6 | ALPHA_ONEONE | |
  21760. * | 7 | ALPHA_PREMULTIPLIED | |
  21761. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21762. * | 9 | ALPHA_INTERPOLATE | |
  21763. * | 10 | ALPHA_SCREENMODE | |
  21764. *
  21765. */
  21766. /**
  21767. * Gets the value of the alpha mode
  21768. */
  21769. alphaMode: number;
  21770. /**
  21771. * Stores the state of the need depth pre-pass value
  21772. */
  21773. private _needDepthPrePass;
  21774. /**
  21775. * Sets the need depth pre-pass value
  21776. */
  21777. /**
  21778. * Gets the depth pre-pass value
  21779. */
  21780. needDepthPrePass: boolean;
  21781. /**
  21782. * Specifies if depth writing should be disabled
  21783. */
  21784. disableDepthWrite: boolean;
  21785. /**
  21786. * Specifies if depth writing should be forced
  21787. */
  21788. forceDepthWrite: boolean;
  21789. /**
  21790. * Specifies if there should be a separate pass for culling
  21791. */
  21792. separateCullingPass: boolean;
  21793. /**
  21794. * Stores the state specifing if fog should be enabled
  21795. */
  21796. private _fogEnabled;
  21797. /**
  21798. * Sets the state for enabling fog
  21799. */
  21800. /**
  21801. * Gets the value of the fog enabled state
  21802. */
  21803. fogEnabled: boolean;
  21804. /**
  21805. * Stores the size of points
  21806. */
  21807. pointSize: number;
  21808. /**
  21809. * Stores the z offset value
  21810. */
  21811. zOffset: number;
  21812. /**
  21813. * Gets a value specifying if wireframe mode is enabled
  21814. */
  21815. /**
  21816. * Sets the state of wireframe mode
  21817. */
  21818. wireframe: boolean;
  21819. /**
  21820. * Gets the value specifying if point clouds are enabled
  21821. */
  21822. /**
  21823. * Sets the state of point cloud mode
  21824. */
  21825. pointsCloud: boolean;
  21826. /**
  21827. * Gets the material fill mode
  21828. */
  21829. /**
  21830. * Sets the material fill mode
  21831. */
  21832. fillMode: number;
  21833. /**
  21834. * @hidden
  21835. * Stores the effects for the material
  21836. */
  21837. _effect: Nullable<Effect>;
  21838. /**
  21839. * @hidden
  21840. * Specifies if the material was previously ready
  21841. */
  21842. _wasPreviouslyReady: boolean;
  21843. /**
  21844. * Specifies if uniform buffers should be used
  21845. */
  21846. private _useUBO;
  21847. /**
  21848. * Stores a reference to the scene
  21849. */
  21850. private _scene;
  21851. /**
  21852. * Stores the fill mode state
  21853. */
  21854. private _fillMode;
  21855. /**
  21856. * Specifies if the depth write state should be cached
  21857. */
  21858. private _cachedDepthWriteState;
  21859. /**
  21860. * Stores the uniform buffer
  21861. */
  21862. protected _uniformBuffer: UniformBuffer;
  21863. /** @hidden */
  21864. _indexInSceneMaterialArray: number;
  21865. /** @hidden */
  21866. meshMap: Nullable<{
  21867. [id: string]: AbstractMesh | undefined;
  21868. }>;
  21869. /**
  21870. * Creates a material instance
  21871. * @param name defines the name of the material
  21872. * @param scene defines the scene to reference
  21873. * @param doNotAdd specifies if the material should be added to the scene
  21874. */
  21875. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21876. /**
  21877. * Returns a string representation of the current material
  21878. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21879. * @returns a string with material information
  21880. */
  21881. toString(fullDetails?: boolean): string;
  21882. /**
  21883. * Gets the class name of the material
  21884. * @returns a string with the class name of the material
  21885. */
  21886. getClassName(): string;
  21887. /**
  21888. * Specifies if updates for the material been locked
  21889. */
  21890. readonly isFrozen: boolean;
  21891. /**
  21892. * Locks updates for the material
  21893. */
  21894. freeze(): void;
  21895. /**
  21896. * Unlocks updates for the material
  21897. */
  21898. unfreeze(): void;
  21899. /**
  21900. * Specifies if the material is ready to be used
  21901. * @param mesh defines the mesh to check
  21902. * @param useInstances specifies if instances should be used
  21903. * @returns a boolean indicating if the material is ready to be used
  21904. */
  21905. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21906. /**
  21907. * Specifies that the submesh is ready to be used
  21908. * @param mesh defines the mesh to check
  21909. * @param subMesh defines which submesh to check
  21910. * @param useInstances specifies that instances should be used
  21911. * @returns a boolean indicating that the submesh is ready or not
  21912. */
  21913. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21914. /**
  21915. * Returns the material effect
  21916. * @returns the effect associated with the material
  21917. */
  21918. getEffect(): Nullable<Effect>;
  21919. /**
  21920. * Returns the current scene
  21921. * @returns a Scene
  21922. */
  21923. getScene(): Scene;
  21924. /**
  21925. * Specifies if the material will require alpha blending
  21926. * @returns a boolean specifying if alpha blending is needed
  21927. */
  21928. needAlphaBlending(): boolean;
  21929. /**
  21930. * Specifies if the mesh will require alpha blending
  21931. * @param mesh defines the mesh to check
  21932. * @returns a boolean specifying if alpha blending is needed for the mesh
  21933. */
  21934. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21935. /**
  21936. * Specifies if this material should be rendered in alpha test mode
  21937. * @returns a boolean specifying if an alpha test is needed.
  21938. */
  21939. needAlphaTesting(): boolean;
  21940. /**
  21941. * Gets the texture used for the alpha test
  21942. * @returns the texture to use for alpha testing
  21943. */
  21944. getAlphaTestTexture(): Nullable<BaseTexture>;
  21945. /**
  21946. * Marks the material to indicate that it needs to be re-calculated
  21947. */
  21948. markDirty(): void;
  21949. /** @hidden */
  21950. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21951. /**
  21952. * Binds the material to the mesh
  21953. * @param world defines the world transformation matrix
  21954. * @param mesh defines the mesh to bind the material to
  21955. */
  21956. bind(world: Matrix, mesh?: Mesh): void;
  21957. /**
  21958. * Binds the submesh to the material
  21959. * @param world defines the world transformation matrix
  21960. * @param mesh defines the mesh containing the submesh
  21961. * @param subMesh defines the submesh to bind the material to
  21962. */
  21963. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21964. /**
  21965. * Binds the world matrix to the material
  21966. * @param world defines the world transformation matrix
  21967. */
  21968. bindOnlyWorldMatrix(world: Matrix): void;
  21969. /**
  21970. * Binds the scene's uniform buffer to the effect.
  21971. * @param effect defines the effect to bind to the scene uniform buffer
  21972. * @param sceneUbo defines the uniform buffer storing scene data
  21973. */
  21974. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21975. /**
  21976. * Binds the view matrix to the effect
  21977. * @param effect defines the effect to bind the view matrix to
  21978. */
  21979. bindView(effect: Effect): void;
  21980. /**
  21981. * Binds the view projection matrix to the effect
  21982. * @param effect defines the effect to bind the view projection matrix to
  21983. */
  21984. bindViewProjection(effect: Effect): void;
  21985. /**
  21986. * Specifies if material alpha testing should be turned on for the mesh
  21987. * @param mesh defines the mesh to check
  21988. */
  21989. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21990. /**
  21991. * Processes to execute after binding the material to a mesh
  21992. * @param mesh defines the rendered mesh
  21993. */
  21994. protected _afterBind(mesh?: Mesh): void;
  21995. /**
  21996. * Unbinds the material from the mesh
  21997. */
  21998. unbind(): void;
  21999. /**
  22000. * Gets the active textures from the material
  22001. * @returns an array of textures
  22002. */
  22003. getActiveTextures(): BaseTexture[];
  22004. /**
  22005. * Specifies if the material uses a texture
  22006. * @param texture defines the texture to check against the material
  22007. * @returns a boolean specifying if the material uses the texture
  22008. */
  22009. hasTexture(texture: BaseTexture): boolean;
  22010. /**
  22011. * Makes a duplicate of the material, and gives it a new name
  22012. * @param name defines the new name for the duplicated material
  22013. * @returns the cloned material
  22014. */
  22015. clone(name: string): Nullable<Material>;
  22016. /**
  22017. * Gets the meshes bound to the material
  22018. * @returns an array of meshes bound to the material
  22019. */
  22020. getBindedMeshes(): AbstractMesh[];
  22021. /**
  22022. * Force shader compilation
  22023. * @param mesh defines the mesh associated with this material
  22024. * @param onCompiled defines a function to execute once the material is compiled
  22025. * @param options defines the options to configure the compilation
  22026. */
  22027. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  22028. clipPlane: boolean;
  22029. }>): void;
  22030. /**
  22031. * Force shader compilation
  22032. * @param mesh defines the mesh that will use this material
  22033. * @param options defines additional options for compiling the shaders
  22034. * @returns a promise that resolves when the compilation completes
  22035. */
  22036. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  22037. clipPlane: boolean;
  22038. }>): Promise<void>;
  22039. private static readonly _ImageProcessingDirtyCallBack;
  22040. private static readonly _TextureDirtyCallBack;
  22041. private static readonly _FresnelDirtyCallBack;
  22042. private static readonly _MiscDirtyCallBack;
  22043. private static readonly _LightsDirtyCallBack;
  22044. private static readonly _AttributeDirtyCallBack;
  22045. private static _FresnelAndMiscDirtyCallBack;
  22046. private static _TextureAndMiscDirtyCallBack;
  22047. private static readonly _DirtyCallbackArray;
  22048. private static readonly _RunDirtyCallBacks;
  22049. /**
  22050. * Marks a define in the material to indicate that it needs to be re-computed
  22051. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  22052. */
  22053. markAsDirty(flag: number): void;
  22054. /**
  22055. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  22056. * @param func defines a function which checks material defines against the submeshes
  22057. */
  22058. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  22059. /**
  22060. * Indicates that image processing needs to be re-calculated for all submeshes
  22061. */
  22062. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  22063. /**
  22064. * Indicates that textures need to be re-calculated for all submeshes
  22065. */
  22066. protected _markAllSubMeshesAsTexturesDirty(): void;
  22067. /**
  22068. * Indicates that fresnel needs to be re-calculated for all submeshes
  22069. */
  22070. protected _markAllSubMeshesAsFresnelDirty(): void;
  22071. /**
  22072. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  22073. */
  22074. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  22075. /**
  22076. * Indicates that lights need to be re-calculated for all submeshes
  22077. */
  22078. protected _markAllSubMeshesAsLightsDirty(): void;
  22079. /**
  22080. * Indicates that attributes need to be re-calculated for all submeshes
  22081. */
  22082. protected _markAllSubMeshesAsAttributesDirty(): void;
  22083. /**
  22084. * Indicates that misc needs to be re-calculated for all submeshes
  22085. */
  22086. protected _markAllSubMeshesAsMiscDirty(): void;
  22087. /**
  22088. * Indicates that textures and misc need to be re-calculated for all submeshes
  22089. */
  22090. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  22091. /**
  22092. * Disposes the material
  22093. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22094. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22095. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22096. */
  22097. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22098. /** @hidden */
  22099. private releaseVertexArrayObject;
  22100. /**
  22101. * Serializes this material
  22102. * @returns the serialized material object
  22103. */
  22104. serialize(): any;
  22105. /**
  22106. * Creates a material from parsed material data
  22107. * @param parsedMaterial defines parsed material data
  22108. * @param scene defines the hosting scene
  22109. * @param rootUrl defines the root URL to use to load textures
  22110. * @returns a new material
  22111. */
  22112. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  22113. }
  22114. }
  22115. declare module BABYLON {
  22116. /**
  22117. * Base class for submeshes
  22118. */
  22119. export class BaseSubMesh {
  22120. /** @hidden */
  22121. _materialDefines: Nullable<MaterialDefines>;
  22122. /** @hidden */
  22123. _materialEffect: Nullable<Effect>;
  22124. /**
  22125. * Gets associated effect
  22126. */
  22127. readonly effect: Nullable<Effect>;
  22128. /**
  22129. * Sets associated effect (effect used to render this submesh)
  22130. * @param effect defines the effect to associate with
  22131. * @param defines defines the set of defines used to compile this effect
  22132. */
  22133. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22134. }
  22135. /**
  22136. * Defines a subdivision inside a mesh
  22137. */
  22138. export class SubMesh extends BaseSubMesh implements ICullable {
  22139. /** the material index to use */
  22140. materialIndex: number;
  22141. /** vertex index start */
  22142. verticesStart: number;
  22143. /** vertices count */
  22144. verticesCount: number;
  22145. /** index start */
  22146. indexStart: number;
  22147. /** indices count */
  22148. indexCount: number;
  22149. /** @hidden */
  22150. _linesIndexCount: number;
  22151. private _mesh;
  22152. private _renderingMesh;
  22153. private _boundingInfo;
  22154. private _linesIndexBuffer;
  22155. /** @hidden */
  22156. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22157. /** @hidden */
  22158. _trianglePlanes: Plane[];
  22159. /** @hidden */
  22160. _lastColliderTransformMatrix: Matrix;
  22161. /** @hidden */
  22162. _renderId: number;
  22163. /** @hidden */
  22164. _alphaIndex: number;
  22165. /** @hidden */
  22166. _distanceToCamera: number;
  22167. /** @hidden */
  22168. _id: number;
  22169. private _currentMaterial;
  22170. /**
  22171. * Add a new submesh to a mesh
  22172. * @param materialIndex defines the material index to use
  22173. * @param verticesStart defines vertex index start
  22174. * @param verticesCount defines vertices count
  22175. * @param indexStart defines index start
  22176. * @param indexCount defines indices count
  22177. * @param mesh defines the parent mesh
  22178. * @param renderingMesh defines an optional rendering mesh
  22179. * @param createBoundingBox defines if bounding box should be created for this submesh
  22180. * @returns the new submesh
  22181. */
  22182. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22183. /**
  22184. * Creates a new submesh
  22185. * @param materialIndex defines the material index to use
  22186. * @param verticesStart defines vertex index start
  22187. * @param verticesCount defines vertices count
  22188. * @param indexStart defines index start
  22189. * @param indexCount defines indices count
  22190. * @param mesh defines the parent mesh
  22191. * @param renderingMesh defines an optional rendering mesh
  22192. * @param createBoundingBox defines if bounding box should be created for this submesh
  22193. */
  22194. constructor(
  22195. /** the material index to use */
  22196. materialIndex: number,
  22197. /** vertex index start */
  22198. verticesStart: number,
  22199. /** vertices count */
  22200. verticesCount: number,
  22201. /** index start */
  22202. indexStart: number,
  22203. /** indices count */
  22204. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22205. /**
  22206. * Returns true if this submesh covers the entire parent mesh
  22207. * @ignorenaming
  22208. */
  22209. readonly IsGlobal: boolean;
  22210. /**
  22211. * Returns the submesh BoudingInfo object
  22212. * @returns current bounding info (or mesh's one if the submesh is global)
  22213. */
  22214. getBoundingInfo(): BoundingInfo;
  22215. /**
  22216. * Sets the submesh BoundingInfo
  22217. * @param boundingInfo defines the new bounding info to use
  22218. * @returns the SubMesh
  22219. */
  22220. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22221. /**
  22222. * Returns the mesh of the current submesh
  22223. * @return the parent mesh
  22224. */
  22225. getMesh(): AbstractMesh;
  22226. /**
  22227. * Returns the rendering mesh of the submesh
  22228. * @returns the rendering mesh (could be different from parent mesh)
  22229. */
  22230. getRenderingMesh(): Mesh;
  22231. /**
  22232. * Returns the submesh material
  22233. * @returns null or the current material
  22234. */
  22235. getMaterial(): Nullable<Material>;
  22236. /**
  22237. * Sets a new updated BoundingInfo object to the submesh
  22238. * @returns the SubMesh
  22239. */
  22240. refreshBoundingInfo(): SubMesh;
  22241. /** @hidden */
  22242. _checkCollision(collider: Collider): boolean;
  22243. /**
  22244. * Updates the submesh BoundingInfo
  22245. * @param world defines the world matrix to use to update the bounding info
  22246. * @returns the submesh
  22247. */
  22248. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22249. /**
  22250. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22251. * @param frustumPlanes defines the frustum planes
  22252. * @returns true if the submesh is intersecting with the frustum
  22253. */
  22254. isInFrustum(frustumPlanes: Plane[]): boolean;
  22255. /**
  22256. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22257. * @param frustumPlanes defines the frustum planes
  22258. * @returns true if the submesh is inside the frustum
  22259. */
  22260. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22261. /**
  22262. * Renders the submesh
  22263. * @param enableAlphaMode defines if alpha needs to be used
  22264. * @returns the submesh
  22265. */
  22266. render(enableAlphaMode: boolean): SubMesh;
  22267. /**
  22268. * @hidden
  22269. */
  22270. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  22271. /**
  22272. * Checks if the submesh intersects with a ray
  22273. * @param ray defines the ray to test
  22274. * @returns true is the passed ray intersects the submesh bounding box
  22275. */
  22276. canIntersects(ray: Ray): boolean;
  22277. /**
  22278. * Intersects current submesh with a ray
  22279. * @param ray defines the ray to test
  22280. * @param positions defines mesh's positions array
  22281. * @param indices defines mesh's indices array
  22282. * @param fastCheck defines if only bounding info should be used
  22283. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22284. * @returns intersection info or null if no intersection
  22285. */
  22286. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22287. /** @hidden */
  22288. private _intersectLines;
  22289. /** @hidden */
  22290. private _intersectTriangles;
  22291. /** @hidden */
  22292. _rebuild(): void;
  22293. /**
  22294. * Creates a new submesh from the passed mesh
  22295. * @param newMesh defines the new hosting mesh
  22296. * @param newRenderingMesh defines an optional rendering mesh
  22297. * @returns the new submesh
  22298. */
  22299. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22300. /**
  22301. * Release associated resources
  22302. */
  22303. dispose(): void;
  22304. /**
  22305. * Gets the class name
  22306. * @returns the string "SubMesh".
  22307. */
  22308. getClassName(): string;
  22309. /**
  22310. * Creates a new submesh from indices data
  22311. * @param materialIndex the index of the main mesh material
  22312. * @param startIndex the index where to start the copy in the mesh indices array
  22313. * @param indexCount the number of indices to copy then from the startIndex
  22314. * @param mesh the main mesh to create the submesh from
  22315. * @param renderingMesh the optional rendering mesh
  22316. * @returns a new submesh
  22317. */
  22318. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22319. }
  22320. }
  22321. declare module BABYLON {
  22322. /**
  22323. * Class used to store geometry data (vertex buffers + index buffer)
  22324. */
  22325. export class Geometry implements IGetSetVerticesData {
  22326. /**
  22327. * Gets or sets the ID of the geometry
  22328. */
  22329. id: string;
  22330. /**
  22331. * Gets or sets the unique ID of the geometry
  22332. */
  22333. uniqueId: number;
  22334. /**
  22335. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22336. */
  22337. delayLoadState: number;
  22338. /**
  22339. * Gets the file containing the data to load when running in delay load state
  22340. */
  22341. delayLoadingFile: Nullable<string>;
  22342. /**
  22343. * Callback called when the geometry is updated
  22344. */
  22345. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22346. private _scene;
  22347. private _engine;
  22348. private _meshes;
  22349. private _totalVertices;
  22350. /** @hidden */
  22351. _indices: IndicesArray;
  22352. /** @hidden */
  22353. _vertexBuffers: {
  22354. [key: string]: VertexBuffer;
  22355. };
  22356. private _isDisposed;
  22357. private _extend;
  22358. private _boundingBias;
  22359. /** @hidden */
  22360. _delayInfo: Array<string>;
  22361. private _indexBuffer;
  22362. private _indexBufferIsUpdatable;
  22363. /** @hidden */
  22364. _boundingInfo: Nullable<BoundingInfo>;
  22365. /** @hidden */
  22366. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22367. /** @hidden */
  22368. _softwareSkinningFrameId: number;
  22369. private _vertexArrayObjects;
  22370. private _updatable;
  22371. /** @hidden */
  22372. _positions: Nullable<Vector3[]>;
  22373. /**
  22374. * 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
  22375. */
  22376. /**
  22377. * 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
  22378. */
  22379. boundingBias: Vector2;
  22380. /**
  22381. * Static function used to attach a new empty geometry to a mesh
  22382. * @param mesh defines the mesh to attach the geometry to
  22383. * @returns the new Geometry
  22384. */
  22385. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22386. /**
  22387. * Creates a new geometry
  22388. * @param id defines the unique ID
  22389. * @param scene defines the hosting scene
  22390. * @param vertexData defines the VertexData used to get geometry data
  22391. * @param updatable defines if geometry must be updatable (false by default)
  22392. * @param mesh defines the mesh that will be associated with the geometry
  22393. */
  22394. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22395. /**
  22396. * Gets the current extend of the geometry
  22397. */
  22398. readonly extend: {
  22399. minimum: Vector3;
  22400. maximum: Vector3;
  22401. };
  22402. /**
  22403. * Gets the hosting scene
  22404. * @returns the hosting Scene
  22405. */
  22406. getScene(): Scene;
  22407. /**
  22408. * Gets the hosting engine
  22409. * @returns the hosting Engine
  22410. */
  22411. getEngine(): Engine;
  22412. /**
  22413. * Defines if the geometry is ready to use
  22414. * @returns true if the geometry is ready to be used
  22415. */
  22416. isReady(): boolean;
  22417. /**
  22418. * Gets a value indicating that the geometry should not be serialized
  22419. */
  22420. readonly doNotSerialize: boolean;
  22421. /** @hidden */
  22422. _rebuild(): void;
  22423. /**
  22424. * Affects all geometry data in one call
  22425. * @param vertexData defines the geometry data
  22426. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22427. */
  22428. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22429. /**
  22430. * Set specific vertex data
  22431. * @param kind defines the data kind (Position, normal, etc...)
  22432. * @param data defines the vertex data to use
  22433. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22434. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22435. */
  22436. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22437. /**
  22438. * Removes a specific vertex data
  22439. * @param kind defines the data kind (Position, normal, etc...)
  22440. */
  22441. removeVerticesData(kind: string): void;
  22442. /**
  22443. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22444. * @param buffer defines the vertex buffer to use
  22445. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22446. */
  22447. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22448. /**
  22449. * Update a specific vertex buffer
  22450. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  22451. * It will do nothing if the buffer is not updatable
  22452. * @param kind defines the data kind (Position, normal, etc...)
  22453. * @param data defines the data to use
  22454. * @param offset defines the offset in the target buffer where to store the data
  22455. * @param useBytes set to true if the offset is in bytes
  22456. */
  22457. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22458. /**
  22459. * Update a specific vertex buffer
  22460. * This function will create a new buffer if the current one is not updatable
  22461. * @param kind defines the data kind (Position, normal, etc...)
  22462. * @param data defines the data to use
  22463. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22464. */
  22465. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22466. private _updateBoundingInfo;
  22467. /** @hidden */
  22468. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  22469. /**
  22470. * Gets total number of vertices
  22471. * @returns the total number of vertices
  22472. */
  22473. getTotalVertices(): number;
  22474. /**
  22475. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22476. * @param kind defines the data kind (Position, normal, etc...)
  22477. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22478. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22479. * @returns a float array containing vertex data
  22480. */
  22481. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22482. /**
  22483. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22484. * @param kind defines the data kind (Position, normal, etc...)
  22485. * @returns true if the vertex buffer with the specified kind is updatable
  22486. */
  22487. isVertexBufferUpdatable(kind: string): boolean;
  22488. /**
  22489. * Gets a specific vertex buffer
  22490. * @param kind defines the data kind (Position, normal, etc...)
  22491. * @returns a VertexBuffer
  22492. */
  22493. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22494. /**
  22495. * Returns all vertex buffers
  22496. * @return an object holding all vertex buffers indexed by kind
  22497. */
  22498. getVertexBuffers(): Nullable<{
  22499. [key: string]: VertexBuffer;
  22500. }>;
  22501. /**
  22502. * Gets a boolean indicating if specific vertex buffer is present
  22503. * @param kind defines the data kind (Position, normal, etc...)
  22504. * @returns true if data is present
  22505. */
  22506. isVerticesDataPresent(kind: string): boolean;
  22507. /**
  22508. * Gets a list of all attached data kinds (Position, normal, etc...)
  22509. * @returns a list of string containing all kinds
  22510. */
  22511. getVerticesDataKinds(): string[];
  22512. /**
  22513. * Update index buffer
  22514. * @param indices defines the indices to store in the index buffer
  22515. * @param offset defines the offset in the target buffer where to store the data
  22516. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  22517. */
  22518. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22519. /**
  22520. * Creates a new index buffer
  22521. * @param indices defines the indices to store in the index buffer
  22522. * @param totalVertices defines the total number of vertices (could be null)
  22523. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22524. */
  22525. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22526. /**
  22527. * Return the total number of indices
  22528. * @returns the total number of indices
  22529. */
  22530. getTotalIndices(): number;
  22531. /**
  22532. * Gets the index buffer array
  22533. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22534. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22535. * @returns the index buffer array
  22536. */
  22537. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22538. /**
  22539. * Gets the index buffer
  22540. * @return the index buffer
  22541. */
  22542. getIndexBuffer(): Nullable<WebGLBuffer>;
  22543. /** @hidden */
  22544. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22545. /**
  22546. * Release the associated resources for a specific mesh
  22547. * @param mesh defines the source mesh
  22548. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22549. */
  22550. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22551. /**
  22552. * Apply current geometry to a given mesh
  22553. * @param mesh defines the mesh to apply geometry to
  22554. */
  22555. applyToMesh(mesh: Mesh): void;
  22556. private _updateExtend;
  22557. private _applyToMesh;
  22558. private notifyUpdate;
  22559. /**
  22560. * Load the geometry if it was flagged as delay loaded
  22561. * @param scene defines the hosting scene
  22562. * @param onLoaded defines a callback called when the geometry is loaded
  22563. */
  22564. load(scene: Scene, onLoaded?: () => void): void;
  22565. private _queueLoad;
  22566. /**
  22567. * Invert the geometry to move from a right handed system to a left handed one.
  22568. */
  22569. toLeftHanded(): void;
  22570. /** @hidden */
  22571. _resetPointsArrayCache(): void;
  22572. /** @hidden */
  22573. _generatePointsArray(): boolean;
  22574. /**
  22575. * Gets a value indicating if the geometry is disposed
  22576. * @returns true if the geometry was disposed
  22577. */
  22578. isDisposed(): boolean;
  22579. private _disposeVertexArrayObjects;
  22580. /**
  22581. * Free all associated resources
  22582. */
  22583. dispose(): void;
  22584. /**
  22585. * Clone the current geometry into a new geometry
  22586. * @param id defines the unique ID of the new geometry
  22587. * @returns a new geometry object
  22588. */
  22589. copy(id: string): Geometry;
  22590. /**
  22591. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22592. * @return a JSON representation of the current geometry data (without the vertices data)
  22593. */
  22594. serialize(): any;
  22595. private toNumberArray;
  22596. /**
  22597. * Serialize all vertices data into a JSON oject
  22598. * @returns a JSON representation of the current geometry data
  22599. */
  22600. serializeVerticeData(): any;
  22601. /**
  22602. * Extracts a clone of a mesh geometry
  22603. * @param mesh defines the source mesh
  22604. * @param id defines the unique ID of the new geometry object
  22605. * @returns the new geometry object
  22606. */
  22607. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22608. /**
  22609. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22610. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22611. * Be aware Math.random() could cause collisions, but:
  22612. * "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"
  22613. * @returns a string containing a new GUID
  22614. */
  22615. static RandomId(): string;
  22616. /** @hidden */
  22617. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22618. private static _CleanMatricesWeights;
  22619. /**
  22620. * Create a new geometry from persisted data (Using .babylon file format)
  22621. * @param parsedVertexData defines the persisted data
  22622. * @param scene defines the hosting scene
  22623. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22624. * @returns the new geometry object
  22625. */
  22626. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22627. }
  22628. }
  22629. declare module BABYLON {
  22630. /**
  22631. * Define an interface for all classes that will get and set the data on vertices
  22632. */
  22633. export interface IGetSetVerticesData {
  22634. /**
  22635. * Gets a boolean indicating if specific vertex data is present
  22636. * @param kind defines the vertex data kind to use
  22637. * @returns true is data kind is present
  22638. */
  22639. isVerticesDataPresent(kind: string): boolean;
  22640. /**
  22641. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22642. * @param kind defines the data kind (Position, normal, etc...)
  22643. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22644. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22645. * @returns a float array containing vertex data
  22646. */
  22647. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22648. /**
  22649. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22650. * @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.
  22651. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22652. * @returns the indices array or an empty array if the mesh has no geometry
  22653. */
  22654. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22655. /**
  22656. * Set specific vertex data
  22657. * @param kind defines the data kind (Position, normal, etc...)
  22658. * @param data defines the vertex data to use
  22659. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22660. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22661. */
  22662. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22663. /**
  22664. * Update a specific associated vertex buffer
  22665. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22666. * - VertexBuffer.PositionKind
  22667. * - VertexBuffer.UVKind
  22668. * - VertexBuffer.UV2Kind
  22669. * - VertexBuffer.UV3Kind
  22670. * - VertexBuffer.UV4Kind
  22671. * - VertexBuffer.UV5Kind
  22672. * - VertexBuffer.UV6Kind
  22673. * - VertexBuffer.ColorKind
  22674. * - VertexBuffer.MatricesIndicesKind
  22675. * - VertexBuffer.MatricesIndicesExtraKind
  22676. * - VertexBuffer.MatricesWeightsKind
  22677. * - VertexBuffer.MatricesWeightsExtraKind
  22678. * @param data defines the data source
  22679. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22680. * @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)
  22681. */
  22682. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22683. /**
  22684. * Creates a new index buffer
  22685. * @param indices defines the indices to store in the index buffer
  22686. * @param totalVertices defines the total number of vertices (could be null)
  22687. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22688. */
  22689. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22690. }
  22691. /**
  22692. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22693. */
  22694. export class VertexData {
  22695. /**
  22696. * Mesh side orientation : usually the external or front surface
  22697. */
  22698. static readonly FRONTSIDE: number;
  22699. /**
  22700. * Mesh side orientation : usually the internal or back surface
  22701. */
  22702. static readonly BACKSIDE: number;
  22703. /**
  22704. * Mesh side orientation : both internal and external or front and back surfaces
  22705. */
  22706. static readonly DOUBLESIDE: number;
  22707. /**
  22708. * Mesh side orientation : by default, `FRONTSIDE`
  22709. */
  22710. static readonly DEFAULTSIDE: number;
  22711. /**
  22712. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22713. */
  22714. positions: Nullable<FloatArray>;
  22715. /**
  22716. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22717. */
  22718. normals: Nullable<FloatArray>;
  22719. /**
  22720. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22721. */
  22722. tangents: Nullable<FloatArray>;
  22723. /**
  22724. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22725. */
  22726. uvs: Nullable<FloatArray>;
  22727. /**
  22728. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22729. */
  22730. uvs2: Nullable<FloatArray>;
  22731. /**
  22732. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22733. */
  22734. uvs3: Nullable<FloatArray>;
  22735. /**
  22736. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22737. */
  22738. uvs4: Nullable<FloatArray>;
  22739. /**
  22740. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22741. */
  22742. uvs5: Nullable<FloatArray>;
  22743. /**
  22744. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22745. */
  22746. uvs6: Nullable<FloatArray>;
  22747. /**
  22748. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22749. */
  22750. colors: Nullable<FloatArray>;
  22751. /**
  22752. * 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).
  22753. */
  22754. matricesIndices: Nullable<FloatArray>;
  22755. /**
  22756. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22757. */
  22758. matricesWeights: Nullable<FloatArray>;
  22759. /**
  22760. * An array extending the number of possible indices
  22761. */
  22762. matricesIndicesExtra: Nullable<FloatArray>;
  22763. /**
  22764. * An array extending the number of possible weights when the number of indices is extended
  22765. */
  22766. matricesWeightsExtra: Nullable<FloatArray>;
  22767. /**
  22768. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22769. */
  22770. indices: Nullable<IndicesArray>;
  22771. /**
  22772. * Uses the passed data array to set the set the values for the specified kind of data
  22773. * @param data a linear array of floating numbers
  22774. * @param kind the type of data that is being set, eg positions, colors etc
  22775. */
  22776. set(data: FloatArray, kind: string): void;
  22777. /**
  22778. * Associates the vertexData to the passed Mesh.
  22779. * Sets it as updatable or not (default `false`)
  22780. * @param mesh the mesh the vertexData is applied to
  22781. * @param updatable when used and having the value true allows new data to update the vertexData
  22782. * @returns the VertexData
  22783. */
  22784. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22785. /**
  22786. * Associates the vertexData to the passed Geometry.
  22787. * Sets it as updatable or not (default `false`)
  22788. * @param geometry the geometry the vertexData is applied to
  22789. * @param updatable when used and having the value true allows new data to update the vertexData
  22790. * @returns VertexData
  22791. */
  22792. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22793. /**
  22794. * Updates the associated mesh
  22795. * @param mesh the mesh to be updated
  22796. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22797. * @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
  22798. * @returns VertexData
  22799. */
  22800. updateMesh(mesh: Mesh): VertexData;
  22801. /**
  22802. * Updates the associated geometry
  22803. * @param geometry the geometry to be updated
  22804. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22805. * @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
  22806. * @returns VertexData.
  22807. */
  22808. updateGeometry(geometry: Geometry): VertexData;
  22809. private _applyTo;
  22810. private _update;
  22811. /**
  22812. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22813. * @param matrix the transforming matrix
  22814. * @returns the VertexData
  22815. */
  22816. transform(matrix: Matrix): VertexData;
  22817. /**
  22818. * Merges the passed VertexData into the current one
  22819. * @param other the VertexData to be merged into the current one
  22820. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22821. * @returns the modified VertexData
  22822. */
  22823. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22824. private _mergeElement;
  22825. private _validate;
  22826. /**
  22827. * Serializes the VertexData
  22828. * @returns a serialized object
  22829. */
  22830. serialize(): any;
  22831. /**
  22832. * Extracts the vertexData from a mesh
  22833. * @param mesh the mesh from which to extract the VertexData
  22834. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22835. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22836. * @returns the object VertexData associated to the passed mesh
  22837. */
  22838. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22839. /**
  22840. * Extracts the vertexData from the geometry
  22841. * @param geometry the geometry from which to extract the VertexData
  22842. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22843. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22844. * @returns the object VertexData associated to the passed mesh
  22845. */
  22846. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22847. private static _ExtractFrom;
  22848. /**
  22849. * Creates the VertexData for a Ribbon
  22850. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22851. * * pathArray array of paths, each of which an array of successive Vector3
  22852. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22853. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22854. * * 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
  22855. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22856. * * 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)
  22857. * * 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)
  22858. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22859. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22860. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22861. * @returns the VertexData of the ribbon
  22862. */
  22863. static CreateRibbon(options: {
  22864. pathArray: Vector3[][];
  22865. closeArray?: boolean;
  22866. closePath?: boolean;
  22867. offset?: number;
  22868. sideOrientation?: number;
  22869. frontUVs?: Vector4;
  22870. backUVs?: Vector4;
  22871. invertUV?: boolean;
  22872. uvs?: Vector2[];
  22873. colors?: Color4[];
  22874. }): VertexData;
  22875. /**
  22876. * Creates the VertexData for a box
  22877. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22878. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22879. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22880. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22881. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22882. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22883. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22884. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22885. * * 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)
  22886. * * 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)
  22887. * @returns the VertexData of the box
  22888. */
  22889. static CreateBox(options: {
  22890. size?: number;
  22891. width?: number;
  22892. height?: number;
  22893. depth?: number;
  22894. faceUV?: Vector4[];
  22895. faceColors?: Color4[];
  22896. sideOrientation?: number;
  22897. frontUVs?: Vector4;
  22898. backUVs?: Vector4;
  22899. }): VertexData;
  22900. /**
  22901. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22902. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22903. * * segments sets the number of horizontal strips optional, default 32
  22904. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22905. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22906. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22907. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22908. * * 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
  22909. * * 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
  22910. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22911. * * 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)
  22912. * * 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)
  22913. * @returns the VertexData of the ellipsoid
  22914. */
  22915. static CreateSphere(options: {
  22916. segments?: number;
  22917. diameter?: number;
  22918. diameterX?: number;
  22919. diameterY?: number;
  22920. diameterZ?: number;
  22921. arc?: number;
  22922. slice?: number;
  22923. sideOrientation?: number;
  22924. frontUVs?: Vector4;
  22925. backUVs?: Vector4;
  22926. }): VertexData;
  22927. /**
  22928. * Creates the VertexData for a cylinder, cone or prism
  22929. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22930. * * height sets the height (y direction) of the cylinder, optional, default 2
  22931. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22932. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22933. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22934. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22935. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22936. * * 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
  22937. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22938. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22939. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22940. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22941. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22942. * * 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)
  22943. * * 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)
  22944. * @returns the VertexData of the cylinder, cone or prism
  22945. */
  22946. static CreateCylinder(options: {
  22947. height?: number;
  22948. diameterTop?: number;
  22949. diameterBottom?: number;
  22950. diameter?: number;
  22951. tessellation?: number;
  22952. subdivisions?: number;
  22953. arc?: number;
  22954. faceColors?: Color4[];
  22955. faceUV?: Vector4[];
  22956. hasRings?: boolean;
  22957. enclose?: boolean;
  22958. sideOrientation?: number;
  22959. frontUVs?: Vector4;
  22960. backUVs?: Vector4;
  22961. }): VertexData;
  22962. /**
  22963. * Creates the VertexData for a torus
  22964. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22965. * * diameter the diameter of the torus, optional default 1
  22966. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22967. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22968. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22969. * * 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)
  22970. * * 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)
  22971. * @returns the VertexData of the torus
  22972. */
  22973. static CreateTorus(options: {
  22974. diameter?: number;
  22975. thickness?: number;
  22976. tessellation?: number;
  22977. sideOrientation?: number;
  22978. frontUVs?: Vector4;
  22979. backUVs?: Vector4;
  22980. }): VertexData;
  22981. /**
  22982. * Creates the VertexData of the LineSystem
  22983. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22984. * - lines an array of lines, each line being an array of successive Vector3
  22985. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22986. * @returns the VertexData of the LineSystem
  22987. */
  22988. static CreateLineSystem(options: {
  22989. lines: Vector3[][];
  22990. colors?: Nullable<Color4[][]>;
  22991. }): VertexData;
  22992. /**
  22993. * Create the VertexData for a DashedLines
  22994. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22995. * - points an array successive Vector3
  22996. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22997. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22998. * - dashNb the intended total number of dashes, optional, default 200
  22999. * @returns the VertexData for the DashedLines
  23000. */
  23001. static CreateDashedLines(options: {
  23002. points: Vector3[];
  23003. dashSize?: number;
  23004. gapSize?: number;
  23005. dashNb?: number;
  23006. }): VertexData;
  23007. /**
  23008. * Creates the VertexData for a Ground
  23009. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23010. * - width the width (x direction) of the ground, optional, default 1
  23011. * - height the height (z direction) of the ground, optional, default 1
  23012. * - subdivisions the number of subdivisions per side, optional, default 1
  23013. * @returns the VertexData of the Ground
  23014. */
  23015. static CreateGround(options: {
  23016. width?: number;
  23017. height?: number;
  23018. subdivisions?: number;
  23019. subdivisionsX?: number;
  23020. subdivisionsY?: number;
  23021. }): VertexData;
  23022. /**
  23023. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23024. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23025. * * xmin the ground minimum X coordinate, optional, default -1
  23026. * * zmin the ground minimum Z coordinate, optional, default -1
  23027. * * xmax the ground maximum X coordinate, optional, default 1
  23028. * * zmax the ground maximum Z coordinate, optional, default 1
  23029. * * 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}
  23030. * * 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}
  23031. * @returns the VertexData of the TiledGround
  23032. */
  23033. static CreateTiledGround(options: {
  23034. xmin: number;
  23035. zmin: number;
  23036. xmax: number;
  23037. zmax: number;
  23038. subdivisions?: {
  23039. w: number;
  23040. h: number;
  23041. };
  23042. precision?: {
  23043. w: number;
  23044. h: number;
  23045. };
  23046. }): VertexData;
  23047. /**
  23048. * Creates the VertexData of the Ground designed from a heightmap
  23049. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23050. * * width the width (x direction) of the ground
  23051. * * height the height (z direction) of the ground
  23052. * * subdivisions the number of subdivisions per side
  23053. * * minHeight the minimum altitude on the ground, optional, default 0
  23054. * * maxHeight the maximum altitude on the ground, optional default 1
  23055. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23056. * * buffer the array holding the image color data
  23057. * * bufferWidth the width of image
  23058. * * bufferHeight the height of image
  23059. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23060. * @returns the VertexData of the Ground designed from a heightmap
  23061. */
  23062. static CreateGroundFromHeightMap(options: {
  23063. width: number;
  23064. height: number;
  23065. subdivisions: number;
  23066. minHeight: number;
  23067. maxHeight: number;
  23068. colorFilter: Color3;
  23069. buffer: Uint8Array;
  23070. bufferWidth: number;
  23071. bufferHeight: number;
  23072. alphaFilter: number;
  23073. }): VertexData;
  23074. /**
  23075. * Creates the VertexData for a Plane
  23076. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23077. * * size sets the width and height of the plane to the value of size, optional default 1
  23078. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23079. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23080. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23081. * * 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)
  23082. * * 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)
  23083. * @returns the VertexData of the box
  23084. */
  23085. static CreatePlane(options: {
  23086. size?: number;
  23087. width?: number;
  23088. height?: number;
  23089. sideOrientation?: number;
  23090. frontUVs?: Vector4;
  23091. backUVs?: Vector4;
  23092. }): VertexData;
  23093. /**
  23094. * Creates the VertexData of the Disc or regular Polygon
  23095. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23096. * * radius the radius of the disc, optional default 0.5
  23097. * * tessellation the number of polygon sides, optional, default 64
  23098. * * 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
  23099. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23100. * * 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)
  23101. * * 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)
  23102. * @returns the VertexData of the box
  23103. */
  23104. static CreateDisc(options: {
  23105. radius?: number;
  23106. tessellation?: number;
  23107. arc?: number;
  23108. sideOrientation?: number;
  23109. frontUVs?: Vector4;
  23110. backUVs?: Vector4;
  23111. }): VertexData;
  23112. /**
  23113. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23114. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23115. * @param polygon a mesh built from polygonTriangulation.build()
  23116. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23117. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23118. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23119. * @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)
  23120. * @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)
  23121. * @returns the VertexData of the Polygon
  23122. */
  23123. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23124. /**
  23125. * Creates the VertexData of the IcoSphere
  23126. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23127. * * radius the radius of the IcoSphere, optional default 1
  23128. * * radiusX allows stretching in the x direction, optional, default radius
  23129. * * radiusY allows stretching in the y direction, optional, default radius
  23130. * * radiusZ allows stretching in the z direction, optional, default radius
  23131. * * flat when true creates a flat shaded mesh, optional, default true
  23132. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23133. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23134. * * 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)
  23135. * * 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)
  23136. * @returns the VertexData of the IcoSphere
  23137. */
  23138. static CreateIcoSphere(options: {
  23139. radius?: number;
  23140. radiusX?: number;
  23141. radiusY?: number;
  23142. radiusZ?: number;
  23143. flat?: boolean;
  23144. subdivisions?: number;
  23145. sideOrientation?: number;
  23146. frontUVs?: Vector4;
  23147. backUVs?: Vector4;
  23148. }): VertexData;
  23149. /**
  23150. * Creates the VertexData for a Polyhedron
  23151. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23152. * * type provided types are:
  23153. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23154. * * 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)
  23155. * * size the size of the IcoSphere, optional default 1
  23156. * * sizeX allows stretching in the x direction, optional, default size
  23157. * * sizeY allows stretching in the y direction, optional, default size
  23158. * * sizeZ allows stretching in the z direction, optional, default size
  23159. * * 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
  23160. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23161. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23162. * * flat when true creates a flat shaded mesh, optional, default true
  23163. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23164. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23165. * * 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)
  23166. * * 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)
  23167. * @returns the VertexData of the Polyhedron
  23168. */
  23169. static CreatePolyhedron(options: {
  23170. type?: number;
  23171. size?: number;
  23172. sizeX?: number;
  23173. sizeY?: number;
  23174. sizeZ?: number;
  23175. custom?: any;
  23176. faceUV?: Vector4[];
  23177. faceColors?: Color4[];
  23178. flat?: boolean;
  23179. sideOrientation?: number;
  23180. frontUVs?: Vector4;
  23181. backUVs?: Vector4;
  23182. }): VertexData;
  23183. /**
  23184. * Creates the VertexData for a TorusKnot
  23185. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23186. * * radius the radius of the torus knot, optional, default 2
  23187. * * tube the thickness of the tube, optional, default 0.5
  23188. * * radialSegments the number of sides on each tube segments, optional, default 32
  23189. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23190. * * p the number of windings around the z axis, optional, default 2
  23191. * * q the number of windings around the x axis, optional, default 3
  23192. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23193. * * 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)
  23194. * * 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)
  23195. * @returns the VertexData of the Torus Knot
  23196. */
  23197. static CreateTorusKnot(options: {
  23198. radius?: number;
  23199. tube?: number;
  23200. radialSegments?: number;
  23201. tubularSegments?: number;
  23202. p?: number;
  23203. q?: number;
  23204. sideOrientation?: number;
  23205. frontUVs?: Vector4;
  23206. backUVs?: Vector4;
  23207. }): VertexData;
  23208. /**
  23209. * Compute normals for given positions and indices
  23210. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23211. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23212. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23213. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23214. * * facetNormals : optional array of facet normals (vector3)
  23215. * * facetPositions : optional array of facet positions (vector3)
  23216. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23217. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23218. * * bInfo : optional bounding info, required for facetPartitioning computation
  23219. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23220. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23221. * * useRightHandedSystem: optional boolean to for right handed system computation
  23222. * * depthSort : optional boolean to enable the facet depth sort computation
  23223. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23224. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23225. */
  23226. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23227. facetNormals?: any;
  23228. facetPositions?: any;
  23229. facetPartitioning?: any;
  23230. ratio?: number;
  23231. bInfo?: any;
  23232. bbSize?: Vector3;
  23233. subDiv?: any;
  23234. useRightHandedSystem?: boolean;
  23235. depthSort?: boolean;
  23236. distanceTo?: Vector3;
  23237. depthSortedFacets?: any;
  23238. }): void;
  23239. /** @hidden */
  23240. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23241. /**
  23242. * Applies VertexData created from the imported parameters to the geometry
  23243. * @param parsedVertexData the parsed data from an imported file
  23244. * @param geometry the geometry to apply the VertexData to
  23245. */
  23246. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23247. }
  23248. }
  23249. declare module BABYLON {
  23250. /**
  23251. * Class containing static functions to help procedurally build meshes
  23252. */
  23253. export class DiscBuilder {
  23254. /**
  23255. * Creates a plane polygonal mesh. By default, this is a disc
  23256. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  23257. * * 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
  23258. * * 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
  23259. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23260. * * 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
  23261. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23262. * @param name defines the name of the mesh
  23263. * @param options defines the options used to create the mesh
  23264. * @param scene defines the hosting scene
  23265. * @returns the plane polygonal mesh
  23266. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  23267. */
  23268. static CreateDisc(name: string, options: {
  23269. radius?: number;
  23270. tessellation?: number;
  23271. arc?: number;
  23272. updatable?: boolean;
  23273. sideOrientation?: number;
  23274. frontUVs?: Vector4;
  23275. backUVs?: Vector4;
  23276. }, scene?: Nullable<Scene>): Mesh;
  23277. }
  23278. }
  23279. declare module BABYLON {
  23280. /**
  23281. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  23282. *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.
  23283. * The SPS is also a particle system. It provides some methods to manage the particles.
  23284. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  23285. *
  23286. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  23287. */
  23288. export class SolidParticleSystem implements IDisposable {
  23289. /**
  23290. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  23291. * Example : var p = SPS.particles[i];
  23292. */
  23293. particles: SolidParticle[];
  23294. /**
  23295. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  23296. */
  23297. nbParticles: number;
  23298. /**
  23299. * If the particles must ever face the camera (default false). Useful for planar particles.
  23300. */
  23301. billboard: boolean;
  23302. /**
  23303. * Recompute normals when adding a shape
  23304. */
  23305. recomputeNormals: boolean;
  23306. /**
  23307. * This a counter ofr your own usage. It's not set by any SPS functions.
  23308. */
  23309. counter: number;
  23310. /**
  23311. * The SPS name. This name is also given to the underlying mesh.
  23312. */
  23313. name: string;
  23314. /**
  23315. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  23316. */
  23317. mesh: Mesh;
  23318. /**
  23319. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  23320. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  23321. */
  23322. vars: any;
  23323. /**
  23324. * This array is populated when the SPS is set as 'pickable'.
  23325. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  23326. * Each element of this array is an object `{idx: int, faceId: int}`.
  23327. * `idx` is the picked particle index in the `SPS.particles` array
  23328. * `faceId` is the picked face index counted within this particle.
  23329. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  23330. */
  23331. pickedParticles: {
  23332. idx: number;
  23333. faceId: number;
  23334. }[];
  23335. /**
  23336. * This array is populated when `enableDepthSort` is set to true.
  23337. * Each element of this array is an instance of the class DepthSortedParticle.
  23338. */
  23339. depthSortedParticles: DepthSortedParticle[];
  23340. /**
  23341. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  23342. * @hidden
  23343. */
  23344. _bSphereOnly: boolean;
  23345. /**
  23346. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  23347. * @hidden
  23348. */
  23349. _bSphereRadiusFactor: number;
  23350. private _scene;
  23351. private _positions;
  23352. private _indices;
  23353. private _normals;
  23354. private _colors;
  23355. private _uvs;
  23356. private _indices32;
  23357. private _positions32;
  23358. private _normals32;
  23359. private _fixedNormal32;
  23360. private _colors32;
  23361. private _uvs32;
  23362. private _index;
  23363. private _updatable;
  23364. private _pickable;
  23365. private _isVisibilityBoxLocked;
  23366. private _alwaysVisible;
  23367. private _depthSort;
  23368. private _shapeCounter;
  23369. private _copy;
  23370. private _color;
  23371. private _computeParticleColor;
  23372. private _computeParticleTexture;
  23373. private _computeParticleRotation;
  23374. private _computeParticleVertex;
  23375. private _computeBoundingBox;
  23376. private _depthSortParticles;
  23377. private _camera;
  23378. private _mustUnrotateFixedNormals;
  23379. private _particlesIntersect;
  23380. private _needs32Bits;
  23381. /**
  23382. * Creates a SPS (Solid Particle System) object.
  23383. * @param name (String) is the SPS name, this will be the underlying mesh name.
  23384. * @param scene (Scene) is the scene in which the SPS is added.
  23385. * @param options defines the options of the sps e.g.
  23386. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  23387. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  23388. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  23389. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  23390. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  23391. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  23392. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  23393. */
  23394. constructor(name: string, scene: Scene, options?: {
  23395. updatable?: boolean;
  23396. isPickable?: boolean;
  23397. enableDepthSort?: boolean;
  23398. particleIntersection?: boolean;
  23399. boundingSphereOnly?: boolean;
  23400. bSphereRadiusFactor?: number;
  23401. });
  23402. /**
  23403. * Builds the SPS underlying mesh. Returns a standard Mesh.
  23404. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  23405. * @returns the created mesh
  23406. */
  23407. buildMesh(): Mesh;
  23408. /**
  23409. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  23410. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  23411. * Thus the particles generated from `digest()` have their property `position` set yet.
  23412. * @param mesh ( Mesh ) is the mesh to be digested
  23413. * @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
  23414. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  23415. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  23416. * @returns the current SPS
  23417. */
  23418. digest(mesh: Mesh, options?: {
  23419. facetNb?: number;
  23420. number?: number;
  23421. delta?: number;
  23422. }): SolidParticleSystem;
  23423. private _unrotateFixedNormals;
  23424. private _resetCopy;
  23425. private _meshBuilder;
  23426. private _posToShape;
  23427. private _uvsToShapeUV;
  23428. private _addParticle;
  23429. /**
  23430. * Adds some particles to the SPS from the model shape. Returns the shape id.
  23431. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  23432. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  23433. * @param nb (positive integer) the number of particles to be created from this model
  23434. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  23435. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  23436. * @returns the number of shapes in the system
  23437. */
  23438. addShape(mesh: Mesh, nb: number, options?: {
  23439. positionFunction?: any;
  23440. vertexFunction?: any;
  23441. }): number;
  23442. private _rebuildParticle;
  23443. /**
  23444. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  23445. * @returns the SPS.
  23446. */
  23447. rebuildMesh(): SolidParticleSystem;
  23448. /**
  23449. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  23450. * This method calls `updateParticle()` for each particle of the SPS.
  23451. * For an animated SPS, it is usually called within the render loop.
  23452. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  23453. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  23454. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  23455. * @returns the SPS.
  23456. */
  23457. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  23458. /**
  23459. * Disposes the SPS.
  23460. */
  23461. dispose(): void;
  23462. /**
  23463. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  23464. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23465. * @returns the SPS.
  23466. */
  23467. refreshVisibleSize(): SolidParticleSystem;
  23468. /**
  23469. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  23470. * @param size the size (float) of the visibility box
  23471. * note : this doesn't lock the SPS mesh bounding box.
  23472. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23473. */
  23474. setVisibilityBox(size: number): void;
  23475. /**
  23476. * Gets whether the SPS as always visible or not
  23477. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23478. */
  23479. /**
  23480. * Sets the SPS as always visible or not
  23481. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23482. */
  23483. isAlwaysVisible: boolean;
  23484. /**
  23485. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23486. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23487. */
  23488. /**
  23489. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23490. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23491. */
  23492. isVisibilityBoxLocked: boolean;
  23493. /**
  23494. * Tells to `setParticles()` to compute the particle rotations or not.
  23495. * Default value : true. The SPS is faster when it's set to false.
  23496. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23497. */
  23498. /**
  23499. * Gets if `setParticles()` computes the particle rotations or not.
  23500. * Default value : true. The SPS is faster when it's set to false.
  23501. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23502. */
  23503. computeParticleRotation: boolean;
  23504. /**
  23505. * Tells to `setParticles()` to compute the particle colors or not.
  23506. * Default value : true. The SPS is faster when it's set to false.
  23507. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23508. */
  23509. /**
  23510. * Gets if `setParticles()` computes the particle colors or not.
  23511. * Default value : true. The SPS is faster when it's set to false.
  23512. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23513. */
  23514. computeParticleColor: boolean;
  23515. /**
  23516. * Gets if `setParticles()` computes the particle textures or not.
  23517. * Default value : true. The SPS is faster when it's set to false.
  23518. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  23519. */
  23520. computeParticleTexture: boolean;
  23521. /**
  23522. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  23523. * Default value : false. The SPS is faster when it's set to false.
  23524. * Note : the particle custom vertex positions aren't stored values.
  23525. */
  23526. /**
  23527. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  23528. * Default value : false. The SPS is faster when it's set to false.
  23529. * Note : the particle custom vertex positions aren't stored values.
  23530. */
  23531. computeParticleVertex: boolean;
  23532. /**
  23533. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  23534. */
  23535. /**
  23536. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  23537. */
  23538. computeBoundingBox: boolean;
  23539. /**
  23540. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  23541. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23542. * Default : `true`
  23543. */
  23544. /**
  23545. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  23546. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23547. * Default : `true`
  23548. */
  23549. depthSortParticles: boolean;
  23550. /**
  23551. * This function does nothing. It may be overwritten to set all the particle first values.
  23552. * The SPS doesn't call this function, you may have to call it by your own.
  23553. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23554. */
  23555. initParticles(): void;
  23556. /**
  23557. * This function does nothing. It may be overwritten to recycle a particle.
  23558. * The SPS doesn't call this function, you may have to call it by your own.
  23559. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23560. * @param particle The particle to recycle
  23561. * @returns the recycled particle
  23562. */
  23563. recycleParticle(particle: SolidParticle): SolidParticle;
  23564. /**
  23565. * Updates a particle : this function should be overwritten by the user.
  23566. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  23567. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23568. * @example : just set a particle position or velocity and recycle conditions
  23569. * @param particle The particle to update
  23570. * @returns the updated particle
  23571. */
  23572. updateParticle(particle: SolidParticle): SolidParticle;
  23573. /**
  23574. * Updates a vertex of a particle : it can be overwritten by the user.
  23575. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  23576. * @param particle the current particle
  23577. * @param vertex the current index of the current particle
  23578. * @param pt the index of the current vertex in the particle shape
  23579. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  23580. * @example : just set a vertex particle position
  23581. * @returns the updated vertex
  23582. */
  23583. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  23584. /**
  23585. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  23586. * This does nothing and may be overwritten by the user.
  23587. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23588. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23589. * @param update the boolean update value actually passed to setParticles()
  23590. */
  23591. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23592. /**
  23593. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  23594. * This will be passed three parameters.
  23595. * This does nothing and may be overwritten by the user.
  23596. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23597. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23598. * @param update the boolean update value actually passed to setParticles()
  23599. */
  23600. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23601. }
  23602. }
  23603. declare module BABYLON {
  23604. /**
  23605. * Represents one particle of a solid particle system.
  23606. */
  23607. export class SolidParticle {
  23608. /**
  23609. * particle global index
  23610. */
  23611. idx: number;
  23612. /**
  23613. * The color of the particle
  23614. */
  23615. color: Nullable<Color4>;
  23616. /**
  23617. * The world space position of the particle.
  23618. */
  23619. position: Vector3;
  23620. /**
  23621. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  23622. */
  23623. rotation: Vector3;
  23624. /**
  23625. * The world space rotation quaternion of the particle.
  23626. */
  23627. rotationQuaternion: Nullable<Quaternion>;
  23628. /**
  23629. * The scaling of the particle.
  23630. */
  23631. scaling: Vector3;
  23632. /**
  23633. * The uvs of the particle.
  23634. */
  23635. uvs: Vector4;
  23636. /**
  23637. * The current speed of the particle.
  23638. */
  23639. velocity: Vector3;
  23640. /**
  23641. * The pivot point in the particle local space.
  23642. */
  23643. pivot: Vector3;
  23644. /**
  23645. * Must the particle be translated from its pivot point in its local space ?
  23646. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  23647. * Default : false
  23648. */
  23649. translateFromPivot: boolean;
  23650. /**
  23651. * Is the particle active or not ?
  23652. */
  23653. alive: boolean;
  23654. /**
  23655. * Is the particle visible or not ?
  23656. */
  23657. isVisible: boolean;
  23658. /**
  23659. * Index of this particle in the global "positions" array (Internal use)
  23660. * @hidden
  23661. */
  23662. _pos: number;
  23663. /**
  23664. * @hidden Index of this particle in the global "indices" array (Internal use)
  23665. */
  23666. _ind: number;
  23667. /**
  23668. * @hidden ModelShape of this particle (Internal use)
  23669. */
  23670. _model: ModelShape;
  23671. /**
  23672. * ModelShape id of this particle
  23673. */
  23674. shapeId: number;
  23675. /**
  23676. * Index of the particle in its shape id (Internal use)
  23677. */
  23678. idxInShape: number;
  23679. /**
  23680. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  23681. */
  23682. _modelBoundingInfo: BoundingInfo;
  23683. /**
  23684. * @hidden Particle BoundingInfo object (Internal use)
  23685. */
  23686. _boundingInfo: BoundingInfo;
  23687. /**
  23688. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  23689. */
  23690. _sps: SolidParticleSystem;
  23691. /**
  23692. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  23693. */
  23694. _stillInvisible: boolean;
  23695. /**
  23696. * @hidden Last computed particle rotation matrix
  23697. */
  23698. _rotationMatrix: number[];
  23699. /**
  23700. * Parent particle Id, if any.
  23701. * Default null.
  23702. */
  23703. parentId: Nullable<number>;
  23704. /**
  23705. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  23706. * The possible values are :
  23707. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  23708. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23709. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  23710. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  23711. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23712. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  23713. * */
  23714. cullingStrategy: number;
  23715. /**
  23716. * @hidden Internal global position in the SPS.
  23717. */
  23718. _globalPosition: Vector3;
  23719. /**
  23720. * Creates a Solid Particle object.
  23721. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  23722. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  23723. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  23724. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  23725. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  23726. * @param shapeId (integer) is the model shape identifier in the SPS.
  23727. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  23728. * @param sps defines the sps it is associated to
  23729. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  23730. */
  23731. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  23732. /**
  23733. * Legacy support, changed scale to scaling
  23734. */
  23735. /**
  23736. * Legacy support, changed scale to scaling
  23737. */
  23738. scale: Vector3;
  23739. /**
  23740. * Legacy support, changed quaternion to rotationQuaternion
  23741. */
  23742. /**
  23743. * Legacy support, changed quaternion to rotationQuaternion
  23744. */
  23745. quaternion: Nullable<Quaternion>;
  23746. /**
  23747. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  23748. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  23749. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  23750. * @returns true if it intersects
  23751. */
  23752. intersectsMesh(target: Mesh | SolidParticle): boolean;
  23753. /**
  23754. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  23755. * A particle is in the frustum if its bounding box intersects the frustum
  23756. * @param frustumPlanes defines the frustum to test
  23757. * @returns true if the particle is in the frustum planes
  23758. */
  23759. isInFrustum(frustumPlanes: Plane[]): boolean;
  23760. /**
  23761. * get the rotation matrix of the particle
  23762. * @hidden
  23763. */
  23764. getRotationMatrix(m: Matrix): void;
  23765. }
  23766. /**
  23767. * Represents the shape of the model used by one particle of a solid particle system.
  23768. * SPS internal tool, don't use it manually.
  23769. */
  23770. export class ModelShape {
  23771. /**
  23772. * The shape id
  23773. * @hidden
  23774. */
  23775. shapeID: number;
  23776. /**
  23777. * flat array of model positions (internal use)
  23778. * @hidden
  23779. */
  23780. _shape: Vector3[];
  23781. /**
  23782. * flat array of model UVs (internal use)
  23783. * @hidden
  23784. */
  23785. _shapeUV: number[];
  23786. /**
  23787. * length of the shape in the model indices array (internal use)
  23788. * @hidden
  23789. */
  23790. _indicesLength: number;
  23791. /**
  23792. * Custom position function (internal use)
  23793. * @hidden
  23794. */
  23795. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  23796. /**
  23797. * Custom vertex function (internal use)
  23798. * @hidden
  23799. */
  23800. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  23801. /**
  23802. * 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.
  23803. * SPS internal tool, don't use it manually.
  23804. * @hidden
  23805. */
  23806. 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>);
  23807. }
  23808. /**
  23809. * Represents a Depth Sorted Particle in the solid particle system.
  23810. */
  23811. export class DepthSortedParticle {
  23812. /**
  23813. * Index of the particle in the "indices" array
  23814. */
  23815. ind: number;
  23816. /**
  23817. * Length of the particle shape in the "indices" array
  23818. */
  23819. indicesLength: number;
  23820. /**
  23821. * Squared distance from the particle to the camera
  23822. */
  23823. sqDistance: number;
  23824. }
  23825. }
  23826. declare module BABYLON {
  23827. /**
  23828. * Class used to store all common mesh properties
  23829. */
  23830. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  23831. /** No occlusion */
  23832. static OCCLUSION_TYPE_NONE: number;
  23833. /** Occlusion set to optimisitic */
  23834. static OCCLUSION_TYPE_OPTIMISTIC: number;
  23835. /** Occlusion set to strict */
  23836. static OCCLUSION_TYPE_STRICT: number;
  23837. /** Use an accurante occlusion algorithm */
  23838. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  23839. /** Use a conservative occlusion algorithm */
  23840. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  23841. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  23842. * Test order :
  23843. * Is the bounding sphere outside the frustum ?
  23844. * If not, are the bounding box vertices outside the frustum ?
  23845. * It not, then the cullable object is in the frustum.
  23846. */
  23847. static readonly CULLINGSTRATEGY_STANDARD: number;
  23848. /** Culling strategy : Bounding Sphere Only.
  23849. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  23850. * It's also less accurate than the standard because some not visible objects can still be selected.
  23851. * Test : is the bounding sphere outside the frustum ?
  23852. * If not, then the cullable object is in the frustum.
  23853. */
  23854. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  23855. /** Culling strategy : Optimistic Inclusion.
  23856. * This in an inclusion test first, then the standard exclusion test.
  23857. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  23858. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  23859. * Anyway, it's as accurate as the standard strategy.
  23860. * Test :
  23861. * Is the cullable object bounding sphere center in the frustum ?
  23862. * If not, apply the default culling strategy.
  23863. */
  23864. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  23865. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  23866. * This in an inclusion test first, then the bounding sphere only exclusion test.
  23867. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  23868. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  23869. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  23870. * Test :
  23871. * Is the cullable object bounding sphere center in the frustum ?
  23872. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  23873. */
  23874. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  23875. /**
  23876. * No billboard
  23877. */
  23878. static readonly BILLBOARDMODE_NONE: number;
  23879. /** Billboard on X axis */
  23880. static readonly BILLBOARDMODE_X: number;
  23881. /** Billboard on Y axis */
  23882. static readonly BILLBOARDMODE_Y: number;
  23883. /** Billboard on Z axis */
  23884. static readonly BILLBOARDMODE_Z: number;
  23885. /** Billboard on all axes */
  23886. static readonly BILLBOARDMODE_ALL: number;
  23887. private _facetData;
  23888. /**
  23889. * The culling strategy to use to check whether the mesh must be rendered or not.
  23890. * This value can be changed at any time and will be used on the next render mesh selection.
  23891. * The possible values are :
  23892. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  23893. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23894. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  23895. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  23896. * Please read each static variable documentation to get details about the culling process.
  23897. * */
  23898. cullingStrategy: number;
  23899. /**
  23900. * Gets the number of facets in the mesh
  23901. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23902. */
  23903. readonly facetNb: number;
  23904. /**
  23905. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  23906. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23907. */
  23908. partitioningSubdivisions: number;
  23909. /**
  23910. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  23911. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  23912. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23913. */
  23914. partitioningBBoxRatio: number;
  23915. /**
  23916. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  23917. * Works only for updatable meshes.
  23918. * Doesn't work with multi-materials
  23919. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23920. */
  23921. mustDepthSortFacets: boolean;
  23922. /**
  23923. * The location (Vector3) where the facet depth sort must be computed from.
  23924. * By default, the active camera position.
  23925. * Used only when facet depth sort is enabled
  23926. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23927. */
  23928. facetDepthSortFrom: Vector3;
  23929. /**
  23930. * gets a boolean indicating if facetData is enabled
  23931. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23932. */
  23933. readonly isFacetDataEnabled: boolean;
  23934. /** @hidden */
  23935. _updateNonUniformScalingState(value: boolean): boolean;
  23936. /**
  23937. * An event triggered when this mesh collides with another one
  23938. */
  23939. onCollideObservable: Observable<AbstractMesh>;
  23940. private _onCollideObserver;
  23941. /** Set a function to call when this mesh collides with another one */
  23942. onCollide: () => void;
  23943. /**
  23944. * An event triggered when the collision's position changes
  23945. */
  23946. onCollisionPositionChangeObservable: Observable<Vector3>;
  23947. private _onCollisionPositionChangeObserver;
  23948. /** Set a function to call when the collision's position changes */
  23949. onCollisionPositionChange: () => void;
  23950. /**
  23951. * An event triggered when material is changed
  23952. */
  23953. onMaterialChangedObservable: Observable<AbstractMesh>;
  23954. /**
  23955. * Gets or sets the orientation for POV movement & rotation
  23956. */
  23957. definedFacingForward: boolean;
  23958. /** @hidden */
  23959. _occlusionQuery: Nullable<WebGLQuery>;
  23960. private _visibility;
  23961. /**
  23962. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  23963. */
  23964. /**
  23965. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  23966. */
  23967. visibility: number;
  23968. /** Gets or sets the alpha index used to sort transparent meshes
  23969. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  23970. */
  23971. alphaIndex: number;
  23972. /**
  23973. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  23974. */
  23975. isVisible: boolean;
  23976. /**
  23977. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  23978. */
  23979. isPickable: boolean;
  23980. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  23981. showSubMeshesBoundingBox: boolean;
  23982. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  23983. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  23984. */
  23985. isBlocker: boolean;
  23986. /**
  23987. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  23988. */
  23989. enablePointerMoveEvents: boolean;
  23990. /**
  23991. * Specifies the rendering group id for this mesh (0 by default)
  23992. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  23993. */
  23994. renderingGroupId: number;
  23995. private _material;
  23996. /** Gets or sets current material */
  23997. material: Nullable<Material>;
  23998. private _receiveShadows;
  23999. /**
  24000. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  24001. * @see http://doc.babylonjs.com/babylon101/shadows
  24002. */
  24003. receiveShadows: boolean;
  24004. /** Defines color to use when rendering outline */
  24005. outlineColor: Color3;
  24006. /** Define width to use when rendering outline */
  24007. outlineWidth: number;
  24008. /** Defines color to use when rendering overlay */
  24009. overlayColor: Color3;
  24010. /** Defines alpha to use when rendering overlay */
  24011. overlayAlpha: number;
  24012. private _hasVertexAlpha;
  24013. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  24014. hasVertexAlpha: boolean;
  24015. private _useVertexColors;
  24016. /** 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) */
  24017. useVertexColors: boolean;
  24018. private _computeBonesUsingShaders;
  24019. /**
  24020. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  24021. */
  24022. computeBonesUsingShaders: boolean;
  24023. private _numBoneInfluencers;
  24024. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  24025. numBoneInfluencers: number;
  24026. private _applyFog;
  24027. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24028. applyFog: boolean;
  24029. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24030. useOctreeForRenderingSelection: boolean;
  24031. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24032. useOctreeForPicking: boolean;
  24033. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24034. useOctreeForCollisions: boolean;
  24035. private _layerMask;
  24036. /**
  24037. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24038. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24039. */
  24040. layerMask: number;
  24041. /**
  24042. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24043. */
  24044. alwaysSelectAsActiveMesh: boolean;
  24045. /**
  24046. * Gets or sets the current action manager
  24047. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24048. */
  24049. actionManager: Nullable<AbstractActionManager>;
  24050. private _checkCollisions;
  24051. private _collisionMask;
  24052. private _collisionGroup;
  24053. /**
  24054. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24055. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24056. */
  24057. ellipsoid: Vector3;
  24058. /**
  24059. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24060. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24061. */
  24062. ellipsoidOffset: Vector3;
  24063. private _collider;
  24064. private _oldPositionForCollisions;
  24065. private _diffPositionForCollisions;
  24066. /**
  24067. * Gets or sets a collision mask used to mask collisions (default is -1).
  24068. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24069. */
  24070. collisionMask: number;
  24071. /**
  24072. * Gets or sets the current collision group mask (-1 by default).
  24073. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24074. */
  24075. collisionGroup: number;
  24076. /**
  24077. * Defines edge width used when edgesRenderer is enabled
  24078. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24079. */
  24080. edgesWidth: number;
  24081. /**
  24082. * Defines edge color used when edgesRenderer is enabled
  24083. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24084. */
  24085. edgesColor: Color4;
  24086. /** @hidden */
  24087. _edgesRenderer: Nullable<IEdgesRenderer>;
  24088. /** @hidden */
  24089. _masterMesh: Nullable<AbstractMesh>;
  24090. /** @hidden */
  24091. _boundingInfo: Nullable<BoundingInfo>;
  24092. /** @hidden */
  24093. _renderId: number;
  24094. /**
  24095. * Gets or sets the list of subMeshes
  24096. * @see http://doc.babylonjs.com/how_to/multi_materials
  24097. */
  24098. subMeshes: SubMesh[];
  24099. /** @hidden */
  24100. _intersectionsInProgress: AbstractMesh[];
  24101. /** @hidden */
  24102. _unIndexed: boolean;
  24103. /** @hidden */
  24104. _lightSources: Light[];
  24105. /** @hidden */
  24106. readonly _positions: Nullable<Vector3[]>;
  24107. /** @hidden */
  24108. _waitingActions: any;
  24109. /** @hidden */
  24110. _waitingFreezeWorldMatrix: Nullable<boolean>;
  24111. private _skeleton;
  24112. /** @hidden */
  24113. _bonesTransformMatrices: Nullable<Float32Array>;
  24114. /**
  24115. * Gets or sets a skeleton to apply skining transformations
  24116. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24117. */
  24118. skeleton: Nullable<Skeleton>;
  24119. /**
  24120. * An event triggered when the mesh is rebuilt.
  24121. */
  24122. onRebuildObservable: Observable<AbstractMesh>;
  24123. /**
  24124. * Creates a new AbstractMesh
  24125. * @param name defines the name of the mesh
  24126. * @param scene defines the hosting scene
  24127. */
  24128. constructor(name: string, scene?: Nullable<Scene>);
  24129. /**
  24130. * Returns the string "AbstractMesh"
  24131. * @returns "AbstractMesh"
  24132. */
  24133. getClassName(): string;
  24134. /**
  24135. * Gets a string representation of the current mesh
  24136. * @param fullDetails defines a boolean indicating if full details must be included
  24137. * @returns a string representation of the current mesh
  24138. */
  24139. toString(fullDetails?: boolean): string;
  24140. /** @hidden */
  24141. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24142. /** @hidden */
  24143. _rebuild(): void;
  24144. /** @hidden */
  24145. _resyncLightSources(): void;
  24146. /** @hidden */
  24147. _resyncLighSource(light: Light): void;
  24148. /** @hidden */
  24149. _unBindEffect(): void;
  24150. /** @hidden */
  24151. _removeLightSource(light: Light): void;
  24152. private _markSubMeshesAsDirty;
  24153. /** @hidden */
  24154. _markSubMeshesAsLightDirty(): void;
  24155. /** @hidden */
  24156. _markSubMeshesAsAttributesDirty(): void;
  24157. /** @hidden */
  24158. _markSubMeshesAsMiscDirty(): void;
  24159. /**
  24160. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24161. */
  24162. scaling: Vector3;
  24163. /**
  24164. * Returns true if the mesh is blocked. Implemented by child classes
  24165. */
  24166. readonly isBlocked: boolean;
  24167. /**
  24168. * Returns the mesh itself by default. Implemented by child classes
  24169. * @param camera defines the camera to use to pick the right LOD level
  24170. * @returns the currentAbstractMesh
  24171. */
  24172. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24173. /**
  24174. * Returns 0 by default. Implemented by child classes
  24175. * @returns an integer
  24176. */
  24177. getTotalVertices(): number;
  24178. /**
  24179. * Returns a positive integer : the total number of indices in this mesh geometry.
  24180. * @returns the numner of indices or zero if the mesh has no geometry.
  24181. */
  24182. getTotalIndices(): number;
  24183. /**
  24184. * Returns null by default. Implemented by child classes
  24185. * @returns null
  24186. */
  24187. getIndices(): Nullable<IndicesArray>;
  24188. /**
  24189. * Returns the array of the requested vertex data kind. Implemented by child classes
  24190. * @param kind defines the vertex data kind to use
  24191. * @returns null
  24192. */
  24193. getVerticesData(kind: string): Nullable<FloatArray>;
  24194. /**
  24195. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24196. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24197. * Note that a new underlying VertexBuffer object is created each call.
  24198. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24199. * @param kind defines vertex data kind:
  24200. * * VertexBuffer.PositionKind
  24201. * * VertexBuffer.UVKind
  24202. * * VertexBuffer.UV2Kind
  24203. * * VertexBuffer.UV3Kind
  24204. * * VertexBuffer.UV4Kind
  24205. * * VertexBuffer.UV5Kind
  24206. * * VertexBuffer.UV6Kind
  24207. * * VertexBuffer.ColorKind
  24208. * * VertexBuffer.MatricesIndicesKind
  24209. * * VertexBuffer.MatricesIndicesExtraKind
  24210. * * VertexBuffer.MatricesWeightsKind
  24211. * * VertexBuffer.MatricesWeightsExtraKind
  24212. * @param data defines the data source
  24213. * @param updatable defines if the data must be flagged as updatable (or static)
  24214. * @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
  24215. * @returns the current mesh
  24216. */
  24217. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24218. /**
  24219. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24220. * If the mesh has no geometry, it is simply returned as it is.
  24221. * @param kind defines vertex data kind:
  24222. * * VertexBuffer.PositionKind
  24223. * * VertexBuffer.UVKind
  24224. * * VertexBuffer.UV2Kind
  24225. * * VertexBuffer.UV3Kind
  24226. * * VertexBuffer.UV4Kind
  24227. * * VertexBuffer.UV5Kind
  24228. * * VertexBuffer.UV6Kind
  24229. * * VertexBuffer.ColorKind
  24230. * * VertexBuffer.MatricesIndicesKind
  24231. * * VertexBuffer.MatricesIndicesExtraKind
  24232. * * VertexBuffer.MatricesWeightsKind
  24233. * * VertexBuffer.MatricesWeightsExtraKind
  24234. * @param data defines the data source
  24235. * @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
  24236. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24237. * @returns the current mesh
  24238. */
  24239. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24240. /**
  24241. * Sets the mesh indices,
  24242. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24243. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24244. * @param totalVertices Defines the total number of vertices
  24245. * @returns the current mesh
  24246. */
  24247. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24248. /**
  24249. * Gets a boolean indicating if specific vertex data is present
  24250. * @param kind defines the vertex data kind to use
  24251. * @returns true is data kind is present
  24252. */
  24253. isVerticesDataPresent(kind: string): boolean;
  24254. /**
  24255. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  24256. * @returns a BoundingInfo
  24257. */
  24258. getBoundingInfo(): BoundingInfo;
  24259. /**
  24260. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24261. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  24262. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  24263. * @returns the current mesh
  24264. */
  24265. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  24266. /**
  24267. * Overwrite the current bounding info
  24268. * @param boundingInfo defines the new bounding info
  24269. * @returns the current mesh
  24270. */
  24271. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24272. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24273. readonly useBones: boolean;
  24274. /** @hidden */
  24275. _preActivate(): void;
  24276. /** @hidden */
  24277. _preActivateForIntermediateRendering(renderId: number): void;
  24278. /** @hidden */
  24279. _activate(renderId: number): void;
  24280. /**
  24281. * Gets the current world matrix
  24282. * @returns a Matrix
  24283. */
  24284. getWorldMatrix(): Matrix;
  24285. /** @hidden */
  24286. _getWorldMatrixDeterminant(): number;
  24287. /**
  24288. * Perform relative position change from the point of view of behind the front of the mesh.
  24289. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24290. * Supports definition of mesh facing forward or backward
  24291. * @param amountRight defines the distance on the right axis
  24292. * @param amountUp defines the distance on the up axis
  24293. * @param amountForward defines the distance on the forward axis
  24294. * @returns the current mesh
  24295. */
  24296. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  24297. /**
  24298. * Calculate relative position change from the point of view of behind the front of the mesh.
  24299. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24300. * Supports definition of mesh facing forward or backward
  24301. * @param amountRight defines the distance on the right axis
  24302. * @param amountUp defines the distance on the up axis
  24303. * @param amountForward defines the distance on the forward axis
  24304. * @returns the new displacement vector
  24305. */
  24306. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  24307. /**
  24308. * Perform relative rotation change from the point of view of behind the front of the mesh.
  24309. * Supports definition of mesh facing forward or backward
  24310. * @param flipBack defines the flip
  24311. * @param twirlClockwise defines the twirl
  24312. * @param tiltRight defines the tilt
  24313. * @returns the current mesh
  24314. */
  24315. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  24316. /**
  24317. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  24318. * Supports definition of mesh facing forward or backward.
  24319. * @param flipBack defines the flip
  24320. * @param twirlClockwise defines the twirl
  24321. * @param tiltRight defines the tilt
  24322. * @returns the new rotation vector
  24323. */
  24324. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  24325. /**
  24326. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  24327. * @param includeDescendants Include bounding info from descendants as well (true by default)
  24328. * @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
  24329. * @returns the new bounding vectors
  24330. */
  24331. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  24332. min: Vector3;
  24333. max: Vector3;
  24334. };
  24335. /**
  24336. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24337. * This means the mesh underlying bounding box and sphere are recomputed.
  24338. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24339. * @returns the current mesh
  24340. */
  24341. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  24342. /** @hidden */
  24343. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  24344. /** @hidden */
  24345. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  24346. /** @hidden */
  24347. _updateBoundingInfo(): AbstractMesh;
  24348. /** @hidden */
  24349. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  24350. /** @hidden */
  24351. protected _afterComputeWorldMatrix(): void;
  24352. /** @hidden */
  24353. readonly _effectiveMesh: AbstractMesh;
  24354. /**
  24355. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24356. * A mesh is in the frustum if its bounding box intersects the frustum
  24357. * @param frustumPlanes defines the frustum to test
  24358. * @returns true if the mesh is in the frustum planes
  24359. */
  24360. isInFrustum(frustumPlanes: Plane[]): boolean;
  24361. /**
  24362. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  24363. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  24364. * @param frustumPlanes defines the frustum to test
  24365. * @returns true if the mesh is completely in the frustum planes
  24366. */
  24367. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24368. /**
  24369. * True if the mesh intersects another mesh or a SolidParticle object
  24370. * @param mesh defines a target mesh or SolidParticle to test
  24371. * @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)
  24372. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  24373. * @returns true if there is an intersection
  24374. */
  24375. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  24376. /**
  24377. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  24378. * @param point defines the point to test
  24379. * @returns true if there is an intersection
  24380. */
  24381. intersectsPoint(point: Vector3): boolean;
  24382. /**
  24383. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  24384. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24385. */
  24386. checkCollisions: boolean;
  24387. /**
  24388. * Gets Collider object used to compute collisions (not physics)
  24389. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24390. */
  24391. readonly collider: Collider;
  24392. /**
  24393. * Move the mesh using collision engine
  24394. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24395. * @param displacement defines the requested displacement vector
  24396. * @returns the current mesh
  24397. */
  24398. moveWithCollisions(displacement: Vector3): AbstractMesh;
  24399. private _onCollisionPositionChange;
  24400. /** @hidden */
  24401. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  24402. /** @hidden */
  24403. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  24404. /** @hidden */
  24405. _checkCollision(collider: Collider): AbstractMesh;
  24406. /** @hidden */
  24407. _generatePointsArray(): boolean;
  24408. /**
  24409. * Checks if the passed Ray intersects with the mesh
  24410. * @param ray defines the ray to use
  24411. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  24412. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  24413. * @returns the picking info
  24414. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24415. */
  24416. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  24417. /**
  24418. * Clones the current mesh
  24419. * @param name defines the mesh name
  24420. * @param newParent defines the new mesh parent
  24421. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  24422. * @returns the new mesh
  24423. */
  24424. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  24425. /**
  24426. * Disposes all the submeshes of the current meshnp
  24427. * @returns the current mesh
  24428. */
  24429. releaseSubMeshes(): AbstractMesh;
  24430. /**
  24431. * Releases resources associated with this abstract mesh.
  24432. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24433. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24434. */
  24435. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24436. /**
  24437. * Adds the passed mesh as a child to the current mesh
  24438. * @param mesh defines the child mesh
  24439. * @returns the current mesh
  24440. */
  24441. addChild(mesh: AbstractMesh): AbstractMesh;
  24442. /**
  24443. * Removes the passed mesh from the current mesh children list
  24444. * @param mesh defines the child mesh
  24445. * @returns the current mesh
  24446. */
  24447. removeChild(mesh: AbstractMesh): AbstractMesh;
  24448. /** @hidden */
  24449. private _initFacetData;
  24450. /**
  24451. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  24452. * This method can be called within the render loop.
  24453. * 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
  24454. * @returns the current mesh
  24455. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24456. */
  24457. updateFacetData(): AbstractMesh;
  24458. /**
  24459. * Returns the facetLocalNormals array.
  24460. * The normals are expressed in the mesh local spac
  24461. * @returns an array of Vector3
  24462. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24463. */
  24464. getFacetLocalNormals(): Vector3[];
  24465. /**
  24466. * Returns the facetLocalPositions array.
  24467. * The facet positions are expressed in the mesh local space
  24468. * @returns an array of Vector3
  24469. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24470. */
  24471. getFacetLocalPositions(): Vector3[];
  24472. /**
  24473. * Returns the facetLocalPartioning array
  24474. * @returns an array of array of numbers
  24475. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24476. */
  24477. getFacetLocalPartitioning(): number[][];
  24478. /**
  24479. * Returns the i-th facet position in the world system.
  24480. * This method allocates a new Vector3 per call
  24481. * @param i defines the facet index
  24482. * @returns a new Vector3
  24483. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24484. */
  24485. getFacetPosition(i: number): Vector3;
  24486. /**
  24487. * Sets the reference Vector3 with the i-th facet position in the world system
  24488. * @param i defines the facet index
  24489. * @param ref defines the target vector
  24490. * @returns the current mesh
  24491. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24492. */
  24493. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  24494. /**
  24495. * Returns the i-th facet normal in the world system.
  24496. * This method allocates a new Vector3 per call
  24497. * @param i defines the facet index
  24498. * @returns a new Vector3
  24499. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24500. */
  24501. getFacetNormal(i: number): Vector3;
  24502. /**
  24503. * Sets the reference Vector3 with the i-th facet normal in the world system
  24504. * @param i defines the facet index
  24505. * @param ref defines the target vector
  24506. * @returns the current mesh
  24507. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24508. */
  24509. getFacetNormalToRef(i: number, ref: Vector3): this;
  24510. /**
  24511. * 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)
  24512. * @param x defines x coordinate
  24513. * @param y defines y coordinate
  24514. * @param z defines z coordinate
  24515. * @returns the array of facet indexes
  24516. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24517. */
  24518. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  24519. /**
  24520. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  24521. * @param projected sets as the (x,y,z) world projection on the facet
  24522. * @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
  24523. * @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
  24524. * @param x defines x coordinate
  24525. * @param y defines y coordinate
  24526. * @param z defines z coordinate
  24527. * @returns the face index if found (or null instead)
  24528. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24529. */
  24530. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24531. /**
  24532. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  24533. * @param projected sets as the (x,y,z) local projection on the facet
  24534. * @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
  24535. * @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
  24536. * @param x defines x coordinate
  24537. * @param y defines y coordinate
  24538. * @param z defines z coordinate
  24539. * @returns the face index if found (or null instead)
  24540. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24541. */
  24542. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24543. /**
  24544. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  24545. * @returns the parameters
  24546. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24547. */
  24548. getFacetDataParameters(): any;
  24549. /**
  24550. * Disables the feature FacetData and frees the related memory
  24551. * @returns the current mesh
  24552. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24553. */
  24554. disableFacetData(): AbstractMesh;
  24555. /**
  24556. * Updates the AbstractMesh indices array
  24557. * @param indices defines the data source
  24558. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24559. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  24560. * @returns the current mesh
  24561. */
  24562. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24563. /**
  24564. * Creates new normals data for the mesh
  24565. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  24566. * @returns the current mesh
  24567. */
  24568. createNormals(updatable: boolean): AbstractMesh;
  24569. /**
  24570. * Align the mesh with a normal
  24571. * @param normal defines the normal to use
  24572. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  24573. * @returns the current mesh
  24574. */
  24575. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  24576. /** @hidden */
  24577. _checkOcclusionQuery(): boolean;
  24578. }
  24579. }
  24580. declare module BABYLON {
  24581. /**
  24582. * Interface used to define ActionEvent
  24583. */
  24584. export interface IActionEvent {
  24585. /** The mesh or sprite that triggered the action */
  24586. source: any;
  24587. /** The X mouse cursor position at the time of the event */
  24588. pointerX: number;
  24589. /** The Y mouse cursor position at the time of the event */
  24590. pointerY: number;
  24591. /** The mesh that is currently pointed at (can be null) */
  24592. meshUnderPointer: Nullable<AbstractMesh>;
  24593. /** the original (browser) event that triggered the ActionEvent */
  24594. sourceEvent?: any;
  24595. /** additional data for the event */
  24596. additionalData?: any;
  24597. }
  24598. /**
  24599. * ActionEvent is the event being sent when an action is triggered.
  24600. */
  24601. export class ActionEvent implements IActionEvent {
  24602. /** The mesh or sprite that triggered the action */
  24603. source: any;
  24604. /** The X mouse cursor position at the time of the event */
  24605. pointerX: number;
  24606. /** The Y mouse cursor position at the time of the event */
  24607. pointerY: number;
  24608. /** The mesh that is currently pointed at (can be null) */
  24609. meshUnderPointer: Nullable<AbstractMesh>;
  24610. /** the original (browser) event that triggered the ActionEvent */
  24611. sourceEvent?: any;
  24612. /** additional data for the event */
  24613. additionalData?: any;
  24614. /**
  24615. * Creates a new ActionEvent
  24616. * @param source The mesh or sprite that triggered the action
  24617. * @param pointerX The X mouse cursor position at the time of the event
  24618. * @param pointerY The Y mouse cursor position at the time of the event
  24619. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  24620. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  24621. * @param additionalData additional data for the event
  24622. */
  24623. constructor(
  24624. /** The mesh or sprite that triggered the action */
  24625. source: any,
  24626. /** The X mouse cursor position at the time of the event */
  24627. pointerX: number,
  24628. /** The Y mouse cursor position at the time of the event */
  24629. pointerY: number,
  24630. /** The mesh that is currently pointed at (can be null) */
  24631. meshUnderPointer: Nullable<AbstractMesh>,
  24632. /** the original (browser) event that triggered the ActionEvent */
  24633. sourceEvent?: any,
  24634. /** additional data for the event */
  24635. additionalData?: any);
  24636. /**
  24637. * Helper function to auto-create an ActionEvent from a source mesh.
  24638. * @param source The source mesh that triggered the event
  24639. * @param evt The original (browser) event
  24640. * @param additionalData additional data for the event
  24641. * @returns the new ActionEvent
  24642. */
  24643. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  24644. /**
  24645. * Helper function to auto-create an ActionEvent from a source sprite
  24646. * @param source The source sprite that triggered the event
  24647. * @param scene Scene associated with the sprite
  24648. * @param evt The original (browser) event
  24649. * @param additionalData additional data for the event
  24650. * @returns the new ActionEvent
  24651. */
  24652. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  24653. /**
  24654. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  24655. * @param scene the scene where the event occurred
  24656. * @param evt The original (browser) event
  24657. * @returns the new ActionEvent
  24658. */
  24659. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  24660. /**
  24661. * Helper function to auto-create an ActionEvent from a primitive
  24662. * @param prim defines the target primitive
  24663. * @param pointerPos defines the pointer position
  24664. * @param evt The original (browser) event
  24665. * @param additionalData additional data for the event
  24666. * @returns the new ActionEvent
  24667. */
  24668. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  24669. }
  24670. }
  24671. declare module BABYLON {
  24672. /**
  24673. * Abstract class used to decouple action Manager from scene and meshes.
  24674. * Do not instantiate.
  24675. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24676. */
  24677. export abstract class AbstractActionManager implements IDisposable {
  24678. /** Gets the list of active triggers */
  24679. static Triggers: {
  24680. [key: string]: number;
  24681. };
  24682. /** Gets the cursor to use when hovering items */
  24683. hoverCursor: string;
  24684. /** Gets the list of actions */
  24685. actions: IAction[];
  24686. /**
  24687. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  24688. */
  24689. isRecursive: boolean;
  24690. /**
  24691. * Releases all associated resources
  24692. */
  24693. abstract dispose(): void;
  24694. /**
  24695. * Does this action manager has pointer triggers
  24696. */
  24697. abstract readonly hasPointerTriggers: boolean;
  24698. /**
  24699. * Does this action manager has pick triggers
  24700. */
  24701. abstract readonly hasPickTriggers: boolean;
  24702. /**
  24703. * Process a specific trigger
  24704. * @param trigger defines the trigger to process
  24705. * @param evt defines the event details to be processed
  24706. */
  24707. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  24708. /**
  24709. * Does this action manager handles actions of any of the given triggers
  24710. * @param triggers defines the triggers to be tested
  24711. * @return a boolean indicating whether one (or more) of the triggers is handled
  24712. */
  24713. abstract hasSpecificTriggers(triggers: number[]): boolean;
  24714. /**
  24715. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  24716. * speed.
  24717. * @param triggerA defines the trigger to be tested
  24718. * @param triggerB defines the trigger to be tested
  24719. * @return a boolean indicating whether one (or more) of the triggers is handled
  24720. */
  24721. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  24722. /**
  24723. * Does this action manager handles actions of a given trigger
  24724. * @param trigger defines the trigger to be tested
  24725. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  24726. * @return whether the trigger is handled
  24727. */
  24728. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  24729. /**
  24730. * Serialize this manager to a JSON object
  24731. * @param name defines the property name to store this manager
  24732. * @returns a JSON representation of this manager
  24733. */
  24734. abstract serialize(name: string): any;
  24735. /**
  24736. * Registers an action to this action manager
  24737. * @param action defines the action to be registered
  24738. * @return the action amended (prepared) after registration
  24739. */
  24740. abstract registerAction(action: IAction): Nullable<IAction>;
  24741. /**
  24742. * Unregisters an action to this action manager
  24743. * @param action defines the action to be unregistered
  24744. * @return a boolean indicating whether the action has been unregistered
  24745. */
  24746. abstract unregisterAction(action: IAction): Boolean;
  24747. /**
  24748. * Does exist one action manager with at least one trigger
  24749. **/
  24750. static readonly HasTriggers: boolean;
  24751. /**
  24752. * Does exist one action manager with at least one pick trigger
  24753. **/
  24754. static readonly HasPickTriggers: boolean;
  24755. /**
  24756. * Does exist one action manager that handles actions of a given trigger
  24757. * @param trigger defines the trigger to be tested
  24758. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  24759. **/
  24760. static HasSpecificTrigger(trigger: number): boolean;
  24761. }
  24762. }
  24763. declare module BABYLON {
  24764. /**
  24765. * Defines how a node can be built from a string name.
  24766. */
  24767. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  24768. /**
  24769. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  24770. */
  24771. export class Node implements IBehaviorAware<Node> {
  24772. /** @hidden */
  24773. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  24774. private static _NodeConstructors;
  24775. /**
  24776. * Add a new node constructor
  24777. * @param type defines the type name of the node to construct
  24778. * @param constructorFunc defines the constructor function
  24779. */
  24780. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  24781. /**
  24782. * Returns a node constructor based on type name
  24783. * @param type defines the type name
  24784. * @param name defines the new node name
  24785. * @param scene defines the hosting scene
  24786. * @param options defines optional options to transmit to constructors
  24787. * @returns the new constructor or null
  24788. */
  24789. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  24790. /**
  24791. * Gets or sets the name of the node
  24792. */
  24793. name: string;
  24794. /**
  24795. * Gets or sets the id of the node
  24796. */
  24797. id: string;
  24798. /**
  24799. * Gets or sets the unique id of the node
  24800. */
  24801. uniqueId: number;
  24802. /**
  24803. * Gets or sets a string used to store user defined state for the node
  24804. */
  24805. state: string;
  24806. /**
  24807. * Gets or sets an object used to store user defined information for the node
  24808. */
  24809. metadata: any;
  24810. /**
  24811. * For internal use only. Please do not use.
  24812. */
  24813. reservedDataStore: any;
  24814. /**
  24815. * List of inspectable custom properties (used by the Inspector)
  24816. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24817. */
  24818. inspectableCustomProperties: IInspectable[];
  24819. /**
  24820. * Gets or sets a boolean used to define if the node must be serialized
  24821. */
  24822. doNotSerialize: boolean;
  24823. /** @hidden */
  24824. _isDisposed: boolean;
  24825. /**
  24826. * Gets a list of Animations associated with the node
  24827. */
  24828. animations: Animation[];
  24829. protected _ranges: {
  24830. [name: string]: Nullable<AnimationRange>;
  24831. };
  24832. /**
  24833. * Callback raised when the node is ready to be used
  24834. */
  24835. onReady: (node: Node) => void;
  24836. private _isEnabled;
  24837. private _isParentEnabled;
  24838. private _isReady;
  24839. /** @hidden */
  24840. _currentRenderId: number;
  24841. private _parentRenderId;
  24842. protected _childRenderId: number;
  24843. /** @hidden */
  24844. _waitingParentId: Nullable<string>;
  24845. /** @hidden */
  24846. _scene: Scene;
  24847. /** @hidden */
  24848. _cache: any;
  24849. private _parentNode;
  24850. private _children;
  24851. /** @hidden */
  24852. _worldMatrix: Matrix;
  24853. /** @hidden */
  24854. _worldMatrixDeterminant: number;
  24855. /** @hidden */
  24856. private _sceneRootNodesIndex;
  24857. /**
  24858. * Gets a boolean indicating if the node has been disposed
  24859. * @returns true if the node was disposed
  24860. */
  24861. isDisposed(): boolean;
  24862. /**
  24863. * Gets or sets the parent of the node (without keeping the current position in the scene)
  24864. * @see https://doc.babylonjs.com/how_to/parenting
  24865. */
  24866. parent: Nullable<Node>;
  24867. private addToSceneRootNodes;
  24868. private removeFromSceneRootNodes;
  24869. private _animationPropertiesOverride;
  24870. /**
  24871. * Gets or sets the animation properties override
  24872. */
  24873. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  24874. /**
  24875. * Gets a string idenfifying the name of the class
  24876. * @returns "Node" string
  24877. */
  24878. getClassName(): string;
  24879. /** @hidden */
  24880. readonly _isNode: boolean;
  24881. /**
  24882. * An event triggered when the mesh is disposed
  24883. */
  24884. onDisposeObservable: Observable<Node>;
  24885. private _onDisposeObserver;
  24886. /**
  24887. * Sets a callback that will be raised when the node will be disposed
  24888. */
  24889. onDispose: () => void;
  24890. /**
  24891. * Creates a new Node
  24892. * @param name the name and id to be given to this node
  24893. * @param scene the scene this node will be added to
  24894. * @param addToRootNodes the node will be added to scene.rootNodes
  24895. */
  24896. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  24897. /**
  24898. * Gets the scene of the node
  24899. * @returns a scene
  24900. */
  24901. getScene(): Scene;
  24902. /**
  24903. * Gets the engine of the node
  24904. * @returns a Engine
  24905. */
  24906. getEngine(): Engine;
  24907. private _behaviors;
  24908. /**
  24909. * Attach a behavior to the node
  24910. * @see http://doc.babylonjs.com/features/behaviour
  24911. * @param behavior defines the behavior to attach
  24912. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  24913. * @returns the current Node
  24914. */
  24915. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  24916. /**
  24917. * Remove an attached behavior
  24918. * @see http://doc.babylonjs.com/features/behaviour
  24919. * @param behavior defines the behavior to attach
  24920. * @returns the current Node
  24921. */
  24922. removeBehavior(behavior: Behavior<Node>): Node;
  24923. /**
  24924. * Gets the list of attached behaviors
  24925. * @see http://doc.babylonjs.com/features/behaviour
  24926. */
  24927. readonly behaviors: Behavior<Node>[];
  24928. /**
  24929. * Gets an attached behavior by name
  24930. * @param name defines the name of the behavior to look for
  24931. * @see http://doc.babylonjs.com/features/behaviour
  24932. * @returns null if behavior was not found else the requested behavior
  24933. */
  24934. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  24935. /**
  24936. * Returns the latest update of the World matrix
  24937. * @returns a Matrix
  24938. */
  24939. getWorldMatrix(): Matrix;
  24940. /** @hidden */
  24941. _getWorldMatrixDeterminant(): number;
  24942. /**
  24943. * Returns directly the latest state of the mesh World matrix.
  24944. * A Matrix is returned.
  24945. */
  24946. readonly worldMatrixFromCache: Matrix;
  24947. /** @hidden */
  24948. _initCache(): void;
  24949. /** @hidden */
  24950. updateCache(force?: boolean): void;
  24951. /** @hidden */
  24952. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24953. /** @hidden */
  24954. _updateCache(ignoreParentClass?: boolean): void;
  24955. /** @hidden */
  24956. _isSynchronized(): boolean;
  24957. /** @hidden */
  24958. _markSyncedWithParent(): void;
  24959. /** @hidden */
  24960. isSynchronizedWithParent(): boolean;
  24961. /** @hidden */
  24962. isSynchronized(): boolean;
  24963. /**
  24964. * Is this node ready to be used/rendered
  24965. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24966. * @return true if the node is ready
  24967. */
  24968. isReady(completeCheck?: boolean): boolean;
  24969. /**
  24970. * Is this node enabled?
  24971. * 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
  24972. * @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
  24973. * @return whether this node (and its parent) is enabled
  24974. */
  24975. isEnabled(checkAncestors?: boolean): boolean;
  24976. /** @hidden */
  24977. protected _syncParentEnabledState(): void;
  24978. /**
  24979. * Set the enabled state of this node
  24980. * @param value defines the new enabled state
  24981. */
  24982. setEnabled(value: boolean): void;
  24983. /**
  24984. * Is this node a descendant of the given node?
  24985. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  24986. * @param ancestor defines the parent node to inspect
  24987. * @returns a boolean indicating if this node is a descendant of the given node
  24988. */
  24989. isDescendantOf(ancestor: Node): boolean;
  24990. /** @hidden */
  24991. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  24992. /**
  24993. * Will return all nodes that have this node as ascendant
  24994. * @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
  24995. * @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
  24996. * @return all children nodes of all types
  24997. */
  24998. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  24999. /**
  25000. * Get all child-meshes of this node
  25001. * @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: false)
  25002. * @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
  25003. * @returns an array of AbstractMesh
  25004. */
  25005. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  25006. /**
  25007. * Get all direct children of this node
  25008. * @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
  25009. * @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)
  25010. * @returns an array of Node
  25011. */
  25012. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  25013. /** @hidden */
  25014. _setReady(state: boolean): void;
  25015. /**
  25016. * Get an animation by name
  25017. * @param name defines the name of the animation to look for
  25018. * @returns null if not found else the requested animation
  25019. */
  25020. getAnimationByName(name: string): Nullable<Animation>;
  25021. /**
  25022. * Creates an animation range for this node
  25023. * @param name defines the name of the range
  25024. * @param from defines the starting key
  25025. * @param to defines the end key
  25026. */
  25027. createAnimationRange(name: string, from: number, to: number): void;
  25028. /**
  25029. * Delete a specific animation range
  25030. * @param name defines the name of the range to delete
  25031. * @param deleteFrames defines if animation frames from the range must be deleted as well
  25032. */
  25033. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  25034. /**
  25035. * Get an animation range by name
  25036. * @param name defines the name of the animation range to look for
  25037. * @returns null if not found else the requested animation range
  25038. */
  25039. getAnimationRange(name: string): Nullable<AnimationRange>;
  25040. /**
  25041. * Gets the list of all animation ranges defined on this node
  25042. * @returns an array
  25043. */
  25044. getAnimationRanges(): Nullable<AnimationRange>[];
  25045. /**
  25046. * Will start the animation sequence
  25047. * @param name defines the range frames for animation sequence
  25048. * @param loop defines if the animation should loop (false by default)
  25049. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  25050. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  25051. * @returns the object created for this animation. If range does not exist, it will return null
  25052. */
  25053. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  25054. /**
  25055. * Serialize animation ranges into a JSON compatible object
  25056. * @returns serialization object
  25057. */
  25058. serializeAnimationRanges(): any;
  25059. /**
  25060. * Computes the world matrix of the node
  25061. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  25062. * @returns the world matrix
  25063. */
  25064. computeWorldMatrix(force?: boolean): Matrix;
  25065. /**
  25066. * Releases resources associated with this node.
  25067. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25068. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25069. */
  25070. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25071. /**
  25072. * Parse animation range data from a serialization object and store them into a given node
  25073. * @param node defines where to store the animation ranges
  25074. * @param parsedNode defines the serialization object to read data from
  25075. * @param scene defines the hosting scene
  25076. */
  25077. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  25078. }
  25079. }
  25080. declare module BABYLON {
  25081. /**
  25082. * Class used to store any kind of animation
  25083. */
  25084. export class Animation {
  25085. /**Name of the animation */
  25086. name: string;
  25087. /**Property to animate */
  25088. targetProperty: string;
  25089. /**The frames per second of the animation */
  25090. framePerSecond: number;
  25091. /**The data type of the animation */
  25092. dataType: number;
  25093. /**The loop mode of the animation */
  25094. loopMode?: number | undefined;
  25095. /**Specifies if blending should be enabled */
  25096. enableBlending?: boolean | undefined;
  25097. /**
  25098. * Use matrix interpolation instead of using direct key value when animating matrices
  25099. */
  25100. static AllowMatricesInterpolation: boolean;
  25101. /**
  25102. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  25103. */
  25104. static AllowMatrixDecomposeForInterpolation: boolean;
  25105. /**
  25106. * Stores the key frames of the animation
  25107. */
  25108. private _keys;
  25109. /**
  25110. * Stores the easing function of the animation
  25111. */
  25112. private _easingFunction;
  25113. /**
  25114. * @hidden Internal use only
  25115. */
  25116. _runtimeAnimations: RuntimeAnimation[];
  25117. /**
  25118. * The set of event that will be linked to this animation
  25119. */
  25120. private _events;
  25121. /**
  25122. * Stores an array of target property paths
  25123. */
  25124. targetPropertyPath: string[];
  25125. /**
  25126. * Stores the blending speed of the animation
  25127. */
  25128. blendingSpeed: number;
  25129. /**
  25130. * Stores the animation ranges for the animation
  25131. */
  25132. private _ranges;
  25133. /**
  25134. * @hidden Internal use
  25135. */
  25136. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  25137. /**
  25138. * Sets up an animation
  25139. * @param property The property to animate
  25140. * @param animationType The animation type to apply
  25141. * @param framePerSecond The frames per second of the animation
  25142. * @param easingFunction The easing function used in the animation
  25143. * @returns The created animation
  25144. */
  25145. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  25146. /**
  25147. * Create and start an animation on a node
  25148. * @param name defines the name of the global animation that will be run on all nodes
  25149. * @param node defines the root node where the animation will take place
  25150. * @param targetProperty defines property to animate
  25151. * @param framePerSecond defines the number of frame per second yo use
  25152. * @param totalFrame defines the number of frames in total
  25153. * @param from defines the initial value
  25154. * @param to defines the final value
  25155. * @param loopMode defines which loop mode you want to use (off by default)
  25156. * @param easingFunction defines the easing function to use (linear by default)
  25157. * @param onAnimationEnd defines the callback to call when animation end
  25158. * @returns the animatable created for this animation
  25159. */
  25160. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25161. /**
  25162. * Create and start an animation on a node and its descendants
  25163. * @param name defines the name of the global animation that will be run on all nodes
  25164. * @param node defines the root node where the animation will take place
  25165. * @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
  25166. * @param targetProperty defines property to animate
  25167. * @param framePerSecond defines the number of frame per second to use
  25168. * @param totalFrame defines the number of frames in total
  25169. * @param from defines the initial value
  25170. * @param to defines the final value
  25171. * @param loopMode defines which loop mode you want to use (off by default)
  25172. * @param easingFunction defines the easing function to use (linear by default)
  25173. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25174. * @returns the list of animatables created for all nodes
  25175. * @example https://www.babylonjs-playground.com/#MH0VLI
  25176. */
  25177. 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[]>;
  25178. /**
  25179. * Creates a new animation, merges it with the existing animations and starts it
  25180. * @param name Name of the animation
  25181. * @param node Node which contains the scene that begins the animations
  25182. * @param targetProperty Specifies which property to animate
  25183. * @param framePerSecond The frames per second of the animation
  25184. * @param totalFrame The total number of frames
  25185. * @param from The frame at the beginning of the animation
  25186. * @param to The frame at the end of the animation
  25187. * @param loopMode Specifies the loop mode of the animation
  25188. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  25189. * @param onAnimationEnd Callback to run once the animation is complete
  25190. * @returns Nullable animation
  25191. */
  25192. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25193. /**
  25194. * Transition property of an host to the target Value
  25195. * @param property The property to transition
  25196. * @param targetValue The target Value of the property
  25197. * @param host The object where the property to animate belongs
  25198. * @param scene Scene used to run the animation
  25199. * @param frameRate Framerate (in frame/s) to use
  25200. * @param transition The transition type we want to use
  25201. * @param duration The duration of the animation, in milliseconds
  25202. * @param onAnimationEnd Callback trigger at the end of the animation
  25203. * @returns Nullable animation
  25204. */
  25205. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  25206. /**
  25207. * Return the array of runtime animations currently using this animation
  25208. */
  25209. readonly runtimeAnimations: RuntimeAnimation[];
  25210. /**
  25211. * Specifies if any of the runtime animations are currently running
  25212. */
  25213. readonly hasRunningRuntimeAnimations: boolean;
  25214. /**
  25215. * Initializes the animation
  25216. * @param name Name of the animation
  25217. * @param targetProperty Property to animate
  25218. * @param framePerSecond The frames per second of the animation
  25219. * @param dataType The data type of the animation
  25220. * @param loopMode The loop mode of the animation
  25221. * @param enableBlending Specifies if blending should be enabled
  25222. */
  25223. constructor(
  25224. /**Name of the animation */
  25225. name: string,
  25226. /**Property to animate */
  25227. targetProperty: string,
  25228. /**The frames per second of the animation */
  25229. framePerSecond: number,
  25230. /**The data type of the animation */
  25231. dataType: number,
  25232. /**The loop mode of the animation */
  25233. loopMode?: number | undefined,
  25234. /**Specifies if blending should be enabled */
  25235. enableBlending?: boolean | undefined);
  25236. /**
  25237. * Converts the animation to a string
  25238. * @param fullDetails support for multiple levels of logging within scene loading
  25239. * @returns String form of the animation
  25240. */
  25241. toString(fullDetails?: boolean): string;
  25242. /**
  25243. * Add an event to this animation
  25244. * @param event Event to add
  25245. */
  25246. addEvent(event: AnimationEvent): void;
  25247. /**
  25248. * Remove all events found at the given frame
  25249. * @param frame The frame to remove events from
  25250. */
  25251. removeEvents(frame: number): void;
  25252. /**
  25253. * Retrieves all the events from the animation
  25254. * @returns Events from the animation
  25255. */
  25256. getEvents(): AnimationEvent[];
  25257. /**
  25258. * Creates an animation range
  25259. * @param name Name of the animation range
  25260. * @param from Starting frame of the animation range
  25261. * @param to Ending frame of the animation
  25262. */
  25263. createRange(name: string, from: number, to: number): void;
  25264. /**
  25265. * Deletes an animation range by name
  25266. * @param name Name of the animation range to delete
  25267. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  25268. */
  25269. deleteRange(name: string, deleteFrames?: boolean): void;
  25270. /**
  25271. * Gets the animation range by name, or null if not defined
  25272. * @param name Name of the animation range
  25273. * @returns Nullable animation range
  25274. */
  25275. getRange(name: string): Nullable<AnimationRange>;
  25276. /**
  25277. * Gets the key frames from the animation
  25278. * @returns The key frames of the animation
  25279. */
  25280. getKeys(): Array<IAnimationKey>;
  25281. /**
  25282. * Gets the highest frame rate of the animation
  25283. * @returns Highest frame rate of the animation
  25284. */
  25285. getHighestFrame(): number;
  25286. /**
  25287. * Gets the easing function of the animation
  25288. * @returns Easing function of the animation
  25289. */
  25290. getEasingFunction(): IEasingFunction;
  25291. /**
  25292. * Sets the easing function of the animation
  25293. * @param easingFunction A custom mathematical formula for animation
  25294. */
  25295. setEasingFunction(easingFunction: EasingFunction): void;
  25296. /**
  25297. * Interpolates a scalar linearly
  25298. * @param startValue Start value of the animation curve
  25299. * @param endValue End value of the animation curve
  25300. * @param gradient Scalar amount to interpolate
  25301. * @returns Interpolated scalar value
  25302. */
  25303. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  25304. /**
  25305. * Interpolates a scalar cubically
  25306. * @param startValue Start value of the animation curve
  25307. * @param outTangent End tangent of the animation
  25308. * @param endValue End value of the animation curve
  25309. * @param inTangent Start tangent of the animation curve
  25310. * @param gradient Scalar amount to interpolate
  25311. * @returns Interpolated scalar value
  25312. */
  25313. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  25314. /**
  25315. * Interpolates a quaternion using a spherical linear interpolation
  25316. * @param startValue Start value of the animation curve
  25317. * @param endValue End value of the animation curve
  25318. * @param gradient Scalar amount to interpolate
  25319. * @returns Interpolated quaternion value
  25320. */
  25321. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  25322. /**
  25323. * Interpolates a quaternion cubically
  25324. * @param startValue Start value of the animation curve
  25325. * @param outTangent End tangent of the animation curve
  25326. * @param endValue End value of the animation curve
  25327. * @param inTangent Start tangent of the animation curve
  25328. * @param gradient Scalar amount to interpolate
  25329. * @returns Interpolated quaternion value
  25330. */
  25331. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  25332. /**
  25333. * Interpolates a Vector3 linearl
  25334. * @param startValue Start value of the animation curve
  25335. * @param endValue End value of the animation curve
  25336. * @param gradient Scalar amount to interpolate
  25337. * @returns Interpolated scalar value
  25338. */
  25339. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  25340. /**
  25341. * Interpolates a Vector3 cubically
  25342. * @param startValue Start value of the animation curve
  25343. * @param outTangent End tangent of the animation
  25344. * @param endValue End value of the animation curve
  25345. * @param inTangent Start tangent of the animation curve
  25346. * @param gradient Scalar amount to interpolate
  25347. * @returns InterpolatedVector3 value
  25348. */
  25349. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  25350. /**
  25351. * Interpolates a Vector2 linearly
  25352. * @param startValue Start value of the animation curve
  25353. * @param endValue End value of the animation curve
  25354. * @param gradient Scalar amount to interpolate
  25355. * @returns Interpolated Vector2 value
  25356. */
  25357. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  25358. /**
  25359. * Interpolates a Vector2 cubically
  25360. * @param startValue Start value of the animation curve
  25361. * @param outTangent End tangent of the animation
  25362. * @param endValue End value of the animation curve
  25363. * @param inTangent Start tangent of the animation curve
  25364. * @param gradient Scalar amount to interpolate
  25365. * @returns Interpolated Vector2 value
  25366. */
  25367. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  25368. /**
  25369. * Interpolates a size linearly
  25370. * @param startValue Start value of the animation curve
  25371. * @param endValue End value of the animation curve
  25372. * @param gradient Scalar amount to interpolate
  25373. * @returns Interpolated Size value
  25374. */
  25375. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  25376. /**
  25377. * Interpolates a Color3 linearly
  25378. * @param startValue Start value of the animation curve
  25379. * @param endValue End value of the animation curve
  25380. * @param gradient Scalar amount to interpolate
  25381. * @returns Interpolated Color3 value
  25382. */
  25383. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  25384. /**
  25385. * @hidden Internal use only
  25386. */
  25387. _getKeyValue(value: any): any;
  25388. /**
  25389. * @hidden Internal use only
  25390. */
  25391. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  25392. /**
  25393. * Defines the function to use to interpolate matrices
  25394. * @param startValue defines the start matrix
  25395. * @param endValue defines the end matrix
  25396. * @param gradient defines the gradient between both matrices
  25397. * @param result defines an optional target matrix where to store the interpolation
  25398. * @returns the interpolated matrix
  25399. */
  25400. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  25401. /**
  25402. * Makes a copy of the animation
  25403. * @returns Cloned animation
  25404. */
  25405. clone(): Animation;
  25406. /**
  25407. * Sets the key frames of the animation
  25408. * @param values The animation key frames to set
  25409. */
  25410. setKeys(values: Array<IAnimationKey>): void;
  25411. /**
  25412. * Serializes the animation to an object
  25413. * @returns Serialized object
  25414. */
  25415. serialize(): any;
  25416. /**
  25417. * Float animation type
  25418. */
  25419. private static _ANIMATIONTYPE_FLOAT;
  25420. /**
  25421. * Vector3 animation type
  25422. */
  25423. private static _ANIMATIONTYPE_VECTOR3;
  25424. /**
  25425. * Quaternion animation type
  25426. */
  25427. private static _ANIMATIONTYPE_QUATERNION;
  25428. /**
  25429. * Matrix animation type
  25430. */
  25431. private static _ANIMATIONTYPE_MATRIX;
  25432. /**
  25433. * Color3 animation type
  25434. */
  25435. private static _ANIMATIONTYPE_COLOR3;
  25436. /**
  25437. * Vector2 animation type
  25438. */
  25439. private static _ANIMATIONTYPE_VECTOR2;
  25440. /**
  25441. * Size animation type
  25442. */
  25443. private static _ANIMATIONTYPE_SIZE;
  25444. /**
  25445. * Relative Loop Mode
  25446. */
  25447. private static _ANIMATIONLOOPMODE_RELATIVE;
  25448. /**
  25449. * Cycle Loop Mode
  25450. */
  25451. private static _ANIMATIONLOOPMODE_CYCLE;
  25452. /**
  25453. * Constant Loop Mode
  25454. */
  25455. private static _ANIMATIONLOOPMODE_CONSTANT;
  25456. /**
  25457. * Get the float animation type
  25458. */
  25459. static readonly ANIMATIONTYPE_FLOAT: number;
  25460. /**
  25461. * Get the Vector3 animation type
  25462. */
  25463. static readonly ANIMATIONTYPE_VECTOR3: number;
  25464. /**
  25465. * Get the Vector2 animation type
  25466. */
  25467. static readonly ANIMATIONTYPE_VECTOR2: number;
  25468. /**
  25469. * Get the Size animation type
  25470. */
  25471. static readonly ANIMATIONTYPE_SIZE: number;
  25472. /**
  25473. * Get the Quaternion animation type
  25474. */
  25475. static readonly ANIMATIONTYPE_QUATERNION: number;
  25476. /**
  25477. * Get the Matrix animation type
  25478. */
  25479. static readonly ANIMATIONTYPE_MATRIX: number;
  25480. /**
  25481. * Get the Color3 animation type
  25482. */
  25483. static readonly ANIMATIONTYPE_COLOR3: number;
  25484. /**
  25485. * Get the Relative Loop Mode
  25486. */
  25487. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  25488. /**
  25489. * Get the Cycle Loop Mode
  25490. */
  25491. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  25492. /**
  25493. * Get the Constant Loop Mode
  25494. */
  25495. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  25496. /** @hidden */
  25497. static _UniversalLerp(left: any, right: any, amount: number): any;
  25498. /**
  25499. * Parses an animation object and creates an animation
  25500. * @param parsedAnimation Parsed animation object
  25501. * @returns Animation object
  25502. */
  25503. static Parse(parsedAnimation: any): Animation;
  25504. /**
  25505. * Appends the serialized animations from the source animations
  25506. * @param source Source containing the animations
  25507. * @param destination Target to store the animations
  25508. */
  25509. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  25510. }
  25511. }
  25512. declare module BABYLON {
  25513. /**
  25514. * Base class of all the textures in babylon.
  25515. * It groups all the common properties the materials, post process, lights... might need
  25516. * in order to make a correct use of the texture.
  25517. */
  25518. export class BaseTexture implements IAnimatable {
  25519. /**
  25520. * Default anisotropic filtering level for the application.
  25521. * It is set to 4 as a good tradeoff between perf and quality.
  25522. */
  25523. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  25524. /**
  25525. * Gets or sets the unique id of the texture
  25526. */
  25527. uniqueId: number;
  25528. /**
  25529. * Define the name of the texture.
  25530. */
  25531. name: string;
  25532. /**
  25533. * Gets or sets an object used to store user defined information.
  25534. */
  25535. metadata: any;
  25536. /**
  25537. * For internal use only. Please do not use.
  25538. */
  25539. reservedDataStore: any;
  25540. private _hasAlpha;
  25541. /**
  25542. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  25543. */
  25544. hasAlpha: boolean;
  25545. /**
  25546. * Defines if the alpha value should be determined via the rgb values.
  25547. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  25548. */
  25549. getAlphaFromRGB: boolean;
  25550. /**
  25551. * Intensity or strength of the texture.
  25552. * It is commonly used by materials to fine tune the intensity of the texture
  25553. */
  25554. level: number;
  25555. /**
  25556. * Define the UV chanel to use starting from 0 and defaulting to 0.
  25557. * This is part of the texture as textures usually maps to one uv set.
  25558. */
  25559. coordinatesIndex: number;
  25560. private _coordinatesMode;
  25561. /**
  25562. * How a texture is mapped.
  25563. *
  25564. * | Value | Type | Description |
  25565. * | ----- | ----------------------------------- | ----------- |
  25566. * | 0 | EXPLICIT_MODE | |
  25567. * | 1 | SPHERICAL_MODE | |
  25568. * | 2 | PLANAR_MODE | |
  25569. * | 3 | CUBIC_MODE | |
  25570. * | 4 | PROJECTION_MODE | |
  25571. * | 5 | SKYBOX_MODE | |
  25572. * | 6 | INVCUBIC_MODE | |
  25573. * | 7 | EQUIRECTANGULAR_MODE | |
  25574. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  25575. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  25576. */
  25577. coordinatesMode: number;
  25578. /**
  25579. * | Value | Type | Description |
  25580. * | ----- | ------------------ | ----------- |
  25581. * | 0 | CLAMP_ADDRESSMODE | |
  25582. * | 1 | WRAP_ADDRESSMODE | |
  25583. * | 2 | MIRROR_ADDRESSMODE | |
  25584. */
  25585. wrapU: number;
  25586. /**
  25587. * | Value | Type | Description |
  25588. * | ----- | ------------------ | ----------- |
  25589. * | 0 | CLAMP_ADDRESSMODE | |
  25590. * | 1 | WRAP_ADDRESSMODE | |
  25591. * | 2 | MIRROR_ADDRESSMODE | |
  25592. */
  25593. wrapV: number;
  25594. /**
  25595. * | Value | Type | Description |
  25596. * | ----- | ------------------ | ----------- |
  25597. * | 0 | CLAMP_ADDRESSMODE | |
  25598. * | 1 | WRAP_ADDRESSMODE | |
  25599. * | 2 | MIRROR_ADDRESSMODE | |
  25600. */
  25601. wrapR: number;
  25602. /**
  25603. * With compliant hardware and browser (supporting anisotropic filtering)
  25604. * this defines the level of anisotropic filtering in the texture.
  25605. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  25606. */
  25607. anisotropicFilteringLevel: number;
  25608. /**
  25609. * Define if the texture is a cube texture or if false a 2d texture.
  25610. */
  25611. isCube: boolean;
  25612. /**
  25613. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  25614. */
  25615. is3D: boolean;
  25616. /**
  25617. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  25618. * HDR texture are usually stored in linear space.
  25619. * This only impacts the PBR and Background materials
  25620. */
  25621. gammaSpace: boolean;
  25622. /**
  25623. * Gets whether or not the texture contains RGBD data.
  25624. */
  25625. readonly isRGBD: boolean;
  25626. /**
  25627. * Is Z inverted in the texture (useful in a cube texture).
  25628. */
  25629. invertZ: boolean;
  25630. /**
  25631. * Are mip maps generated for this texture or not.
  25632. */
  25633. readonly noMipmap: boolean;
  25634. /**
  25635. * @hidden
  25636. */
  25637. lodLevelInAlpha: boolean;
  25638. /**
  25639. * With prefiltered texture, defined the offset used during the prefiltering steps.
  25640. */
  25641. lodGenerationOffset: number;
  25642. /**
  25643. * With prefiltered texture, defined the scale used during the prefiltering steps.
  25644. */
  25645. lodGenerationScale: number;
  25646. /**
  25647. * Define if the texture is a render target.
  25648. */
  25649. isRenderTarget: boolean;
  25650. /**
  25651. * Define the unique id of the texture in the scene.
  25652. */
  25653. readonly uid: string;
  25654. /**
  25655. * Return a string representation of the texture.
  25656. * @returns the texture as a string
  25657. */
  25658. toString(): string;
  25659. /**
  25660. * Get the class name of the texture.
  25661. * @returns "BaseTexture"
  25662. */
  25663. getClassName(): string;
  25664. /**
  25665. * Define the list of animation attached to the texture.
  25666. */
  25667. animations: Animation[];
  25668. /**
  25669. * An event triggered when the texture is disposed.
  25670. */
  25671. onDisposeObservable: Observable<BaseTexture>;
  25672. private _onDisposeObserver;
  25673. /**
  25674. * Callback triggered when the texture has been disposed.
  25675. * Kept for back compatibility, you can use the onDisposeObservable instead.
  25676. */
  25677. onDispose: () => void;
  25678. /**
  25679. * Define the current state of the loading sequence when in delayed load mode.
  25680. */
  25681. delayLoadState: number;
  25682. private _scene;
  25683. /** @hidden */
  25684. _texture: Nullable<InternalTexture>;
  25685. private _uid;
  25686. /**
  25687. * Define if the texture is preventinga material to render or not.
  25688. * If not and the texture is not ready, the engine will use a default black texture instead.
  25689. */
  25690. readonly isBlocking: boolean;
  25691. /**
  25692. * Instantiates a new BaseTexture.
  25693. * Base class of all the textures in babylon.
  25694. * It groups all the common properties the materials, post process, lights... might need
  25695. * in order to make a correct use of the texture.
  25696. * @param scene Define the scene the texture blongs to
  25697. */
  25698. constructor(scene: Nullable<Scene>);
  25699. /**
  25700. * Get the scene the texture belongs to.
  25701. * @returns the scene or null if undefined
  25702. */
  25703. getScene(): Nullable<Scene>;
  25704. /**
  25705. * Get the texture transform matrix used to offset tile the texture for istance.
  25706. * @returns the transformation matrix
  25707. */
  25708. getTextureMatrix(): Matrix;
  25709. /**
  25710. * Get the texture reflection matrix used to rotate/transform the reflection.
  25711. * @returns the reflection matrix
  25712. */
  25713. getReflectionTextureMatrix(): Matrix;
  25714. /**
  25715. * Get the underlying lower level texture from Babylon.
  25716. * @returns the insternal texture
  25717. */
  25718. getInternalTexture(): Nullable<InternalTexture>;
  25719. /**
  25720. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  25721. * @returns true if ready or not blocking
  25722. */
  25723. isReadyOrNotBlocking(): boolean;
  25724. /**
  25725. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  25726. * @returns true if fully ready
  25727. */
  25728. isReady(): boolean;
  25729. private _cachedSize;
  25730. /**
  25731. * Get the size of the texture.
  25732. * @returns the texture size.
  25733. */
  25734. getSize(): ISize;
  25735. /**
  25736. * Get the base size of the texture.
  25737. * It can be different from the size if the texture has been resized for POT for instance
  25738. * @returns the base size
  25739. */
  25740. getBaseSize(): ISize;
  25741. /**
  25742. * Update the sampling mode of the texture.
  25743. * Default is Trilinear mode.
  25744. *
  25745. * | Value | Type | Description |
  25746. * | ----- | ------------------ | ----------- |
  25747. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  25748. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  25749. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  25750. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  25751. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  25752. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  25753. * | 7 | NEAREST_LINEAR | |
  25754. * | 8 | NEAREST_NEAREST | |
  25755. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  25756. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  25757. * | 11 | LINEAR_LINEAR | |
  25758. * | 12 | LINEAR_NEAREST | |
  25759. *
  25760. * > _mag_: magnification filter (close to the viewer)
  25761. * > _min_: minification filter (far from the viewer)
  25762. * > _mip_: filter used between mip map levels
  25763. *@param samplingMode Define the new sampling mode of the texture
  25764. */
  25765. updateSamplingMode(samplingMode: number): void;
  25766. /**
  25767. * Scales the texture if is `canRescale()`
  25768. * @param ratio the resize factor we want to use to rescale
  25769. */
  25770. scale(ratio: number): void;
  25771. /**
  25772. * Get if the texture can rescale.
  25773. */
  25774. readonly canRescale: boolean;
  25775. /** @hidden */
  25776. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  25777. /** @hidden */
  25778. _rebuild(): void;
  25779. /**
  25780. * Triggers the load sequence in delayed load mode.
  25781. */
  25782. delayLoad(): void;
  25783. /**
  25784. * Clones the texture.
  25785. * @returns the cloned texture
  25786. */
  25787. clone(): Nullable<BaseTexture>;
  25788. /**
  25789. * Get the texture underlying type (INT, FLOAT...)
  25790. */
  25791. readonly textureType: number;
  25792. /**
  25793. * Get the texture underlying format (RGB, RGBA...)
  25794. */
  25795. readonly textureFormat: number;
  25796. /**
  25797. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  25798. * This will returns an RGBA array buffer containing either in values (0-255) or
  25799. * float values (0-1) depending of the underlying buffer type.
  25800. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  25801. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  25802. * @param buffer defines a user defined buffer to fill with data (can be null)
  25803. * @returns The Array buffer containing the pixels data.
  25804. */
  25805. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  25806. /**
  25807. * Release and destroy the underlying lower level texture aka internalTexture.
  25808. */
  25809. releaseInternalTexture(): void;
  25810. /**
  25811. * Get the polynomial representation of the texture data.
  25812. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  25813. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  25814. */
  25815. sphericalPolynomial: Nullable<SphericalPolynomial>;
  25816. /** @hidden */
  25817. readonly _lodTextureHigh: Nullable<BaseTexture>;
  25818. /** @hidden */
  25819. readonly _lodTextureMid: Nullable<BaseTexture>;
  25820. /** @hidden */
  25821. readonly _lodTextureLow: Nullable<BaseTexture>;
  25822. /**
  25823. * Dispose the texture and release its associated resources.
  25824. */
  25825. dispose(): void;
  25826. /**
  25827. * Serialize the texture into a JSON representation that can be parsed later on.
  25828. * @returns the JSON representation of the texture
  25829. */
  25830. serialize(): any;
  25831. /**
  25832. * Helper function to be called back once a list of texture contains only ready textures.
  25833. * @param textures Define the list of textures to wait for
  25834. * @param callback Define the callback triggered once the entire list will be ready
  25835. */
  25836. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  25837. }
  25838. }
  25839. declare module BABYLON {
  25840. /**
  25841. * Uniform buffer objects.
  25842. *
  25843. * Handles blocks of uniform on the GPU.
  25844. *
  25845. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  25846. *
  25847. * For more information, please refer to :
  25848. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  25849. */
  25850. export class UniformBuffer {
  25851. private _engine;
  25852. private _buffer;
  25853. private _data;
  25854. private _bufferData;
  25855. private _dynamic?;
  25856. private _uniformLocations;
  25857. private _uniformSizes;
  25858. private _uniformLocationPointer;
  25859. private _needSync;
  25860. private _noUBO;
  25861. private _currentEffect;
  25862. private static _MAX_UNIFORM_SIZE;
  25863. private static _tempBuffer;
  25864. /**
  25865. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  25866. * This is dynamic to allow compat with webgl 1 and 2.
  25867. * You will need to pass the name of the uniform as well as the value.
  25868. */
  25869. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  25870. /**
  25871. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  25872. * This is dynamic to allow compat with webgl 1 and 2.
  25873. * You will need to pass the name of the uniform as well as the value.
  25874. */
  25875. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  25876. /**
  25877. * Lambda to Update a single float in a uniform buffer.
  25878. * This is dynamic to allow compat with webgl 1 and 2.
  25879. * You will need to pass the name of the uniform as well as the value.
  25880. */
  25881. updateFloat: (name: string, x: number) => void;
  25882. /**
  25883. * Lambda to Update a vec2 of float in a uniform buffer.
  25884. * This is dynamic to allow compat with webgl 1 and 2.
  25885. * You will need to pass the name of the uniform as well as the value.
  25886. */
  25887. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  25888. /**
  25889. * Lambda to Update a vec3 of float in a uniform buffer.
  25890. * This is dynamic to allow compat with webgl 1 and 2.
  25891. * You will need to pass the name of the uniform as well as the value.
  25892. */
  25893. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  25894. /**
  25895. * Lambda to Update a vec4 of float in a uniform buffer.
  25896. * This is dynamic to allow compat with webgl 1 and 2.
  25897. * You will need to pass the name of the uniform as well as the value.
  25898. */
  25899. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  25900. /**
  25901. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  25902. * This is dynamic to allow compat with webgl 1 and 2.
  25903. * You will need to pass the name of the uniform as well as the value.
  25904. */
  25905. updateMatrix: (name: string, mat: Matrix) => void;
  25906. /**
  25907. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  25908. * This is dynamic to allow compat with webgl 1 and 2.
  25909. * You will need to pass the name of the uniform as well as the value.
  25910. */
  25911. updateVector3: (name: string, vector: Vector3) => void;
  25912. /**
  25913. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  25914. * This is dynamic to allow compat with webgl 1 and 2.
  25915. * You will need to pass the name of the uniform as well as the value.
  25916. */
  25917. updateVector4: (name: string, vector: Vector4) => void;
  25918. /**
  25919. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  25920. * This is dynamic to allow compat with webgl 1 and 2.
  25921. * You will need to pass the name of the uniform as well as the value.
  25922. */
  25923. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  25924. /**
  25925. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  25926. * This is dynamic to allow compat with webgl 1 and 2.
  25927. * You will need to pass the name of the uniform as well as the value.
  25928. */
  25929. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  25930. /**
  25931. * Instantiates a new Uniform buffer objects.
  25932. *
  25933. * Handles blocks of uniform on the GPU.
  25934. *
  25935. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  25936. *
  25937. * For more information, please refer to :
  25938. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  25939. * @param engine Define the engine the buffer is associated with
  25940. * @param data Define the data contained in the buffer
  25941. * @param dynamic Define if the buffer is updatable
  25942. */
  25943. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  25944. /**
  25945. * Indicates if the buffer is using the WebGL2 UBO implementation,
  25946. * or just falling back on setUniformXXX calls.
  25947. */
  25948. readonly useUbo: boolean;
  25949. /**
  25950. * Indicates if the WebGL underlying uniform buffer is in sync
  25951. * with the javascript cache data.
  25952. */
  25953. readonly isSync: boolean;
  25954. /**
  25955. * Indicates if the WebGL underlying uniform buffer is dynamic.
  25956. * Also, a dynamic UniformBuffer will disable cache verification and always
  25957. * update the underlying WebGL uniform buffer to the GPU.
  25958. * @returns if Dynamic, otherwise false
  25959. */
  25960. isDynamic(): boolean;
  25961. /**
  25962. * The data cache on JS side.
  25963. * @returns the underlying data as a float array
  25964. */
  25965. getData(): Float32Array;
  25966. /**
  25967. * The underlying WebGL Uniform buffer.
  25968. * @returns the webgl buffer
  25969. */
  25970. getBuffer(): Nullable<WebGLBuffer>;
  25971. /**
  25972. * std140 layout specifies how to align data within an UBO structure.
  25973. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  25974. * for specs.
  25975. */
  25976. private _fillAlignment;
  25977. /**
  25978. * Adds an uniform in the buffer.
  25979. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  25980. * for the layout to be correct !
  25981. * @param name Name of the uniform, as used in the uniform block in the shader.
  25982. * @param size Data size, or data directly.
  25983. */
  25984. addUniform(name: string, size: number | number[]): void;
  25985. /**
  25986. * Adds a Matrix 4x4 to the uniform buffer.
  25987. * @param name Name of the uniform, as used in the uniform block in the shader.
  25988. * @param mat A 4x4 matrix.
  25989. */
  25990. addMatrix(name: string, mat: Matrix): void;
  25991. /**
  25992. * Adds a vec2 to the uniform buffer.
  25993. * @param name Name of the uniform, as used in the uniform block in the shader.
  25994. * @param x Define the x component value of the vec2
  25995. * @param y Define the y component value of the vec2
  25996. */
  25997. addFloat2(name: string, x: number, y: number): void;
  25998. /**
  25999. * Adds a vec3 to the uniform buffer.
  26000. * @param name Name of the uniform, as used in the uniform block in the shader.
  26001. * @param x Define the x component value of the vec3
  26002. * @param y Define the y component value of the vec3
  26003. * @param z Define the z component value of the vec3
  26004. */
  26005. addFloat3(name: string, x: number, y: number, z: number): void;
  26006. /**
  26007. * Adds a vec3 to the uniform buffer.
  26008. * @param name Name of the uniform, as used in the uniform block in the shader.
  26009. * @param color Define the vec3 from a Color
  26010. */
  26011. addColor3(name: string, color: Color3): void;
  26012. /**
  26013. * Adds a vec4 to the uniform buffer.
  26014. * @param name Name of the uniform, as used in the uniform block in the shader.
  26015. * @param color Define the rgb components from a Color
  26016. * @param alpha Define the a component of the vec4
  26017. */
  26018. addColor4(name: string, color: Color3, alpha: number): void;
  26019. /**
  26020. * Adds a vec3 to the uniform buffer.
  26021. * @param name Name of the uniform, as used in the uniform block in the shader.
  26022. * @param vector Define the vec3 components from a Vector
  26023. */
  26024. addVector3(name: string, vector: Vector3): void;
  26025. /**
  26026. * Adds a Matrix 3x3 to the uniform buffer.
  26027. * @param name Name of the uniform, as used in the uniform block in the shader.
  26028. */
  26029. addMatrix3x3(name: string): void;
  26030. /**
  26031. * Adds a Matrix 2x2 to the uniform buffer.
  26032. * @param name Name of the uniform, as used in the uniform block in the shader.
  26033. */
  26034. addMatrix2x2(name: string): void;
  26035. /**
  26036. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  26037. */
  26038. create(): void;
  26039. /** @hidden */
  26040. _rebuild(): void;
  26041. /**
  26042. * Updates the WebGL Uniform Buffer on the GPU.
  26043. * If the `dynamic` flag is set to true, no cache comparison is done.
  26044. * Otherwise, the buffer will be updated only if the cache differs.
  26045. */
  26046. update(): void;
  26047. /**
  26048. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  26049. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26050. * @param data Define the flattened data
  26051. * @param size Define the size of the data.
  26052. */
  26053. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  26054. private _updateMatrix3x3ForUniform;
  26055. private _updateMatrix3x3ForEffect;
  26056. private _updateMatrix2x2ForEffect;
  26057. private _updateMatrix2x2ForUniform;
  26058. private _updateFloatForEffect;
  26059. private _updateFloatForUniform;
  26060. private _updateFloat2ForEffect;
  26061. private _updateFloat2ForUniform;
  26062. private _updateFloat3ForEffect;
  26063. private _updateFloat3ForUniform;
  26064. private _updateFloat4ForEffect;
  26065. private _updateFloat4ForUniform;
  26066. private _updateMatrixForEffect;
  26067. private _updateMatrixForUniform;
  26068. private _updateVector3ForEffect;
  26069. private _updateVector3ForUniform;
  26070. private _updateVector4ForEffect;
  26071. private _updateVector4ForUniform;
  26072. private _updateColor3ForEffect;
  26073. private _updateColor3ForUniform;
  26074. private _updateColor4ForEffect;
  26075. private _updateColor4ForUniform;
  26076. /**
  26077. * Sets a sampler uniform on the effect.
  26078. * @param name Define the name of the sampler.
  26079. * @param texture Define the texture to set in the sampler
  26080. */
  26081. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  26082. /**
  26083. * Directly updates the value of the uniform in the cache AND on the GPU.
  26084. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26085. * @param data Define the flattened data
  26086. */
  26087. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  26088. /**
  26089. * Binds this uniform buffer to an effect.
  26090. * @param effect Define the effect to bind the buffer to
  26091. * @param name Name of the uniform block in the shader.
  26092. */
  26093. bindToEffect(effect: Effect, name: string): void;
  26094. /**
  26095. * Disposes the uniform buffer.
  26096. */
  26097. dispose(): void;
  26098. }
  26099. }
  26100. declare module BABYLON {
  26101. /**
  26102. * This represents the required contract to create a new type of texture loader.
  26103. */
  26104. export interface IInternalTextureLoader {
  26105. /**
  26106. * Defines wether the loader supports cascade loading the different faces.
  26107. */
  26108. supportCascades: boolean;
  26109. /**
  26110. * This returns if the loader support the current file information.
  26111. * @param extension defines the file extension of the file being loaded
  26112. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26113. * @param fallback defines the fallback internal texture if any
  26114. * @param isBase64 defines whether the texture is encoded as a base64
  26115. * @param isBuffer defines whether the texture data are stored as a buffer
  26116. * @returns true if the loader can load the specified file
  26117. */
  26118. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  26119. /**
  26120. * Transform the url before loading if required.
  26121. * @param rootUrl the url of the texture
  26122. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26123. * @returns the transformed texture
  26124. */
  26125. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  26126. /**
  26127. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  26128. * @param rootUrl the url of the texture
  26129. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26130. * @returns the fallback texture
  26131. */
  26132. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  26133. /**
  26134. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  26135. * @param data contains the texture data
  26136. * @param texture defines the BabylonJS internal texture
  26137. * @param createPolynomials will be true if polynomials have been requested
  26138. * @param onLoad defines the callback to trigger once the texture is ready
  26139. * @param onError defines the callback to trigger in case of error
  26140. */
  26141. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  26142. /**
  26143. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  26144. * @param data contains the texture data
  26145. * @param texture defines the BabylonJS internal texture
  26146. * @param callback defines the method to call once ready to upload
  26147. */
  26148. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  26149. }
  26150. }
  26151. declare module BABYLON {
  26152. /**
  26153. * Creation options of the multi render target texture.
  26154. */
  26155. export interface IMultiRenderTargetOptions {
  26156. /**
  26157. * Define if the texture needs to create mip maps after render.
  26158. */
  26159. generateMipMaps?: boolean;
  26160. /**
  26161. * Define the types of all the draw buffers we want to create
  26162. */
  26163. types?: number[];
  26164. /**
  26165. * Define the sampling modes of all the draw buffers we want to create
  26166. */
  26167. samplingModes?: number[];
  26168. /**
  26169. * Define if a depth buffer is required
  26170. */
  26171. generateDepthBuffer?: boolean;
  26172. /**
  26173. * Define if a stencil buffer is required
  26174. */
  26175. generateStencilBuffer?: boolean;
  26176. /**
  26177. * Define if a depth texture is required instead of a depth buffer
  26178. */
  26179. generateDepthTexture?: boolean;
  26180. /**
  26181. * Define the number of desired draw buffers
  26182. */
  26183. textureCount?: number;
  26184. /**
  26185. * Define if aspect ratio should be adapted to the texture or stay the scene one
  26186. */
  26187. doNotChangeAspectRatio?: boolean;
  26188. /**
  26189. * Define the default type of the buffers we are creating
  26190. */
  26191. defaultType?: number;
  26192. }
  26193. /**
  26194. * A multi render target, like a render target provides the ability to render to a texture.
  26195. * Unlike the render target, it can render to several draw buffers in one draw.
  26196. * This is specially interesting in deferred rendering or for any effects requiring more than
  26197. * just one color from a single pass.
  26198. */
  26199. export class MultiRenderTarget extends RenderTargetTexture {
  26200. private _internalTextures;
  26201. private _textures;
  26202. private _multiRenderTargetOptions;
  26203. /**
  26204. * Get if draw buffers are currently supported by the used hardware and browser.
  26205. */
  26206. readonly isSupported: boolean;
  26207. /**
  26208. * Get the list of textures generated by the multi render target.
  26209. */
  26210. readonly textures: Texture[];
  26211. /**
  26212. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  26213. */
  26214. readonly depthTexture: Texture;
  26215. /**
  26216. * Set the wrapping mode on U of all the textures we are rendering to.
  26217. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26218. */
  26219. wrapU: number;
  26220. /**
  26221. * Set the wrapping mode on V of all the textures we are rendering to.
  26222. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26223. */
  26224. wrapV: number;
  26225. /**
  26226. * Instantiate a new multi render target texture.
  26227. * A multi render target, like a render target provides the ability to render to a texture.
  26228. * Unlike the render target, it can render to several draw buffers in one draw.
  26229. * This is specially interesting in deferred rendering or for any effects requiring more than
  26230. * just one color from a single pass.
  26231. * @param name Define the name of the texture
  26232. * @param size Define the size of the buffers to render to
  26233. * @param count Define the number of target we are rendering into
  26234. * @param scene Define the scene the texture belongs to
  26235. * @param options Define the options used to create the multi render target
  26236. */
  26237. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  26238. /** @hidden */
  26239. _rebuild(): void;
  26240. private _createInternalTextures;
  26241. private _createTextures;
  26242. /**
  26243. * Define the number of samples used if MSAA is enabled.
  26244. */
  26245. samples: number;
  26246. /**
  26247. * Resize all the textures in the multi render target.
  26248. * Be carrefull as it will recreate all the data in the new texture.
  26249. * @param size Define the new size
  26250. */
  26251. resize(size: any): void;
  26252. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  26253. /**
  26254. * Dispose the render targets and their associated resources
  26255. */
  26256. dispose(): void;
  26257. /**
  26258. * Release all the underlying texture used as draw buffers.
  26259. */
  26260. releaseInternalTextures(): void;
  26261. }
  26262. }
  26263. declare module BABYLON {
  26264. /**
  26265. * Class used to work with sound analyzer using fast fourier transform (FFT)
  26266. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26267. */
  26268. export class Analyser {
  26269. /**
  26270. * Gets or sets the smoothing
  26271. * @ignorenaming
  26272. */
  26273. SMOOTHING: number;
  26274. /**
  26275. * Gets or sets the FFT table size
  26276. * @ignorenaming
  26277. */
  26278. FFT_SIZE: number;
  26279. /**
  26280. * Gets or sets the bar graph amplitude
  26281. * @ignorenaming
  26282. */
  26283. BARGRAPHAMPLITUDE: number;
  26284. /**
  26285. * Gets or sets the position of the debug canvas
  26286. * @ignorenaming
  26287. */
  26288. DEBUGCANVASPOS: {
  26289. x: number;
  26290. y: number;
  26291. };
  26292. /**
  26293. * Gets or sets the debug canvas size
  26294. * @ignorenaming
  26295. */
  26296. DEBUGCANVASSIZE: {
  26297. width: number;
  26298. height: number;
  26299. };
  26300. private _byteFreqs;
  26301. private _byteTime;
  26302. private _floatFreqs;
  26303. private _webAudioAnalyser;
  26304. private _debugCanvas;
  26305. private _debugCanvasContext;
  26306. private _scene;
  26307. private _registerFunc;
  26308. private _audioEngine;
  26309. /**
  26310. * Creates a new analyser
  26311. * @param scene defines hosting scene
  26312. */
  26313. constructor(scene: Scene);
  26314. /**
  26315. * Get the number of data values you will have to play with for the visualization
  26316. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  26317. * @returns a number
  26318. */
  26319. getFrequencyBinCount(): number;
  26320. /**
  26321. * Gets the current frequency data as a byte array
  26322. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26323. * @returns a Uint8Array
  26324. */
  26325. getByteFrequencyData(): Uint8Array;
  26326. /**
  26327. * Gets the current waveform as a byte array
  26328. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  26329. * @returns a Uint8Array
  26330. */
  26331. getByteTimeDomainData(): Uint8Array;
  26332. /**
  26333. * Gets the current frequency data as a float array
  26334. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26335. * @returns a Float32Array
  26336. */
  26337. getFloatFrequencyData(): Float32Array;
  26338. /**
  26339. * Renders the debug canvas
  26340. */
  26341. drawDebugCanvas(): void;
  26342. /**
  26343. * Stops rendering the debug canvas and removes it
  26344. */
  26345. stopDebugCanvas(): void;
  26346. /**
  26347. * Connects two audio nodes
  26348. * @param inputAudioNode defines first node to connect
  26349. * @param outputAudioNode defines second node to connect
  26350. */
  26351. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  26352. /**
  26353. * Releases all associated resources
  26354. */
  26355. dispose(): void;
  26356. }
  26357. }
  26358. declare module BABYLON {
  26359. /**
  26360. * This represents an audio engine and it is responsible
  26361. * to play, synchronize and analyse sounds throughout the application.
  26362. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26363. */
  26364. export interface IAudioEngine extends IDisposable {
  26365. /**
  26366. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26367. */
  26368. readonly canUseWebAudio: boolean;
  26369. /**
  26370. * Gets the current AudioContext if available.
  26371. */
  26372. readonly audioContext: Nullable<AudioContext>;
  26373. /**
  26374. * The master gain node defines the global audio volume of your audio engine.
  26375. */
  26376. readonly masterGain: GainNode;
  26377. /**
  26378. * Gets whether or not mp3 are supported by your browser.
  26379. */
  26380. readonly isMP3supported: boolean;
  26381. /**
  26382. * Gets whether or not ogg are supported by your browser.
  26383. */
  26384. readonly isOGGsupported: boolean;
  26385. /**
  26386. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26387. * @ignoreNaming
  26388. */
  26389. WarnedWebAudioUnsupported: boolean;
  26390. /**
  26391. * Defines if the audio engine relies on a custom unlocked button.
  26392. * In this case, the embedded button will not be displayed.
  26393. */
  26394. useCustomUnlockedButton: boolean;
  26395. /**
  26396. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  26397. */
  26398. readonly unlocked: boolean;
  26399. /**
  26400. * Event raised when audio has been unlocked on the browser.
  26401. */
  26402. onAudioUnlockedObservable: Observable<AudioEngine>;
  26403. /**
  26404. * Event raised when audio has been locked on the browser.
  26405. */
  26406. onAudioLockedObservable: Observable<AudioEngine>;
  26407. /**
  26408. * Flags the audio engine in Locked state.
  26409. * This happens due to new browser policies preventing audio to autoplay.
  26410. */
  26411. lock(): void;
  26412. /**
  26413. * Unlocks the audio engine once a user action has been done on the dom.
  26414. * This is helpful to resume play once browser policies have been satisfied.
  26415. */
  26416. unlock(): void;
  26417. }
  26418. /**
  26419. * This represents the default audio engine used in babylon.
  26420. * It is responsible to play, synchronize and analyse sounds throughout the application.
  26421. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26422. */
  26423. export class AudioEngine implements IAudioEngine {
  26424. private _audioContext;
  26425. private _audioContextInitialized;
  26426. private _muteButton;
  26427. private _hostElement;
  26428. /**
  26429. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26430. */
  26431. canUseWebAudio: boolean;
  26432. /**
  26433. * The master gain node defines the global audio volume of your audio engine.
  26434. */
  26435. masterGain: GainNode;
  26436. /**
  26437. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26438. * @ignoreNaming
  26439. */
  26440. WarnedWebAudioUnsupported: boolean;
  26441. /**
  26442. * Gets whether or not mp3 are supported by your browser.
  26443. */
  26444. isMP3supported: boolean;
  26445. /**
  26446. * Gets whether or not ogg are supported by your browser.
  26447. */
  26448. isOGGsupported: boolean;
  26449. /**
  26450. * Gets whether audio has been unlocked on the device.
  26451. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  26452. * a user interaction has happened.
  26453. */
  26454. unlocked: boolean;
  26455. /**
  26456. * Defines if the audio engine relies on a custom unlocked button.
  26457. * In this case, the embedded button will not be displayed.
  26458. */
  26459. useCustomUnlockedButton: boolean;
  26460. /**
  26461. * Event raised when audio has been unlocked on the browser.
  26462. */
  26463. onAudioUnlockedObservable: Observable<AudioEngine>;
  26464. /**
  26465. * Event raised when audio has been locked on the browser.
  26466. */
  26467. onAudioLockedObservable: Observable<AudioEngine>;
  26468. /**
  26469. * Gets the current AudioContext if available.
  26470. */
  26471. readonly audioContext: Nullable<AudioContext>;
  26472. private _connectedAnalyser;
  26473. /**
  26474. * Instantiates a new audio engine.
  26475. *
  26476. * There should be only one per page as some browsers restrict the number
  26477. * of audio contexts you can create.
  26478. * @param hostElement defines the host element where to display the mute icon if necessary
  26479. */
  26480. constructor(hostElement?: Nullable<HTMLElement>);
  26481. /**
  26482. * Flags the audio engine in Locked state.
  26483. * This happens due to new browser policies preventing audio to autoplay.
  26484. */
  26485. lock(): void;
  26486. /**
  26487. * Unlocks the audio engine once a user action has been done on the dom.
  26488. * This is helpful to resume play once browser policies have been satisfied.
  26489. */
  26490. unlock(): void;
  26491. private _resumeAudioContext;
  26492. private _initializeAudioContext;
  26493. private _tryToRun;
  26494. private _triggerRunningState;
  26495. private _triggerSuspendedState;
  26496. private _displayMuteButton;
  26497. private _moveButtonToTopLeft;
  26498. private _onResize;
  26499. private _hideMuteButton;
  26500. /**
  26501. * Destroy and release the resources associated with the audio ccontext.
  26502. */
  26503. dispose(): void;
  26504. /**
  26505. * Gets the global volume sets on the master gain.
  26506. * @returns the global volume if set or -1 otherwise
  26507. */
  26508. getGlobalVolume(): number;
  26509. /**
  26510. * Sets the global volume of your experience (sets on the master gain).
  26511. * @param newVolume Defines the new global volume of the application
  26512. */
  26513. setGlobalVolume(newVolume: number): void;
  26514. /**
  26515. * Connect the audio engine to an audio analyser allowing some amazing
  26516. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  26517. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  26518. * @param analyser The analyser to connect to the engine
  26519. */
  26520. connectToAnalyser(analyser: Analyser): void;
  26521. }
  26522. }
  26523. declare module BABYLON {
  26524. /**
  26525. * Interface used to present a loading screen while loading a scene
  26526. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26527. */
  26528. export interface ILoadingScreen {
  26529. /**
  26530. * Function called to display the loading screen
  26531. */
  26532. displayLoadingUI: () => void;
  26533. /**
  26534. * Function called to hide the loading screen
  26535. */
  26536. hideLoadingUI: () => void;
  26537. /**
  26538. * Gets or sets the color to use for the background
  26539. */
  26540. loadingUIBackgroundColor: string;
  26541. /**
  26542. * Gets or sets the text to display while loading
  26543. */
  26544. loadingUIText: string;
  26545. }
  26546. /**
  26547. * Class used for the default loading screen
  26548. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26549. */
  26550. export class DefaultLoadingScreen implements ILoadingScreen {
  26551. private _renderingCanvas;
  26552. private _loadingText;
  26553. private _loadingDivBackgroundColor;
  26554. private _loadingDiv;
  26555. private _loadingTextDiv;
  26556. /**
  26557. * Creates a new default loading screen
  26558. * @param _renderingCanvas defines the canvas used to render the scene
  26559. * @param _loadingText defines the default text to display
  26560. * @param _loadingDivBackgroundColor defines the default background color
  26561. */
  26562. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  26563. /**
  26564. * Function called to display the loading screen
  26565. */
  26566. displayLoadingUI(): void;
  26567. /**
  26568. * Function called to hide the loading screen
  26569. */
  26570. hideLoadingUI(): void;
  26571. /**
  26572. * Gets or sets the text to display while loading
  26573. */
  26574. loadingUIText: string;
  26575. /**
  26576. * Gets or sets the color to use for the background
  26577. */
  26578. loadingUIBackgroundColor: string;
  26579. private _resizeLoadingUI;
  26580. }
  26581. }
  26582. declare module BABYLON {
  26583. /**
  26584. * Settings for finer control over video usage
  26585. */
  26586. export interface VideoTextureSettings {
  26587. /**
  26588. * Applies `autoplay` to video, if specified
  26589. */
  26590. autoPlay?: boolean;
  26591. /**
  26592. * Applies `loop` to video, if specified
  26593. */
  26594. loop?: boolean;
  26595. /**
  26596. * Automatically updates internal texture from video at every frame in the render loop
  26597. */
  26598. autoUpdateTexture: boolean;
  26599. /**
  26600. * Image src displayed during the video loading or until the user interacts with the video.
  26601. */
  26602. poster?: string;
  26603. }
  26604. /**
  26605. * If you want to display a video in your scene, this is the special texture for that.
  26606. * This special texture works similar to other textures, with the exception of a few parameters.
  26607. * @see https://doc.babylonjs.com/how_to/video_texture
  26608. */
  26609. export class VideoTexture extends Texture {
  26610. /**
  26611. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  26612. */
  26613. readonly autoUpdateTexture: boolean;
  26614. /**
  26615. * The video instance used by the texture internally
  26616. */
  26617. readonly video: HTMLVideoElement;
  26618. private _onUserActionRequestedObservable;
  26619. /**
  26620. * Event triggerd when a dom action is required by the user to play the video.
  26621. * This happens due to recent changes in browser policies preventing video to auto start.
  26622. */
  26623. readonly onUserActionRequestedObservable: Observable<Texture>;
  26624. private _generateMipMaps;
  26625. private _engine;
  26626. private _stillImageCaptured;
  26627. private _displayingPosterTexture;
  26628. private _settings;
  26629. private _createInternalTextureOnEvent;
  26630. /**
  26631. * Creates a video texture.
  26632. * If you want to display a video in your scene, this is the special texture for that.
  26633. * This special texture works similar to other textures, with the exception of a few parameters.
  26634. * @see https://doc.babylonjs.com/how_to/video_texture
  26635. * @param name optional name, will detect from video source, if not defined
  26636. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  26637. * @param scene is obviously the current scene.
  26638. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  26639. * @param invertY is false by default but can be used to invert video on Y axis
  26640. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  26641. * @param settings allows finer control over video usage
  26642. */
  26643. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  26644. private _getName;
  26645. private _getVideo;
  26646. private _createInternalTexture;
  26647. private reset;
  26648. /**
  26649. * @hidden Internal method to initiate `update`.
  26650. */
  26651. _rebuild(): void;
  26652. /**
  26653. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  26654. */
  26655. update(): void;
  26656. /**
  26657. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  26658. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  26659. */
  26660. updateTexture(isVisible: boolean): void;
  26661. protected _updateInternalTexture: () => void;
  26662. /**
  26663. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  26664. * @param url New url.
  26665. */
  26666. updateURL(url: string): void;
  26667. /**
  26668. * Dispose the texture and release its associated resources.
  26669. */
  26670. dispose(): void;
  26671. /**
  26672. * Creates a video texture straight from a stream.
  26673. * @param scene Define the scene the texture should be created in
  26674. * @param stream Define the stream the texture should be created from
  26675. * @returns The created video texture as a promise
  26676. */
  26677. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  26678. /**
  26679. * Creates a video texture straight from your WebCam video feed.
  26680. * @param scene Define the scene the texture should be created in
  26681. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26682. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  26683. * @returns The created video texture as a promise
  26684. */
  26685. static CreateFromWebCamAsync(scene: Scene, constraints: {
  26686. minWidth: number;
  26687. maxWidth: number;
  26688. minHeight: number;
  26689. maxHeight: number;
  26690. deviceId: string;
  26691. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  26692. /**
  26693. * Creates a video texture straight from your WebCam video feed.
  26694. * @param scene Define the scene the texture should be created in
  26695. * @param onReady Define a callback to triggered once the texture will be ready
  26696. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26697. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  26698. */
  26699. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  26700. minWidth: number;
  26701. maxWidth: number;
  26702. minHeight: number;
  26703. maxHeight: number;
  26704. deviceId: string;
  26705. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  26706. }
  26707. }
  26708. declare module BABYLON {
  26709. /**
  26710. * Interface for attribute information associated with buffer instanciation
  26711. */
  26712. export class InstancingAttributeInfo {
  26713. /**
  26714. * Index/offset of the attribute in the vertex shader
  26715. */
  26716. index: number;
  26717. /**
  26718. * size of the attribute, 1, 2, 3 or 4
  26719. */
  26720. attributeSize: number;
  26721. /**
  26722. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  26723. * default is FLOAT
  26724. */
  26725. attribyteType: number;
  26726. /**
  26727. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  26728. */
  26729. normalized: boolean;
  26730. /**
  26731. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  26732. */
  26733. offset: number;
  26734. /**
  26735. * Name of the GLSL attribute, for debugging purpose only
  26736. */
  26737. attributeName: string;
  26738. }
  26739. /**
  26740. * Define options used to create a depth texture
  26741. */
  26742. export class DepthTextureCreationOptions {
  26743. /** Specifies whether or not a stencil should be allocated in the texture */
  26744. generateStencil?: boolean;
  26745. /** Specifies whether or not bilinear filtering is enable on the texture */
  26746. bilinearFiltering?: boolean;
  26747. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  26748. comparisonFunction?: number;
  26749. /** Specifies if the created texture is a cube texture */
  26750. isCube?: boolean;
  26751. }
  26752. /**
  26753. * Class used to describe the capabilities of the engine relatively to the current browser
  26754. */
  26755. export class EngineCapabilities {
  26756. /** Maximum textures units per fragment shader */
  26757. maxTexturesImageUnits: number;
  26758. /** Maximum texture units per vertex shader */
  26759. maxVertexTextureImageUnits: number;
  26760. /** Maximum textures units in the entire pipeline */
  26761. maxCombinedTexturesImageUnits: number;
  26762. /** Maximum texture size */
  26763. maxTextureSize: number;
  26764. /** Maximum cube texture size */
  26765. maxCubemapTextureSize: number;
  26766. /** Maximum render texture size */
  26767. maxRenderTextureSize: number;
  26768. /** Maximum number of vertex attributes */
  26769. maxVertexAttribs: number;
  26770. /** Maximum number of varyings */
  26771. maxVaryingVectors: number;
  26772. /** Maximum number of uniforms per vertex shader */
  26773. maxVertexUniformVectors: number;
  26774. /** Maximum number of uniforms per fragment shader */
  26775. maxFragmentUniformVectors: number;
  26776. /** Defines if standard derivates (dx/dy) are supported */
  26777. standardDerivatives: boolean;
  26778. /** Defines if s3tc texture compression is supported */
  26779. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  26780. /** Defines if pvrtc texture compression is supported */
  26781. pvrtc: any;
  26782. /** Defines if etc1 texture compression is supported */
  26783. etc1: any;
  26784. /** Defines if etc2 texture compression is supported */
  26785. etc2: any;
  26786. /** Defines if astc texture compression is supported */
  26787. astc: any;
  26788. /** Defines if float textures are supported */
  26789. textureFloat: boolean;
  26790. /** Defines if vertex array objects are supported */
  26791. vertexArrayObject: boolean;
  26792. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  26793. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  26794. /** Gets the maximum level of anisotropy supported */
  26795. maxAnisotropy: number;
  26796. /** Defines if instancing is supported */
  26797. instancedArrays: boolean;
  26798. /** Defines if 32 bits indices are supported */
  26799. uintIndices: boolean;
  26800. /** Defines if high precision shaders are supported */
  26801. highPrecisionShaderSupported: boolean;
  26802. /** Defines if depth reading in the fragment shader is supported */
  26803. fragmentDepthSupported: boolean;
  26804. /** Defines if float texture linear filtering is supported*/
  26805. textureFloatLinearFiltering: boolean;
  26806. /** Defines if rendering to float textures is supported */
  26807. textureFloatRender: boolean;
  26808. /** Defines if half float textures are supported*/
  26809. textureHalfFloat: boolean;
  26810. /** Defines if half float texture linear filtering is supported*/
  26811. textureHalfFloatLinearFiltering: boolean;
  26812. /** Defines if rendering to half float textures is supported */
  26813. textureHalfFloatRender: boolean;
  26814. /** Defines if textureLOD shader command is supported */
  26815. textureLOD: boolean;
  26816. /** Defines if draw buffers extension is supported */
  26817. drawBuffersExtension: boolean;
  26818. /** Defines if depth textures are supported */
  26819. depthTextureExtension: boolean;
  26820. /** Defines if float color buffer are supported */
  26821. colorBufferFloat: boolean;
  26822. /** Gets disjoint timer query extension (null if not supported) */
  26823. timerQuery: EXT_disjoint_timer_query;
  26824. /** Defines if timestamp can be used with timer query */
  26825. canUseTimestampForTimerQuery: boolean;
  26826. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  26827. multiview: any;
  26828. /** Function used to let the system compiles shaders in background */
  26829. parallelShaderCompile: {
  26830. COMPLETION_STATUS_KHR: number;
  26831. };
  26832. }
  26833. /** Interface defining initialization parameters for Engine class */
  26834. export interface EngineOptions extends WebGLContextAttributes {
  26835. /**
  26836. * Defines if the engine should no exceed a specified device ratio
  26837. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  26838. */
  26839. limitDeviceRatio?: number;
  26840. /**
  26841. * Defines if webvr should be enabled automatically
  26842. * @see http://doc.babylonjs.com/how_to/webvr_camera
  26843. */
  26844. autoEnableWebVR?: boolean;
  26845. /**
  26846. * Defines if webgl2 should be turned off even if supported
  26847. * @see http://doc.babylonjs.com/features/webgl2
  26848. */
  26849. disableWebGL2Support?: boolean;
  26850. /**
  26851. * Defines if webaudio should be initialized as well
  26852. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26853. */
  26854. audioEngine?: boolean;
  26855. /**
  26856. * Defines if animations should run using a deterministic lock step
  26857. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  26858. */
  26859. deterministicLockstep?: boolean;
  26860. /** Defines the maximum steps to use with deterministic lock step mode */
  26861. lockstepMaxSteps?: number;
  26862. /**
  26863. * Defines that engine should ignore context lost events
  26864. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  26865. */
  26866. doNotHandleContextLost?: boolean;
  26867. /**
  26868. * Defines that engine should ignore modifying touch action attribute and style
  26869. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  26870. */
  26871. doNotHandleTouchAction?: boolean;
  26872. /**
  26873. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  26874. */
  26875. useHighPrecisionFloats?: boolean;
  26876. }
  26877. /**
  26878. * Defines the interface used by display changed events
  26879. */
  26880. export interface IDisplayChangedEventArgs {
  26881. /** Gets the vrDisplay object (if any) */
  26882. vrDisplay: Nullable<any>;
  26883. /** Gets a boolean indicating if webVR is supported */
  26884. vrSupported: boolean;
  26885. }
  26886. /**
  26887. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  26888. */
  26889. export class Engine {
  26890. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  26891. static ExceptionList: ({
  26892. key: string;
  26893. capture: string;
  26894. captureConstraint: number;
  26895. targets: string[];
  26896. } | {
  26897. key: string;
  26898. capture: null;
  26899. captureConstraint: null;
  26900. targets: string[];
  26901. })[];
  26902. /** Gets the list of created engines */
  26903. static readonly Instances: Engine[];
  26904. /**
  26905. * Gets the latest created engine
  26906. */
  26907. static readonly LastCreatedEngine: Nullable<Engine>;
  26908. /**
  26909. * Gets the latest created scene
  26910. */
  26911. static readonly LastCreatedScene: Nullable<Scene>;
  26912. /**
  26913. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  26914. * @param flag defines which part of the materials must be marked as dirty
  26915. * @param predicate defines a predicate used to filter which materials should be affected
  26916. */
  26917. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  26918. /**
  26919. * Hidden
  26920. */
  26921. static _TextureLoaders: IInternalTextureLoader[];
  26922. /** Defines that alpha blending is disabled */
  26923. static readonly ALPHA_DISABLE: number;
  26924. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  26925. static readonly ALPHA_ADD: number;
  26926. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  26927. static readonly ALPHA_COMBINE: number;
  26928. /** Defines that alpha blending to DEST - SRC * DEST */
  26929. static readonly ALPHA_SUBTRACT: number;
  26930. /** Defines that alpha blending to SRC * DEST */
  26931. static readonly ALPHA_MULTIPLY: number;
  26932. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  26933. static readonly ALPHA_MAXIMIZED: number;
  26934. /** Defines that alpha blending to SRC + DEST */
  26935. static readonly ALPHA_ONEONE: number;
  26936. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  26937. static readonly ALPHA_PREMULTIPLIED: number;
  26938. /**
  26939. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  26940. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  26941. */
  26942. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  26943. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  26944. static readonly ALPHA_INTERPOLATE: number;
  26945. /**
  26946. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  26947. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  26948. */
  26949. static readonly ALPHA_SCREENMODE: number;
  26950. /** Defines that the ressource is not delayed*/
  26951. static readonly DELAYLOADSTATE_NONE: number;
  26952. /** Defines that the ressource was successfully delay loaded */
  26953. static readonly DELAYLOADSTATE_LOADED: number;
  26954. /** Defines that the ressource is currently delay loading */
  26955. static readonly DELAYLOADSTATE_LOADING: number;
  26956. /** Defines that the ressource is delayed and has not started loading */
  26957. static readonly DELAYLOADSTATE_NOTLOADED: number;
  26958. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  26959. static readonly NEVER: number;
  26960. /** 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 */
  26961. static readonly ALWAYS: number;
  26962. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  26963. static readonly LESS: number;
  26964. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  26965. static readonly EQUAL: number;
  26966. /** 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 */
  26967. static readonly LEQUAL: number;
  26968. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  26969. static readonly GREATER: number;
  26970. /** 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 */
  26971. static readonly GEQUAL: number;
  26972. /** 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 */
  26973. static readonly NOTEQUAL: number;
  26974. /** Passed to stencilOperation to specify that stencil value must be kept */
  26975. static readonly KEEP: number;
  26976. /** Passed to stencilOperation to specify that stencil value must be replaced */
  26977. static readonly REPLACE: number;
  26978. /** Passed to stencilOperation to specify that stencil value must be incremented */
  26979. static readonly INCR: number;
  26980. /** Passed to stencilOperation to specify that stencil value must be decremented */
  26981. static readonly DECR: number;
  26982. /** Passed to stencilOperation to specify that stencil value must be inverted */
  26983. static readonly INVERT: number;
  26984. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  26985. static readonly INCR_WRAP: number;
  26986. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  26987. static readonly DECR_WRAP: number;
  26988. /** Texture is not repeating outside of 0..1 UVs */
  26989. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  26990. /** Texture is repeating outside of 0..1 UVs */
  26991. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  26992. /** Texture is repeating and mirrored */
  26993. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  26994. /** ALPHA */
  26995. static readonly TEXTUREFORMAT_ALPHA: number;
  26996. /** LUMINANCE */
  26997. static readonly TEXTUREFORMAT_LUMINANCE: number;
  26998. /** LUMINANCE_ALPHA */
  26999. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  27000. /** RGB */
  27001. static readonly TEXTUREFORMAT_RGB: number;
  27002. /** RGBA */
  27003. static readonly TEXTUREFORMAT_RGBA: number;
  27004. /** RED */
  27005. static readonly TEXTUREFORMAT_RED: number;
  27006. /** RED (2nd reference) */
  27007. static readonly TEXTUREFORMAT_R: number;
  27008. /** RG */
  27009. static readonly TEXTUREFORMAT_RG: number;
  27010. /** RED_INTEGER */
  27011. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  27012. /** RED_INTEGER (2nd reference) */
  27013. static readonly TEXTUREFORMAT_R_INTEGER: number;
  27014. /** RG_INTEGER */
  27015. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  27016. /** RGB_INTEGER */
  27017. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  27018. /** RGBA_INTEGER */
  27019. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  27020. /** UNSIGNED_BYTE */
  27021. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  27022. /** UNSIGNED_BYTE (2nd reference) */
  27023. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  27024. /** FLOAT */
  27025. static readonly TEXTURETYPE_FLOAT: number;
  27026. /** HALF_FLOAT */
  27027. static readonly TEXTURETYPE_HALF_FLOAT: number;
  27028. /** BYTE */
  27029. static readonly TEXTURETYPE_BYTE: number;
  27030. /** SHORT */
  27031. static readonly TEXTURETYPE_SHORT: number;
  27032. /** UNSIGNED_SHORT */
  27033. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  27034. /** INT */
  27035. static readonly TEXTURETYPE_INT: number;
  27036. /** UNSIGNED_INT */
  27037. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  27038. /** UNSIGNED_SHORT_4_4_4_4 */
  27039. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  27040. /** UNSIGNED_SHORT_5_5_5_1 */
  27041. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  27042. /** UNSIGNED_SHORT_5_6_5 */
  27043. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  27044. /** UNSIGNED_INT_2_10_10_10_REV */
  27045. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  27046. /** UNSIGNED_INT_24_8 */
  27047. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  27048. /** UNSIGNED_INT_10F_11F_11F_REV */
  27049. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  27050. /** UNSIGNED_INT_5_9_9_9_REV */
  27051. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  27052. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  27053. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  27054. /** nearest is mag = nearest and min = nearest and mip = linear */
  27055. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  27056. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27057. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  27058. /** Trilinear is mag = linear and min = linear and mip = linear */
  27059. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  27060. /** nearest is mag = nearest and min = nearest and mip = linear */
  27061. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  27062. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27063. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  27064. /** Trilinear is mag = linear and min = linear and mip = linear */
  27065. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  27066. /** mag = nearest and min = nearest and mip = nearest */
  27067. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  27068. /** mag = nearest and min = linear and mip = nearest */
  27069. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  27070. /** mag = nearest and min = linear and mip = linear */
  27071. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  27072. /** mag = nearest and min = linear and mip = none */
  27073. static readonly TEXTURE_NEAREST_LINEAR: number;
  27074. /** mag = nearest and min = nearest and mip = none */
  27075. static readonly TEXTURE_NEAREST_NEAREST: number;
  27076. /** mag = linear and min = nearest and mip = nearest */
  27077. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  27078. /** mag = linear and min = nearest and mip = linear */
  27079. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  27080. /** mag = linear and min = linear and mip = none */
  27081. static readonly TEXTURE_LINEAR_LINEAR: number;
  27082. /** mag = linear and min = nearest and mip = none */
  27083. static readonly TEXTURE_LINEAR_NEAREST: number;
  27084. /** Explicit coordinates mode */
  27085. static readonly TEXTURE_EXPLICIT_MODE: number;
  27086. /** Spherical coordinates mode */
  27087. static readonly TEXTURE_SPHERICAL_MODE: number;
  27088. /** Planar coordinates mode */
  27089. static readonly TEXTURE_PLANAR_MODE: number;
  27090. /** Cubic coordinates mode */
  27091. static readonly TEXTURE_CUBIC_MODE: number;
  27092. /** Projection coordinates mode */
  27093. static readonly TEXTURE_PROJECTION_MODE: number;
  27094. /** Skybox coordinates mode */
  27095. static readonly TEXTURE_SKYBOX_MODE: number;
  27096. /** Inverse Cubic coordinates mode */
  27097. static readonly TEXTURE_INVCUBIC_MODE: number;
  27098. /** Equirectangular coordinates mode */
  27099. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  27100. /** Equirectangular Fixed coordinates mode */
  27101. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  27102. /** Equirectangular Fixed Mirrored coordinates mode */
  27103. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  27104. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  27105. static readonly SCALEMODE_FLOOR: number;
  27106. /** Defines that texture rescaling will look for the nearest power of 2 size */
  27107. static readonly SCALEMODE_NEAREST: number;
  27108. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  27109. static readonly SCALEMODE_CEILING: number;
  27110. /**
  27111. * Returns the current npm package of the sdk
  27112. */
  27113. static readonly NpmPackage: string;
  27114. /**
  27115. * Returns the current version of the framework
  27116. */
  27117. static readonly Version: string;
  27118. /**
  27119. * Returns a string describing the current engine
  27120. */
  27121. readonly description: string;
  27122. /**
  27123. * Gets or sets the epsilon value used by collision engine
  27124. */
  27125. static CollisionsEpsilon: number;
  27126. /**
  27127. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27128. */
  27129. static ShadersRepository: string;
  27130. /**
  27131. * Method called to create the default loading screen.
  27132. * This can be overriden in your own app.
  27133. * @param canvas The rendering canvas element
  27134. * @returns The loading screen
  27135. */
  27136. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  27137. /**
  27138. * Method called to create the default rescale post process on each engine.
  27139. */
  27140. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  27141. /**
  27142. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  27143. */
  27144. forcePOTTextures: boolean;
  27145. /**
  27146. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  27147. */
  27148. isFullscreen: boolean;
  27149. /**
  27150. * Gets a boolean indicating if the pointer is currently locked
  27151. */
  27152. isPointerLock: boolean;
  27153. /**
  27154. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  27155. */
  27156. cullBackFaces: boolean;
  27157. /**
  27158. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  27159. */
  27160. renderEvenInBackground: boolean;
  27161. /**
  27162. * Gets or sets a boolean indicating that cache can be kept between frames
  27163. */
  27164. preventCacheWipeBetweenFrames: boolean;
  27165. /**
  27166. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  27167. **/
  27168. enableOfflineSupport: boolean;
  27169. /**
  27170. * Gets or sets a boolean to enable/disable checking manifest if IndexedDB support is enabled (js will always consider the database is up to date)
  27171. **/
  27172. disableManifestCheck: boolean;
  27173. /**
  27174. * Gets the list of created scenes
  27175. */
  27176. scenes: Scene[];
  27177. /**
  27178. * Event raised when a new scene is created
  27179. */
  27180. onNewSceneAddedObservable: Observable<Scene>;
  27181. /**
  27182. * Gets the list of created postprocesses
  27183. */
  27184. postProcesses: PostProcess[];
  27185. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  27186. validateShaderPrograms: boolean;
  27187. /**
  27188. * Observable event triggered each time the rendering canvas is resized
  27189. */
  27190. onResizeObservable: Observable<Engine>;
  27191. /**
  27192. * Observable event triggered each time the canvas loses focus
  27193. */
  27194. onCanvasBlurObservable: Observable<Engine>;
  27195. /**
  27196. * Observable event triggered each time the canvas gains focus
  27197. */
  27198. onCanvasFocusObservable: Observable<Engine>;
  27199. /**
  27200. * Observable event triggered each time the canvas receives pointerout event
  27201. */
  27202. onCanvasPointerOutObservable: Observable<PointerEvent>;
  27203. /**
  27204. * Observable event triggered before each texture is initialized
  27205. */
  27206. onBeforeTextureInitObservable: Observable<Texture>;
  27207. private _vrDisplay;
  27208. private _vrSupported;
  27209. private _oldSize;
  27210. private _oldHardwareScaleFactor;
  27211. private _vrExclusivePointerMode;
  27212. private _webVRInitPromise;
  27213. /**
  27214. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  27215. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  27216. */
  27217. readonly isInVRExclusivePointerMode: boolean;
  27218. /**
  27219. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  27220. */
  27221. disableUniformBuffers: boolean;
  27222. /** @hidden */
  27223. _uniformBuffers: UniformBuffer[];
  27224. /**
  27225. * Gets a boolean indicating that the engine supports uniform buffers
  27226. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27227. */
  27228. readonly supportsUniformBuffers: boolean;
  27229. /**
  27230. * Observable raised when the engine begins a new frame
  27231. */
  27232. onBeginFrameObservable: Observable<Engine>;
  27233. /**
  27234. * If set, will be used to request the next animation frame for the render loop
  27235. */
  27236. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  27237. /**
  27238. * Observable raised when the engine ends the current frame
  27239. */
  27240. onEndFrameObservable: Observable<Engine>;
  27241. /**
  27242. * Observable raised when the engine is about to compile a shader
  27243. */
  27244. onBeforeShaderCompilationObservable: Observable<Engine>;
  27245. /**
  27246. * Observable raised when the engine has jsut compiled a shader
  27247. */
  27248. onAfterShaderCompilationObservable: Observable<Engine>;
  27249. /** @hidden */
  27250. _gl: WebGLRenderingContext;
  27251. private _renderingCanvas;
  27252. private _windowIsBackground;
  27253. private _webGLVersion;
  27254. protected _highPrecisionShadersAllowed: boolean;
  27255. /** @hidden */
  27256. readonly _shouldUseHighPrecisionShader: boolean;
  27257. /**
  27258. * Gets a boolean indicating that only power of 2 textures are supported
  27259. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  27260. */
  27261. readonly needPOTTextures: boolean;
  27262. /** @hidden */
  27263. _badOS: boolean;
  27264. /** @hidden */
  27265. _badDesktopOS: boolean;
  27266. /**
  27267. * Gets or sets a value indicating if we want to disable texture binding optimization.
  27268. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  27269. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  27270. */
  27271. disableTextureBindingOptimization: boolean;
  27272. /**
  27273. * Gets the audio engine
  27274. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27275. * @ignorenaming
  27276. */
  27277. static audioEngine: IAudioEngine;
  27278. /**
  27279. * Default AudioEngine factory responsible of creating the Audio Engine.
  27280. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  27281. */
  27282. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  27283. /**
  27284. * Default offline support factory responsible of creating a tool used to store data locally.
  27285. * By default, this will create a Database object if the workload has been embedded.
  27286. */
  27287. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  27288. private _onFocus;
  27289. private _onBlur;
  27290. private _onCanvasPointerOut;
  27291. private _onCanvasBlur;
  27292. private _onCanvasFocus;
  27293. private _onFullscreenChange;
  27294. private _onPointerLockChange;
  27295. private _onVRDisplayPointerRestricted;
  27296. private _onVRDisplayPointerUnrestricted;
  27297. private _onVrDisplayConnect;
  27298. private _onVrDisplayDisconnect;
  27299. private _onVrDisplayPresentChange;
  27300. /**
  27301. * Observable signaled when VR display mode changes
  27302. */
  27303. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  27304. /**
  27305. * Observable signaled when VR request present is complete
  27306. */
  27307. onVRRequestPresentComplete: Observable<boolean>;
  27308. /**
  27309. * Observable signaled when VR request present starts
  27310. */
  27311. onVRRequestPresentStart: Observable<Engine>;
  27312. private _hardwareScalingLevel;
  27313. /** @hidden */
  27314. protected _caps: EngineCapabilities;
  27315. private _pointerLockRequested;
  27316. private _isStencilEnable;
  27317. private _colorWrite;
  27318. private _loadingScreen;
  27319. /** @hidden */
  27320. _drawCalls: PerfCounter;
  27321. /** @hidden */
  27322. _textureCollisions: PerfCounter;
  27323. private _glVersion;
  27324. private _glRenderer;
  27325. private _glVendor;
  27326. private _videoTextureSupported;
  27327. private _renderingQueueLaunched;
  27328. private _activeRenderLoops;
  27329. private _deterministicLockstep;
  27330. private _lockstepMaxSteps;
  27331. /**
  27332. * Observable signaled when a context lost event is raised
  27333. */
  27334. onContextLostObservable: Observable<Engine>;
  27335. /**
  27336. * Observable signaled when a context restored event is raised
  27337. */
  27338. onContextRestoredObservable: Observable<Engine>;
  27339. private _onContextLost;
  27340. private _onContextRestored;
  27341. private _contextWasLost;
  27342. private _doNotHandleContextLost;
  27343. /**
  27344. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  27345. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  27346. */
  27347. doNotHandleContextLost: boolean;
  27348. private _performanceMonitor;
  27349. private _fps;
  27350. private _deltaTime;
  27351. /**
  27352. * Turn this value on if you want to pause FPS computation when in background
  27353. */
  27354. disablePerformanceMonitorInBackground: boolean;
  27355. /**
  27356. * Gets the performance monitor attached to this engine
  27357. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  27358. */
  27359. readonly performanceMonitor: PerformanceMonitor;
  27360. /** @hidden */
  27361. protected _depthCullingState: _DepthCullingState;
  27362. /** @hidden */
  27363. protected _stencilState: _StencilState;
  27364. /** @hidden */
  27365. protected _alphaState: _AlphaState;
  27366. /** @hidden */
  27367. protected _alphaMode: number;
  27368. protected _internalTexturesCache: InternalTexture[];
  27369. /** @hidden */
  27370. protected _activeChannel: number;
  27371. private _currentTextureChannel;
  27372. /** @hidden */
  27373. protected _boundTexturesCache: {
  27374. [key: string]: Nullable<InternalTexture>;
  27375. };
  27376. /** @hidden */
  27377. protected _currentEffect: Nullable<Effect>;
  27378. /** @hidden */
  27379. protected _currentProgram: Nullable<WebGLProgram>;
  27380. private _compiledEffects;
  27381. private _vertexAttribArraysEnabled;
  27382. /** @hidden */
  27383. protected _cachedViewport: Nullable<Viewport>;
  27384. private _cachedVertexArrayObject;
  27385. /** @hidden */
  27386. protected _cachedVertexBuffers: any;
  27387. /** @hidden */
  27388. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  27389. /** @hidden */
  27390. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  27391. /** @hidden */
  27392. protected _currentRenderTarget: Nullable<InternalTexture>;
  27393. private _uintIndicesCurrentlySet;
  27394. private _currentBoundBuffer;
  27395. /** @hidden */
  27396. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  27397. private _currentBufferPointers;
  27398. private _currentInstanceLocations;
  27399. private _currentInstanceBuffers;
  27400. private _textureUnits;
  27401. private _firstBoundInternalTextureTracker;
  27402. private _lastBoundInternalTextureTracker;
  27403. private _workingCanvas;
  27404. private _workingContext;
  27405. private _rescalePostProcess;
  27406. private _dummyFramebuffer;
  27407. private _externalData;
  27408. private _bindedRenderFunction;
  27409. private _vaoRecordInProgress;
  27410. private _mustWipeVertexAttributes;
  27411. private _emptyTexture;
  27412. private _emptyCubeTexture;
  27413. private _emptyTexture3D;
  27414. /** @hidden */
  27415. _frameHandler: number;
  27416. private _nextFreeTextureSlots;
  27417. private _maxSimultaneousTextures;
  27418. private _activeRequests;
  27419. private _texturesSupported;
  27420. private _textureFormatInUse;
  27421. /**
  27422. * Gets the list of texture formats supported
  27423. */
  27424. readonly texturesSupported: Array<string>;
  27425. /**
  27426. * Gets the list of texture formats in use
  27427. */
  27428. readonly textureFormatInUse: Nullable<string>;
  27429. /**
  27430. * Gets the current viewport
  27431. */
  27432. readonly currentViewport: Nullable<Viewport>;
  27433. /**
  27434. * Gets the default empty texture
  27435. */
  27436. readonly emptyTexture: InternalTexture;
  27437. /**
  27438. * Gets the default empty 3D texture
  27439. */
  27440. readonly emptyTexture3D: InternalTexture;
  27441. /**
  27442. * Gets the default empty cube texture
  27443. */
  27444. readonly emptyCubeTexture: InternalTexture;
  27445. /**
  27446. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  27447. */
  27448. readonly premultipliedAlpha: boolean;
  27449. /**
  27450. * Creates a new engine
  27451. * @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
  27452. * @param antialias defines enable antialiasing (default: false)
  27453. * @param options defines further options to be sent to the getContext() function
  27454. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  27455. */
  27456. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  27457. private _disableTouchAction;
  27458. private _rebuildInternalTextures;
  27459. private _rebuildEffects;
  27460. /**
  27461. * Gets a boolean indicating if all created effects are ready
  27462. * @returns true if all effects are ready
  27463. */
  27464. areAllEffectsReady(): boolean;
  27465. private _rebuildBuffers;
  27466. private _initGLContext;
  27467. /**
  27468. * Gets version of the current webGL context
  27469. */
  27470. readonly webGLVersion: number;
  27471. /**
  27472. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  27473. */
  27474. readonly isStencilEnable: boolean;
  27475. private _prepareWorkingCanvas;
  27476. /**
  27477. * Reset the texture cache to empty state
  27478. */
  27479. resetTextureCache(): void;
  27480. /**
  27481. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  27482. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27483. * @returns true if engine is in deterministic lock step mode
  27484. */
  27485. isDeterministicLockStep(): boolean;
  27486. /**
  27487. * Gets the max steps when engine is running in deterministic lock step
  27488. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27489. * @returns the max steps
  27490. */
  27491. getLockstepMaxSteps(): number;
  27492. /**
  27493. * Gets an object containing information about the current webGL context
  27494. * @returns an object containing the vender, the renderer and the version of the current webGL context
  27495. */
  27496. getGlInfo(): {
  27497. vendor: string;
  27498. renderer: string;
  27499. version: string;
  27500. };
  27501. /**
  27502. * Gets current aspect ratio
  27503. * @param camera defines the camera to use to get the aspect ratio
  27504. * @param useScreen defines if screen size must be used (or the current render target if any)
  27505. * @returns a number defining the aspect ratio
  27506. */
  27507. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  27508. /**
  27509. * Gets current screen aspect ratio
  27510. * @returns a number defining the aspect ratio
  27511. */
  27512. getScreenAspectRatio(): number;
  27513. /**
  27514. * Gets the current render width
  27515. * @param useScreen defines if screen size must be used (or the current render target if any)
  27516. * @returns a number defining the current render width
  27517. */
  27518. getRenderWidth(useScreen?: boolean): number;
  27519. /**
  27520. * Gets the current render height
  27521. * @param useScreen defines if screen size must be used (or the current render target if any)
  27522. * @returns a number defining the current render height
  27523. */
  27524. getRenderHeight(useScreen?: boolean): number;
  27525. /**
  27526. * Gets the HTML canvas attached with the current webGL context
  27527. * @returns a HTML canvas
  27528. */
  27529. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  27530. /**
  27531. * Gets the client rect of the HTML canvas attached with the current webGL context
  27532. * @returns a client rectanglee
  27533. */
  27534. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  27535. /**
  27536. * Defines the hardware scaling level.
  27537. * By default the hardware scaling level is computed from the window device ratio.
  27538. * 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.
  27539. * @param level defines the level to use
  27540. */
  27541. setHardwareScalingLevel(level: number): void;
  27542. /**
  27543. * Gets the current hardware scaling level.
  27544. * By default the hardware scaling level is computed from the window device ratio.
  27545. * 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.
  27546. * @returns a number indicating the current hardware scaling level
  27547. */
  27548. getHardwareScalingLevel(): number;
  27549. /**
  27550. * Gets the list of loaded textures
  27551. * @returns an array containing all loaded textures
  27552. */
  27553. getLoadedTexturesCache(): InternalTexture[];
  27554. /**
  27555. * Gets the object containing all engine capabilities
  27556. * @returns the EngineCapabilities object
  27557. */
  27558. getCaps(): EngineCapabilities;
  27559. /**
  27560. * Gets the current depth function
  27561. * @returns a number defining the depth function
  27562. */
  27563. getDepthFunction(): Nullable<number>;
  27564. /**
  27565. * Sets the current depth function
  27566. * @param depthFunc defines the function to use
  27567. */
  27568. setDepthFunction(depthFunc: number): void;
  27569. /**
  27570. * Sets the current depth function to GREATER
  27571. */
  27572. setDepthFunctionToGreater(): void;
  27573. /**
  27574. * Sets the current depth function to GEQUAL
  27575. */
  27576. setDepthFunctionToGreaterOrEqual(): void;
  27577. /**
  27578. * Sets the current depth function to LESS
  27579. */
  27580. setDepthFunctionToLess(): void;
  27581. private _cachedStencilBuffer;
  27582. private _cachedStencilFunction;
  27583. private _cachedStencilMask;
  27584. private _cachedStencilOperationPass;
  27585. private _cachedStencilOperationFail;
  27586. private _cachedStencilOperationDepthFail;
  27587. private _cachedStencilReference;
  27588. /**
  27589. * Caches the the state of the stencil buffer
  27590. */
  27591. cacheStencilState(): void;
  27592. /**
  27593. * Restores the state of the stencil buffer
  27594. */
  27595. restoreStencilState(): void;
  27596. /**
  27597. * Sets the current depth function to LEQUAL
  27598. */
  27599. setDepthFunctionToLessOrEqual(): void;
  27600. /**
  27601. * Gets a boolean indicating if stencil buffer is enabled
  27602. * @returns the current stencil buffer state
  27603. */
  27604. getStencilBuffer(): boolean;
  27605. /**
  27606. * Enable or disable the stencil buffer
  27607. * @param enable defines if the stencil buffer must be enabled or disabled
  27608. */
  27609. setStencilBuffer(enable: boolean): void;
  27610. /**
  27611. * Gets the current stencil mask
  27612. * @returns a number defining the new stencil mask to use
  27613. */
  27614. getStencilMask(): number;
  27615. /**
  27616. * Sets the current stencil mask
  27617. * @param mask defines the new stencil mask to use
  27618. */
  27619. setStencilMask(mask: number): void;
  27620. /**
  27621. * Gets the current stencil function
  27622. * @returns a number defining the stencil function to use
  27623. */
  27624. getStencilFunction(): number;
  27625. /**
  27626. * Gets the current stencil reference value
  27627. * @returns a number defining the stencil reference value to use
  27628. */
  27629. getStencilFunctionReference(): number;
  27630. /**
  27631. * Gets the current stencil mask
  27632. * @returns a number defining the stencil mask to use
  27633. */
  27634. getStencilFunctionMask(): number;
  27635. /**
  27636. * Sets the current stencil function
  27637. * @param stencilFunc defines the new stencil function to use
  27638. */
  27639. setStencilFunction(stencilFunc: number): void;
  27640. /**
  27641. * Sets the current stencil reference
  27642. * @param reference defines the new stencil reference to use
  27643. */
  27644. setStencilFunctionReference(reference: number): void;
  27645. /**
  27646. * Sets the current stencil mask
  27647. * @param mask defines the new stencil mask to use
  27648. */
  27649. setStencilFunctionMask(mask: number): void;
  27650. /**
  27651. * Gets the current stencil operation when stencil fails
  27652. * @returns a number defining stencil operation to use when stencil fails
  27653. */
  27654. getStencilOperationFail(): number;
  27655. /**
  27656. * Gets the current stencil operation when depth fails
  27657. * @returns a number defining stencil operation to use when depth fails
  27658. */
  27659. getStencilOperationDepthFail(): number;
  27660. /**
  27661. * Gets the current stencil operation when stencil passes
  27662. * @returns a number defining stencil operation to use when stencil passes
  27663. */
  27664. getStencilOperationPass(): number;
  27665. /**
  27666. * Sets the stencil operation to use when stencil fails
  27667. * @param operation defines the stencil operation to use when stencil fails
  27668. */
  27669. setStencilOperationFail(operation: number): void;
  27670. /**
  27671. * Sets the stencil operation to use when depth fails
  27672. * @param operation defines the stencil operation to use when depth fails
  27673. */
  27674. setStencilOperationDepthFail(operation: number): void;
  27675. /**
  27676. * Sets the stencil operation to use when stencil passes
  27677. * @param operation defines the stencil operation to use when stencil passes
  27678. */
  27679. setStencilOperationPass(operation: number): void;
  27680. /**
  27681. * Sets a boolean indicating if the dithering state is enabled or disabled
  27682. * @param value defines the dithering state
  27683. */
  27684. setDitheringState(value: boolean): void;
  27685. /**
  27686. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  27687. * @param value defines the rasterizer state
  27688. */
  27689. setRasterizerState(value: boolean): void;
  27690. /**
  27691. * stop executing a render loop function and remove it from the execution array
  27692. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  27693. */
  27694. stopRenderLoop(renderFunction?: () => void): void;
  27695. /** @hidden */
  27696. _renderLoop(): void;
  27697. /**
  27698. * Register and execute a render loop. The engine can have more than one render function
  27699. * @param renderFunction defines the function to continuously execute
  27700. */
  27701. runRenderLoop(renderFunction: () => void): void;
  27702. /**
  27703. * Toggle full screen mode
  27704. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27705. */
  27706. switchFullscreen(requestPointerLock: boolean): void;
  27707. /**
  27708. * Enters full screen mode
  27709. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27710. */
  27711. enterFullscreen(requestPointerLock: boolean): void;
  27712. /**
  27713. * Exits full screen mode
  27714. */
  27715. exitFullscreen(): void;
  27716. /**
  27717. * Clear the current render buffer or the current render target (if any is set up)
  27718. * @param color defines the color to use
  27719. * @param backBuffer defines if the back buffer must be cleared
  27720. * @param depth defines if the depth buffer must be cleared
  27721. * @param stencil defines if the stencil buffer must be cleared
  27722. */
  27723. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  27724. /**
  27725. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  27726. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27727. * @param y defines the y-coordinate of the corner of the clear rectangle
  27728. * @param width defines the width of the clear rectangle
  27729. * @param height defines the height of the clear rectangle
  27730. * @param clearColor defines the clear color
  27731. */
  27732. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  27733. /**
  27734. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  27735. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27736. * @param y defines the y-coordinate of the corner of the clear rectangle
  27737. * @param width defines the width of the clear rectangle
  27738. * @param height defines the height of the clear rectangle
  27739. */
  27740. enableScissor(x: number, y: number, width: number, height: number): void;
  27741. /**
  27742. * Disable previously set scissor test rectangle
  27743. */
  27744. disableScissor(): void;
  27745. private _viewportCached;
  27746. /** @hidden */
  27747. _viewport(x: number, y: number, width: number, height: number): void;
  27748. /**
  27749. * Set the WebGL's viewport
  27750. * @param viewport defines the viewport element to be used
  27751. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  27752. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  27753. */
  27754. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  27755. /**
  27756. * Directly set the WebGL Viewport
  27757. * @param x defines the x coordinate of the viewport (in screen space)
  27758. * @param y defines the y coordinate of the viewport (in screen space)
  27759. * @param width defines the width of the viewport (in screen space)
  27760. * @param height defines the height of the viewport (in screen space)
  27761. * @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
  27762. */
  27763. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  27764. /**
  27765. * Begin a new frame
  27766. */
  27767. beginFrame(): void;
  27768. /**
  27769. * Enf the current frame
  27770. */
  27771. endFrame(): void;
  27772. /**
  27773. * Resize the view according to the canvas' size
  27774. */
  27775. resize(): void;
  27776. /**
  27777. * Force a specific size of the canvas
  27778. * @param width defines the new canvas' width
  27779. * @param height defines the new canvas' height
  27780. */
  27781. setSize(width: number, height: number): void;
  27782. /**
  27783. * Gets a boolean indicating if a webVR device was detected
  27784. * @returns true if a webVR device was detected
  27785. */
  27786. isVRDevicePresent(): boolean;
  27787. /**
  27788. * Gets the current webVR device
  27789. * @returns the current webVR device (or null)
  27790. */
  27791. getVRDevice(): any;
  27792. /**
  27793. * Initializes a webVR display and starts listening to display change events
  27794. * The onVRDisplayChangedObservable will be notified upon these changes
  27795. * @returns The onVRDisplayChangedObservable
  27796. */
  27797. initWebVR(): Observable<IDisplayChangedEventArgs>;
  27798. /**
  27799. * Initializes a webVR display and starts listening to display change events
  27800. * The onVRDisplayChangedObservable will be notified upon these changes
  27801. * @returns A promise containing a VRDisplay and if vr is supported
  27802. */
  27803. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  27804. /**
  27805. * Call this function to switch to webVR mode
  27806. * Will do nothing if webVR is not supported or if there is no webVR device
  27807. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27808. */
  27809. enableVR(): void;
  27810. /**
  27811. * Call this function to leave webVR mode
  27812. * Will do nothing if webVR is not supported or if there is no webVR device
  27813. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27814. */
  27815. disableVR(): void;
  27816. private _onVRFullScreenTriggered;
  27817. private _getVRDisplaysAsync;
  27818. /**
  27819. * Binds the frame buffer to the specified texture.
  27820. * @param texture The texture to render to or null for the default canvas
  27821. * @param faceIndex The face of the texture to render to in case of cube texture
  27822. * @param requiredWidth The width of the target to render to
  27823. * @param requiredHeight The height of the target to render to
  27824. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  27825. * @param depthStencilTexture The depth stencil texture to use to render
  27826. * @param lodLevel defines le lod level to bind to the frame buffer
  27827. */
  27828. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  27829. private bindUnboundFramebuffer;
  27830. /**
  27831. * Unbind the current render target texture from the webGL context
  27832. * @param texture defines the render target texture to unbind
  27833. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  27834. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  27835. */
  27836. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  27837. /**
  27838. * Unbind a list of render target textures from the webGL context
  27839. * This is used only when drawBuffer extension or webGL2 are active
  27840. * @param textures defines the render target textures to unbind
  27841. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  27842. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  27843. */
  27844. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  27845. /**
  27846. * Force the mipmap generation for the given render target texture
  27847. * @param texture defines the render target texture to use
  27848. */
  27849. generateMipMapsForCubemap(texture: InternalTexture): void;
  27850. /**
  27851. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  27852. */
  27853. flushFramebuffer(): void;
  27854. /**
  27855. * Unbind the current render target and bind the default framebuffer
  27856. */
  27857. restoreDefaultFramebuffer(): void;
  27858. /**
  27859. * Create an uniform buffer
  27860. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27861. * @param elements defines the content of the uniform buffer
  27862. * @returns the webGL uniform buffer
  27863. */
  27864. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  27865. /**
  27866. * Create a dynamic uniform buffer
  27867. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27868. * @param elements defines the content of the uniform buffer
  27869. * @returns the webGL uniform buffer
  27870. */
  27871. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  27872. /**
  27873. * Update an existing uniform buffer
  27874. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27875. * @param uniformBuffer defines the target uniform buffer
  27876. * @param elements defines the content to update
  27877. * @param offset defines the offset in the uniform buffer where update should start
  27878. * @param count defines the size of the data to update
  27879. */
  27880. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  27881. private _resetVertexBufferBinding;
  27882. /**
  27883. * Creates a vertex buffer
  27884. * @param data the data for the vertex buffer
  27885. * @returns the new WebGL static buffer
  27886. */
  27887. createVertexBuffer(data: DataArray): WebGLBuffer;
  27888. /**
  27889. * Creates a dynamic vertex buffer
  27890. * @param data the data for the dynamic vertex buffer
  27891. * @returns the new WebGL dynamic buffer
  27892. */
  27893. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  27894. /**
  27895. * Update a dynamic index buffer
  27896. * @param indexBuffer defines the target index buffer
  27897. * @param indices defines the data to update
  27898. * @param offset defines the offset in the target index buffer where update should start
  27899. */
  27900. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  27901. /**
  27902. * Updates a dynamic vertex buffer.
  27903. * @param vertexBuffer the vertex buffer to update
  27904. * @param data the data used to update the vertex buffer
  27905. * @param byteOffset the byte offset of the data
  27906. * @param byteLength the byte length of the data
  27907. */
  27908. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  27909. private _resetIndexBufferBinding;
  27910. /**
  27911. * Creates a new index buffer
  27912. * @param indices defines the content of the index buffer
  27913. * @param updatable defines if the index buffer must be updatable
  27914. * @returns a new webGL buffer
  27915. */
  27916. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  27917. /**
  27918. * Bind a webGL buffer to the webGL context
  27919. * @param buffer defines the buffer to bind
  27920. */
  27921. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  27922. /**
  27923. * Bind an uniform buffer to the current webGL context
  27924. * @param buffer defines the buffer to bind
  27925. */
  27926. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  27927. /**
  27928. * Bind a buffer to the current webGL context at a given location
  27929. * @param buffer defines the buffer to bind
  27930. * @param location defines the index where to bind the buffer
  27931. */
  27932. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  27933. /**
  27934. * Bind a specific block at a given index in a specific shader program
  27935. * @param shaderProgram defines the shader program
  27936. * @param blockName defines the block name
  27937. * @param index defines the index where to bind the block
  27938. */
  27939. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  27940. private bindIndexBuffer;
  27941. private bindBuffer;
  27942. /**
  27943. * update the bound buffer with the given data
  27944. * @param data defines the data to update
  27945. */
  27946. updateArrayBuffer(data: Float32Array): void;
  27947. private _vertexAttribPointer;
  27948. private _bindIndexBufferWithCache;
  27949. private _bindVertexBuffersAttributes;
  27950. /**
  27951. * Records a vertex array object
  27952. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  27953. * @param vertexBuffers defines the list of vertex buffers to store
  27954. * @param indexBuffer defines the index buffer to store
  27955. * @param effect defines the effect to store
  27956. * @returns the new vertex array object
  27957. */
  27958. recordVertexArrayObject(vertexBuffers: {
  27959. [key: string]: VertexBuffer;
  27960. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  27961. /**
  27962. * Bind a specific vertex array object
  27963. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  27964. * @param vertexArrayObject defines the vertex array object to bind
  27965. * @param indexBuffer defines the index buffer to bind
  27966. */
  27967. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  27968. /**
  27969. * Bind webGl buffers directly to the webGL context
  27970. * @param vertexBuffer defines the vertex buffer to bind
  27971. * @param indexBuffer defines the index buffer to bind
  27972. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  27973. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  27974. * @param effect defines the effect associated with the vertex buffer
  27975. */
  27976. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  27977. private _unbindVertexArrayObject;
  27978. /**
  27979. * Bind a list of vertex buffers to the webGL context
  27980. * @param vertexBuffers defines the list of vertex buffers to bind
  27981. * @param indexBuffer defines the index buffer to bind
  27982. * @param effect defines the effect associated with the vertex buffers
  27983. */
  27984. bindBuffers(vertexBuffers: {
  27985. [key: string]: Nullable<VertexBuffer>;
  27986. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  27987. /**
  27988. * Unbind all instance attributes
  27989. */
  27990. unbindInstanceAttributes(): void;
  27991. /**
  27992. * Release and free the memory of a vertex array object
  27993. * @param vao defines the vertex array object to delete
  27994. */
  27995. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  27996. /** @hidden */
  27997. _releaseBuffer(buffer: WebGLBuffer): boolean;
  27998. /**
  27999. * Creates a webGL buffer to use with instanciation
  28000. * @param capacity defines the size of the buffer
  28001. * @returns the webGL buffer
  28002. */
  28003. createInstancesBuffer(capacity: number): WebGLBuffer;
  28004. /**
  28005. * Delete a webGL buffer used with instanciation
  28006. * @param buffer defines the webGL buffer to delete
  28007. */
  28008. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  28009. /**
  28010. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  28011. * @param instancesBuffer defines the webGL buffer to update and bind
  28012. * @param data defines the data to store in the buffer
  28013. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  28014. */
  28015. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  28016. /**
  28017. * Apply all cached states (depth, culling, stencil and alpha)
  28018. */
  28019. applyStates(): void;
  28020. /**
  28021. * Send a draw order
  28022. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28023. * @param indexStart defines the starting index
  28024. * @param indexCount defines the number of index to draw
  28025. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28026. */
  28027. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  28028. /**
  28029. * Draw a list of points
  28030. * @param verticesStart defines the index of first vertex to draw
  28031. * @param verticesCount defines the count of vertices to draw
  28032. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28033. */
  28034. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28035. /**
  28036. * Draw a list of unindexed primitives
  28037. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28038. * @param verticesStart defines the index of first vertex to draw
  28039. * @param verticesCount defines the count of vertices to draw
  28040. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28041. */
  28042. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28043. /**
  28044. * Draw a list of indexed primitives
  28045. * @param fillMode defines the primitive to use
  28046. * @param indexStart defines the starting index
  28047. * @param indexCount defines the number of index to draw
  28048. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28049. */
  28050. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  28051. /**
  28052. * Draw a list of unindexed primitives
  28053. * @param fillMode defines the primitive to use
  28054. * @param verticesStart defines the index of first vertex to draw
  28055. * @param verticesCount defines the count of vertices to draw
  28056. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28057. */
  28058. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28059. private _drawMode;
  28060. /** @hidden */
  28061. _releaseEffect(effect: Effect): void;
  28062. /** @hidden */
  28063. _deleteProgram(program: WebGLProgram): void;
  28064. /**
  28065. * Create a new effect (used to store vertex/fragment shaders)
  28066. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  28067. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  28068. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  28069. * @param samplers defines an array of string used to represent textures
  28070. * @param defines defines the string containing the defines to use to compile the shaders
  28071. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  28072. * @param onCompiled defines a function to call when the effect creation is successful
  28073. * @param onError defines a function to call when the effect creation has failed
  28074. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  28075. * @returns the new Effect
  28076. */
  28077. 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;
  28078. private _compileShader;
  28079. private _compileRawShader;
  28080. /**
  28081. * Directly creates a webGL program
  28082. * @param vertexCode defines the vertex shader code to use
  28083. * @param fragmentCode defines the fragment shader code to use
  28084. * @param context defines the webGL context to use (if not set, the current one will be used)
  28085. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28086. * @returns the new webGL program
  28087. */
  28088. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28089. /**
  28090. * Creates a webGL program
  28091. * @param vertexCode defines the vertex shader code to use
  28092. * @param fragmentCode defines the fragment shader code to use
  28093. * @param defines defines the string containing the defines to use to compile the shaders
  28094. * @param context defines the webGL context to use (if not set, the current one will be used)
  28095. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28096. * @returns the new webGL program
  28097. */
  28098. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28099. private _createShaderProgram;
  28100. private _finalizeProgram;
  28101. /** @hidden */
  28102. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  28103. /** @hidden */
  28104. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  28105. /**
  28106. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  28107. * @param shaderProgram defines the webGL program to use
  28108. * @param uniformsNames defines the list of uniform names
  28109. * @returns an array of webGL uniform locations
  28110. */
  28111. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  28112. /**
  28113. * Gets the lsit of active attributes for a given webGL program
  28114. * @param shaderProgram defines the webGL program to use
  28115. * @param attributesNames defines the list of attribute names to get
  28116. * @returns an array of indices indicating the offset of each attribute
  28117. */
  28118. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  28119. /**
  28120. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  28121. * @param effect defines the effect to activate
  28122. */
  28123. enableEffect(effect: Nullable<Effect>): void;
  28124. /**
  28125. * Set the value of an uniform to an array of int32
  28126. * @param uniform defines the webGL uniform location where to store the value
  28127. * @param array defines the array of int32 to store
  28128. */
  28129. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28130. /**
  28131. * Set the value of an uniform to an array of int32 (stored as vec2)
  28132. * @param uniform defines the webGL uniform location where to store the value
  28133. * @param array defines the array of int32 to store
  28134. */
  28135. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28136. /**
  28137. * Set the value of an uniform to an array of int32 (stored as vec3)
  28138. * @param uniform defines the webGL uniform location where to store the value
  28139. * @param array defines the array of int32 to store
  28140. */
  28141. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28142. /**
  28143. * Set the value of an uniform to an array of int32 (stored as vec4)
  28144. * @param uniform defines the webGL uniform location where to store the value
  28145. * @param array defines the array of int32 to store
  28146. */
  28147. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28148. /**
  28149. * Set the value of an uniform to an array of float32
  28150. * @param uniform defines the webGL uniform location where to store the value
  28151. * @param array defines the array of float32 to store
  28152. */
  28153. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28154. /**
  28155. * Set the value of an uniform to an array of float32 (stored as vec2)
  28156. * @param uniform defines the webGL uniform location where to store the value
  28157. * @param array defines the array of float32 to store
  28158. */
  28159. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28160. /**
  28161. * Set the value of an uniform to an array of float32 (stored as vec3)
  28162. * @param uniform defines the webGL uniform location where to store the value
  28163. * @param array defines the array of float32 to store
  28164. */
  28165. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28166. /**
  28167. * Set the value of an uniform to an array of float32 (stored as vec4)
  28168. * @param uniform defines the webGL uniform location where to store the value
  28169. * @param array defines the array of float32 to store
  28170. */
  28171. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28172. /**
  28173. * Set the value of an uniform to an array of number
  28174. * @param uniform defines the webGL uniform location where to store the value
  28175. * @param array defines the array of number to store
  28176. */
  28177. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28178. /**
  28179. * Set the value of an uniform to an array of number (stored as vec2)
  28180. * @param uniform defines the webGL uniform location where to store the value
  28181. * @param array defines the array of number to store
  28182. */
  28183. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28184. /**
  28185. * Set the value of an uniform to an array of number (stored as vec3)
  28186. * @param uniform defines the webGL uniform location where to store the value
  28187. * @param array defines the array of number to store
  28188. */
  28189. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28190. /**
  28191. * Set the value of an uniform to an array of number (stored as vec4)
  28192. * @param uniform defines the webGL uniform location where to store the value
  28193. * @param array defines the array of number to store
  28194. */
  28195. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28196. /**
  28197. * Set the value of an uniform to an array of float32 (stored as matrices)
  28198. * @param uniform defines the webGL uniform location where to store the value
  28199. * @param matrices defines the array of float32 to store
  28200. */
  28201. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  28202. /**
  28203. * Set the value of an uniform to a matrix
  28204. * @param uniform defines the webGL uniform location where to store the value
  28205. * @param matrix defines the matrix to store
  28206. */
  28207. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  28208. /**
  28209. * Set the value of an uniform to a matrix (3x3)
  28210. * @param uniform defines the webGL uniform location where to store the value
  28211. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  28212. */
  28213. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28214. /**
  28215. * Set the value of an uniform to a matrix (2x2)
  28216. * @param uniform defines the webGL uniform location where to store the value
  28217. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  28218. */
  28219. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28220. /**
  28221. * Set the value of an uniform to a number (int)
  28222. * @param uniform defines the webGL uniform location where to store the value
  28223. * @param value defines the int number to store
  28224. */
  28225. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28226. /**
  28227. * Set the value of an uniform to a number (float)
  28228. * @param uniform defines the webGL uniform location where to store the value
  28229. * @param value defines the float number to store
  28230. */
  28231. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28232. /**
  28233. * Set the value of an uniform to a vec2
  28234. * @param uniform defines the webGL uniform location where to store the value
  28235. * @param x defines the 1st component of the value
  28236. * @param y defines the 2nd component of the value
  28237. */
  28238. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  28239. /**
  28240. * Set the value of an uniform to a vec3
  28241. * @param uniform defines the webGL uniform location where to store the value
  28242. * @param x defines the 1st component of the value
  28243. * @param y defines the 2nd component of the value
  28244. * @param z defines the 3rd component of the value
  28245. */
  28246. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  28247. /**
  28248. * Set the value of an uniform to a boolean
  28249. * @param uniform defines the webGL uniform location where to store the value
  28250. * @param bool defines the boolean to store
  28251. */
  28252. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  28253. /**
  28254. * Set the value of an uniform to a vec4
  28255. * @param uniform defines the webGL uniform location where to store the value
  28256. * @param x defines the 1st component of the value
  28257. * @param y defines the 2nd component of the value
  28258. * @param z defines the 3rd component of the value
  28259. * @param w defines the 4th component of the value
  28260. */
  28261. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  28262. /**
  28263. * Set the value of an uniform to a Color3
  28264. * @param uniform defines the webGL uniform location where to store the value
  28265. * @param color3 defines the color to store
  28266. */
  28267. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  28268. /**
  28269. * Set the value of an uniform to a Color3 and an alpha value
  28270. * @param uniform defines the webGL uniform location where to store the value
  28271. * @param color3 defines the color to store
  28272. * @param alpha defines the alpha component to store
  28273. */
  28274. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  28275. /**
  28276. * Sets a Color4 on a uniform variable
  28277. * @param uniform defines the uniform location
  28278. * @param color4 defines the value to be set
  28279. */
  28280. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  28281. /**
  28282. * Set various states to the webGL context
  28283. * @param culling defines backface culling state
  28284. * @param zOffset defines the value to apply to zOffset (0 by default)
  28285. * @param force defines if states must be applied even if cache is up to date
  28286. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  28287. */
  28288. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  28289. /**
  28290. * Set the z offset to apply to current rendering
  28291. * @param value defines the offset to apply
  28292. */
  28293. setZOffset(value: number): void;
  28294. /**
  28295. * Gets the current value of the zOffset
  28296. * @returns the current zOffset state
  28297. */
  28298. getZOffset(): number;
  28299. /**
  28300. * Enable or disable depth buffering
  28301. * @param enable defines the state to set
  28302. */
  28303. setDepthBuffer(enable: boolean): void;
  28304. /**
  28305. * Gets a boolean indicating if depth writing is enabled
  28306. * @returns the current depth writing state
  28307. */
  28308. getDepthWrite(): boolean;
  28309. /**
  28310. * Enable or disable depth writing
  28311. * @param enable defines the state to set
  28312. */
  28313. setDepthWrite(enable: boolean): void;
  28314. /**
  28315. * Enable or disable color writing
  28316. * @param enable defines the state to set
  28317. */
  28318. setColorWrite(enable: boolean): void;
  28319. /**
  28320. * Gets a boolean indicating if color writing is enabled
  28321. * @returns the current color writing state
  28322. */
  28323. getColorWrite(): boolean;
  28324. /**
  28325. * Sets alpha constants used by some alpha blending modes
  28326. * @param r defines the red component
  28327. * @param g defines the green component
  28328. * @param b defines the blue component
  28329. * @param a defines the alpha component
  28330. */
  28331. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  28332. /**
  28333. * Sets the current alpha mode
  28334. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  28335. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  28336. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28337. */
  28338. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  28339. /**
  28340. * Gets the current alpha mode
  28341. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28342. * @returns the current alpha mode
  28343. */
  28344. getAlphaMode(): number;
  28345. /**
  28346. * Clears the list of texture accessible through engine.
  28347. * This can help preventing texture load conflict due to name collision.
  28348. */
  28349. clearInternalTexturesCache(): void;
  28350. /**
  28351. * Force the entire cache to be cleared
  28352. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  28353. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  28354. */
  28355. wipeCaches(bruteForce?: boolean): void;
  28356. /**
  28357. * Set the compressed texture format to use, based on the formats you have, and the formats
  28358. * supported by the hardware / browser.
  28359. *
  28360. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  28361. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  28362. * to API arguments needed to compressed textures. This puts the burden on the container
  28363. * generator to house the arcane code for determining these for current & future formats.
  28364. *
  28365. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  28366. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  28367. *
  28368. * Note: The result of this call is not taken into account when a texture is base64.
  28369. *
  28370. * @param formatsAvailable defines the list of those format families you have created
  28371. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  28372. *
  28373. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  28374. * @returns The extension selected.
  28375. */
  28376. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  28377. private _getSamplingParameters;
  28378. private _partialLoadImg;
  28379. private _cascadeLoadImgs;
  28380. /** @hidden */
  28381. _createTexture(): WebGLTexture;
  28382. /**
  28383. * Usually called from Texture.ts.
  28384. * Passed information to create a WebGLTexture
  28385. * @param urlArg defines a value which contains one of the following:
  28386. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  28387. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  28388. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  28389. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  28390. * @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)
  28391. * @param scene needed for loading to the correct scene
  28392. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  28393. * @param onLoad optional callback to be called upon successful completion
  28394. * @param onError optional callback to be called upon failure
  28395. * @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
  28396. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  28397. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  28398. * @param forcedExtension defines the extension to use to pick the right loader
  28399. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  28400. * @returns a InternalTexture for assignment back into BABYLON.Texture
  28401. */
  28402. 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;
  28403. private _rescaleTexture;
  28404. /**
  28405. * Update a raw texture
  28406. * @param texture defines the texture to update
  28407. * @param data defines the data to store in the texture
  28408. * @param format defines the format of the data
  28409. * @param invertY defines if data must be stored with Y axis inverted
  28410. * @param compression defines the compression used (null by default)
  28411. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28412. */
  28413. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  28414. /**
  28415. * Creates a raw texture
  28416. * @param data defines the data to store in the texture
  28417. * @param width defines the width of the texture
  28418. * @param height defines the height of the texture
  28419. * @param format defines the format of the data
  28420. * @param generateMipMaps defines if the engine should generate the mip levels
  28421. * @param invertY defines if data must be stored with Y axis inverted
  28422. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28423. * @param compression defines the compression used (null by default)
  28424. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28425. * @returns the raw texture inside an InternalTexture
  28426. */
  28427. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  28428. private _unpackFlipYCached;
  28429. /**
  28430. * In case you are sharing the context with other applications, it might
  28431. * be interested to not cache the unpack flip y state to ensure a consistent
  28432. * value would be set.
  28433. */
  28434. enableUnpackFlipYCached: boolean;
  28435. /** @hidden */
  28436. _unpackFlipY(value: boolean): void;
  28437. /** @hidden */
  28438. _getUnpackAlignement(): number;
  28439. /**
  28440. * Creates a dynamic texture
  28441. * @param width defines the width of the texture
  28442. * @param height defines the height of the texture
  28443. * @param generateMipMaps defines if the engine should generate the mip levels
  28444. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28445. * @returns the dynamic texture inside an InternalTexture
  28446. */
  28447. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  28448. /**
  28449. * Update the sampling mode of a given texture
  28450. * @param samplingMode defines the required sampling mode
  28451. * @param texture defines the texture to update
  28452. */
  28453. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  28454. /**
  28455. * Update the content of a dynamic texture
  28456. * @param texture defines the texture to update
  28457. * @param canvas defines the canvas containing the source
  28458. * @param invertY defines if data must be stored with Y axis inverted
  28459. * @param premulAlpha defines if alpha is stored as premultiplied
  28460. * @param format defines the format of the data
  28461. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  28462. */
  28463. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  28464. /**
  28465. * Update a video texture
  28466. * @param texture defines the texture to update
  28467. * @param video defines the video element to use
  28468. * @param invertY defines if data must be stored with Y axis inverted
  28469. */
  28470. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  28471. /**
  28472. * Updates a depth texture Comparison Mode and Function.
  28473. * If the comparison Function is equal to 0, the mode will be set to none.
  28474. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  28475. * @param texture The texture to set the comparison function for
  28476. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  28477. */
  28478. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  28479. private _setupDepthStencilTexture;
  28480. /**
  28481. * Creates a depth stencil texture.
  28482. * This is only available in WebGL 2 or with the depth texture extension available.
  28483. * @param size The size of face edge in the texture.
  28484. * @param options The options defining the texture.
  28485. * @returns The texture
  28486. */
  28487. createDepthStencilTexture(size: number | {
  28488. width: number;
  28489. height: number;
  28490. }, options: DepthTextureCreationOptions): InternalTexture;
  28491. /**
  28492. * Creates a depth stencil texture.
  28493. * This is only available in WebGL 2 or with the depth texture extension available.
  28494. * @param size The size of face edge in the texture.
  28495. * @param options The options defining the texture.
  28496. * @returns The texture
  28497. */
  28498. private _createDepthStencilTexture;
  28499. /**
  28500. * Creates a depth stencil cube texture.
  28501. * This is only available in WebGL 2.
  28502. * @param size The size of face edge in the cube texture.
  28503. * @param options The options defining the cube texture.
  28504. * @returns The cube texture
  28505. */
  28506. private _createDepthStencilCubeTexture;
  28507. /**
  28508. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  28509. * @param renderTarget The render target to set the frame buffer for
  28510. */
  28511. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  28512. /**
  28513. * Creates a new render target texture
  28514. * @param size defines the size of the texture
  28515. * @param options defines the options used to create the texture
  28516. * @returns a new render target texture stored in an InternalTexture
  28517. */
  28518. createRenderTargetTexture(size: number | {
  28519. width: number;
  28520. height: number;
  28521. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  28522. /**
  28523. * Create a multi render target texture
  28524. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  28525. * @param size defines the size of the texture
  28526. * @param options defines the creation options
  28527. * @returns the cube texture as an InternalTexture
  28528. */
  28529. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  28530. private _setupFramebufferDepthAttachments;
  28531. /**
  28532. * Updates the sample count of a render target texture
  28533. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28534. * @param texture defines the texture to update
  28535. * @param samples defines the sample count to set
  28536. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28537. */
  28538. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  28539. /**
  28540. * Update the sample count for a given multiple render target texture
  28541. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28542. * @param textures defines the textures to update
  28543. * @param samples defines the sample count to set
  28544. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28545. */
  28546. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  28547. /** @hidden */
  28548. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28549. /** @hidden */
  28550. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28551. /** @hidden */
  28552. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28553. /** @hidden */
  28554. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  28555. /**
  28556. * Creates a new multiview render target
  28557. * @param width defines the width of the texture
  28558. * @param height defines the height of the texture
  28559. * @returns the created multiview texture
  28560. */
  28561. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  28562. /**
  28563. * Binds a multiview framebuffer to be drawn to
  28564. * @param multiviewTexture texture to bind
  28565. */
  28566. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  28567. /**
  28568. * Creates a new render target cube texture
  28569. * @param size defines the size of the texture
  28570. * @param options defines the options used to create the texture
  28571. * @returns a new render target cube texture stored in an InternalTexture
  28572. */
  28573. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  28574. /**
  28575. * Creates a cube texture
  28576. * @param rootUrl defines the url where the files to load is located
  28577. * @param scene defines the current scene
  28578. * @param files defines the list of files to load (1 per face)
  28579. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  28580. * @param onLoad defines an optional callback raised when the texture is loaded
  28581. * @param onError defines an optional callback raised if there is an issue to load the texture
  28582. * @param format defines the format of the data
  28583. * @param forcedExtension defines the extension to use to pick the right loader
  28584. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  28585. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  28586. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  28587. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  28588. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  28589. * @returns the cube texture as an InternalTexture
  28590. */
  28591. 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;
  28592. /**
  28593. * @hidden
  28594. */
  28595. _setCubeMapTextureParams(loadMipmap: boolean): void;
  28596. /**
  28597. * Update a raw cube texture
  28598. * @param texture defines the texture to udpdate
  28599. * @param data defines the data to store
  28600. * @param format defines the data format
  28601. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28602. * @param invertY defines if data must be stored with Y axis inverted
  28603. * @param compression defines the compression used (null by default)
  28604. * @param level defines which level of the texture to update
  28605. */
  28606. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  28607. /**
  28608. * Creates a new raw cube texture
  28609. * @param data defines the array of data to use to create each face
  28610. * @param size defines the size of the textures
  28611. * @param format defines the format of the data
  28612. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  28613. * @param generateMipMaps defines if the engine should generate the mip levels
  28614. * @param invertY defines if data must be stored with Y axis inverted
  28615. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28616. * @param compression defines the compression used (null by default)
  28617. * @returns the cube texture as an InternalTexture
  28618. */
  28619. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  28620. /**
  28621. * Creates a new raw cube texture from a specified url
  28622. * @param url defines the url where the data is located
  28623. * @param scene defines the current scene
  28624. * @param size defines the size of the textures
  28625. * @param format defines the format of the data
  28626. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  28627. * @param noMipmap defines if the engine should avoid generating the mip levels
  28628. * @param callback defines a callback used to extract texture data from loaded data
  28629. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  28630. * @param onLoad defines a callback called when texture is loaded
  28631. * @param onError defines a callback called if there is an error
  28632. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28633. * @param invertY defines if data must be stored with Y axis inverted
  28634. * @returns the cube texture as an InternalTexture
  28635. */
  28636. 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;
  28637. /**
  28638. * Update a raw 3D texture
  28639. * @param texture defines the texture to update
  28640. * @param data defines the data to store
  28641. * @param format defines the data format
  28642. * @param invertY defines if data must be stored with Y axis inverted
  28643. * @param compression defines the used compression (can be null)
  28644. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  28645. */
  28646. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  28647. /**
  28648. * Creates a new raw 3D texture
  28649. * @param data defines the data used to create the texture
  28650. * @param width defines the width of the texture
  28651. * @param height defines the height of the texture
  28652. * @param depth defines the depth of the texture
  28653. * @param format defines the format of the texture
  28654. * @param generateMipMaps defines if the engine must generate mip levels
  28655. * @param invertY defines if data must be stored with Y axis inverted
  28656. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28657. * @param compression defines the compressed used (can be null)
  28658. * @param textureType defines the compressed used (can be null)
  28659. * @returns a new raw 3D texture (stored in an InternalTexture)
  28660. */
  28661. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  28662. private _prepareWebGLTextureContinuation;
  28663. private _prepareWebGLTexture;
  28664. private _convertRGBtoRGBATextureData;
  28665. /** @hidden */
  28666. _releaseFramebufferObjects(texture: InternalTexture): void;
  28667. /** @hidden */
  28668. _releaseTexture(texture: InternalTexture): void;
  28669. private setProgram;
  28670. private _boundUniforms;
  28671. /**
  28672. * Binds an effect to the webGL context
  28673. * @param effect defines the effect to bind
  28674. */
  28675. bindSamplers(effect: Effect): void;
  28676. private _moveBoundTextureOnTop;
  28677. private _getCorrectTextureChannel;
  28678. private _linkTrackers;
  28679. private _removeDesignatedSlot;
  28680. private _activateCurrentTexture;
  28681. /** @hidden */
  28682. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  28683. /** @hidden */
  28684. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  28685. /**
  28686. * Sets a texture to the webGL context from a postprocess
  28687. * @param channel defines the channel to use
  28688. * @param postProcess defines the source postprocess
  28689. */
  28690. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  28691. /**
  28692. * Binds the output of the passed in post process to the texture channel specified
  28693. * @param channel The channel the texture should be bound to
  28694. * @param postProcess The post process which's output should be bound
  28695. */
  28696. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  28697. /**
  28698. * Unbind all textures from the webGL context
  28699. */
  28700. unbindAllTextures(): void;
  28701. /**
  28702. * Sets a texture to the according uniform.
  28703. * @param channel The texture channel
  28704. * @param uniform The uniform to set
  28705. * @param texture The texture to apply
  28706. */
  28707. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  28708. /**
  28709. * Sets a depth stencil texture from a render target to the according uniform.
  28710. * @param channel The texture channel
  28711. * @param uniform The uniform to set
  28712. * @param texture The render target texture containing the depth stencil texture to apply
  28713. */
  28714. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  28715. private _bindSamplerUniformToChannel;
  28716. private _getTextureWrapMode;
  28717. private _setTexture;
  28718. /**
  28719. * Sets an array of texture to the webGL context
  28720. * @param channel defines the channel where the texture array must be set
  28721. * @param uniform defines the associated uniform location
  28722. * @param textures defines the array of textures to bind
  28723. */
  28724. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  28725. /** @hidden */
  28726. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  28727. private _setTextureParameterFloat;
  28728. private _setTextureParameterInteger;
  28729. /**
  28730. * Reads pixels from the current frame buffer. Please note that this function can be slow
  28731. * @param x defines the x coordinate of the rectangle where pixels must be read
  28732. * @param y defines the y coordinate of the rectangle where pixels must be read
  28733. * @param width defines the width of the rectangle where pixels must be read
  28734. * @param height defines the height of the rectangle where pixels must be read
  28735. * @returns a Uint8Array containing RGBA colors
  28736. */
  28737. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  28738. /**
  28739. * Add an externaly attached data from its key.
  28740. * This method call will fail and return false, if such key already exists.
  28741. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  28742. * @param key the unique key that identifies the data
  28743. * @param data the data object to associate to the key for this Engine instance
  28744. * @return true if no such key were already present and the data was added successfully, false otherwise
  28745. */
  28746. addExternalData<T>(key: string, data: T): boolean;
  28747. /**
  28748. * Get an externaly attached data from its key
  28749. * @param key the unique key that identifies the data
  28750. * @return the associated data, if present (can be null), or undefined if not present
  28751. */
  28752. getExternalData<T>(key: string): T;
  28753. /**
  28754. * Get an externaly attached data from its key, create it using a factory if it's not already present
  28755. * @param key the unique key that identifies the data
  28756. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  28757. * @return the associated data, can be null if the factory returned null.
  28758. */
  28759. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  28760. /**
  28761. * Remove an externaly attached data from the Engine instance
  28762. * @param key the unique key that identifies the data
  28763. * @return true if the data was successfully removed, false if it doesn't exist
  28764. */
  28765. removeExternalData(key: string): boolean;
  28766. /**
  28767. * Unbind all vertex attributes from the webGL context
  28768. */
  28769. unbindAllAttributes(): void;
  28770. /**
  28771. * 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
  28772. */
  28773. releaseEffects(): void;
  28774. /**
  28775. * Dispose and release all associated resources
  28776. */
  28777. dispose(): void;
  28778. /**
  28779. * Display the loading screen
  28780. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28781. */
  28782. displayLoadingUI(): void;
  28783. /**
  28784. * Hide the loading screen
  28785. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28786. */
  28787. hideLoadingUI(): void;
  28788. /**
  28789. * Gets the current loading screen object
  28790. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28791. */
  28792. /**
  28793. * Sets the current loading screen object
  28794. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28795. */
  28796. loadingScreen: ILoadingScreen;
  28797. /**
  28798. * Sets the current loading screen text
  28799. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28800. */
  28801. loadingUIText: string;
  28802. /**
  28803. * Sets the current loading screen background color
  28804. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28805. */
  28806. loadingUIBackgroundColor: string;
  28807. /**
  28808. * Attach a new callback raised when context lost event is fired
  28809. * @param callback defines the callback to call
  28810. */
  28811. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28812. /**
  28813. * Attach a new callback raised when context restored event is fired
  28814. * @param callback defines the callback to call
  28815. */
  28816. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28817. /**
  28818. * Gets the source code of the vertex shader associated with a specific webGL program
  28819. * @param program defines the program to use
  28820. * @returns a string containing the source code of the vertex shader associated with the program
  28821. */
  28822. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  28823. /**
  28824. * Gets the source code of the fragment shader associated with a specific webGL program
  28825. * @param program defines the program to use
  28826. * @returns a string containing the source code of the fragment shader associated with the program
  28827. */
  28828. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  28829. /**
  28830. * Get the current error code of the webGL context
  28831. * @returns the error code
  28832. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  28833. */
  28834. getError(): number;
  28835. /**
  28836. * Gets the current framerate
  28837. * @returns a number representing the framerate
  28838. */
  28839. getFps(): number;
  28840. /**
  28841. * Gets the time spent between current and previous frame
  28842. * @returns a number representing the delta time in ms
  28843. */
  28844. getDeltaTime(): number;
  28845. private _measureFps;
  28846. /** @hidden */
  28847. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  28848. private _canRenderToFloatFramebuffer;
  28849. private _canRenderToHalfFloatFramebuffer;
  28850. private _canRenderToFramebuffer;
  28851. /** @hidden */
  28852. _getWebGLTextureType(type: number): number;
  28853. private _getInternalFormat;
  28854. /** @hidden */
  28855. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  28856. /** @hidden */
  28857. _getRGBAMultiSampleBufferFormat(type: number): number;
  28858. /** @hidden */
  28859. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  28860. /** @hidden */
  28861. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  28862. private _partialLoadFile;
  28863. private _cascadeLoadFiles;
  28864. /**
  28865. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  28866. * @returns true if the engine can be created
  28867. * @ignorenaming
  28868. */
  28869. static isSupported(): boolean;
  28870. }
  28871. }
  28872. declare module BABYLON {
  28873. /**
  28874. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28875. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28876. */
  28877. export class EffectFallbacks {
  28878. private _defines;
  28879. private _currentRank;
  28880. private _maxRank;
  28881. private _mesh;
  28882. /**
  28883. * Removes the fallback from the bound mesh.
  28884. */
  28885. unBindMesh(): void;
  28886. /**
  28887. * Adds a fallback on the specified property.
  28888. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28889. * @param define The name of the define in the shader
  28890. */
  28891. addFallback(rank: number, define: string): void;
  28892. /**
  28893. * Sets the mesh to use CPU skinning when needing to fallback.
  28894. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28895. * @param mesh The mesh to use the fallbacks.
  28896. */
  28897. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  28898. /**
  28899. * Checks to see if more fallbacks are still availible.
  28900. */
  28901. readonly isMoreFallbacks: boolean;
  28902. /**
  28903. * Removes the defines that shoould be removed when falling back.
  28904. * @param currentDefines defines the current define statements for the shader.
  28905. * @param effect defines the current effect we try to compile
  28906. * @returns The resulting defines with defines of the current rank removed.
  28907. */
  28908. reduce(currentDefines: string, effect: Effect): string;
  28909. }
  28910. /**
  28911. * Options to be used when creating an effect.
  28912. */
  28913. export class EffectCreationOptions {
  28914. /**
  28915. * Atrributes that will be used in the shader.
  28916. */
  28917. attributes: string[];
  28918. /**
  28919. * Uniform varible names that will be set in the shader.
  28920. */
  28921. uniformsNames: string[];
  28922. /**
  28923. * Uniform buffer varible names that will be set in the shader.
  28924. */
  28925. uniformBuffersNames: string[];
  28926. /**
  28927. * Sampler texture variable names that will be set in the shader.
  28928. */
  28929. samplers: string[];
  28930. /**
  28931. * Define statements that will be set in the shader.
  28932. */
  28933. defines: any;
  28934. /**
  28935. * Possible fallbacks for this effect to improve performance when needed.
  28936. */
  28937. fallbacks: Nullable<EffectFallbacks>;
  28938. /**
  28939. * Callback that will be called when the shader is compiled.
  28940. */
  28941. onCompiled: Nullable<(effect: Effect) => void>;
  28942. /**
  28943. * Callback that will be called if an error occurs during shader compilation.
  28944. */
  28945. onError: Nullable<(effect: Effect, errors: string) => void>;
  28946. /**
  28947. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28948. */
  28949. indexParameters: any;
  28950. /**
  28951. * Max number of lights that can be used in the shader.
  28952. */
  28953. maxSimultaneousLights: number;
  28954. /**
  28955. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28956. */
  28957. transformFeedbackVaryings: Nullable<string[]>;
  28958. }
  28959. /**
  28960. * Effect containing vertex and fragment shader that can be executed on an object.
  28961. */
  28962. export class Effect {
  28963. /**
  28964. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28965. */
  28966. static ShadersRepository: string;
  28967. /**
  28968. * Name of the effect.
  28969. */
  28970. name: any;
  28971. /**
  28972. * String container all the define statements that should be set on the shader.
  28973. */
  28974. defines: string;
  28975. /**
  28976. * Callback that will be called when the shader is compiled.
  28977. */
  28978. onCompiled: Nullable<(effect: Effect) => void>;
  28979. /**
  28980. * Callback that will be called if an error occurs during shader compilation.
  28981. */
  28982. onError: Nullable<(effect: Effect, errors: string) => void>;
  28983. /**
  28984. * Callback that will be called when effect is bound.
  28985. */
  28986. onBind: Nullable<(effect: Effect) => void>;
  28987. /**
  28988. * Unique ID of the effect.
  28989. */
  28990. uniqueId: number;
  28991. /**
  28992. * Observable that will be called when the shader is compiled.
  28993. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  28994. */
  28995. onCompileObservable: Observable<Effect>;
  28996. /**
  28997. * Observable that will be called if an error occurs during shader compilation.
  28998. */
  28999. onErrorObservable: Observable<Effect>;
  29000. /** @hidden */
  29001. _onBindObservable: Nullable<Observable<Effect>>;
  29002. /**
  29003. * Observable that will be called when effect is bound.
  29004. */
  29005. readonly onBindObservable: Observable<Effect>;
  29006. /** @hidden */
  29007. _bonesComputationForcedToCPU: boolean;
  29008. private static _uniqueIdSeed;
  29009. private _engine;
  29010. private _uniformBuffersNames;
  29011. private _uniformsNames;
  29012. private _samplers;
  29013. private _isReady;
  29014. private _compilationError;
  29015. private _attributesNames;
  29016. private _attributes;
  29017. private _uniforms;
  29018. /**
  29019. * Key for the effect.
  29020. * @hidden
  29021. */
  29022. _key: string;
  29023. private _indexParameters;
  29024. private _fallbacks;
  29025. private _vertexSourceCode;
  29026. private _fragmentSourceCode;
  29027. private _vertexSourceCodeOverride;
  29028. private _fragmentSourceCodeOverride;
  29029. private _transformFeedbackVaryings;
  29030. /**
  29031. * Compiled shader to webGL program.
  29032. * @hidden
  29033. */
  29034. _program: WebGLProgram;
  29035. private _valueCache;
  29036. private static _baseCache;
  29037. /**
  29038. * Instantiates an effect.
  29039. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29040. * @param baseName Name of the effect.
  29041. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29042. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29043. * @param samplers List of sampler variables that will be passed to the shader.
  29044. * @param engine Engine to be used to render the effect
  29045. * @param defines Define statements to be added to the shader.
  29046. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29047. * @param onCompiled Callback that will be called when the shader is compiled.
  29048. * @param onError Callback that will be called if an error occurs during shader compilation.
  29049. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29050. */
  29051. 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);
  29052. /**
  29053. * Unique key for this effect
  29054. */
  29055. readonly key: string;
  29056. /**
  29057. * If the effect has been compiled and prepared.
  29058. * @returns if the effect is compiled and prepared.
  29059. */
  29060. isReady(): boolean;
  29061. /**
  29062. * The engine the effect was initialized with.
  29063. * @returns the engine.
  29064. */
  29065. getEngine(): Engine;
  29066. /**
  29067. * The compiled webGL program for the effect
  29068. * @returns the webGL program.
  29069. */
  29070. getProgram(): WebGLProgram;
  29071. /**
  29072. * The set of names of attribute variables for the shader.
  29073. * @returns An array of attribute names.
  29074. */
  29075. getAttributesNames(): string[];
  29076. /**
  29077. * Returns the attribute at the given index.
  29078. * @param index The index of the attribute.
  29079. * @returns The location of the attribute.
  29080. */
  29081. getAttributeLocation(index: number): number;
  29082. /**
  29083. * Returns the attribute based on the name of the variable.
  29084. * @param name of the attribute to look up.
  29085. * @returns the attribute location.
  29086. */
  29087. getAttributeLocationByName(name: string): number;
  29088. /**
  29089. * The number of attributes.
  29090. * @returns the numnber of attributes.
  29091. */
  29092. getAttributesCount(): number;
  29093. /**
  29094. * Gets the index of a uniform variable.
  29095. * @param uniformName of the uniform to look up.
  29096. * @returns the index.
  29097. */
  29098. getUniformIndex(uniformName: string): number;
  29099. /**
  29100. * Returns the attribute based on the name of the variable.
  29101. * @param uniformName of the uniform to look up.
  29102. * @returns the location of the uniform.
  29103. */
  29104. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29105. /**
  29106. * Returns an array of sampler variable names
  29107. * @returns The array of sampler variable neames.
  29108. */
  29109. getSamplers(): string[];
  29110. /**
  29111. * The error from the last compilation.
  29112. * @returns the error string.
  29113. */
  29114. getCompilationError(): string;
  29115. /**
  29116. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29117. * @param func The callback to be used.
  29118. */
  29119. executeWhenCompiled(func: (effect: Effect) => void): void;
  29120. private _checkIsReady;
  29121. /** @hidden */
  29122. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29123. /** @hidden */
  29124. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29125. /** @hidden */
  29126. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29127. private _processShaderConversion;
  29128. private _processIncludes;
  29129. private _processPrecision;
  29130. /**
  29131. * Recompiles the webGL program
  29132. * @param vertexSourceCode The source code for the vertex shader.
  29133. * @param fragmentSourceCode The source code for the fragment shader.
  29134. * @param onCompiled Callback called when completed.
  29135. * @param onError Callback called on error.
  29136. * @hidden
  29137. */
  29138. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  29139. /**
  29140. * Gets the uniform locations of the the specified variable names
  29141. * @param names THe names of the variables to lookup.
  29142. * @returns Array of locations in the same order as variable names.
  29143. */
  29144. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  29145. /**
  29146. * Prepares the effect
  29147. * @hidden
  29148. */
  29149. _prepareEffect(): void;
  29150. /**
  29151. * Checks if the effect is supported. (Must be called after compilation)
  29152. */
  29153. readonly isSupported: boolean;
  29154. /**
  29155. * Binds a texture to the engine to be used as output of the shader.
  29156. * @param channel Name of the output variable.
  29157. * @param texture Texture to bind.
  29158. * @hidden
  29159. */
  29160. _bindTexture(channel: string, texture: InternalTexture): void;
  29161. /**
  29162. * Sets a texture on the engine to be used in the shader.
  29163. * @param channel Name of the sampler variable.
  29164. * @param texture Texture to set.
  29165. */
  29166. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29167. /**
  29168. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29169. * @param channel Name of the sampler variable.
  29170. * @param texture Texture to set.
  29171. */
  29172. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29173. /**
  29174. * Sets an array of textures on the engine to be used in the shader.
  29175. * @param channel Name of the variable.
  29176. * @param textures Textures to set.
  29177. */
  29178. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29179. /**
  29180. * 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)
  29181. * @param channel Name of the sampler variable.
  29182. * @param postProcess Post process to get the input texture from.
  29183. */
  29184. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29185. /**
  29186. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29187. * 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)
  29188. * @param channel Name of the sampler variable.
  29189. * @param postProcess Post process to get the output texture from.
  29190. */
  29191. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29192. /** @hidden */
  29193. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  29194. /** @hidden */
  29195. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29196. /** @hidden */
  29197. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29198. /** @hidden */
  29199. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29200. /**
  29201. * Binds a buffer to a uniform.
  29202. * @param buffer Buffer to bind.
  29203. * @param name Name of the uniform variable to bind to.
  29204. */
  29205. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  29206. /**
  29207. * Binds block to a uniform.
  29208. * @param blockName Name of the block to bind.
  29209. * @param index Index to bind.
  29210. */
  29211. bindUniformBlock(blockName: string, index: number): void;
  29212. /**
  29213. * Sets an interger value on a uniform variable.
  29214. * @param uniformName Name of the variable.
  29215. * @param value Value to be set.
  29216. * @returns this effect.
  29217. */
  29218. setInt(uniformName: string, value: number): Effect;
  29219. /**
  29220. * Sets an int array on a uniform variable.
  29221. * @param uniformName Name of the variable.
  29222. * @param array array to be set.
  29223. * @returns this effect.
  29224. */
  29225. setIntArray(uniformName: string, array: Int32Array): Effect;
  29226. /**
  29227. * 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)
  29228. * @param uniformName Name of the variable.
  29229. * @param array array to be set.
  29230. * @returns this effect.
  29231. */
  29232. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29233. /**
  29234. * 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)
  29235. * @param uniformName Name of the variable.
  29236. * @param array array to be set.
  29237. * @returns this effect.
  29238. */
  29239. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29240. /**
  29241. * 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)
  29242. * @param uniformName Name of the variable.
  29243. * @param array array to be set.
  29244. * @returns this effect.
  29245. */
  29246. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29247. /**
  29248. * Sets an float array on a uniform variable.
  29249. * @param uniformName Name of the variable.
  29250. * @param array array to be set.
  29251. * @returns this effect.
  29252. */
  29253. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29254. /**
  29255. * 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)
  29256. * @param uniformName Name of the variable.
  29257. * @param array array to be set.
  29258. * @returns this effect.
  29259. */
  29260. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29261. /**
  29262. * 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)
  29263. * @param uniformName Name of the variable.
  29264. * @param array array to be set.
  29265. * @returns this effect.
  29266. */
  29267. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29268. /**
  29269. * 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)
  29270. * @param uniformName Name of the variable.
  29271. * @param array array to be set.
  29272. * @returns this effect.
  29273. */
  29274. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29275. /**
  29276. * Sets an array on a uniform variable.
  29277. * @param uniformName Name of the variable.
  29278. * @param array array to be set.
  29279. * @returns this effect.
  29280. */
  29281. setArray(uniformName: string, array: number[]): Effect;
  29282. /**
  29283. * 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)
  29284. * @param uniformName Name of the variable.
  29285. * @param array array to be set.
  29286. * @returns this effect.
  29287. */
  29288. setArray2(uniformName: string, array: number[]): Effect;
  29289. /**
  29290. * 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)
  29291. * @param uniformName Name of the variable.
  29292. * @param array array to be set.
  29293. * @returns this effect.
  29294. */
  29295. setArray3(uniformName: string, array: number[]): Effect;
  29296. /**
  29297. * 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)
  29298. * @param uniformName Name of the variable.
  29299. * @param array array to be set.
  29300. * @returns this effect.
  29301. */
  29302. setArray4(uniformName: string, array: number[]): Effect;
  29303. /**
  29304. * Sets matrices on a uniform variable.
  29305. * @param uniformName Name of the variable.
  29306. * @param matrices matrices to be set.
  29307. * @returns this effect.
  29308. */
  29309. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29310. /**
  29311. * Sets matrix on a uniform variable.
  29312. * @param uniformName Name of the variable.
  29313. * @param matrix matrix to be set.
  29314. * @returns this effect.
  29315. */
  29316. setMatrix(uniformName: string, matrix: Matrix): Effect;
  29317. /**
  29318. * 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)
  29319. * @param uniformName Name of the variable.
  29320. * @param matrix matrix to be set.
  29321. * @returns this effect.
  29322. */
  29323. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29324. /**
  29325. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29326. * @param uniformName Name of the variable.
  29327. * @param matrix matrix to be set.
  29328. * @returns this effect.
  29329. */
  29330. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29331. /**
  29332. * Sets a float on a uniform variable.
  29333. * @param uniformName Name of the variable.
  29334. * @param value value to be set.
  29335. * @returns this effect.
  29336. */
  29337. setFloat(uniformName: string, value: number): Effect;
  29338. /**
  29339. * Sets a boolean on a uniform variable.
  29340. * @param uniformName Name of the variable.
  29341. * @param bool value to be set.
  29342. * @returns this effect.
  29343. */
  29344. setBool(uniformName: string, bool: boolean): Effect;
  29345. /**
  29346. * Sets a Vector2 on a uniform variable.
  29347. * @param uniformName Name of the variable.
  29348. * @param vector2 vector2 to be set.
  29349. * @returns this effect.
  29350. */
  29351. setVector2(uniformName: string, vector2: Vector2): Effect;
  29352. /**
  29353. * Sets a float2 on a uniform variable.
  29354. * @param uniformName Name of the variable.
  29355. * @param x First float in float2.
  29356. * @param y Second float in float2.
  29357. * @returns this effect.
  29358. */
  29359. setFloat2(uniformName: string, x: number, y: number): Effect;
  29360. /**
  29361. * Sets a Vector3 on a uniform variable.
  29362. * @param uniformName Name of the variable.
  29363. * @param vector3 Value to be set.
  29364. * @returns this effect.
  29365. */
  29366. setVector3(uniformName: string, vector3: Vector3): Effect;
  29367. /**
  29368. * Sets a float3 on a uniform variable.
  29369. * @param uniformName Name of the variable.
  29370. * @param x First float in float3.
  29371. * @param y Second float in float3.
  29372. * @param z Third float in float3.
  29373. * @returns this effect.
  29374. */
  29375. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29376. /**
  29377. * Sets a Vector4 on a uniform variable.
  29378. * @param uniformName Name of the variable.
  29379. * @param vector4 Value to be set.
  29380. * @returns this effect.
  29381. */
  29382. setVector4(uniformName: string, vector4: Vector4): Effect;
  29383. /**
  29384. * Sets a float4 on a uniform variable.
  29385. * @param uniformName Name of the variable.
  29386. * @param x First float in float4.
  29387. * @param y Second float in float4.
  29388. * @param z Third float in float4.
  29389. * @param w Fourth float in float4.
  29390. * @returns this effect.
  29391. */
  29392. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29393. /**
  29394. * Sets a Color3 on a uniform variable.
  29395. * @param uniformName Name of the variable.
  29396. * @param color3 Value to be set.
  29397. * @returns this effect.
  29398. */
  29399. setColor3(uniformName: string, color3: Color3): Effect;
  29400. /**
  29401. * Sets a Color4 on a uniform variable.
  29402. * @param uniformName Name of the variable.
  29403. * @param color3 Value to be set.
  29404. * @param alpha Alpha value to be set.
  29405. * @returns this effect.
  29406. */
  29407. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  29408. /**
  29409. * Sets a Color4 on a uniform variable
  29410. * @param uniformName defines the name of the variable
  29411. * @param color4 defines the value to be set
  29412. * @returns this effect.
  29413. */
  29414. setDirectColor4(uniformName: string, color4: Color4): Effect;
  29415. /**
  29416. * This function will add a new shader to the shader store
  29417. * @param name the name of the shader
  29418. * @param pixelShader optional pixel shader content
  29419. * @param vertexShader optional vertex shader content
  29420. */
  29421. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29422. /**
  29423. * Store of each shader (The can be looked up using effect.key)
  29424. */
  29425. static ShadersStore: {
  29426. [key: string]: string;
  29427. };
  29428. /**
  29429. * Store of each included file for a shader (The can be looked up using effect.key)
  29430. */
  29431. static IncludesShadersStore: {
  29432. [key: string]: string;
  29433. };
  29434. /**
  29435. * Resets the cache of effects.
  29436. */
  29437. static ResetCache(): void;
  29438. }
  29439. }
  29440. declare module BABYLON {
  29441. /**
  29442. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29443. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29444. * 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;
  29445. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29446. */
  29447. export class ColorCurves {
  29448. private _dirty;
  29449. private _tempColor;
  29450. private _globalCurve;
  29451. private _highlightsCurve;
  29452. private _midtonesCurve;
  29453. private _shadowsCurve;
  29454. private _positiveCurve;
  29455. private _negativeCurve;
  29456. private _globalHue;
  29457. private _globalDensity;
  29458. private _globalSaturation;
  29459. private _globalExposure;
  29460. /**
  29461. * Gets the global Hue value.
  29462. * 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).
  29463. */
  29464. /**
  29465. * Sets the global Hue value.
  29466. * 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).
  29467. */
  29468. globalHue: number;
  29469. /**
  29470. * Gets the global Density value.
  29471. * 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.
  29472. * Values less than zero provide a filter of opposite hue.
  29473. */
  29474. /**
  29475. * Sets the global Density value.
  29476. * 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.
  29477. * Values less than zero provide a filter of opposite hue.
  29478. */
  29479. globalDensity: number;
  29480. /**
  29481. * Gets the global Saturation value.
  29482. * 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.
  29483. */
  29484. /**
  29485. * Sets the global Saturation value.
  29486. * 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.
  29487. */
  29488. globalSaturation: number;
  29489. /**
  29490. * Gets the global Exposure value.
  29491. * 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.
  29492. */
  29493. /**
  29494. * Sets the global Exposure value.
  29495. * 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.
  29496. */
  29497. globalExposure: number;
  29498. private _highlightsHue;
  29499. private _highlightsDensity;
  29500. private _highlightsSaturation;
  29501. private _highlightsExposure;
  29502. /**
  29503. * Gets the highlights Hue value.
  29504. * 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).
  29505. */
  29506. /**
  29507. * Sets the highlights Hue value.
  29508. * 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).
  29509. */
  29510. highlightsHue: number;
  29511. /**
  29512. * Gets the highlights Density value.
  29513. * 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.
  29514. * Values less than zero provide a filter of opposite hue.
  29515. */
  29516. /**
  29517. * Sets the highlights Density value.
  29518. * 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.
  29519. * Values less than zero provide a filter of opposite hue.
  29520. */
  29521. highlightsDensity: number;
  29522. /**
  29523. * Gets the highlights Saturation value.
  29524. * 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.
  29525. */
  29526. /**
  29527. * Sets the highlights Saturation value.
  29528. * 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.
  29529. */
  29530. highlightsSaturation: number;
  29531. /**
  29532. * Gets the highlights Exposure value.
  29533. * 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.
  29534. */
  29535. /**
  29536. * Sets the highlights Exposure value.
  29537. * 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.
  29538. */
  29539. highlightsExposure: number;
  29540. private _midtonesHue;
  29541. private _midtonesDensity;
  29542. private _midtonesSaturation;
  29543. private _midtonesExposure;
  29544. /**
  29545. * Gets the midtones Hue value.
  29546. * 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).
  29547. */
  29548. /**
  29549. * Sets the midtones Hue value.
  29550. * 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).
  29551. */
  29552. midtonesHue: number;
  29553. /**
  29554. * Gets the midtones Density value.
  29555. * 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.
  29556. * Values less than zero provide a filter of opposite hue.
  29557. */
  29558. /**
  29559. * Sets the midtones Density value.
  29560. * 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.
  29561. * Values less than zero provide a filter of opposite hue.
  29562. */
  29563. midtonesDensity: number;
  29564. /**
  29565. * Gets the midtones Saturation value.
  29566. * 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.
  29567. */
  29568. /**
  29569. * Sets the midtones Saturation value.
  29570. * 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.
  29571. */
  29572. midtonesSaturation: number;
  29573. /**
  29574. * Gets the midtones Exposure value.
  29575. * 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.
  29576. */
  29577. /**
  29578. * Sets the midtones Exposure value.
  29579. * 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.
  29580. */
  29581. midtonesExposure: number;
  29582. private _shadowsHue;
  29583. private _shadowsDensity;
  29584. private _shadowsSaturation;
  29585. private _shadowsExposure;
  29586. /**
  29587. * Gets the shadows Hue value.
  29588. * 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).
  29589. */
  29590. /**
  29591. * Sets the shadows Hue value.
  29592. * 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).
  29593. */
  29594. shadowsHue: number;
  29595. /**
  29596. * Gets the shadows Density value.
  29597. * 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.
  29598. * Values less than zero provide a filter of opposite hue.
  29599. */
  29600. /**
  29601. * Sets the shadows Density value.
  29602. * 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.
  29603. * Values less than zero provide a filter of opposite hue.
  29604. */
  29605. shadowsDensity: number;
  29606. /**
  29607. * Gets the shadows Saturation value.
  29608. * 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.
  29609. */
  29610. /**
  29611. * Sets the shadows Saturation value.
  29612. * 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.
  29613. */
  29614. shadowsSaturation: number;
  29615. /**
  29616. * Gets the shadows Exposure value.
  29617. * 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.
  29618. */
  29619. /**
  29620. * Sets the shadows Exposure value.
  29621. * 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.
  29622. */
  29623. shadowsExposure: number;
  29624. /**
  29625. * Returns the class name
  29626. * @returns The class name
  29627. */
  29628. getClassName(): string;
  29629. /**
  29630. * Binds the color curves to the shader.
  29631. * @param colorCurves The color curve to bind
  29632. * @param effect The effect to bind to
  29633. * @param positiveUniform The positive uniform shader parameter
  29634. * @param neutralUniform The neutral uniform shader parameter
  29635. * @param negativeUniform The negative uniform shader parameter
  29636. */
  29637. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  29638. /**
  29639. * Prepare the list of uniforms associated with the ColorCurves effects.
  29640. * @param uniformsList The list of uniforms used in the effect
  29641. */
  29642. static PrepareUniforms(uniformsList: string[]): void;
  29643. /**
  29644. * Returns color grading data based on a hue, density, saturation and exposure value.
  29645. * @param filterHue The hue of the color filter.
  29646. * @param filterDensity The density of the color filter.
  29647. * @param saturation The saturation.
  29648. * @param exposure The exposure.
  29649. * @param result The result data container.
  29650. */
  29651. private getColorGradingDataToRef;
  29652. /**
  29653. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  29654. * @param value The input slider value in range [-100,100].
  29655. * @returns Adjusted value.
  29656. */
  29657. private static applyColorGradingSliderNonlinear;
  29658. /**
  29659. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  29660. * @param hue The hue (H) input.
  29661. * @param saturation The saturation (S) input.
  29662. * @param brightness The brightness (B) input.
  29663. * @result An RGBA color represented as Vector4.
  29664. */
  29665. private static fromHSBToRef;
  29666. /**
  29667. * Returns a value clamped between min and max
  29668. * @param value The value to clamp
  29669. * @param min The minimum of value
  29670. * @param max The maximum of value
  29671. * @returns The clamped value.
  29672. */
  29673. private static clamp;
  29674. /**
  29675. * Clones the current color curve instance.
  29676. * @return The cloned curves
  29677. */
  29678. clone(): ColorCurves;
  29679. /**
  29680. * Serializes the current color curve instance to a json representation.
  29681. * @return a JSON representation
  29682. */
  29683. serialize(): any;
  29684. /**
  29685. * Parses the color curve from a json representation.
  29686. * @param source the JSON source to parse
  29687. * @return The parsed curves
  29688. */
  29689. static Parse(source: any): ColorCurves;
  29690. }
  29691. }
  29692. declare module BABYLON {
  29693. /**
  29694. * Interface to follow in your material defines to integrate easily the
  29695. * Image proccessing functions.
  29696. * @hidden
  29697. */
  29698. export interface IImageProcessingConfigurationDefines {
  29699. IMAGEPROCESSING: boolean;
  29700. VIGNETTE: boolean;
  29701. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29702. VIGNETTEBLENDMODEOPAQUE: boolean;
  29703. TONEMAPPING: boolean;
  29704. TONEMAPPING_ACES: boolean;
  29705. CONTRAST: boolean;
  29706. EXPOSURE: boolean;
  29707. COLORCURVES: boolean;
  29708. COLORGRADING: boolean;
  29709. COLORGRADING3D: boolean;
  29710. SAMPLER3DGREENDEPTH: boolean;
  29711. SAMPLER3DBGRMAP: boolean;
  29712. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29713. }
  29714. /**
  29715. * @hidden
  29716. */
  29717. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  29718. IMAGEPROCESSING: boolean;
  29719. VIGNETTE: boolean;
  29720. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29721. VIGNETTEBLENDMODEOPAQUE: boolean;
  29722. TONEMAPPING: boolean;
  29723. TONEMAPPING_ACES: boolean;
  29724. CONTRAST: boolean;
  29725. COLORCURVES: boolean;
  29726. COLORGRADING: boolean;
  29727. COLORGRADING3D: boolean;
  29728. SAMPLER3DGREENDEPTH: boolean;
  29729. SAMPLER3DBGRMAP: boolean;
  29730. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29731. EXPOSURE: boolean;
  29732. constructor();
  29733. }
  29734. /**
  29735. * This groups together the common properties used for image processing either in direct forward pass
  29736. * or through post processing effect depending on the use of the image processing pipeline in your scene
  29737. * or not.
  29738. */
  29739. export class ImageProcessingConfiguration {
  29740. /**
  29741. * Default tone mapping applied in BabylonJS.
  29742. */
  29743. static readonly TONEMAPPING_STANDARD: number;
  29744. /**
  29745. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  29746. * to other engines rendering to increase portability.
  29747. */
  29748. static readonly TONEMAPPING_ACES: number;
  29749. /**
  29750. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  29751. */
  29752. colorCurves: Nullable<ColorCurves>;
  29753. private _colorCurvesEnabled;
  29754. /**
  29755. * Gets wether the color curves effect is enabled.
  29756. */
  29757. /**
  29758. * Sets wether the color curves effect is enabled.
  29759. */
  29760. colorCurvesEnabled: boolean;
  29761. private _colorGradingTexture;
  29762. /**
  29763. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29764. */
  29765. /**
  29766. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29767. */
  29768. colorGradingTexture: Nullable<BaseTexture>;
  29769. private _colorGradingEnabled;
  29770. /**
  29771. * Gets wether the color grading effect is enabled.
  29772. */
  29773. /**
  29774. * Sets wether the color grading effect is enabled.
  29775. */
  29776. colorGradingEnabled: boolean;
  29777. private _colorGradingWithGreenDepth;
  29778. /**
  29779. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  29780. */
  29781. /**
  29782. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  29783. */
  29784. colorGradingWithGreenDepth: boolean;
  29785. private _colorGradingBGR;
  29786. /**
  29787. * Gets wether the color grading texture contains BGR values.
  29788. */
  29789. /**
  29790. * Sets wether the color grading texture contains BGR values.
  29791. */
  29792. colorGradingBGR: boolean;
  29793. /** @hidden */
  29794. _exposure: number;
  29795. /**
  29796. * Gets the Exposure used in the effect.
  29797. */
  29798. /**
  29799. * Sets the Exposure used in the effect.
  29800. */
  29801. exposure: number;
  29802. private _toneMappingEnabled;
  29803. /**
  29804. * Gets wether the tone mapping effect is enabled.
  29805. */
  29806. /**
  29807. * Sets wether the tone mapping effect is enabled.
  29808. */
  29809. toneMappingEnabled: boolean;
  29810. private _toneMappingType;
  29811. /**
  29812. * Gets the type of tone mapping effect.
  29813. */
  29814. /**
  29815. * Sets the type of tone mapping effect used in BabylonJS.
  29816. */
  29817. toneMappingType: number;
  29818. protected _contrast: number;
  29819. /**
  29820. * Gets the contrast used in the effect.
  29821. */
  29822. /**
  29823. * Sets the contrast used in the effect.
  29824. */
  29825. contrast: number;
  29826. /**
  29827. * Vignette stretch size.
  29828. */
  29829. vignetteStretch: number;
  29830. /**
  29831. * Vignette centre X Offset.
  29832. */
  29833. vignetteCentreX: number;
  29834. /**
  29835. * Vignette centre Y Offset.
  29836. */
  29837. vignetteCentreY: number;
  29838. /**
  29839. * Vignette weight or intensity of the vignette effect.
  29840. */
  29841. vignetteWeight: number;
  29842. /**
  29843. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  29844. * if vignetteEnabled is set to true.
  29845. */
  29846. vignetteColor: Color4;
  29847. /**
  29848. * Camera field of view used by the Vignette effect.
  29849. */
  29850. vignetteCameraFov: number;
  29851. private _vignetteBlendMode;
  29852. /**
  29853. * Gets the vignette blend mode allowing different kind of effect.
  29854. */
  29855. /**
  29856. * Sets the vignette blend mode allowing different kind of effect.
  29857. */
  29858. vignetteBlendMode: number;
  29859. private _vignetteEnabled;
  29860. /**
  29861. * Gets wether the vignette effect is enabled.
  29862. */
  29863. /**
  29864. * Sets wether the vignette effect is enabled.
  29865. */
  29866. vignetteEnabled: boolean;
  29867. private _applyByPostProcess;
  29868. /**
  29869. * Gets wether the image processing is applied through a post process or not.
  29870. */
  29871. /**
  29872. * Sets wether the image processing is applied through a post process or not.
  29873. */
  29874. applyByPostProcess: boolean;
  29875. private _isEnabled;
  29876. /**
  29877. * Gets wether the image processing is enabled or not.
  29878. */
  29879. /**
  29880. * Sets wether the image processing is enabled or not.
  29881. */
  29882. isEnabled: boolean;
  29883. /**
  29884. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  29885. */
  29886. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  29887. /**
  29888. * Method called each time the image processing information changes requires to recompile the effect.
  29889. */
  29890. protected _updateParameters(): void;
  29891. /**
  29892. * Gets the current class name.
  29893. * @return "ImageProcessingConfiguration"
  29894. */
  29895. getClassName(): string;
  29896. /**
  29897. * Prepare the list of uniforms associated with the Image Processing effects.
  29898. * @param uniforms The list of uniforms used in the effect
  29899. * @param defines the list of defines currently in use
  29900. */
  29901. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  29902. /**
  29903. * Prepare the list of samplers associated with the Image Processing effects.
  29904. * @param samplersList The list of uniforms used in the effect
  29905. * @param defines the list of defines currently in use
  29906. */
  29907. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  29908. /**
  29909. * Prepare the list of defines associated to the shader.
  29910. * @param defines the list of defines to complete
  29911. * @param forPostProcess Define if we are currently in post process mode or not
  29912. */
  29913. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  29914. /**
  29915. * Returns true if all the image processing information are ready.
  29916. * @returns True if ready, otherwise, false
  29917. */
  29918. isReady(): boolean;
  29919. /**
  29920. * Binds the image processing to the shader.
  29921. * @param effect The effect to bind to
  29922. * @param aspectRatio Define the current aspect ratio of the effect
  29923. */
  29924. bind(effect: Effect, aspectRatio?: number): void;
  29925. /**
  29926. * Clones the current image processing instance.
  29927. * @return The cloned image processing
  29928. */
  29929. clone(): ImageProcessingConfiguration;
  29930. /**
  29931. * Serializes the current image processing instance to a json representation.
  29932. * @return a JSON representation
  29933. */
  29934. serialize(): any;
  29935. /**
  29936. * Parses the image processing from a json representation.
  29937. * @param source the JSON source to parse
  29938. * @return The parsed image processing
  29939. */
  29940. static Parse(source: any): ImageProcessingConfiguration;
  29941. private static _VIGNETTEMODE_MULTIPLY;
  29942. private static _VIGNETTEMODE_OPAQUE;
  29943. /**
  29944. * Used to apply the vignette as a mix with the pixel color.
  29945. */
  29946. static readonly VIGNETTEMODE_MULTIPLY: number;
  29947. /**
  29948. * Used to apply the vignette as a replacement of the pixel color.
  29949. */
  29950. static readonly VIGNETTEMODE_OPAQUE: number;
  29951. }
  29952. }
  29953. declare module BABYLON {
  29954. /**
  29955. * This represents all the required information to add a fresnel effect on a material:
  29956. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29957. */
  29958. export class FresnelParameters {
  29959. private _isEnabled;
  29960. /**
  29961. * Define if the fresnel effect is enable or not.
  29962. */
  29963. isEnabled: boolean;
  29964. /**
  29965. * Define the color used on edges (grazing angle)
  29966. */
  29967. leftColor: Color3;
  29968. /**
  29969. * Define the color used on center
  29970. */
  29971. rightColor: Color3;
  29972. /**
  29973. * Define bias applied to computed fresnel term
  29974. */
  29975. bias: number;
  29976. /**
  29977. * Defined the power exponent applied to fresnel term
  29978. */
  29979. power: number;
  29980. /**
  29981. * Clones the current fresnel and its valuues
  29982. * @returns a clone fresnel configuration
  29983. */
  29984. clone(): FresnelParameters;
  29985. /**
  29986. * Serializes the current fresnel parameters to a JSON representation.
  29987. * @return the JSON serialization
  29988. */
  29989. serialize(): any;
  29990. /**
  29991. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  29992. * @param parsedFresnelParameters Define the JSON representation
  29993. * @returns the parsed parameters
  29994. */
  29995. static Parse(parsedFresnelParameters: any): FresnelParameters;
  29996. }
  29997. }
  29998. declare module BABYLON {
  29999. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30000. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30001. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30002. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30003. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30004. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30005. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30006. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30007. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30008. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30009. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30010. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30011. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30012. /**
  30013. * Decorator used to define property that can be serialized as reference to a camera
  30014. * @param sourceName defines the name of the property to decorate
  30015. */
  30016. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30017. /**
  30018. * Class used to help serialization objects
  30019. */
  30020. export class SerializationHelper {
  30021. /** hidden */
  30022. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  30023. /** hidden */
  30024. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  30025. /** hidden */
  30026. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  30027. /** hidden */
  30028. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  30029. /**
  30030. * Appends the serialized animations from the source animations
  30031. * @param source Source containing the animations
  30032. * @param destination Target to store the animations
  30033. */
  30034. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30035. /**
  30036. * Static function used to serialized a specific entity
  30037. * @param entity defines the entity to serialize
  30038. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30039. * @returns a JSON compatible object representing the serialization of the entity
  30040. */
  30041. static Serialize<T>(entity: T, serializationObject?: any): any;
  30042. /**
  30043. * Creates a new entity from a serialization data object
  30044. * @param creationFunction defines a function used to instanciated the new entity
  30045. * @param source defines the source serialization data
  30046. * @param scene defines the hosting scene
  30047. * @param rootUrl defines the root url for resources
  30048. * @returns a new entity
  30049. */
  30050. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30051. /**
  30052. * Clones an object
  30053. * @param creationFunction defines the function used to instanciate the new object
  30054. * @param source defines the source object
  30055. * @returns the cloned object
  30056. */
  30057. static Clone<T>(creationFunction: () => T, source: T): T;
  30058. /**
  30059. * Instanciates a new object based on a source one (some data will be shared between both object)
  30060. * @param creationFunction defines the function used to instanciate the new object
  30061. * @param source defines the source object
  30062. * @returns the new object
  30063. */
  30064. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30065. }
  30066. }
  30067. declare module BABYLON {
  30068. /**
  30069. * This is the base class of all the camera used in the application.
  30070. * @see http://doc.babylonjs.com/features/cameras
  30071. */
  30072. export class Camera extends Node {
  30073. /** @hidden */
  30074. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30075. /**
  30076. * This is the default projection mode used by the cameras.
  30077. * It helps recreating a feeling of perspective and better appreciate depth.
  30078. * This is the best way to simulate real life cameras.
  30079. */
  30080. static readonly PERSPECTIVE_CAMERA: number;
  30081. /**
  30082. * This helps creating camera with an orthographic mode.
  30083. * 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.
  30084. */
  30085. static readonly ORTHOGRAPHIC_CAMERA: number;
  30086. /**
  30087. * This is the default FOV mode for perspective cameras.
  30088. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30089. */
  30090. static readonly FOVMODE_VERTICAL_FIXED: number;
  30091. /**
  30092. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30093. */
  30094. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30095. /**
  30096. * This specifies ther is no need for a camera rig.
  30097. * Basically only one eye is rendered corresponding to the camera.
  30098. */
  30099. static readonly RIG_MODE_NONE: number;
  30100. /**
  30101. * Simulates a camera Rig with one blue eye and one red eye.
  30102. * This can be use with 3d blue and red glasses.
  30103. */
  30104. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30105. /**
  30106. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30107. */
  30108. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30109. /**
  30110. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30111. */
  30112. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30113. /**
  30114. * Defines that both eyes of the camera will be rendered over under each other.
  30115. */
  30116. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30117. /**
  30118. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30119. */
  30120. static readonly RIG_MODE_VR: number;
  30121. /**
  30122. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30123. */
  30124. static readonly RIG_MODE_WEBVR: number;
  30125. /**
  30126. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30127. */
  30128. static readonly RIG_MODE_CUSTOM: number;
  30129. /**
  30130. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30131. */
  30132. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30133. /**
  30134. * Define the input manager associated with the camera.
  30135. */
  30136. inputs: CameraInputsManager<Camera>;
  30137. /** @hidden */
  30138. _position: Vector3;
  30139. /**
  30140. * Define the current local position of the camera in the scene
  30141. */
  30142. position: Vector3;
  30143. /**
  30144. * The vector the camera should consider as up.
  30145. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30146. */
  30147. upVector: Vector3;
  30148. /**
  30149. * Define the current limit on the left side for an orthographic camera
  30150. * In scene unit
  30151. */
  30152. orthoLeft: Nullable<number>;
  30153. /**
  30154. * Define the current limit on the right side for an orthographic camera
  30155. * In scene unit
  30156. */
  30157. orthoRight: Nullable<number>;
  30158. /**
  30159. * Define the current limit on the bottom side for an orthographic camera
  30160. * In scene unit
  30161. */
  30162. orthoBottom: Nullable<number>;
  30163. /**
  30164. * Define the current limit on the top side for an orthographic camera
  30165. * In scene unit
  30166. */
  30167. orthoTop: Nullable<number>;
  30168. /**
  30169. * Field Of View is set in Radians. (default is 0.8)
  30170. */
  30171. fov: number;
  30172. /**
  30173. * Define the minimum distance the camera can see from.
  30174. * This is important to note that the depth buffer are not infinite and the closer it starts
  30175. * the more your scene might encounter depth fighting issue.
  30176. */
  30177. minZ: number;
  30178. /**
  30179. * Define the maximum distance the camera can see to.
  30180. * This is important to note that the depth buffer are not infinite and the further it end
  30181. * the more your scene might encounter depth fighting issue.
  30182. */
  30183. maxZ: number;
  30184. /**
  30185. * Define the default inertia of the camera.
  30186. * This helps giving a smooth feeling to the camera movement.
  30187. */
  30188. inertia: number;
  30189. /**
  30190. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  30191. */
  30192. mode: number;
  30193. /**
  30194. * Define wether the camera is intermediate.
  30195. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30196. */
  30197. isIntermediate: boolean;
  30198. /**
  30199. * Define the viewport of the camera.
  30200. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30201. */
  30202. viewport: Viewport;
  30203. /**
  30204. * Restricts the camera to viewing objects with the same layerMask.
  30205. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30206. */
  30207. layerMask: number;
  30208. /**
  30209. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30210. */
  30211. fovMode: number;
  30212. /**
  30213. * Rig mode of the camera.
  30214. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30215. * This is normally controlled byt the camera themselves as internal use.
  30216. */
  30217. cameraRigMode: number;
  30218. /**
  30219. * Defines the distance between both "eyes" in case of a RIG
  30220. */
  30221. interaxialDistance: number;
  30222. /**
  30223. * Defines if stereoscopic rendering is done side by side or over under.
  30224. */
  30225. isStereoscopicSideBySide: boolean;
  30226. /**
  30227. * 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
  30228. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30229. * else in the scene.
  30230. */
  30231. customRenderTargets: RenderTargetTexture[];
  30232. /**
  30233. * When set, the camera will render to this render target instead of the default canvas
  30234. */
  30235. outputRenderTarget: Nullable<RenderTargetTexture>;
  30236. /**
  30237. * @hidden
  30238. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  30239. */
  30240. _useMultiviewToSingleView: boolean;
  30241. /**
  30242. * @hidden
  30243. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  30244. */
  30245. _multiviewTexture: Nullable<RenderTargetTexture>;
  30246. /**
  30247. * @hidden
  30248. * ensures the multiview texture of the camera exists and has the specified width/height
  30249. * @param width height to set on the multiview texture
  30250. * @param height width to set on the multiview texture
  30251. */
  30252. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  30253. /**
  30254. * Observable triggered when the camera view matrix has changed.
  30255. */
  30256. onViewMatrixChangedObservable: Observable<Camera>;
  30257. /**
  30258. * Observable triggered when the camera Projection matrix has changed.
  30259. */
  30260. onProjectionMatrixChangedObservable: Observable<Camera>;
  30261. /**
  30262. * Observable triggered when the inputs have been processed.
  30263. */
  30264. onAfterCheckInputsObservable: Observable<Camera>;
  30265. /**
  30266. * Observable triggered when reset has been called and applied to the camera.
  30267. */
  30268. onRestoreStateObservable: Observable<Camera>;
  30269. /** @hidden */
  30270. _cameraRigParams: any;
  30271. /** @hidden */
  30272. _rigCameras: Camera[];
  30273. /** @hidden */
  30274. _rigPostProcess: Nullable<PostProcess>;
  30275. protected _webvrViewMatrix: Matrix;
  30276. /** @hidden */
  30277. _skipRendering: boolean;
  30278. /** @hidden */
  30279. _projectionMatrix: Matrix;
  30280. /** @hidden */
  30281. _postProcesses: Nullable<PostProcess>[];
  30282. /** @hidden */
  30283. _activeMeshes: SmartArray<AbstractMesh>;
  30284. protected _globalPosition: Vector3;
  30285. /** hidden */
  30286. _computedViewMatrix: Matrix;
  30287. private _doNotComputeProjectionMatrix;
  30288. private _transformMatrix;
  30289. private _frustumPlanes;
  30290. private _refreshFrustumPlanes;
  30291. private _storedFov;
  30292. private _stateStored;
  30293. /**
  30294. * Instantiates a new camera object.
  30295. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  30296. * @see http://doc.babylonjs.com/features/cameras
  30297. * @param name Defines the name of the camera in the scene
  30298. * @param position Defines the position of the camera
  30299. * @param scene Defines the scene the camera belongs too
  30300. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  30301. */
  30302. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  30303. /**
  30304. * Store current camera state (fov, position, etc..)
  30305. * @returns the camera
  30306. */
  30307. storeState(): Camera;
  30308. /**
  30309. * Restores the camera state values if it has been stored. You must call storeState() first
  30310. */
  30311. protected _restoreStateValues(): boolean;
  30312. /**
  30313. * Restored camera state. You must call storeState() first.
  30314. * @returns true if restored and false otherwise
  30315. */
  30316. restoreState(): boolean;
  30317. /**
  30318. * Gets the class name of the camera.
  30319. * @returns the class name
  30320. */
  30321. getClassName(): string;
  30322. /** @hidden */
  30323. readonly _isCamera: boolean;
  30324. /**
  30325. * Gets a string representation of the camera useful for debug purpose.
  30326. * @param fullDetails Defines that a more verboe level of logging is required
  30327. * @returns the string representation
  30328. */
  30329. toString(fullDetails?: boolean): string;
  30330. /**
  30331. * Gets the current world space position of the camera.
  30332. */
  30333. readonly globalPosition: Vector3;
  30334. /**
  30335. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  30336. * @returns the active meshe list
  30337. */
  30338. getActiveMeshes(): SmartArray<AbstractMesh>;
  30339. /**
  30340. * Check wether a mesh is part of the current active mesh list of the camera
  30341. * @param mesh Defines the mesh to check
  30342. * @returns true if active, false otherwise
  30343. */
  30344. isActiveMesh(mesh: Mesh): boolean;
  30345. /**
  30346. * Is this camera ready to be used/rendered
  30347. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  30348. * @return true if the camera is ready
  30349. */
  30350. isReady(completeCheck?: boolean): boolean;
  30351. /** @hidden */
  30352. _initCache(): void;
  30353. /** @hidden */
  30354. _updateCache(ignoreParentClass?: boolean): void;
  30355. /** @hidden */
  30356. _isSynchronized(): boolean;
  30357. /** @hidden */
  30358. _isSynchronizedViewMatrix(): boolean;
  30359. /** @hidden */
  30360. _isSynchronizedProjectionMatrix(): boolean;
  30361. /**
  30362. * Attach the input controls to a specific dom element to get the input from.
  30363. * @param element Defines the element the controls should be listened from
  30364. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  30365. */
  30366. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30367. /**
  30368. * Detach the current controls from the specified dom element.
  30369. * @param element Defines the element to stop listening the inputs from
  30370. */
  30371. detachControl(element: HTMLElement): void;
  30372. /**
  30373. * Update the camera state according to the different inputs gathered during the frame.
  30374. */
  30375. update(): void;
  30376. /** @hidden */
  30377. _checkInputs(): void;
  30378. /** @hidden */
  30379. readonly rigCameras: Camera[];
  30380. /**
  30381. * Gets the post process used by the rig cameras
  30382. */
  30383. readonly rigPostProcess: Nullable<PostProcess>;
  30384. /**
  30385. * Internal, gets the first post proces.
  30386. * @returns the first post process to be run on this camera.
  30387. */
  30388. _getFirstPostProcess(): Nullable<PostProcess>;
  30389. private _cascadePostProcessesToRigCams;
  30390. /**
  30391. * Attach a post process to the camera.
  30392. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30393. * @param postProcess The post process to attach to the camera
  30394. * @param insertAt The position of the post process in case several of them are in use in the scene
  30395. * @returns the position the post process has been inserted at
  30396. */
  30397. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  30398. /**
  30399. * Detach a post process to the camera.
  30400. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30401. * @param postProcess The post process to detach from the camera
  30402. */
  30403. detachPostProcess(postProcess: PostProcess): void;
  30404. /**
  30405. * Gets the current world matrix of the camera
  30406. */
  30407. getWorldMatrix(): Matrix;
  30408. /** @hidden */
  30409. _getViewMatrix(): Matrix;
  30410. /**
  30411. * Gets the current view matrix of the camera.
  30412. * @param force forces the camera to recompute the matrix without looking at the cached state
  30413. * @returns the view matrix
  30414. */
  30415. getViewMatrix(force?: boolean): Matrix;
  30416. /**
  30417. * Freeze the projection matrix.
  30418. * It will prevent the cache check of the camera projection compute and can speed up perf
  30419. * if no parameter of the camera are meant to change
  30420. * @param projection Defines manually a projection if necessary
  30421. */
  30422. freezeProjectionMatrix(projection?: Matrix): void;
  30423. /**
  30424. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  30425. */
  30426. unfreezeProjectionMatrix(): void;
  30427. /**
  30428. * Gets the current projection matrix of the camera.
  30429. * @param force forces the camera to recompute the matrix without looking at the cached state
  30430. * @returns the projection matrix
  30431. */
  30432. getProjectionMatrix(force?: boolean): Matrix;
  30433. /**
  30434. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  30435. * @returns a Matrix
  30436. */
  30437. getTransformationMatrix(): Matrix;
  30438. private _updateFrustumPlanes;
  30439. /**
  30440. * Checks if a cullable object (mesh...) is in the camera frustum
  30441. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  30442. * @param target The object to check
  30443. * @returns true if the object is in frustum otherwise false
  30444. */
  30445. isInFrustum(target: ICullable): boolean;
  30446. /**
  30447. * Checks if a cullable object (mesh...) is in the camera frustum
  30448. * Unlike isInFrustum this cheks the full bounding box
  30449. * @param target The object to check
  30450. * @returns true if the object is in frustum otherwise false
  30451. */
  30452. isCompletelyInFrustum(target: ICullable): boolean;
  30453. /**
  30454. * Gets a ray in the forward direction from the camera.
  30455. * @param length Defines the length of the ray to create
  30456. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30457. * @param origin Defines the start point of the ray which defaults to the camera position
  30458. * @returns the forward ray
  30459. */
  30460. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30461. /**
  30462. * Releases resources associated with this node.
  30463. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30464. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30465. */
  30466. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30467. /** @hidden */
  30468. _isLeftCamera: boolean;
  30469. /**
  30470. * Gets the left camera of a rig setup in case of Rigged Camera
  30471. */
  30472. readonly isLeftCamera: boolean;
  30473. /** @hidden */
  30474. _isRightCamera: boolean;
  30475. /**
  30476. * Gets the right camera of a rig setup in case of Rigged Camera
  30477. */
  30478. readonly isRightCamera: boolean;
  30479. /**
  30480. * Gets the left camera of a rig setup in case of Rigged Camera
  30481. */
  30482. readonly leftCamera: Nullable<FreeCamera>;
  30483. /**
  30484. * Gets the right camera of a rig setup in case of Rigged Camera
  30485. */
  30486. readonly rightCamera: Nullable<FreeCamera>;
  30487. /**
  30488. * Gets the left camera target of a rig setup in case of Rigged Camera
  30489. * @returns the target position
  30490. */
  30491. getLeftTarget(): Nullable<Vector3>;
  30492. /**
  30493. * Gets the right camera target of a rig setup in case of Rigged Camera
  30494. * @returns the target position
  30495. */
  30496. getRightTarget(): Nullable<Vector3>;
  30497. /**
  30498. * @hidden
  30499. */
  30500. setCameraRigMode(mode: number, rigParams: any): void;
  30501. /** @hidden */
  30502. static _setStereoscopicRigMode(camera: Camera): void;
  30503. /** @hidden */
  30504. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  30505. /** @hidden */
  30506. static _setVRRigMode(camera: Camera, rigParams: any): void;
  30507. /** @hidden */
  30508. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  30509. /** @hidden */
  30510. _getVRProjectionMatrix(): Matrix;
  30511. protected _updateCameraRotationMatrix(): void;
  30512. protected _updateWebVRCameraRotationMatrix(): void;
  30513. /**
  30514. * This function MUST be overwritten by the different WebVR cameras available.
  30515. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30516. * @hidden
  30517. */
  30518. _getWebVRProjectionMatrix(): Matrix;
  30519. /**
  30520. * This function MUST be overwritten by the different WebVR cameras available.
  30521. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30522. * @hidden
  30523. */
  30524. _getWebVRViewMatrix(): Matrix;
  30525. /** @hidden */
  30526. setCameraRigParameter(name: string, value: any): void;
  30527. /**
  30528. * needs to be overridden by children so sub has required properties to be copied
  30529. * @hidden
  30530. */
  30531. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  30532. /**
  30533. * May need to be overridden by children
  30534. * @hidden
  30535. */
  30536. _updateRigCameras(): void;
  30537. /** @hidden */
  30538. _setupInputs(): void;
  30539. /**
  30540. * Serialiaze the camera setup to a json represention
  30541. * @returns the JSON representation
  30542. */
  30543. serialize(): any;
  30544. /**
  30545. * Clones the current camera.
  30546. * @param name The cloned camera name
  30547. * @returns the cloned camera
  30548. */
  30549. clone(name: string): Camera;
  30550. /**
  30551. * Gets the direction of the camera relative to a given local axis.
  30552. * @param localAxis Defines the reference axis to provide a relative direction.
  30553. * @return the direction
  30554. */
  30555. getDirection(localAxis: Vector3): Vector3;
  30556. /**
  30557. * Gets the direction of the camera relative to a given local axis into a passed vector.
  30558. * @param localAxis Defines the reference axis to provide a relative direction.
  30559. * @param result Defines the vector to store the result in
  30560. */
  30561. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  30562. /**
  30563. * Gets a camera constructor for a given camera type
  30564. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  30565. * @param name The name of the camera the result will be able to instantiate
  30566. * @param scene The scene the result will construct the camera in
  30567. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  30568. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  30569. * @returns a factory method to construc the camera
  30570. */
  30571. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  30572. /**
  30573. * Compute the world matrix of the camera.
  30574. * @returns the camera workd matrix
  30575. */
  30576. computeWorldMatrix(): Matrix;
  30577. /**
  30578. * Parse a JSON and creates the camera from the parsed information
  30579. * @param parsedCamera The JSON to parse
  30580. * @param scene The scene to instantiate the camera in
  30581. * @returns the newly constructed camera
  30582. */
  30583. static Parse(parsedCamera: any, scene: Scene): Camera;
  30584. }
  30585. }
  30586. declare module BABYLON {
  30587. /**
  30588. * Interface for any object that can request an animation frame
  30589. */
  30590. export interface ICustomAnimationFrameRequester {
  30591. /**
  30592. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30593. */
  30594. renderFunction?: Function;
  30595. /**
  30596. * Called to request the next frame to render to
  30597. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30598. */
  30599. requestAnimationFrame: Function;
  30600. /**
  30601. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30602. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30603. */
  30604. requestID?: number;
  30605. }
  30606. /**
  30607. * Interface containing an array of animations
  30608. */
  30609. export interface IAnimatable {
  30610. /**
  30611. * Array of animations
  30612. */
  30613. animations: Array<Animation>;
  30614. }
  30615. /** Interface used by value gradients (color, factor, ...) */
  30616. export interface IValueGradient {
  30617. /**
  30618. * Gets or sets the gradient value (between 0 and 1)
  30619. */
  30620. gradient: number;
  30621. }
  30622. /** Class used to store color4 gradient */
  30623. export class ColorGradient implements IValueGradient {
  30624. /**
  30625. * Gets or sets the gradient value (between 0 and 1)
  30626. */
  30627. gradient: number;
  30628. /**
  30629. * Gets or sets first associated color
  30630. */
  30631. color1: Color4;
  30632. /**
  30633. * Gets or sets second associated color
  30634. */
  30635. color2?: Color4;
  30636. /**
  30637. * Will get a color picked randomly between color1 and color2.
  30638. * If color2 is undefined then color1 will be used
  30639. * @param result defines the target Color4 to store the result in
  30640. */
  30641. getColorToRef(result: Color4): void;
  30642. }
  30643. /** Class used to store color 3 gradient */
  30644. export class Color3Gradient implements IValueGradient {
  30645. /**
  30646. * Gets or sets the gradient value (between 0 and 1)
  30647. */
  30648. gradient: number;
  30649. /**
  30650. * Gets or sets the associated color
  30651. */
  30652. color: Color3;
  30653. }
  30654. /** Class used to store factor gradient */
  30655. export class FactorGradient implements IValueGradient {
  30656. /**
  30657. * Gets or sets the gradient value (between 0 and 1)
  30658. */
  30659. gradient: number;
  30660. /**
  30661. * Gets or sets first associated factor
  30662. */
  30663. factor1: number;
  30664. /**
  30665. * Gets or sets second associated factor
  30666. */
  30667. factor2?: number;
  30668. /**
  30669. * Will get a number picked randomly between factor1 and factor2.
  30670. * If factor2 is undefined then factor1 will be used
  30671. * @returns the picked number
  30672. */
  30673. getFactor(): number;
  30674. }
  30675. /**
  30676. * @ignore
  30677. * Application error to support additional information when loading a file
  30678. */
  30679. export class LoadFileError extends Error {
  30680. /** defines the optional web request */
  30681. request?: WebRequest | undefined;
  30682. private static _setPrototypeOf;
  30683. /**
  30684. * Creates a new LoadFileError
  30685. * @param message defines the message of the error
  30686. * @param request defines the optional web request
  30687. */
  30688. constructor(message: string,
  30689. /** defines the optional web request */
  30690. request?: WebRequest | undefined);
  30691. }
  30692. /**
  30693. * Class used to define a retry strategy when error happens while loading assets
  30694. */
  30695. export class RetryStrategy {
  30696. /**
  30697. * Function used to defines an exponential back off strategy
  30698. * @param maxRetries defines the maximum number of retries (3 by default)
  30699. * @param baseInterval defines the interval between retries
  30700. * @returns the strategy function to use
  30701. */
  30702. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  30703. }
  30704. /**
  30705. * File request interface
  30706. */
  30707. export interface IFileRequest {
  30708. /**
  30709. * Raised when the request is complete (success or error).
  30710. */
  30711. onCompleteObservable: Observable<IFileRequest>;
  30712. /**
  30713. * Aborts the request for a file.
  30714. */
  30715. abort: () => void;
  30716. }
  30717. /**
  30718. * Class containing a set of static utilities functions
  30719. */
  30720. export class Tools {
  30721. /**
  30722. * Gets or sets the base URL to use to load assets
  30723. */
  30724. static BaseUrl: string;
  30725. /**
  30726. * Enable/Disable Custom HTTP Request Headers globally.
  30727. * default = false
  30728. * @see CustomRequestHeaders
  30729. */
  30730. static UseCustomRequestHeaders: boolean;
  30731. /**
  30732. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  30733. * i.e. when loading files, where the server/service expects an Authorization header
  30734. */
  30735. static CustomRequestHeaders: {
  30736. [key: string]: string;
  30737. };
  30738. /**
  30739. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  30740. */
  30741. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  30742. /**
  30743. * Default behaviour for cors in the application.
  30744. * It can be a string if the expected behavior is identical in the entire app.
  30745. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  30746. */
  30747. static CorsBehavior: string | ((url: string | string[]) => string);
  30748. /**
  30749. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  30750. * @ignorenaming
  30751. */
  30752. static UseFallbackTexture: boolean;
  30753. /**
  30754. * Use this object to register external classes like custom textures or material
  30755. * to allow the laoders to instantiate them
  30756. */
  30757. static RegisteredExternalClasses: {
  30758. [key: string]: Object;
  30759. };
  30760. /**
  30761. * Texture content used if a texture cannot loaded
  30762. * @ignorenaming
  30763. */
  30764. static fallbackTexture: string;
  30765. /**
  30766. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  30767. * @param u defines the coordinate on X axis
  30768. * @param v defines the coordinate on Y axis
  30769. * @param width defines the width of the source data
  30770. * @param height defines the height of the source data
  30771. * @param pixels defines the source byte array
  30772. * @param color defines the output color
  30773. */
  30774. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  30775. /**
  30776. * Interpolates between a and b via alpha
  30777. * @param a The lower value (returned when alpha = 0)
  30778. * @param b The upper value (returned when alpha = 1)
  30779. * @param alpha The interpolation-factor
  30780. * @return The mixed value
  30781. */
  30782. static Mix(a: number, b: number, alpha: number): number;
  30783. /**
  30784. * Tries to instantiate a new object from a given class name
  30785. * @param className defines the class name to instantiate
  30786. * @returns the new object or null if the system was not able to do the instantiation
  30787. */
  30788. static Instantiate(className: string): any;
  30789. /**
  30790. * Provides a slice function that will work even on IE
  30791. * @param data defines the array to slice
  30792. * @param start defines the start of the data (optional)
  30793. * @param end defines the end of the data (optional)
  30794. * @returns the new sliced array
  30795. */
  30796. static Slice<T>(data: T, start?: number, end?: number): T;
  30797. /**
  30798. * Polyfill for setImmediate
  30799. * @param action defines the action to execute after the current execution block
  30800. */
  30801. static SetImmediate(action: () => void): void;
  30802. /**
  30803. * Function indicating if a number is an exponent of 2
  30804. * @param value defines the value to test
  30805. * @returns true if the value is an exponent of 2
  30806. */
  30807. static IsExponentOfTwo(value: number): boolean;
  30808. private static _tmpFloatArray;
  30809. /**
  30810. * Returns the nearest 32-bit single precision float representation of a Number
  30811. * @param value A Number. If the parameter is of a different type, it will get converted
  30812. * to a number or to NaN if it cannot be converted
  30813. * @returns number
  30814. */
  30815. static FloatRound(value: number): number;
  30816. /**
  30817. * Find the next highest power of two.
  30818. * @param x Number to start search from.
  30819. * @return Next highest power of two.
  30820. */
  30821. static CeilingPOT(x: number): number;
  30822. /**
  30823. * Find the next lowest power of two.
  30824. * @param x Number to start search from.
  30825. * @return Next lowest power of two.
  30826. */
  30827. static FloorPOT(x: number): number;
  30828. /**
  30829. * Find the nearest power of two.
  30830. * @param x Number to start search from.
  30831. * @return Next nearest power of two.
  30832. */
  30833. static NearestPOT(x: number): number;
  30834. /**
  30835. * Get the closest exponent of two
  30836. * @param value defines the value to approximate
  30837. * @param max defines the maximum value to return
  30838. * @param mode defines how to define the closest value
  30839. * @returns closest exponent of two of the given value
  30840. */
  30841. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30842. /**
  30843. * Extracts the filename from a path
  30844. * @param path defines the path to use
  30845. * @returns the filename
  30846. */
  30847. static GetFilename(path: string): string;
  30848. /**
  30849. * Extracts the "folder" part of a path (everything before the filename).
  30850. * @param uri The URI to extract the info from
  30851. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  30852. * @returns The "folder" part of the path
  30853. */
  30854. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  30855. /**
  30856. * Extracts text content from a DOM element hierarchy
  30857. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  30858. */
  30859. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  30860. /**
  30861. * Convert an angle in radians to degrees
  30862. * @param angle defines the angle to convert
  30863. * @returns the angle in degrees
  30864. */
  30865. static ToDegrees(angle: number): number;
  30866. /**
  30867. * Convert an angle in degrees to radians
  30868. * @param angle defines the angle to convert
  30869. * @returns the angle in radians
  30870. */
  30871. static ToRadians(angle: number): number;
  30872. /**
  30873. * Encode a buffer to a base64 string
  30874. * @param buffer defines the buffer to encode
  30875. * @returns the encoded string
  30876. */
  30877. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  30878. /**
  30879. * Extracts minimum and maximum values from a list of indexed positions
  30880. * @param positions defines the positions to use
  30881. * @param indices defines the indices to the positions
  30882. * @param indexStart defines the start index
  30883. * @param indexCount defines the end index
  30884. * @param bias defines bias value to add to the result
  30885. * @return minimum and maximum values
  30886. */
  30887. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  30888. minimum: Vector3;
  30889. maximum: Vector3;
  30890. };
  30891. /**
  30892. * Extracts minimum and maximum values from a list of positions
  30893. * @param positions defines the positions to use
  30894. * @param start defines the start index in the positions array
  30895. * @param count defines the number of positions to handle
  30896. * @param bias defines bias value to add to the result
  30897. * @param stride defines the stride size to use (distance between two positions in the positions array)
  30898. * @return minimum and maximum values
  30899. */
  30900. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  30901. minimum: Vector3;
  30902. maximum: Vector3;
  30903. };
  30904. /**
  30905. * Returns an array if obj is not an array
  30906. * @param obj defines the object to evaluate as an array
  30907. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  30908. * @returns either obj directly if obj is an array or a new array containing obj
  30909. */
  30910. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  30911. /**
  30912. * Gets the pointer prefix to use
  30913. * @returns "pointer" if touch is enabled. Else returns "mouse"
  30914. */
  30915. static GetPointerPrefix(): string;
  30916. /**
  30917. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  30918. * @param func - the function to be called
  30919. * @param requester - the object that will request the next frame. Falls back to window.
  30920. * @returns frame number
  30921. */
  30922. static QueueNewFrame(func: () => void, requester?: any): number;
  30923. /**
  30924. * Ask the browser to promote the current element to fullscreen rendering mode
  30925. * @param element defines the DOM element to promote
  30926. */
  30927. static RequestFullscreen(element: HTMLElement): void;
  30928. /**
  30929. * Asks the browser to exit fullscreen mode
  30930. */
  30931. static ExitFullscreen(): void;
  30932. /**
  30933. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  30934. * @param url define the url we are trying
  30935. * @param element define the dom element where to configure the cors policy
  30936. */
  30937. static SetCorsBehavior(url: string | string[], element: {
  30938. crossOrigin: string | null;
  30939. }): void;
  30940. /**
  30941. * Removes unwanted characters from an url
  30942. * @param url defines the url to clean
  30943. * @returns the cleaned url
  30944. */
  30945. static CleanUrl(url: string): string;
  30946. /**
  30947. * Gets or sets a function used to pre-process url before using them to load assets
  30948. */
  30949. static PreprocessUrl: (url: string) => string;
  30950. /**
  30951. * Loads an image as an HTMLImageElement.
  30952. * @param input url string, ArrayBuffer, or Blob to load
  30953. * @param onLoad callback called when the image successfully loads
  30954. * @param onError callback called when the image fails to load
  30955. * @param offlineProvider offline provider for caching
  30956. * @returns the HTMLImageElement of the loaded image
  30957. */
  30958. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  30959. /**
  30960. * Loads a file
  30961. * @param url url string, ArrayBuffer, or Blob to load
  30962. * @param onSuccess callback called when the file successfully loads
  30963. * @param onProgress callback called while file is loading (if the server supports this mode)
  30964. * @param offlineProvider defines the offline provider for caching
  30965. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  30966. * @param onError callback called when the file fails to load
  30967. * @returns a file request object
  30968. */
  30969. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  30970. /**
  30971. * Load a script (identified by an url). When the url returns, the
  30972. * content of this file is added into a new script element, attached to the DOM (body element)
  30973. * @param scriptUrl defines the url of the script to laod
  30974. * @param onSuccess defines the callback called when the script is loaded
  30975. * @param onError defines the callback to call if an error occurs
  30976. */
  30977. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  30978. /**
  30979. * Loads a file from a blob
  30980. * @param fileToLoad defines the blob to use
  30981. * @param callback defines the callback to call when data is loaded
  30982. * @param progressCallback defines the callback to call during loading process
  30983. * @returns a file request object
  30984. */
  30985. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  30986. /**
  30987. * Loads a file
  30988. * @param fileToLoad defines the file to load
  30989. * @param callback defines the callback to call when data is loaded
  30990. * @param progressCallBack defines the callback to call during loading process
  30991. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  30992. * @returns a file request object
  30993. */
  30994. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  30995. /**
  30996. * Creates a data url from a given string content
  30997. * @param content defines the content to convert
  30998. * @returns the new data url link
  30999. */
  31000. static FileAsURL(content: string): string;
  31001. /**
  31002. * Format the given number to a specific decimal format
  31003. * @param value defines the number to format
  31004. * @param decimals defines the number of decimals to use
  31005. * @returns the formatted string
  31006. */
  31007. static Format(value: number, decimals?: number): string;
  31008. /**
  31009. * Checks if a given vector is inside a specific range
  31010. * @param v defines the vector to test
  31011. * @param min defines the minimum range
  31012. * @param max defines the maximum range
  31013. */
  31014. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  31015. /**
  31016. * Tries to copy an object by duplicating every property
  31017. * @param source defines the source object
  31018. * @param destination defines the target object
  31019. * @param doNotCopyList defines a list of properties to avoid
  31020. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31021. */
  31022. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31023. /**
  31024. * Gets a boolean indicating if the given object has no own property
  31025. * @param obj defines the object to test
  31026. * @returns true if object has no own property
  31027. */
  31028. static IsEmpty(obj: any): boolean;
  31029. /**
  31030. * Function used to register events at window level
  31031. * @param events defines the events to register
  31032. */
  31033. static RegisterTopRootEvents(events: {
  31034. name: string;
  31035. handler: Nullable<(e: FocusEvent) => any>;
  31036. }[]): void;
  31037. /**
  31038. * Function used to unregister events from window level
  31039. * @param events defines the events to unregister
  31040. */
  31041. static UnregisterTopRootEvents(events: {
  31042. name: string;
  31043. handler: Nullable<(e: FocusEvent) => any>;
  31044. }[]): void;
  31045. /**
  31046. * @ignore
  31047. */
  31048. static _ScreenshotCanvas: HTMLCanvasElement;
  31049. /**
  31050. * Dumps the current bound framebuffer
  31051. * @param width defines the rendering width
  31052. * @param height defines the rendering height
  31053. * @param engine defines the hosting engine
  31054. * @param successCallback defines the callback triggered once the data are available
  31055. * @param mimeType defines the mime type of the result
  31056. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31057. */
  31058. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31059. /**
  31060. * Converts the canvas data to blob.
  31061. * This acts as a polyfill for browsers not supporting the to blob function.
  31062. * @param canvas Defines the canvas to extract the data from
  31063. * @param successCallback Defines the callback triggered once the data are available
  31064. * @param mimeType Defines the mime type of the result
  31065. */
  31066. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31067. /**
  31068. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31069. * @param successCallback defines the callback triggered once the data are available
  31070. * @param mimeType defines the mime type of the result
  31071. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31072. */
  31073. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31074. /**
  31075. * Downloads a blob in the browser
  31076. * @param blob defines the blob to download
  31077. * @param fileName defines the name of the downloaded file
  31078. */
  31079. static Download(blob: Blob, fileName: string): void;
  31080. /**
  31081. * Captures a screenshot of the current rendering
  31082. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31083. * @param engine defines the rendering engine
  31084. * @param camera defines the source camera
  31085. * @param size This parameter can be set to a single number or to an object with the
  31086. * following (optional) properties: precision, width, height. If a single number is passed,
  31087. * it will be used for both width and height. If an object is passed, the screenshot size
  31088. * will be derived from the parameters. The precision property is a multiplier allowing
  31089. * rendering at a higher or lower resolution
  31090. * @param successCallback defines the callback receives a single parameter which contains the
  31091. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31092. * src parameter of an <img> to display it
  31093. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31094. * Check your browser for supported MIME types
  31095. */
  31096. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  31097. /**
  31098. * Generates an image screenshot from the specified camera.
  31099. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31100. * @param engine The engine to use for rendering
  31101. * @param camera The camera to use for rendering
  31102. * @param size This parameter can be set to a single number or to an object with the
  31103. * following (optional) properties: precision, width, height. If a single number is passed,
  31104. * it will be used for both width and height. If an object is passed, the screenshot size
  31105. * will be derived from the parameters. The precision property is a multiplier allowing
  31106. * rendering at a higher or lower resolution
  31107. * @param successCallback The callback receives a single parameter which contains the
  31108. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31109. * src parameter of an <img> to display it
  31110. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31111. * Check your browser for supported MIME types
  31112. * @param samples Texture samples (default: 1)
  31113. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31114. * @param fileName A name for for the downloaded file.
  31115. */
  31116. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31117. /**
  31118. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31119. * Be aware Math.random() could cause collisions, but:
  31120. * "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"
  31121. * @returns a pseudo random id
  31122. */
  31123. static RandomId(): string;
  31124. /**
  31125. * Test if the given uri is a base64 string
  31126. * @param uri The uri to test
  31127. * @return True if the uri is a base64 string or false otherwise
  31128. */
  31129. static IsBase64(uri: string): boolean;
  31130. /**
  31131. * Decode the given base64 uri.
  31132. * @param uri The uri to decode
  31133. * @return The decoded base64 data.
  31134. */
  31135. static DecodeBase64(uri: string): ArrayBuffer;
  31136. /**
  31137. * No log
  31138. */
  31139. static readonly NoneLogLevel: number;
  31140. /**
  31141. * Only message logs
  31142. */
  31143. static readonly MessageLogLevel: number;
  31144. /**
  31145. * Only warning logs
  31146. */
  31147. static readonly WarningLogLevel: number;
  31148. /**
  31149. * Only error logs
  31150. */
  31151. static readonly ErrorLogLevel: number;
  31152. /**
  31153. * All logs
  31154. */
  31155. static readonly AllLogLevel: number;
  31156. /**
  31157. * Gets a value indicating the number of loading errors
  31158. * @ignorenaming
  31159. */
  31160. static readonly errorsCount: number;
  31161. /**
  31162. * Callback called when a new log is added
  31163. */
  31164. static OnNewCacheEntry: (entry: string) => void;
  31165. /**
  31166. * Log a message to the console
  31167. * @param message defines the message to log
  31168. */
  31169. static Log(message: string): void;
  31170. /**
  31171. * Write a warning message to the console
  31172. * @param message defines the message to log
  31173. */
  31174. static Warn(message: string): void;
  31175. /**
  31176. * Write an error message to the console
  31177. * @param message defines the message to log
  31178. */
  31179. static Error(message: string): void;
  31180. /**
  31181. * Gets current log cache (list of logs)
  31182. */
  31183. static readonly LogCache: string;
  31184. /**
  31185. * Clears the log cache
  31186. */
  31187. static ClearLogCache(): void;
  31188. /**
  31189. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  31190. */
  31191. static LogLevels: number;
  31192. /**
  31193. * Checks if the loaded document was accessed via `file:`-Protocol.
  31194. * @returns boolean
  31195. */
  31196. static IsFileURL(): boolean;
  31197. /**
  31198. * Checks if the window object exists
  31199. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  31200. */
  31201. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  31202. /**
  31203. * No performance log
  31204. */
  31205. static readonly PerformanceNoneLogLevel: number;
  31206. /**
  31207. * Use user marks to log performance
  31208. */
  31209. static readonly PerformanceUserMarkLogLevel: number;
  31210. /**
  31211. * Log performance to the console
  31212. */
  31213. static readonly PerformanceConsoleLogLevel: number;
  31214. private static _performance;
  31215. /**
  31216. * Sets the current performance log level
  31217. */
  31218. static PerformanceLogLevel: number;
  31219. private static _StartPerformanceCounterDisabled;
  31220. private static _EndPerformanceCounterDisabled;
  31221. private static _StartUserMark;
  31222. private static _EndUserMark;
  31223. private static _StartPerformanceConsole;
  31224. private static _EndPerformanceConsole;
  31225. /**
  31226. * Starts a performance counter
  31227. */
  31228. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31229. /**
  31230. * Ends a specific performance coutner
  31231. */
  31232. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31233. /**
  31234. * Gets either window.performance.now() if supported or Date.now() else
  31235. */
  31236. static readonly Now: number;
  31237. /**
  31238. * This method will return the name of the class used to create the instance of the given object.
  31239. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  31240. * @param object the object to get the class name from
  31241. * @param isType defines if the object is actually a type
  31242. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  31243. */
  31244. static GetClassName(object: any, isType?: boolean): string;
  31245. /**
  31246. * Gets the first element of an array satisfying a given predicate
  31247. * @param array defines the array to browse
  31248. * @param predicate defines the predicate to use
  31249. * @returns null if not found or the element
  31250. */
  31251. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  31252. /**
  31253. * This method will return the name of the full name of the class, including its owning module (if any).
  31254. * 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).
  31255. * @param object the object to get the class name from
  31256. * @param isType defines if the object is actually a type
  31257. * @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.
  31258. * @ignorenaming
  31259. */
  31260. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  31261. /**
  31262. * Returns a promise that resolves after the given amount of time.
  31263. * @param delay Number of milliseconds to delay
  31264. * @returns Promise that resolves after the given amount of time
  31265. */
  31266. static DelayAsync(delay: number): Promise<void>;
  31267. /**
  31268. * Gets the current gradient from an array of IValueGradient
  31269. * @param ratio defines the current ratio to get
  31270. * @param gradients defines the array of IValueGradient
  31271. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  31272. */
  31273. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  31274. }
  31275. /**
  31276. * This class is used to track a performance counter which is number based.
  31277. * The user has access to many properties which give statistics of different nature.
  31278. *
  31279. * The implementer can track two kinds of Performance Counter: time and count.
  31280. * 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.
  31281. * 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.
  31282. */
  31283. export class PerfCounter {
  31284. /**
  31285. * Gets or sets a global boolean to turn on and off all the counters
  31286. */
  31287. static Enabled: boolean;
  31288. /**
  31289. * Returns the smallest value ever
  31290. */
  31291. readonly min: number;
  31292. /**
  31293. * Returns the biggest value ever
  31294. */
  31295. readonly max: number;
  31296. /**
  31297. * Returns the average value since the performance counter is running
  31298. */
  31299. readonly average: number;
  31300. /**
  31301. * Returns the average value of the last second the counter was monitored
  31302. */
  31303. readonly lastSecAverage: number;
  31304. /**
  31305. * Returns the current value
  31306. */
  31307. readonly current: number;
  31308. /**
  31309. * Gets the accumulated total
  31310. */
  31311. readonly total: number;
  31312. /**
  31313. * Gets the total value count
  31314. */
  31315. readonly count: number;
  31316. /**
  31317. * Creates a new counter
  31318. */
  31319. constructor();
  31320. /**
  31321. * Call this method to start monitoring a new frame.
  31322. * 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.
  31323. */
  31324. fetchNewFrame(): void;
  31325. /**
  31326. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  31327. * @param newCount the count value to add to the monitored count
  31328. * @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.
  31329. */
  31330. addCount(newCount: number, fetchResult: boolean): void;
  31331. /**
  31332. * Start monitoring this performance counter
  31333. */
  31334. beginMonitoring(): void;
  31335. /**
  31336. * Compute the time lapsed since the previous beginMonitoring() call.
  31337. * @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
  31338. */
  31339. endMonitoring(newFrame?: boolean): void;
  31340. private _fetchResult;
  31341. private _startMonitoringTime;
  31342. private _min;
  31343. private _max;
  31344. private _average;
  31345. private _current;
  31346. private _totalValueCount;
  31347. private _totalAccumulated;
  31348. private _lastSecAverage;
  31349. private _lastSecAccumulated;
  31350. private _lastSecTime;
  31351. private _lastSecValueCount;
  31352. }
  31353. /**
  31354. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  31355. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  31356. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  31357. * @param name The name of the class, case should be preserved
  31358. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  31359. */
  31360. export function className(name: string, module?: string): (target: Object) => void;
  31361. /**
  31362. * An implementation of a loop for asynchronous functions.
  31363. */
  31364. export class AsyncLoop {
  31365. /**
  31366. * Defines the number of iterations for the loop
  31367. */
  31368. iterations: number;
  31369. /**
  31370. * Defines the current index of the loop.
  31371. */
  31372. index: number;
  31373. private _done;
  31374. private _fn;
  31375. private _successCallback;
  31376. /**
  31377. * Constructor.
  31378. * @param iterations the number of iterations.
  31379. * @param func the function to run each iteration
  31380. * @param successCallback the callback that will be called upon succesful execution
  31381. * @param offset starting offset.
  31382. */
  31383. constructor(
  31384. /**
  31385. * Defines the number of iterations for the loop
  31386. */
  31387. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  31388. /**
  31389. * Execute the next iteration. Must be called after the last iteration was finished.
  31390. */
  31391. executeNext(): void;
  31392. /**
  31393. * Break the loop and run the success callback.
  31394. */
  31395. breakLoop(): void;
  31396. /**
  31397. * Create and run an async loop.
  31398. * @param iterations the number of iterations.
  31399. * @param fn the function to run each iteration
  31400. * @param successCallback the callback that will be called upon succesful execution
  31401. * @param offset starting offset.
  31402. * @returns the created async loop object
  31403. */
  31404. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  31405. /**
  31406. * A for-loop that will run a given number of iterations synchronous and the rest async.
  31407. * @param iterations total number of iterations
  31408. * @param syncedIterations number of synchronous iterations in each async iteration.
  31409. * @param fn the function to call each iteration.
  31410. * @param callback a success call back that will be called when iterating stops.
  31411. * @param breakFunction a break condition (optional)
  31412. * @param timeout timeout settings for the setTimeout function. default - 0.
  31413. * @returns the created async loop object
  31414. */
  31415. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  31416. }
  31417. }
  31418. declare module BABYLON {
  31419. /** @hidden */
  31420. export interface ICollisionCoordinator {
  31421. createCollider(): Collider;
  31422. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31423. init(scene: Scene): void;
  31424. }
  31425. /** @hidden */
  31426. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  31427. private _scene;
  31428. private _scaledPosition;
  31429. private _scaledVelocity;
  31430. private _finalPosition;
  31431. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31432. createCollider(): Collider;
  31433. init(scene: Scene): void;
  31434. private _collideWithWorld;
  31435. }
  31436. }
  31437. declare module BABYLON {
  31438. /**
  31439. * This class defines the direct association between an animation and a target
  31440. */
  31441. export class TargetedAnimation {
  31442. /**
  31443. * Animation to perform
  31444. */
  31445. animation: Animation;
  31446. /**
  31447. * Target to animate
  31448. */
  31449. target: any;
  31450. }
  31451. /**
  31452. * Use this class to create coordinated animations on multiple targets
  31453. */
  31454. export class AnimationGroup implements IDisposable {
  31455. /** The name of the animation group */
  31456. name: string;
  31457. private _scene;
  31458. private _targetedAnimations;
  31459. private _animatables;
  31460. private _from;
  31461. private _to;
  31462. private _isStarted;
  31463. private _isPaused;
  31464. private _speedRatio;
  31465. /**
  31466. * Gets or sets the unique id of the node
  31467. */
  31468. uniqueId: number;
  31469. /**
  31470. * This observable will notify when one animation have ended
  31471. */
  31472. onAnimationEndObservable: Observable<TargetedAnimation>;
  31473. /**
  31474. * Observer raised when one animation loops
  31475. */
  31476. onAnimationLoopObservable: Observable<TargetedAnimation>;
  31477. /**
  31478. * This observable will notify when all animations have ended.
  31479. */
  31480. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  31481. /**
  31482. * This observable will notify when all animations have paused.
  31483. */
  31484. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  31485. /**
  31486. * This observable will notify when all animations are playing.
  31487. */
  31488. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  31489. /**
  31490. * Gets the first frame
  31491. */
  31492. readonly from: number;
  31493. /**
  31494. * Gets the last frame
  31495. */
  31496. readonly to: number;
  31497. /**
  31498. * Define if the animations are started
  31499. */
  31500. readonly isStarted: boolean;
  31501. /**
  31502. * Gets a value indicating that the current group is playing
  31503. */
  31504. readonly isPlaying: boolean;
  31505. /**
  31506. * Gets or sets the speed ratio to use for all animations
  31507. */
  31508. /**
  31509. * Gets or sets the speed ratio to use for all animations
  31510. */
  31511. speedRatio: number;
  31512. /**
  31513. * Gets the targeted animations for this animation group
  31514. */
  31515. readonly targetedAnimations: Array<TargetedAnimation>;
  31516. /**
  31517. * returning the list of animatables controlled by this animation group.
  31518. */
  31519. readonly animatables: Array<Animatable>;
  31520. /**
  31521. * Instantiates a new Animation Group.
  31522. * This helps managing several animations at once.
  31523. * @see http://doc.babylonjs.com/how_to/group
  31524. * @param name Defines the name of the group
  31525. * @param scene Defines the scene the group belongs to
  31526. */
  31527. constructor(
  31528. /** The name of the animation group */
  31529. name: string, scene?: Nullable<Scene>);
  31530. /**
  31531. * Add an animation (with its target) in the group
  31532. * @param animation defines the animation we want to add
  31533. * @param target defines the target of the animation
  31534. * @returns the TargetedAnimation object
  31535. */
  31536. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  31537. /**
  31538. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  31539. * It can add constant keys at begin or end
  31540. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  31541. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  31542. * @returns the animation group
  31543. */
  31544. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  31545. /**
  31546. * Start all animations on given targets
  31547. * @param loop defines if animations must loop
  31548. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  31549. * @param from defines the from key (optional)
  31550. * @param to defines the to key (optional)
  31551. * @returns the current animation group
  31552. */
  31553. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  31554. /**
  31555. * Pause all animations
  31556. * @returns the animation group
  31557. */
  31558. pause(): AnimationGroup;
  31559. /**
  31560. * Play all animations to initial state
  31561. * This function will start() the animations if they were not started or will restart() them if they were paused
  31562. * @param loop defines if animations must loop
  31563. * @returns the animation group
  31564. */
  31565. play(loop?: boolean): AnimationGroup;
  31566. /**
  31567. * Reset all animations to initial state
  31568. * @returns the animation group
  31569. */
  31570. reset(): AnimationGroup;
  31571. /**
  31572. * Restart animations from key 0
  31573. * @returns the animation group
  31574. */
  31575. restart(): AnimationGroup;
  31576. /**
  31577. * Stop all animations
  31578. * @returns the animation group
  31579. */
  31580. stop(): AnimationGroup;
  31581. /**
  31582. * Set animation weight for all animatables
  31583. * @param weight defines the weight to use
  31584. * @return the animationGroup
  31585. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31586. */
  31587. setWeightForAllAnimatables(weight: number): AnimationGroup;
  31588. /**
  31589. * Synchronize and normalize all animatables with a source animatable
  31590. * @param root defines the root animatable to synchronize with
  31591. * @return the animationGroup
  31592. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31593. */
  31594. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  31595. /**
  31596. * Goes to a specific frame in this animation group
  31597. * @param frame the frame number to go to
  31598. * @return the animationGroup
  31599. */
  31600. goToFrame(frame: number): AnimationGroup;
  31601. /**
  31602. * Dispose all associated resources
  31603. */
  31604. dispose(): void;
  31605. private _checkAnimationGroupEnded;
  31606. /**
  31607. * Clone the current animation group and returns a copy
  31608. * @param newName defines the name of the new group
  31609. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  31610. * @returns the new aniamtion group
  31611. */
  31612. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  31613. /**
  31614. * Returns a new AnimationGroup object parsed from the source provided.
  31615. * @param parsedAnimationGroup defines the source
  31616. * @param scene defines the scene that will receive the animationGroup
  31617. * @returns a new AnimationGroup
  31618. */
  31619. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  31620. /**
  31621. * Returns the string "AnimationGroup"
  31622. * @returns "AnimationGroup"
  31623. */
  31624. getClassName(): string;
  31625. /**
  31626. * Creates a detailled string about the object
  31627. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  31628. * @returns a string representing the object
  31629. */
  31630. toString(fullDetails?: boolean): string;
  31631. }
  31632. }
  31633. declare module BABYLON {
  31634. /**
  31635. * Define an interface for all classes that will hold resources
  31636. */
  31637. export interface IDisposable {
  31638. /**
  31639. * Releases all held resources
  31640. */
  31641. dispose(): void;
  31642. }
  31643. /** Interface defining initialization parameters for Scene class */
  31644. export interface SceneOptions {
  31645. /**
  31646. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  31647. * It will improve performance when the number of geometries becomes important.
  31648. */
  31649. useGeometryUniqueIdsMap?: boolean;
  31650. /**
  31651. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  31652. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31653. */
  31654. useMaterialMeshMap?: boolean;
  31655. /**
  31656. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  31657. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31658. */
  31659. useClonedMeshhMap?: boolean;
  31660. }
  31661. /**
  31662. * Represents a scene to be rendered by the engine.
  31663. * @see http://doc.babylonjs.com/features/scene
  31664. */
  31665. export class Scene extends AbstractScene implements IAnimatable {
  31666. private static _uniqueIdCounter;
  31667. /** The fog is deactivated */
  31668. static readonly FOGMODE_NONE: number;
  31669. /** The fog density is following an exponential function */
  31670. static readonly FOGMODE_EXP: number;
  31671. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  31672. static readonly FOGMODE_EXP2: number;
  31673. /** The fog density is following a linear function. */
  31674. static readonly FOGMODE_LINEAR: number;
  31675. /**
  31676. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  31677. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31678. */
  31679. static MinDeltaTime: number;
  31680. /**
  31681. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  31682. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31683. */
  31684. static MaxDeltaTime: number;
  31685. /**
  31686. * Factory used to create the default material.
  31687. * @param name The name of the material to create
  31688. * @param scene The scene to create the material for
  31689. * @returns The default material
  31690. */
  31691. static DefaultMaterialFactory(scene: Scene): Material;
  31692. /**
  31693. * Factory used to create the a collision coordinator.
  31694. * @returns The collision coordinator
  31695. */
  31696. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  31697. /** @hidden */
  31698. readonly _isScene: boolean;
  31699. /**
  31700. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  31701. */
  31702. autoClear: boolean;
  31703. /**
  31704. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  31705. */
  31706. autoClearDepthAndStencil: boolean;
  31707. /**
  31708. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  31709. */
  31710. clearColor: Color4;
  31711. /**
  31712. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  31713. */
  31714. ambientColor: Color3;
  31715. /**
  31716. * This is use to store the default BRDF lookup for PBR materials in your scene.
  31717. * It should only be one of the following (if not the default embedded one):
  31718. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  31719. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  31720. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  31721. * The material properties need to be setup according to the type of texture in use.
  31722. */
  31723. environmentBRDFTexture: BaseTexture;
  31724. /** @hidden */
  31725. protected _environmentTexture: Nullable<BaseTexture>;
  31726. /**
  31727. * Texture used in all pbr material as the reflection texture.
  31728. * As in the majority of the scene they are the same (exception for multi room and so on),
  31729. * this is easier to reference from here than from all the materials.
  31730. */
  31731. /**
  31732. * Texture used in all pbr material as the reflection texture.
  31733. * As in the majority of the scene they are the same (exception for multi room and so on),
  31734. * this is easier to set here than in all the materials.
  31735. */
  31736. environmentTexture: Nullable<BaseTexture>;
  31737. /** @hidden */
  31738. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31739. /**
  31740. * Default image processing configuration used either in the rendering
  31741. * Forward main pass or through the imageProcessingPostProcess if present.
  31742. * As in the majority of the scene they are the same (exception for multi camera),
  31743. * this is easier to reference from here than from all the materials and post process.
  31744. *
  31745. * No setter as we it is a shared configuration, you can set the values instead.
  31746. */
  31747. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  31748. private _forceWireframe;
  31749. /**
  31750. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  31751. */
  31752. forceWireframe: boolean;
  31753. private _forcePointsCloud;
  31754. /**
  31755. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  31756. */
  31757. forcePointsCloud: boolean;
  31758. /**
  31759. * Gets or sets the active clipplane 1
  31760. */
  31761. clipPlane: Nullable<Plane>;
  31762. /**
  31763. * Gets or sets the active clipplane 2
  31764. */
  31765. clipPlane2: Nullable<Plane>;
  31766. /**
  31767. * Gets or sets the active clipplane 3
  31768. */
  31769. clipPlane3: Nullable<Plane>;
  31770. /**
  31771. * Gets or sets the active clipplane 4
  31772. */
  31773. clipPlane4: Nullable<Plane>;
  31774. /**
  31775. * Gets or sets a boolean indicating if animations are enabled
  31776. */
  31777. animationsEnabled: boolean;
  31778. private _animationPropertiesOverride;
  31779. /**
  31780. * Gets or sets the animation properties override
  31781. */
  31782. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  31783. /**
  31784. * Gets or sets a boolean indicating if a constant deltatime has to be used
  31785. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  31786. */
  31787. useConstantAnimationDeltaTime: boolean;
  31788. /**
  31789. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  31790. * Please note that it requires to run a ray cast through the scene on every frame
  31791. */
  31792. constantlyUpdateMeshUnderPointer: boolean;
  31793. /**
  31794. * Defines the HTML cursor to use when hovering over interactive elements
  31795. */
  31796. hoverCursor: string;
  31797. /**
  31798. * Defines the HTML default cursor to use (empty by default)
  31799. */
  31800. defaultCursor: string;
  31801. /**
  31802. * This is used to call preventDefault() on pointer down
  31803. * in order to block unwanted artifacts like system double clicks
  31804. */
  31805. preventDefaultOnPointerDown: boolean;
  31806. /**
  31807. * This is used to call preventDefault() on pointer up
  31808. * in order to block unwanted artifacts like system double clicks
  31809. */
  31810. preventDefaultOnPointerUp: boolean;
  31811. /**
  31812. * Gets or sets user defined metadata
  31813. */
  31814. metadata: any;
  31815. /**
  31816. * For internal use only. Please do not use.
  31817. */
  31818. reservedDataStore: any;
  31819. /**
  31820. * Gets the name of the plugin used to load this scene (null by default)
  31821. */
  31822. loadingPluginName: string;
  31823. /**
  31824. * Use this array to add regular expressions used to disable offline support for specific urls
  31825. */
  31826. disableOfflineSupportExceptionRules: RegExp[];
  31827. /**
  31828. * An event triggered when the scene is disposed.
  31829. */
  31830. onDisposeObservable: Observable<Scene>;
  31831. private _onDisposeObserver;
  31832. /** Sets a function to be executed when this scene is disposed. */
  31833. onDispose: () => void;
  31834. /**
  31835. * An event triggered before rendering the scene (right after animations and physics)
  31836. */
  31837. onBeforeRenderObservable: Observable<Scene>;
  31838. private _onBeforeRenderObserver;
  31839. /** Sets a function to be executed before rendering this scene */
  31840. beforeRender: Nullable<() => void>;
  31841. /**
  31842. * An event triggered after rendering the scene
  31843. */
  31844. onAfterRenderObservable: Observable<Scene>;
  31845. private _onAfterRenderObserver;
  31846. /** Sets a function to be executed after rendering this scene */
  31847. afterRender: Nullable<() => void>;
  31848. /**
  31849. * An event triggered before animating the scene
  31850. */
  31851. onBeforeAnimationsObservable: Observable<Scene>;
  31852. /**
  31853. * An event triggered after animations processing
  31854. */
  31855. onAfterAnimationsObservable: Observable<Scene>;
  31856. /**
  31857. * An event triggered before draw calls are ready to be sent
  31858. */
  31859. onBeforeDrawPhaseObservable: Observable<Scene>;
  31860. /**
  31861. * An event triggered after draw calls have been sent
  31862. */
  31863. onAfterDrawPhaseObservable: Observable<Scene>;
  31864. /**
  31865. * An event triggered when the scene is ready
  31866. */
  31867. onReadyObservable: Observable<Scene>;
  31868. /**
  31869. * An event triggered before rendering a camera
  31870. */
  31871. onBeforeCameraRenderObservable: Observable<Camera>;
  31872. private _onBeforeCameraRenderObserver;
  31873. /** Sets a function to be executed before rendering a camera*/
  31874. beforeCameraRender: () => void;
  31875. /**
  31876. * An event triggered after rendering a camera
  31877. */
  31878. onAfterCameraRenderObservable: Observable<Camera>;
  31879. private _onAfterCameraRenderObserver;
  31880. /** Sets a function to be executed after rendering a camera*/
  31881. afterCameraRender: () => void;
  31882. /**
  31883. * An event triggered when active meshes evaluation is about to start
  31884. */
  31885. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  31886. /**
  31887. * An event triggered when active meshes evaluation is done
  31888. */
  31889. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  31890. /**
  31891. * An event triggered when particles rendering is about to start
  31892. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  31893. */
  31894. onBeforeParticlesRenderingObservable: Observable<Scene>;
  31895. /**
  31896. * An event triggered when particles rendering is done
  31897. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  31898. */
  31899. onAfterParticlesRenderingObservable: Observable<Scene>;
  31900. /**
  31901. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  31902. */
  31903. onDataLoadedObservable: Observable<Scene>;
  31904. /**
  31905. * An event triggered when a camera is created
  31906. */
  31907. onNewCameraAddedObservable: Observable<Camera>;
  31908. /**
  31909. * An event triggered when a camera is removed
  31910. */
  31911. onCameraRemovedObservable: Observable<Camera>;
  31912. /**
  31913. * An event triggered when a light is created
  31914. */
  31915. onNewLightAddedObservable: Observable<Light>;
  31916. /**
  31917. * An event triggered when a light is removed
  31918. */
  31919. onLightRemovedObservable: Observable<Light>;
  31920. /**
  31921. * An event triggered when a geometry is created
  31922. */
  31923. onNewGeometryAddedObservable: Observable<Geometry>;
  31924. /**
  31925. * An event triggered when a geometry is removed
  31926. */
  31927. onGeometryRemovedObservable: Observable<Geometry>;
  31928. /**
  31929. * An event triggered when a transform node is created
  31930. */
  31931. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  31932. /**
  31933. * An event triggered when a transform node is removed
  31934. */
  31935. onTransformNodeRemovedObservable: Observable<TransformNode>;
  31936. /**
  31937. * An event triggered when a mesh is created
  31938. */
  31939. onNewMeshAddedObservable: Observable<AbstractMesh>;
  31940. /**
  31941. * An event triggered when a mesh is removed
  31942. */
  31943. onMeshRemovedObservable: Observable<AbstractMesh>;
  31944. /**
  31945. * An event triggered when a skeleton is created
  31946. */
  31947. onNewSkeletonAddedObservable: Observable<Skeleton>;
  31948. /**
  31949. * An event triggered when a skeleton is removed
  31950. */
  31951. onSkeletonRemovedObservable: Observable<Skeleton>;
  31952. /**
  31953. * An event triggered when a material is created
  31954. */
  31955. onNewMaterialAddedObservable: Observable<Material>;
  31956. /**
  31957. * An event triggered when a material is removed
  31958. */
  31959. onMaterialRemovedObservable: Observable<Material>;
  31960. /**
  31961. * An event triggered when a texture is created
  31962. */
  31963. onNewTextureAddedObservable: Observable<BaseTexture>;
  31964. /**
  31965. * An event triggered when a texture is removed
  31966. */
  31967. onTextureRemovedObservable: Observable<BaseTexture>;
  31968. /**
  31969. * An event triggered when render targets are about to be rendered
  31970. * Can happen multiple times per frame.
  31971. */
  31972. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  31973. /**
  31974. * An event triggered when render targets were rendered.
  31975. * Can happen multiple times per frame.
  31976. */
  31977. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  31978. /**
  31979. * An event triggered before calculating deterministic simulation step
  31980. */
  31981. onBeforeStepObservable: Observable<Scene>;
  31982. /**
  31983. * An event triggered after calculating deterministic simulation step
  31984. */
  31985. onAfterStepObservable: Observable<Scene>;
  31986. /**
  31987. * An event triggered when the activeCamera property is updated
  31988. */
  31989. onActiveCameraChanged: Observable<Scene>;
  31990. /**
  31991. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  31992. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  31993. * 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)
  31994. */
  31995. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  31996. /**
  31997. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  31998. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  31999. * 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)
  32000. */
  32001. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32002. /**
  32003. * This Observable will when a mesh has been imported into the scene.
  32004. */
  32005. onMeshImportedObservable: Observable<AbstractMesh>;
  32006. /**
  32007. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  32008. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  32009. */
  32010. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  32011. /** @hidden */
  32012. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  32013. /**
  32014. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  32015. */
  32016. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  32017. /**
  32018. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  32019. */
  32020. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  32021. /**
  32022. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  32023. */
  32024. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  32025. private _onPointerMove;
  32026. private _onPointerDown;
  32027. private _onPointerUp;
  32028. /** Callback called when a pointer move is detected */
  32029. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32030. /** Callback called when a pointer down is detected */
  32031. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32032. /** Callback called when a pointer up is detected */
  32033. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  32034. /** Callback called when a pointer pick is detected */
  32035. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  32036. /**
  32037. * 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).
  32038. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  32039. */
  32040. onPrePointerObservable: Observable<PointerInfoPre>;
  32041. /**
  32042. * Observable event triggered each time an input event is received from the rendering canvas
  32043. */
  32044. onPointerObservable: Observable<PointerInfo>;
  32045. /**
  32046. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  32047. */
  32048. readonly unTranslatedPointer: Vector2;
  32049. /** The distance in pixel that you have to move to prevent some events */
  32050. static DragMovementThreshold: number;
  32051. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32052. static LongPressDelay: number;
  32053. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32054. static DoubleClickDelay: number;
  32055. /** If you need to check double click without raising a single click at first click, enable this flag */
  32056. static ExclusiveDoubleClickMode: boolean;
  32057. private _initClickEvent;
  32058. private _initActionManager;
  32059. private _delayedSimpleClick;
  32060. private _delayedSimpleClickTimeout;
  32061. private _previousDelayedSimpleClickTimeout;
  32062. private _meshPickProceed;
  32063. private _previousButtonPressed;
  32064. private _currentPickResult;
  32065. private _previousPickResult;
  32066. private _totalPointersPressed;
  32067. private _doubleClickOccured;
  32068. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32069. cameraToUseForPointers: Nullable<Camera>;
  32070. private _pointerX;
  32071. private _pointerY;
  32072. private _unTranslatedPointerX;
  32073. private _unTranslatedPointerY;
  32074. private _startingPointerPosition;
  32075. private _previousStartingPointerPosition;
  32076. private _startingPointerTime;
  32077. private _previousStartingPointerTime;
  32078. private _pointerCaptures;
  32079. private _timeAccumulator;
  32080. private _currentStepId;
  32081. private _currentInternalStep;
  32082. /** @hidden */
  32083. _mirroredCameraPosition: Nullable<Vector3>;
  32084. /**
  32085. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  32086. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  32087. */
  32088. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  32089. /**
  32090. * Observable event triggered each time an keyboard event is received from the hosting window
  32091. */
  32092. onKeyboardObservable: Observable<KeyboardInfo>;
  32093. private _onKeyDown;
  32094. private _onKeyUp;
  32095. private _onCanvasFocusObserver;
  32096. private _onCanvasBlurObserver;
  32097. private _useRightHandedSystem;
  32098. /**
  32099. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  32100. */
  32101. useRightHandedSystem: boolean;
  32102. /**
  32103. * Sets the step Id used by deterministic lock step
  32104. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32105. * @param newStepId defines the step Id
  32106. */
  32107. setStepId(newStepId: number): void;
  32108. /**
  32109. * Gets the step Id used by deterministic lock step
  32110. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32111. * @returns the step Id
  32112. */
  32113. getStepId(): number;
  32114. /**
  32115. * Gets the internal step used by deterministic lock step
  32116. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32117. * @returns the internal step
  32118. */
  32119. getInternalStep(): number;
  32120. private _fogEnabled;
  32121. /**
  32122. * Gets or sets a boolean indicating if fog is enabled on this scene
  32123. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32124. * (Default is true)
  32125. */
  32126. fogEnabled: boolean;
  32127. private _fogMode;
  32128. /**
  32129. * Gets or sets the fog mode to use
  32130. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32131. * | mode | value |
  32132. * | --- | --- |
  32133. * | FOGMODE_NONE | 0 |
  32134. * | FOGMODE_EXP | 1 |
  32135. * | FOGMODE_EXP2 | 2 |
  32136. * | FOGMODE_LINEAR | 3 |
  32137. */
  32138. fogMode: number;
  32139. /**
  32140. * Gets or sets the fog color to use
  32141. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32142. * (Default is Color3(0.2, 0.2, 0.3))
  32143. */
  32144. fogColor: Color3;
  32145. /**
  32146. * Gets or sets the fog density to use
  32147. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32148. * (Default is 0.1)
  32149. */
  32150. fogDensity: number;
  32151. /**
  32152. * Gets or sets the fog start distance to use
  32153. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32154. * (Default is 0)
  32155. */
  32156. fogStart: number;
  32157. /**
  32158. * Gets or sets the fog end distance to use
  32159. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32160. * (Default is 1000)
  32161. */
  32162. fogEnd: number;
  32163. private _shadowsEnabled;
  32164. /**
  32165. * Gets or sets a boolean indicating if shadows are enabled on this scene
  32166. */
  32167. shadowsEnabled: boolean;
  32168. private _lightsEnabled;
  32169. /**
  32170. * Gets or sets a boolean indicating if lights are enabled on this scene
  32171. */
  32172. lightsEnabled: boolean;
  32173. /** All of the active cameras added to this scene. */
  32174. activeCameras: Camera[];
  32175. private _activeCamera;
  32176. /** Gets or sets the current active camera */
  32177. activeCamera: Nullable<Camera>;
  32178. private _defaultMaterial;
  32179. /** The default material used on meshes when no material is affected */
  32180. /** The default material used on meshes when no material is affected */
  32181. defaultMaterial: Material;
  32182. private _texturesEnabled;
  32183. /**
  32184. * Gets or sets a boolean indicating if textures are enabled on this scene
  32185. */
  32186. texturesEnabled: boolean;
  32187. /**
  32188. * Gets or sets a boolean indicating if particles are enabled on this scene
  32189. */
  32190. particlesEnabled: boolean;
  32191. /**
  32192. * Gets or sets a boolean indicating if sprites are enabled on this scene
  32193. */
  32194. spritesEnabled: boolean;
  32195. private _skeletonsEnabled;
  32196. /**
  32197. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  32198. */
  32199. skeletonsEnabled: boolean;
  32200. /**
  32201. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  32202. */
  32203. lensFlaresEnabled: boolean;
  32204. /**
  32205. * Gets or sets a boolean indicating if collisions are enabled on this scene
  32206. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32207. */
  32208. collisionsEnabled: boolean;
  32209. private _collisionCoordinator;
  32210. /** @hidden */
  32211. readonly collisionCoordinator: ICollisionCoordinator;
  32212. /**
  32213. * Defines the gravity applied to this scene (used only for collisions)
  32214. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32215. */
  32216. gravity: Vector3;
  32217. /**
  32218. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  32219. */
  32220. postProcessesEnabled: boolean;
  32221. /**
  32222. * The list of postprocesses added to the scene
  32223. */
  32224. postProcesses: PostProcess[];
  32225. /**
  32226. * Gets the current postprocess manager
  32227. */
  32228. postProcessManager: PostProcessManager;
  32229. /**
  32230. * Gets or sets a boolean indicating if render targets are enabled on this scene
  32231. */
  32232. renderTargetsEnabled: boolean;
  32233. /**
  32234. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  32235. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  32236. */
  32237. dumpNextRenderTargets: boolean;
  32238. /**
  32239. * The list of user defined render targets added to the scene
  32240. */
  32241. customRenderTargets: RenderTargetTexture[];
  32242. /**
  32243. * Defines if texture loading must be delayed
  32244. * If true, textures will only be loaded when they need to be rendered
  32245. */
  32246. useDelayedTextureLoading: boolean;
  32247. /**
  32248. * Gets the list of meshes imported to the scene through SceneLoader
  32249. */
  32250. importedMeshesFiles: String[];
  32251. /**
  32252. * Gets or sets a boolean indicating if probes are enabled on this scene
  32253. */
  32254. probesEnabled: boolean;
  32255. /**
  32256. * Gets or sets the current offline provider to use to store scene data
  32257. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  32258. */
  32259. offlineProvider: IOfflineProvider;
  32260. /**
  32261. * Gets or sets the action manager associated with the scene
  32262. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32263. */
  32264. actionManager: AbstractActionManager;
  32265. private _meshesForIntersections;
  32266. /**
  32267. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  32268. */
  32269. proceduralTexturesEnabled: boolean;
  32270. private _engine;
  32271. private _totalVertices;
  32272. /** @hidden */
  32273. _activeIndices: PerfCounter;
  32274. /** @hidden */
  32275. _activeParticles: PerfCounter;
  32276. /** @hidden */
  32277. _activeBones: PerfCounter;
  32278. private _animationRatio;
  32279. /** @hidden */
  32280. _animationTimeLast: number;
  32281. /** @hidden */
  32282. _animationTime: number;
  32283. /**
  32284. * Gets or sets a general scale for animation speed
  32285. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  32286. */
  32287. animationTimeScale: number;
  32288. /** @hidden */
  32289. _cachedMaterial: Nullable<Material>;
  32290. /** @hidden */
  32291. _cachedEffect: Nullable<Effect>;
  32292. /** @hidden */
  32293. _cachedVisibility: Nullable<number>;
  32294. private _renderId;
  32295. private _frameId;
  32296. private _executeWhenReadyTimeoutId;
  32297. private _intermediateRendering;
  32298. private _viewUpdateFlag;
  32299. private _projectionUpdateFlag;
  32300. /** @hidden */
  32301. _toBeDisposed: Nullable<IDisposable>[];
  32302. private _activeRequests;
  32303. /** @hidden */
  32304. _pendingData: any[];
  32305. private _isDisposed;
  32306. /**
  32307. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  32308. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  32309. */
  32310. dispatchAllSubMeshesOfActiveMeshes: boolean;
  32311. private _activeMeshes;
  32312. private _processedMaterials;
  32313. private _renderTargets;
  32314. /** @hidden */
  32315. _activeParticleSystems: SmartArray<IParticleSystem>;
  32316. private _activeSkeletons;
  32317. private _softwareSkinnedMeshes;
  32318. private _renderingManager;
  32319. /** @hidden */
  32320. _activeAnimatables: Animatable[];
  32321. private _transformMatrix;
  32322. private _transformMatrixR;
  32323. private _sceneUbo;
  32324. private _multiviewSceneUbo;
  32325. private _viewMatrix;
  32326. private _projectionMatrix;
  32327. private _wheelEventName;
  32328. /** @hidden */
  32329. _forcedViewPosition: Nullable<Vector3>;
  32330. private _frustumPlanes;
  32331. /**
  32332. * Gets the list of frustum planes (built from the active camera)
  32333. */
  32334. readonly frustumPlanes: Plane[];
  32335. /**
  32336. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  32337. * This is useful if there are more lights that the maximum simulteanous authorized
  32338. */
  32339. requireLightSorting: boolean;
  32340. /** @hidden */
  32341. readonly useMaterialMeshMap: boolean;
  32342. /** @hidden */
  32343. readonly useClonedMeshhMap: boolean;
  32344. private _pointerOverMesh;
  32345. private _pickedDownMesh;
  32346. private _pickedUpMesh;
  32347. private _externalData;
  32348. private _uid;
  32349. /**
  32350. * @hidden
  32351. * Backing store of defined scene components.
  32352. */
  32353. _components: ISceneComponent[];
  32354. /**
  32355. * @hidden
  32356. * Backing store of defined scene components.
  32357. */
  32358. _serializableComponents: ISceneSerializableComponent[];
  32359. /**
  32360. * List of components to register on the next registration step.
  32361. */
  32362. private _transientComponents;
  32363. /**
  32364. * Registers the transient components if needed.
  32365. */
  32366. private _registerTransientComponents;
  32367. /**
  32368. * @hidden
  32369. * Add a component to the scene.
  32370. * Note that the ccomponent could be registered on th next frame if this is called after
  32371. * the register component stage.
  32372. * @param component Defines the component to add to the scene
  32373. */
  32374. _addComponent(component: ISceneComponent): void;
  32375. /**
  32376. * @hidden
  32377. * Gets a component from the scene.
  32378. * @param name defines the name of the component to retrieve
  32379. * @returns the component or null if not present
  32380. */
  32381. _getComponent(name: string): Nullable<ISceneComponent>;
  32382. /**
  32383. * @hidden
  32384. * Defines the actions happening before camera updates.
  32385. */
  32386. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  32387. /**
  32388. * @hidden
  32389. * Defines the actions happening before clear the canvas.
  32390. */
  32391. _beforeClearStage: Stage<SimpleStageAction>;
  32392. /**
  32393. * @hidden
  32394. * Defines the actions when collecting render targets for the frame.
  32395. */
  32396. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32397. /**
  32398. * @hidden
  32399. * Defines the actions happening for one camera in the frame.
  32400. */
  32401. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32402. /**
  32403. * @hidden
  32404. * Defines the actions happening during the per mesh ready checks.
  32405. */
  32406. _isReadyForMeshStage: Stage<MeshStageAction>;
  32407. /**
  32408. * @hidden
  32409. * Defines the actions happening before evaluate active mesh checks.
  32410. */
  32411. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  32412. /**
  32413. * @hidden
  32414. * Defines the actions happening during the evaluate sub mesh checks.
  32415. */
  32416. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  32417. /**
  32418. * @hidden
  32419. * Defines the actions happening during the active mesh stage.
  32420. */
  32421. _activeMeshStage: Stage<ActiveMeshStageAction>;
  32422. /**
  32423. * @hidden
  32424. * Defines the actions happening during the per camera render target step.
  32425. */
  32426. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  32427. /**
  32428. * @hidden
  32429. * Defines the actions happening just before the active camera is drawing.
  32430. */
  32431. _beforeCameraDrawStage: Stage<CameraStageAction>;
  32432. /**
  32433. * @hidden
  32434. * Defines the actions happening just before a render target is drawing.
  32435. */
  32436. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32437. /**
  32438. * @hidden
  32439. * Defines the actions happening just before a rendering group is drawing.
  32440. */
  32441. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32442. /**
  32443. * @hidden
  32444. * Defines the actions happening just before a mesh is drawing.
  32445. */
  32446. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32447. /**
  32448. * @hidden
  32449. * Defines the actions happening just after a mesh has been drawn.
  32450. */
  32451. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32452. /**
  32453. * @hidden
  32454. * Defines the actions happening just after a rendering group has been drawn.
  32455. */
  32456. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32457. /**
  32458. * @hidden
  32459. * Defines the actions happening just after the active camera has been drawn.
  32460. */
  32461. _afterCameraDrawStage: Stage<CameraStageAction>;
  32462. /**
  32463. * @hidden
  32464. * Defines the actions happening just after a render target has been drawn.
  32465. */
  32466. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32467. /**
  32468. * @hidden
  32469. * Defines the actions happening just after rendering all cameras and computing intersections.
  32470. */
  32471. _afterRenderStage: Stage<SimpleStageAction>;
  32472. /**
  32473. * @hidden
  32474. * Defines the actions happening when a pointer move event happens.
  32475. */
  32476. _pointerMoveStage: Stage<PointerMoveStageAction>;
  32477. /**
  32478. * @hidden
  32479. * Defines the actions happening when a pointer down event happens.
  32480. */
  32481. _pointerDownStage: Stage<PointerUpDownStageAction>;
  32482. /**
  32483. * @hidden
  32484. * Defines the actions happening when a pointer up event happens.
  32485. */
  32486. _pointerUpStage: Stage<PointerUpDownStageAction>;
  32487. /**
  32488. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  32489. */
  32490. private geometriesByUniqueId;
  32491. /**
  32492. * Creates a new Scene
  32493. * @param engine defines the engine to use to render this scene
  32494. * @param options defines the scene options
  32495. */
  32496. constructor(engine: Engine, options?: SceneOptions);
  32497. /**
  32498. * Gets a string idenfifying the name of the class
  32499. * @returns "Scene" string
  32500. */
  32501. getClassName(): string;
  32502. private _defaultMeshCandidates;
  32503. /**
  32504. * @hidden
  32505. */
  32506. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  32507. private _defaultSubMeshCandidates;
  32508. /**
  32509. * @hidden
  32510. */
  32511. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  32512. /**
  32513. * Sets the default candidate providers for the scene.
  32514. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  32515. * and getCollidingSubMeshCandidates to their default function
  32516. */
  32517. setDefaultCandidateProviders(): void;
  32518. /**
  32519. * Gets the mesh that is currently under the pointer
  32520. */
  32521. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32522. /**
  32523. * Gets or sets the current on-screen X position of the pointer
  32524. */
  32525. pointerX: number;
  32526. /**
  32527. * Gets or sets the current on-screen Y position of the pointer
  32528. */
  32529. pointerY: number;
  32530. /**
  32531. * Gets the cached material (ie. the latest rendered one)
  32532. * @returns the cached material
  32533. */
  32534. getCachedMaterial(): Nullable<Material>;
  32535. /**
  32536. * Gets the cached effect (ie. the latest rendered one)
  32537. * @returns the cached effect
  32538. */
  32539. getCachedEffect(): Nullable<Effect>;
  32540. /**
  32541. * Gets the cached visibility state (ie. the latest rendered one)
  32542. * @returns the cached visibility state
  32543. */
  32544. getCachedVisibility(): Nullable<number>;
  32545. /**
  32546. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  32547. * @param material defines the current material
  32548. * @param effect defines the current effect
  32549. * @param visibility defines the current visibility state
  32550. * @returns true if one parameter is not cached
  32551. */
  32552. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  32553. /**
  32554. * Gets the engine associated with the scene
  32555. * @returns an Engine
  32556. */
  32557. getEngine(): Engine;
  32558. /**
  32559. * Gets the total number of vertices rendered per frame
  32560. * @returns the total number of vertices rendered per frame
  32561. */
  32562. getTotalVertices(): number;
  32563. /**
  32564. * Gets the performance counter for total vertices
  32565. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32566. */
  32567. readonly totalVerticesPerfCounter: PerfCounter;
  32568. /**
  32569. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  32570. * @returns the total number of active indices rendered per frame
  32571. */
  32572. getActiveIndices(): number;
  32573. /**
  32574. * Gets the performance counter for active indices
  32575. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32576. */
  32577. readonly totalActiveIndicesPerfCounter: PerfCounter;
  32578. /**
  32579. * Gets the total number of active particles rendered per frame
  32580. * @returns the total number of active particles rendered per frame
  32581. */
  32582. getActiveParticles(): number;
  32583. /**
  32584. * Gets the performance counter for active particles
  32585. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32586. */
  32587. readonly activeParticlesPerfCounter: PerfCounter;
  32588. /**
  32589. * Gets the total number of active bones rendered per frame
  32590. * @returns the total number of active bones rendered per frame
  32591. */
  32592. getActiveBones(): number;
  32593. /**
  32594. * Gets the performance counter for active bones
  32595. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32596. */
  32597. readonly activeBonesPerfCounter: PerfCounter;
  32598. /**
  32599. * Gets the array of active meshes
  32600. * @returns an array of AbstractMesh
  32601. */
  32602. getActiveMeshes(): SmartArray<AbstractMesh>;
  32603. /**
  32604. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  32605. * @returns a number
  32606. */
  32607. getAnimationRatio(): number;
  32608. /**
  32609. * Gets an unique Id for the current render phase
  32610. * @returns a number
  32611. */
  32612. getRenderId(): number;
  32613. /**
  32614. * Gets an unique Id for the current frame
  32615. * @returns a number
  32616. */
  32617. getFrameId(): number;
  32618. /** Call this function if you want to manually increment the render Id*/
  32619. incrementRenderId(): void;
  32620. private _updatePointerPosition;
  32621. private _createUbo;
  32622. private _createMultiviewUbo;
  32623. private _setRayOnPointerInfo;
  32624. /**
  32625. * Use this method to simulate a pointer move on a mesh
  32626. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32627. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32628. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32629. * @returns the current scene
  32630. */
  32631. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32632. private _processPointerMove;
  32633. private _checkPrePointerObservable;
  32634. /**
  32635. * Use this method to simulate a pointer down on a mesh
  32636. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32637. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32638. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32639. * @returns the current scene
  32640. */
  32641. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32642. private _processPointerDown;
  32643. /**
  32644. * Use this method to simulate a pointer up on a mesh
  32645. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32646. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32647. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32648. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32649. * @returns the current scene
  32650. */
  32651. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  32652. private _processPointerUp;
  32653. /**
  32654. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32655. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32656. * @returns true if the pointer was captured
  32657. */
  32658. isPointerCaptured(pointerId?: number): boolean;
  32659. /** @hidden */
  32660. _isPointerSwiping(): boolean;
  32661. /**
  32662. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32663. * @param attachUp defines if you want to attach events to pointerup
  32664. * @param attachDown defines if you want to attach events to pointerdown
  32665. * @param attachMove defines if you want to attach events to pointermove
  32666. */
  32667. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32668. /** Detaches all event handlers*/
  32669. detachControl(): void;
  32670. /**
  32671. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  32672. * Delay loaded resources are not taking in account
  32673. * @return true if all required resources are ready
  32674. */
  32675. isReady(): boolean;
  32676. /** Resets all cached information relative to material (including effect and visibility) */
  32677. resetCachedMaterial(): void;
  32678. /**
  32679. * Registers a function to be called before every frame render
  32680. * @param func defines the function to register
  32681. */
  32682. registerBeforeRender(func: () => void): void;
  32683. /**
  32684. * Unregisters a function called before every frame render
  32685. * @param func defines the function to unregister
  32686. */
  32687. unregisterBeforeRender(func: () => void): void;
  32688. /**
  32689. * Registers a function to be called after every frame render
  32690. * @param func defines the function to register
  32691. */
  32692. registerAfterRender(func: () => void): void;
  32693. /**
  32694. * Unregisters a function called after every frame render
  32695. * @param func defines the function to unregister
  32696. */
  32697. unregisterAfterRender(func: () => void): void;
  32698. private _executeOnceBeforeRender;
  32699. /**
  32700. * The provided function will run before render once and will be disposed afterwards.
  32701. * A timeout delay can be provided so that the function will be executed in N ms.
  32702. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  32703. * @param func The function to be executed.
  32704. * @param timeout optional delay in ms
  32705. */
  32706. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  32707. /** @hidden */
  32708. _addPendingData(data: any): void;
  32709. /** @hidden */
  32710. _removePendingData(data: any): void;
  32711. /**
  32712. * Returns the number of items waiting to be loaded
  32713. * @returns the number of items waiting to be loaded
  32714. */
  32715. getWaitingItemsCount(): number;
  32716. /**
  32717. * Returns a boolean indicating if the scene is still loading data
  32718. */
  32719. readonly isLoading: boolean;
  32720. /**
  32721. * Registers a function to be executed when the scene is ready
  32722. * @param {Function} func - the function to be executed
  32723. */
  32724. executeWhenReady(func: () => void): void;
  32725. /**
  32726. * Returns a promise that resolves when the scene is ready
  32727. * @returns A promise that resolves when the scene is ready
  32728. */
  32729. whenReadyAsync(): Promise<void>;
  32730. /** @hidden */
  32731. _checkIsReady(): void;
  32732. /**
  32733. * Gets all animatable attached to the scene
  32734. */
  32735. readonly animatables: Animatable[];
  32736. /**
  32737. * Resets the last animation time frame.
  32738. * Useful to override when animations start running when loading a scene for the first time.
  32739. */
  32740. resetLastAnimationTimeFrame(): void;
  32741. /**
  32742. * Gets the current view matrix
  32743. * @returns a Matrix
  32744. */
  32745. getViewMatrix(): Matrix;
  32746. /**
  32747. * Gets the current projection matrix
  32748. * @returns a Matrix
  32749. */
  32750. getProjectionMatrix(): Matrix;
  32751. /**
  32752. * Gets the current transform matrix
  32753. * @returns a Matrix made of View * Projection
  32754. */
  32755. getTransformMatrix(): Matrix;
  32756. /**
  32757. * Sets the current transform matrix
  32758. * @param viewL defines the View matrix to use
  32759. * @param projectionL defines the Projection matrix to use
  32760. * @param viewR defines the right View matrix to use (if provided)
  32761. * @param projectionR defines the right Projection matrix to use (if provided)
  32762. */
  32763. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  32764. /**
  32765. * Gets the uniform buffer used to store scene data
  32766. * @returns a UniformBuffer
  32767. */
  32768. getSceneUniformBuffer(): UniformBuffer;
  32769. /**
  32770. * Gets an unique (relatively to the current scene) Id
  32771. * @returns an unique number for the scene
  32772. */
  32773. getUniqueId(): number;
  32774. /**
  32775. * Add a mesh to the list of scene's meshes
  32776. * @param newMesh defines the mesh to add
  32777. * @param recursive if all child meshes should also be added to the scene
  32778. */
  32779. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  32780. /**
  32781. * Remove a mesh for the list of scene's meshes
  32782. * @param toRemove defines the mesh to remove
  32783. * @param recursive if all child meshes should also be removed from the scene
  32784. * @returns the index where the mesh was in the mesh list
  32785. */
  32786. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  32787. /**
  32788. * Add a transform node to the list of scene's transform nodes
  32789. * @param newTransformNode defines the transform node to add
  32790. */
  32791. addTransformNode(newTransformNode: TransformNode): void;
  32792. /**
  32793. * Remove a transform node for the list of scene's transform nodes
  32794. * @param toRemove defines the transform node to remove
  32795. * @returns the index where the transform node was in the transform node list
  32796. */
  32797. removeTransformNode(toRemove: TransformNode): number;
  32798. /**
  32799. * Remove a skeleton for the list of scene's skeletons
  32800. * @param toRemove defines the skeleton to remove
  32801. * @returns the index where the skeleton was in the skeleton list
  32802. */
  32803. removeSkeleton(toRemove: Skeleton): number;
  32804. /**
  32805. * Remove a morph target for the list of scene's morph targets
  32806. * @param toRemove defines the morph target to remove
  32807. * @returns the index where the morph target was in the morph target list
  32808. */
  32809. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  32810. /**
  32811. * Remove a light for the list of scene's lights
  32812. * @param toRemove defines the light to remove
  32813. * @returns the index where the light was in the light list
  32814. */
  32815. removeLight(toRemove: Light): number;
  32816. /**
  32817. * Remove a camera for the list of scene's cameras
  32818. * @param toRemove defines the camera to remove
  32819. * @returns the index where the camera was in the camera list
  32820. */
  32821. removeCamera(toRemove: Camera): number;
  32822. /**
  32823. * Remove a particle system for the list of scene's particle systems
  32824. * @param toRemove defines the particle system to remove
  32825. * @returns the index where the particle system was in the particle system list
  32826. */
  32827. removeParticleSystem(toRemove: IParticleSystem): number;
  32828. /**
  32829. * Remove a animation for the list of scene's animations
  32830. * @param toRemove defines the animation to remove
  32831. * @returns the index where the animation was in the animation list
  32832. */
  32833. removeAnimation(toRemove: Animation): number;
  32834. /**
  32835. * Removes the given animation group from this scene.
  32836. * @param toRemove The animation group to remove
  32837. * @returns The index of the removed animation group
  32838. */
  32839. removeAnimationGroup(toRemove: AnimationGroup): number;
  32840. /**
  32841. * Removes the given multi-material from this scene.
  32842. * @param toRemove The multi-material to remove
  32843. * @returns The index of the removed multi-material
  32844. */
  32845. removeMultiMaterial(toRemove: MultiMaterial): number;
  32846. /**
  32847. * Removes the given material from this scene.
  32848. * @param toRemove The material to remove
  32849. * @returns The index of the removed material
  32850. */
  32851. removeMaterial(toRemove: Material): number;
  32852. /**
  32853. * Removes the given action manager from this scene.
  32854. * @param toRemove The action manager to remove
  32855. * @returns The index of the removed action manager
  32856. */
  32857. removeActionManager(toRemove: AbstractActionManager): number;
  32858. /**
  32859. * Removes the given texture from this scene.
  32860. * @param toRemove The texture to remove
  32861. * @returns The index of the removed texture
  32862. */
  32863. removeTexture(toRemove: BaseTexture): number;
  32864. /**
  32865. * Adds the given light to this scene
  32866. * @param newLight The light to add
  32867. */
  32868. addLight(newLight: Light): void;
  32869. /**
  32870. * Sorts the list list based on light priorities
  32871. */
  32872. sortLightsByPriority(): void;
  32873. /**
  32874. * Adds the given camera to this scene
  32875. * @param newCamera The camera to add
  32876. */
  32877. addCamera(newCamera: Camera): void;
  32878. /**
  32879. * Adds the given skeleton to this scene
  32880. * @param newSkeleton The skeleton to add
  32881. */
  32882. addSkeleton(newSkeleton: Skeleton): void;
  32883. /**
  32884. * Adds the given particle system to this scene
  32885. * @param newParticleSystem The particle system to add
  32886. */
  32887. addParticleSystem(newParticleSystem: IParticleSystem): void;
  32888. /**
  32889. * Adds the given animation to this scene
  32890. * @param newAnimation The animation to add
  32891. */
  32892. addAnimation(newAnimation: Animation): void;
  32893. /**
  32894. * Adds the given animation group to this scene.
  32895. * @param newAnimationGroup The animation group to add
  32896. */
  32897. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  32898. /**
  32899. * Adds the given multi-material to this scene
  32900. * @param newMultiMaterial The multi-material to add
  32901. */
  32902. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  32903. /**
  32904. * Adds the given material to this scene
  32905. * @param newMaterial The material to add
  32906. */
  32907. addMaterial(newMaterial: Material): void;
  32908. /**
  32909. * Adds the given morph target to this scene
  32910. * @param newMorphTargetManager The morph target to add
  32911. */
  32912. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  32913. /**
  32914. * Adds the given geometry to this scene
  32915. * @param newGeometry The geometry to add
  32916. */
  32917. addGeometry(newGeometry: Geometry): void;
  32918. /**
  32919. * Adds the given action manager to this scene
  32920. * @param newActionManager The action manager to add
  32921. */
  32922. addActionManager(newActionManager: AbstractActionManager): void;
  32923. /**
  32924. * Adds the given texture to this scene.
  32925. * @param newTexture The texture to add
  32926. */
  32927. addTexture(newTexture: BaseTexture): void;
  32928. /**
  32929. * Switch active camera
  32930. * @param newCamera defines the new active camera
  32931. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  32932. */
  32933. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  32934. /**
  32935. * sets the active camera of the scene using its ID
  32936. * @param id defines the camera's ID
  32937. * @return the new active camera or null if none found.
  32938. */
  32939. setActiveCameraByID(id: string): Nullable<Camera>;
  32940. /**
  32941. * sets the active camera of the scene using its name
  32942. * @param name defines the camera's name
  32943. * @returns the new active camera or null if none found.
  32944. */
  32945. setActiveCameraByName(name: string): Nullable<Camera>;
  32946. /**
  32947. * get an animation group using its name
  32948. * @param name defines the material's name
  32949. * @return the animation group or null if none found.
  32950. */
  32951. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  32952. /**
  32953. * Get a material using its unique id
  32954. * @param uniqueId defines the material's unique id
  32955. * @return the material or null if none found.
  32956. */
  32957. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  32958. /**
  32959. * get a material using its id
  32960. * @param id defines the material's ID
  32961. * @return the material or null if none found.
  32962. */
  32963. getMaterialByID(id: string): Nullable<Material>;
  32964. /**
  32965. * Gets a material using its name
  32966. * @param name defines the material's name
  32967. * @return the material or null if none found.
  32968. */
  32969. getMaterialByName(name: string): Nullable<Material>;
  32970. /**
  32971. * Gets a camera using its id
  32972. * @param id defines the id to look for
  32973. * @returns the camera or null if not found
  32974. */
  32975. getCameraByID(id: string): Nullable<Camera>;
  32976. /**
  32977. * Gets a camera using its unique id
  32978. * @param uniqueId defines the unique id to look for
  32979. * @returns the camera or null if not found
  32980. */
  32981. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  32982. /**
  32983. * Gets a camera using its name
  32984. * @param name defines the camera's name
  32985. * @return the camera or null if none found.
  32986. */
  32987. getCameraByName(name: string): Nullable<Camera>;
  32988. /**
  32989. * Gets a bone using its id
  32990. * @param id defines the bone's id
  32991. * @return the bone or null if not found
  32992. */
  32993. getBoneByID(id: string): Nullable<Bone>;
  32994. /**
  32995. * Gets a bone using its id
  32996. * @param name defines the bone's name
  32997. * @return the bone or null if not found
  32998. */
  32999. getBoneByName(name: string): Nullable<Bone>;
  33000. /**
  33001. * Gets a light node using its name
  33002. * @param name defines the the light's name
  33003. * @return the light or null if none found.
  33004. */
  33005. getLightByName(name: string): Nullable<Light>;
  33006. /**
  33007. * Gets a light node using its id
  33008. * @param id defines the light's id
  33009. * @return the light or null if none found.
  33010. */
  33011. getLightByID(id: string): Nullable<Light>;
  33012. /**
  33013. * Gets a light node using its scene-generated unique ID
  33014. * @param uniqueId defines the light's unique id
  33015. * @return the light or null if none found.
  33016. */
  33017. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  33018. /**
  33019. * Gets a particle system by id
  33020. * @param id defines the particle system id
  33021. * @return the corresponding system or null if none found
  33022. */
  33023. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  33024. /**
  33025. * Gets a geometry using its ID
  33026. * @param id defines the geometry's id
  33027. * @return the geometry or null if none found.
  33028. */
  33029. getGeometryByID(id: string): Nullable<Geometry>;
  33030. private _getGeometryByUniqueID;
  33031. /**
  33032. * Add a new geometry to this scene
  33033. * @param geometry defines the geometry to be added to the scene.
  33034. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  33035. * @return a boolean defining if the geometry was added or not
  33036. */
  33037. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  33038. /**
  33039. * Removes an existing geometry
  33040. * @param geometry defines the geometry to be removed from the scene
  33041. * @return a boolean defining if the geometry was removed or not
  33042. */
  33043. removeGeometry(geometry: Geometry): boolean;
  33044. /**
  33045. * Gets the list of geometries attached to the scene
  33046. * @returns an array of Geometry
  33047. */
  33048. getGeometries(): Geometry[];
  33049. /**
  33050. * Gets the first added mesh found of a given ID
  33051. * @param id defines the id to search for
  33052. * @return the mesh found or null if not found at all
  33053. */
  33054. getMeshByID(id: string): Nullable<AbstractMesh>;
  33055. /**
  33056. * Gets a list of meshes using their id
  33057. * @param id defines the id to search for
  33058. * @returns a list of meshes
  33059. */
  33060. getMeshesByID(id: string): Array<AbstractMesh>;
  33061. /**
  33062. * Gets the first added transform node found of a given ID
  33063. * @param id defines the id to search for
  33064. * @return the found transform node or null if not found at all.
  33065. */
  33066. getTransformNodeByID(id: string): Nullable<TransformNode>;
  33067. /**
  33068. * Gets a transform node with its auto-generated unique id
  33069. * @param uniqueId efines the unique id to search for
  33070. * @return the found transform node or null if not found at all.
  33071. */
  33072. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  33073. /**
  33074. * Gets a list of transform nodes using their id
  33075. * @param id defines the id to search for
  33076. * @returns a list of transform nodes
  33077. */
  33078. getTransformNodesByID(id: string): Array<TransformNode>;
  33079. /**
  33080. * Gets a mesh with its auto-generated unique id
  33081. * @param uniqueId defines the unique id to search for
  33082. * @return the found mesh or null if not found at all.
  33083. */
  33084. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  33085. /**
  33086. * Gets a the last added mesh using a given id
  33087. * @param id defines the id to search for
  33088. * @return the found mesh or null if not found at all.
  33089. */
  33090. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  33091. /**
  33092. * Gets a the last added node (Mesh, Camera, Light) using a given id
  33093. * @param id defines the id to search for
  33094. * @return the found node or null if not found at all
  33095. */
  33096. getLastEntryByID(id: string): Nullable<Node>;
  33097. /**
  33098. * Gets a node (Mesh, Camera, Light) using a given id
  33099. * @param id defines the id to search for
  33100. * @return the found node or null if not found at all
  33101. */
  33102. getNodeByID(id: string): Nullable<Node>;
  33103. /**
  33104. * Gets a node (Mesh, Camera, Light) using a given name
  33105. * @param name defines the name to search for
  33106. * @return the found node or null if not found at all.
  33107. */
  33108. getNodeByName(name: string): Nullable<Node>;
  33109. /**
  33110. * Gets a mesh using a given name
  33111. * @param name defines the name to search for
  33112. * @return the found mesh or null if not found at all.
  33113. */
  33114. getMeshByName(name: string): Nullable<AbstractMesh>;
  33115. /**
  33116. * Gets a transform node using a given name
  33117. * @param name defines the name to search for
  33118. * @return the found transform node or null if not found at all.
  33119. */
  33120. getTransformNodeByName(name: string): Nullable<TransformNode>;
  33121. /**
  33122. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  33123. * @param id defines the id to search for
  33124. * @return the found skeleton or null if not found at all.
  33125. */
  33126. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  33127. /**
  33128. * Gets a skeleton using a given auto generated unique id
  33129. * @param uniqueId defines the unique id to search for
  33130. * @return the found skeleton or null if not found at all.
  33131. */
  33132. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  33133. /**
  33134. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  33135. * @param id defines the id to search for
  33136. * @return the found skeleton or null if not found at all.
  33137. */
  33138. getSkeletonById(id: string): Nullable<Skeleton>;
  33139. /**
  33140. * Gets a skeleton using a given name
  33141. * @param name defines the name to search for
  33142. * @return the found skeleton or null if not found at all.
  33143. */
  33144. getSkeletonByName(name: string): Nullable<Skeleton>;
  33145. /**
  33146. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  33147. * @param id defines the id to search for
  33148. * @return the found morph target manager or null if not found at all.
  33149. */
  33150. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  33151. /**
  33152. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  33153. * @param id defines the id to search for
  33154. * @return the found morph target or null if not found at all.
  33155. */
  33156. getMorphTargetById(id: string): Nullable<MorphTarget>;
  33157. /**
  33158. * Gets a boolean indicating if the given mesh is active
  33159. * @param mesh defines the mesh to look for
  33160. * @returns true if the mesh is in the active list
  33161. */
  33162. isActiveMesh(mesh: AbstractMesh): boolean;
  33163. /**
  33164. * Return a unique id as a string which can serve as an identifier for the scene
  33165. */
  33166. readonly uid: string;
  33167. /**
  33168. * Add an externaly attached data from its key.
  33169. * This method call will fail and return false, if such key already exists.
  33170. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33171. * @param key the unique key that identifies the data
  33172. * @param data the data object to associate to the key for this Engine instance
  33173. * @return true if no such key were already present and the data was added successfully, false otherwise
  33174. */
  33175. addExternalData<T>(key: string, data: T): boolean;
  33176. /**
  33177. * Get an externaly attached data from its key
  33178. * @param key the unique key that identifies the data
  33179. * @return the associated data, if present (can be null), or undefined if not present
  33180. */
  33181. getExternalData<T>(key: string): Nullable<T>;
  33182. /**
  33183. * Get an externaly attached data from its key, create it using a factory if it's not already present
  33184. * @param key the unique key that identifies the data
  33185. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  33186. * @return the associated data, can be null if the factory returned null.
  33187. */
  33188. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  33189. /**
  33190. * Remove an externaly attached data from the Engine instance
  33191. * @param key the unique key that identifies the data
  33192. * @return true if the data was successfully removed, false if it doesn't exist
  33193. */
  33194. removeExternalData(key: string): boolean;
  33195. private _evaluateSubMesh;
  33196. /**
  33197. * Clear the processed materials smart array preventing retention point in material dispose.
  33198. */
  33199. freeProcessedMaterials(): void;
  33200. private _preventFreeActiveMeshesAndRenderingGroups;
  33201. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  33202. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  33203. * when disposing several meshes in a row or a hierarchy of meshes.
  33204. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  33205. */
  33206. blockfreeActiveMeshesAndRenderingGroups: boolean;
  33207. /**
  33208. * Clear the active meshes smart array preventing retention point in mesh dispose.
  33209. */
  33210. freeActiveMeshes(): void;
  33211. /**
  33212. * Clear the info related to rendering groups preventing retention points during dispose.
  33213. */
  33214. freeRenderingGroups(): void;
  33215. /** @hidden */
  33216. _isInIntermediateRendering(): boolean;
  33217. /**
  33218. * Lambda returning the list of potentially active meshes.
  33219. */
  33220. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  33221. /**
  33222. * Lambda returning the list of potentially active sub meshes.
  33223. */
  33224. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  33225. /**
  33226. * Lambda returning the list of potentially intersecting sub meshes.
  33227. */
  33228. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  33229. /**
  33230. * Lambda returning the list of potentially colliding sub meshes.
  33231. */
  33232. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  33233. private _activeMeshesFrozen;
  33234. /**
  33235. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  33236. * @returns the current scene
  33237. */
  33238. freezeActiveMeshes(): Scene;
  33239. /**
  33240. * Use this function to restart evaluating active meshes on every frame
  33241. * @returns the current scene
  33242. */
  33243. unfreezeActiveMeshes(): Scene;
  33244. private _evaluateActiveMeshes;
  33245. private _activeMesh;
  33246. /**
  33247. * Update the transform matrix to update from the current active camera
  33248. * @param force defines a boolean used to force the update even if cache is up to date
  33249. */
  33250. updateTransformMatrix(force?: boolean): void;
  33251. private _bindFrameBuffer;
  33252. /** @hidden */
  33253. _allowPostProcessClearColor: boolean;
  33254. private _renderForCamera;
  33255. private _processSubCameras;
  33256. private _checkIntersections;
  33257. /** @hidden */
  33258. _advancePhysicsEngineStep(step: number): void;
  33259. /**
  33260. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  33261. */
  33262. getDeterministicFrameTime: () => number;
  33263. /** @hidden */
  33264. _animate(): void;
  33265. /**
  33266. * Render the scene
  33267. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  33268. */
  33269. render(updateCameras?: boolean): void;
  33270. /**
  33271. * Freeze all materials
  33272. * A frozen material will not be updatable but should be faster to render
  33273. */
  33274. freezeMaterials(): void;
  33275. /**
  33276. * Unfreeze all materials
  33277. * A frozen material will not be updatable but should be faster to render
  33278. */
  33279. unfreezeMaterials(): void;
  33280. /**
  33281. * Releases all held ressources
  33282. */
  33283. dispose(): void;
  33284. /**
  33285. * Gets if the scene is already disposed
  33286. */
  33287. readonly isDisposed: boolean;
  33288. /**
  33289. * Call this function to reduce memory footprint of the scene.
  33290. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  33291. */
  33292. clearCachedVertexData(): void;
  33293. /**
  33294. * This function will remove the local cached buffer data from texture.
  33295. * It will save memory but will prevent the texture from being rebuilt
  33296. */
  33297. cleanCachedTextureBuffer(): void;
  33298. /**
  33299. * Get the world extend vectors with an optional filter
  33300. *
  33301. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  33302. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  33303. */
  33304. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  33305. min: Vector3;
  33306. max: Vector3;
  33307. };
  33308. /**
  33309. * Creates a ray that can be used to pick in the scene
  33310. * @param x defines the x coordinate of the origin (on-screen)
  33311. * @param y defines the y coordinate of the origin (on-screen)
  33312. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33313. * @param camera defines the camera to use for the picking
  33314. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33315. * @returns a Ray
  33316. */
  33317. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  33318. /**
  33319. * Creates a ray that can be used to pick in the scene
  33320. * @param x defines the x coordinate of the origin (on-screen)
  33321. * @param y defines the y coordinate of the origin (on-screen)
  33322. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33323. * @param result defines the ray where to store the picking ray
  33324. * @param camera defines the camera to use for the picking
  33325. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33326. * @returns the current scene
  33327. */
  33328. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  33329. /**
  33330. * Creates a ray that can be used to pick in the scene
  33331. * @param x defines the x coordinate of the origin (on-screen)
  33332. * @param y defines the y coordinate of the origin (on-screen)
  33333. * @param camera defines the camera to use for the picking
  33334. * @returns a Ray
  33335. */
  33336. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  33337. /**
  33338. * Creates a ray that can be used to pick in the scene
  33339. * @param x defines the x coordinate of the origin (on-screen)
  33340. * @param y defines the y coordinate of the origin (on-screen)
  33341. * @param result defines the ray where to store the picking ray
  33342. * @param camera defines the camera to use for the picking
  33343. * @returns the current scene
  33344. */
  33345. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  33346. /** Launch a ray to try to pick a mesh in the scene
  33347. * @param x position on screen
  33348. * @param y position on screen
  33349. * @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
  33350. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  33351. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33352. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33353. * @returns a PickingInfo
  33354. */
  33355. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  33356. /** Use the given ray to pick a mesh in the scene
  33357. * @param ray The ray to use to pick meshes
  33358. * @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
  33359. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  33360. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33361. * @returns a PickingInfo
  33362. */
  33363. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  33364. /**
  33365. * Launch a ray to try to pick a mesh in the scene
  33366. * @param x X position on screen
  33367. * @param y Y position on screen
  33368. * @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
  33369. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33370. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33371. * @returns an array of PickingInfo
  33372. */
  33373. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33374. /**
  33375. * Launch a ray to try to pick a mesh in the scene
  33376. * @param ray Ray to use
  33377. * @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
  33378. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33379. * @returns an array of PickingInfo
  33380. */
  33381. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33382. /**
  33383. * Force the value of meshUnderPointer
  33384. * @param mesh defines the mesh to use
  33385. */
  33386. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33387. /**
  33388. * Gets the mesh under the pointer
  33389. * @returns a Mesh or null if no mesh is under the pointer
  33390. */
  33391. getPointerOverMesh(): Nullable<AbstractMesh>;
  33392. /** @hidden */
  33393. _rebuildGeometries(): void;
  33394. /** @hidden */
  33395. _rebuildTextures(): void;
  33396. private _getByTags;
  33397. /**
  33398. * Get a list of meshes by tags
  33399. * @param tagsQuery defines the tags query to use
  33400. * @param forEach defines a predicate used to filter results
  33401. * @returns an array of Mesh
  33402. */
  33403. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  33404. /**
  33405. * Get a list of cameras by tags
  33406. * @param tagsQuery defines the tags query to use
  33407. * @param forEach defines a predicate used to filter results
  33408. * @returns an array of Camera
  33409. */
  33410. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  33411. /**
  33412. * Get a list of lights by tags
  33413. * @param tagsQuery defines the tags query to use
  33414. * @param forEach defines a predicate used to filter results
  33415. * @returns an array of Light
  33416. */
  33417. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  33418. /**
  33419. * Get a list of materials by tags
  33420. * @param tagsQuery defines the tags query to use
  33421. * @param forEach defines a predicate used to filter results
  33422. * @returns an array of Material
  33423. */
  33424. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  33425. /**
  33426. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  33427. * This allowed control for front to back rendering or reversly depending of the special needs.
  33428. *
  33429. * @param renderingGroupId The rendering group id corresponding to its index
  33430. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  33431. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  33432. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  33433. */
  33434. 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;
  33435. /**
  33436. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  33437. *
  33438. * @param renderingGroupId The rendering group id corresponding to its index
  33439. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  33440. * @param depth Automatically clears depth between groups if true and autoClear is true.
  33441. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  33442. */
  33443. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  33444. /**
  33445. * Gets the current auto clear configuration for one rendering group of the rendering
  33446. * manager.
  33447. * @param index the rendering group index to get the information for
  33448. * @returns The auto clear setup for the requested rendering group
  33449. */
  33450. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  33451. private _blockMaterialDirtyMechanism;
  33452. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  33453. blockMaterialDirtyMechanism: boolean;
  33454. /**
  33455. * Will flag all materials as dirty to trigger new shader compilation
  33456. * @param flag defines the flag used to specify which material part must be marked as dirty
  33457. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  33458. */
  33459. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33460. /** @hidden */
  33461. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  33462. /** @hidden */
  33463. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33464. }
  33465. }
  33466. declare module BABYLON {
  33467. /**
  33468. * Set of assets to keep when moving a scene into an asset container.
  33469. */
  33470. export class KeepAssets extends AbstractScene {
  33471. }
  33472. /**
  33473. * Container with a set of assets that can be added or removed from a scene.
  33474. */
  33475. export class AssetContainer extends AbstractScene {
  33476. /**
  33477. * The scene the AssetContainer belongs to.
  33478. */
  33479. scene: Scene;
  33480. /**
  33481. * Instantiates an AssetContainer.
  33482. * @param scene The scene the AssetContainer belongs to.
  33483. */
  33484. constructor(scene: Scene);
  33485. /**
  33486. * Adds all the assets from the container to the scene.
  33487. */
  33488. addAllToScene(): void;
  33489. /**
  33490. * Removes all the assets in the container from the scene
  33491. */
  33492. removeAllFromScene(): void;
  33493. /**
  33494. * Disposes all the assets in the container
  33495. */
  33496. dispose(): void;
  33497. private _moveAssets;
  33498. /**
  33499. * Removes all the assets contained in the scene and adds them to the container.
  33500. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  33501. */
  33502. moveAllFromScene(keepAssets?: KeepAssets): void;
  33503. /**
  33504. * 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.
  33505. * @returns the root mesh
  33506. */
  33507. createRootMesh(): Mesh;
  33508. }
  33509. }
  33510. declare module BABYLON {
  33511. /**
  33512. * Defines how the parser contract is defined.
  33513. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  33514. */
  33515. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  33516. /**
  33517. * Defines how the individual parser contract is defined.
  33518. * These parser can parse an individual asset
  33519. */
  33520. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  33521. /**
  33522. * Base class of the scene acting as a container for the different elements composing a scene.
  33523. * This class is dynamically extended by the different components of the scene increasing
  33524. * flexibility and reducing coupling
  33525. */
  33526. export abstract class AbstractScene {
  33527. /**
  33528. * Stores the list of available parsers in the application.
  33529. */
  33530. private static _BabylonFileParsers;
  33531. /**
  33532. * Stores the list of available individual parsers in the application.
  33533. */
  33534. private static _IndividualBabylonFileParsers;
  33535. /**
  33536. * Adds a parser in the list of available ones
  33537. * @param name Defines the name of the parser
  33538. * @param parser Defines the parser to add
  33539. */
  33540. static AddParser(name: string, parser: BabylonFileParser): void;
  33541. /**
  33542. * Gets a general parser from the list of avaialble ones
  33543. * @param name Defines the name of the parser
  33544. * @returns the requested parser or null
  33545. */
  33546. static GetParser(name: string): Nullable<BabylonFileParser>;
  33547. /**
  33548. * Adds n individual parser in the list of available ones
  33549. * @param name Defines the name of the parser
  33550. * @param parser Defines the parser to add
  33551. */
  33552. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  33553. /**
  33554. * Gets an individual parser from the list of avaialble ones
  33555. * @param name Defines the name of the parser
  33556. * @returns the requested parser or null
  33557. */
  33558. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  33559. /**
  33560. * Parser json data and populate both a scene and its associated container object
  33561. * @param jsonData Defines the data to parse
  33562. * @param scene Defines the scene to parse the data for
  33563. * @param container Defines the container attached to the parsing sequence
  33564. * @param rootUrl Defines the root url of the data
  33565. */
  33566. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  33567. /**
  33568. * Gets the list of root nodes (ie. nodes with no parent)
  33569. */
  33570. rootNodes: Node[];
  33571. /** All of the cameras added to this scene
  33572. * @see http://doc.babylonjs.com/babylon101/cameras
  33573. */
  33574. cameras: Camera[];
  33575. /**
  33576. * All of the lights added to this scene
  33577. * @see http://doc.babylonjs.com/babylon101/lights
  33578. */
  33579. lights: Light[];
  33580. /**
  33581. * All of the (abstract) meshes added to this scene
  33582. */
  33583. meshes: AbstractMesh[];
  33584. /**
  33585. * The list of skeletons added to the scene
  33586. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  33587. */
  33588. skeletons: Skeleton[];
  33589. /**
  33590. * All of the particle systems added to this scene
  33591. * @see http://doc.babylonjs.com/babylon101/particles
  33592. */
  33593. particleSystems: IParticleSystem[];
  33594. /**
  33595. * Gets a list of Animations associated with the scene
  33596. */
  33597. animations: Animation[];
  33598. /**
  33599. * All of the animation groups added to this scene
  33600. * @see http://doc.babylonjs.com/how_to/group
  33601. */
  33602. animationGroups: AnimationGroup[];
  33603. /**
  33604. * All of the multi-materials added to this scene
  33605. * @see http://doc.babylonjs.com/how_to/multi_materials
  33606. */
  33607. multiMaterials: MultiMaterial[];
  33608. /**
  33609. * All of the materials added to this scene
  33610. * In the context of a Scene, it is not supposed to be modified manually.
  33611. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  33612. * Note also that the order of the Material wihin the array is not significant and might change.
  33613. * @see http://doc.babylonjs.com/babylon101/materials
  33614. */
  33615. materials: Material[];
  33616. /**
  33617. * The list of morph target managers added to the scene
  33618. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  33619. */
  33620. morphTargetManagers: MorphTargetManager[];
  33621. /**
  33622. * The list of geometries used in the scene.
  33623. */
  33624. geometries: Geometry[];
  33625. /**
  33626. * All of the tranform nodes added to this scene
  33627. * In the context of a Scene, it is not supposed to be modified manually.
  33628. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  33629. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  33630. * @see http://doc.babylonjs.com/how_to/transformnode
  33631. */
  33632. transformNodes: TransformNode[];
  33633. /**
  33634. * ActionManagers available on the scene.
  33635. */
  33636. actionManagers: AbstractActionManager[];
  33637. /**
  33638. * Textures to keep.
  33639. */
  33640. textures: BaseTexture[];
  33641. /**
  33642. * Environment texture for the scene
  33643. */
  33644. environmentTexture: Nullable<BaseTexture>;
  33645. }
  33646. }
  33647. declare module BABYLON {
  33648. /**
  33649. * Defines a sound that can be played in the application.
  33650. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  33651. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33652. */
  33653. export class Sound {
  33654. /**
  33655. * The name of the sound in the scene.
  33656. */
  33657. name: string;
  33658. /**
  33659. * Does the sound autoplay once loaded.
  33660. */
  33661. autoplay: boolean;
  33662. /**
  33663. * Does the sound loop after it finishes playing once.
  33664. */
  33665. loop: boolean;
  33666. /**
  33667. * Does the sound use a custom attenuation curve to simulate the falloff
  33668. * happening when the source gets further away from the camera.
  33669. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33670. */
  33671. useCustomAttenuation: boolean;
  33672. /**
  33673. * The sound track id this sound belongs to.
  33674. */
  33675. soundTrackId: number;
  33676. /**
  33677. * Is this sound currently played.
  33678. */
  33679. isPlaying: boolean;
  33680. /**
  33681. * Is this sound currently paused.
  33682. */
  33683. isPaused: boolean;
  33684. /**
  33685. * Does this sound enables spatial sound.
  33686. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33687. */
  33688. spatialSound: boolean;
  33689. /**
  33690. * Define the reference distance the sound should be heard perfectly.
  33691. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33692. */
  33693. refDistance: number;
  33694. /**
  33695. * Define the roll off factor of spatial sounds.
  33696. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33697. */
  33698. rolloffFactor: number;
  33699. /**
  33700. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  33701. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33702. */
  33703. maxDistance: number;
  33704. /**
  33705. * Define the distance attenuation model the sound will follow.
  33706. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33707. */
  33708. distanceModel: string;
  33709. /**
  33710. * @hidden
  33711. * Back Compat
  33712. **/
  33713. onended: () => any;
  33714. /**
  33715. * Observable event when the current playing sound finishes.
  33716. */
  33717. onEndedObservable: Observable<Sound>;
  33718. private _panningModel;
  33719. private _playbackRate;
  33720. private _streaming;
  33721. private _startTime;
  33722. private _startOffset;
  33723. private _position;
  33724. /** @hidden */
  33725. _positionInEmitterSpace: boolean;
  33726. private _localDirection;
  33727. private _volume;
  33728. private _isReadyToPlay;
  33729. private _isDirectional;
  33730. private _readyToPlayCallback;
  33731. private _audioBuffer;
  33732. private _soundSource;
  33733. private _streamingSource;
  33734. private _soundPanner;
  33735. private _soundGain;
  33736. private _inputAudioNode;
  33737. private _outputAudioNode;
  33738. private _coneInnerAngle;
  33739. private _coneOuterAngle;
  33740. private _coneOuterGain;
  33741. private _scene;
  33742. private _connectedTransformNode;
  33743. private _customAttenuationFunction;
  33744. private _registerFunc;
  33745. private _isOutputConnected;
  33746. private _htmlAudioElement;
  33747. private _urlType;
  33748. /** @hidden */
  33749. static _SceneComponentInitialization: (scene: Scene) => void;
  33750. /**
  33751. * Create a sound and attach it to a scene
  33752. * @param name Name of your sound
  33753. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  33754. * @param scene defines the scene the sound belongs to
  33755. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  33756. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  33757. */
  33758. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  33759. /**
  33760. * Release the sound and its associated resources
  33761. */
  33762. dispose(): void;
  33763. /**
  33764. * Gets if the sounds is ready to be played or not.
  33765. * @returns true if ready, otherwise false
  33766. */
  33767. isReady(): boolean;
  33768. private _soundLoaded;
  33769. /**
  33770. * Sets the data of the sound from an audiobuffer
  33771. * @param audioBuffer The audioBuffer containing the data
  33772. */
  33773. setAudioBuffer(audioBuffer: AudioBuffer): void;
  33774. /**
  33775. * Updates the current sounds options such as maxdistance, loop...
  33776. * @param options A JSON object containing values named as the object properties
  33777. */
  33778. updateOptions(options: any): void;
  33779. private _createSpatialParameters;
  33780. private _updateSpatialParameters;
  33781. /**
  33782. * Switch the panning model to HRTF:
  33783. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  33784. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33785. */
  33786. switchPanningModelToHRTF(): void;
  33787. /**
  33788. * Switch the panning model to Equal Power:
  33789. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  33790. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33791. */
  33792. switchPanningModelToEqualPower(): void;
  33793. private _switchPanningModel;
  33794. /**
  33795. * Connect this sound to a sound track audio node like gain...
  33796. * @param soundTrackAudioNode the sound track audio node to connect to
  33797. */
  33798. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  33799. /**
  33800. * Transform this sound into a directional source
  33801. * @param coneInnerAngle Size of the inner cone in degree
  33802. * @param coneOuterAngle Size of the outer cone in degree
  33803. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  33804. */
  33805. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  33806. /**
  33807. * Gets or sets the inner angle for the directional cone.
  33808. */
  33809. /**
  33810. * Gets or sets the inner angle for the directional cone.
  33811. */
  33812. directionalConeInnerAngle: number;
  33813. /**
  33814. * Gets or sets the outer angle for the directional cone.
  33815. */
  33816. /**
  33817. * Gets or sets the outer angle for the directional cone.
  33818. */
  33819. directionalConeOuterAngle: number;
  33820. /**
  33821. * Sets the position of the emitter if spatial sound is enabled
  33822. * @param newPosition Defines the new posisiton
  33823. */
  33824. setPosition(newPosition: Vector3): void;
  33825. /**
  33826. * Sets the local direction of the emitter if spatial sound is enabled
  33827. * @param newLocalDirection Defines the new local direction
  33828. */
  33829. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  33830. private _updateDirection;
  33831. /** @hidden */
  33832. updateDistanceFromListener(): void;
  33833. /**
  33834. * Sets a new custom attenuation function for the sound.
  33835. * @param callback Defines the function used for the attenuation
  33836. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33837. */
  33838. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  33839. /**
  33840. * Play the sound
  33841. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  33842. * @param offset (optional) Start the sound setting it at a specific time
  33843. */
  33844. play(time?: number, offset?: number): void;
  33845. private _onended;
  33846. /**
  33847. * Stop the sound
  33848. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  33849. */
  33850. stop(time?: number): void;
  33851. /**
  33852. * Put the sound in pause
  33853. */
  33854. pause(): void;
  33855. /**
  33856. * Sets a dedicated volume for this sounds
  33857. * @param newVolume Define the new volume of the sound
  33858. * @param time Define in how long the sound should be at this value
  33859. */
  33860. setVolume(newVolume: number, time?: number): void;
  33861. /**
  33862. * Set the sound play back rate
  33863. * @param newPlaybackRate Define the playback rate the sound should be played at
  33864. */
  33865. setPlaybackRate(newPlaybackRate: number): void;
  33866. /**
  33867. * Gets the volume of the sound.
  33868. * @returns the volume of the sound
  33869. */
  33870. getVolume(): number;
  33871. /**
  33872. * Attach the sound to a dedicated mesh
  33873. * @param transformNode The transform node to connect the sound with
  33874. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  33875. */
  33876. attachToMesh(transformNode: TransformNode): void;
  33877. /**
  33878. * Detach the sound from the previously attached mesh
  33879. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  33880. */
  33881. detachFromMesh(): void;
  33882. private _onRegisterAfterWorldMatrixUpdate;
  33883. /**
  33884. * Clone the current sound in the scene.
  33885. * @returns the new sound clone
  33886. */
  33887. clone(): Nullable<Sound>;
  33888. /**
  33889. * Gets the current underlying audio buffer containing the data
  33890. * @returns the audio buffer
  33891. */
  33892. getAudioBuffer(): Nullable<AudioBuffer>;
  33893. /**
  33894. * Serializes the Sound in a JSON representation
  33895. * @returns the JSON representation of the sound
  33896. */
  33897. serialize(): any;
  33898. /**
  33899. * Parse a JSON representation of a sound to innstantiate in a given scene
  33900. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  33901. * @param scene Define the scene the new parsed sound should be created in
  33902. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  33903. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  33904. * @returns the newly parsed sound
  33905. */
  33906. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  33907. }
  33908. }
  33909. declare module BABYLON {
  33910. /**
  33911. * This defines an action helpful to play a defined sound on a triggered action.
  33912. */
  33913. export class PlaySoundAction extends Action {
  33914. private _sound;
  33915. /**
  33916. * Instantiate the action
  33917. * @param triggerOptions defines the trigger options
  33918. * @param sound defines the sound to play
  33919. * @param condition defines the trigger related conditions
  33920. */
  33921. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  33922. /** @hidden */
  33923. _prepare(): void;
  33924. /**
  33925. * Execute the action and play the sound.
  33926. */
  33927. execute(): void;
  33928. /**
  33929. * Serializes the actions and its related information.
  33930. * @param parent defines the object to serialize in
  33931. * @returns the serialized object
  33932. */
  33933. serialize(parent: any): any;
  33934. }
  33935. /**
  33936. * This defines an action helpful to stop a defined sound on a triggered action.
  33937. */
  33938. export class StopSoundAction extends Action {
  33939. private _sound;
  33940. /**
  33941. * Instantiate the action
  33942. * @param triggerOptions defines the trigger options
  33943. * @param sound defines the sound to stop
  33944. * @param condition defines the trigger related conditions
  33945. */
  33946. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  33947. /** @hidden */
  33948. _prepare(): void;
  33949. /**
  33950. * Execute the action and stop the sound.
  33951. */
  33952. execute(): void;
  33953. /**
  33954. * Serializes the actions and its related information.
  33955. * @param parent defines the object to serialize in
  33956. * @returns the serialized object
  33957. */
  33958. serialize(parent: any): any;
  33959. }
  33960. }
  33961. declare module BABYLON {
  33962. /**
  33963. * This defines an action responsible to change the value of a property
  33964. * by interpolating between its current value and the newly set one once triggered.
  33965. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33966. */
  33967. export class InterpolateValueAction extends Action {
  33968. /**
  33969. * Defines the path of the property where the value should be interpolated
  33970. */
  33971. propertyPath: string;
  33972. /**
  33973. * Defines the target value at the end of the interpolation.
  33974. */
  33975. value: any;
  33976. /**
  33977. * Defines the time it will take for the property to interpolate to the value.
  33978. */
  33979. duration: number;
  33980. /**
  33981. * Defines if the other scene animations should be stopped when the action has been triggered
  33982. */
  33983. stopOtherAnimations?: boolean;
  33984. /**
  33985. * Defines a callback raised once the interpolation animation has been done.
  33986. */
  33987. onInterpolationDone?: () => void;
  33988. /**
  33989. * Observable triggered once the interpolation animation has been done.
  33990. */
  33991. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  33992. private _target;
  33993. private _effectiveTarget;
  33994. private _property;
  33995. /**
  33996. * Instantiate the action
  33997. * @param triggerOptions defines the trigger options
  33998. * @param target defines the object containing the value to interpolate
  33999. * @param propertyPath defines the path to the property in the target object
  34000. * @param value defines the target value at the end of the interpolation
  34001. * @param duration deines the time it will take for the property to interpolate to the value.
  34002. * @param condition defines the trigger related conditions
  34003. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  34004. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  34005. */
  34006. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  34007. /** @hidden */
  34008. _prepare(): void;
  34009. /**
  34010. * Execute the action starts the value interpolation.
  34011. */
  34012. execute(): void;
  34013. /**
  34014. * Serializes the actions and its related information.
  34015. * @param parent defines the object to serialize in
  34016. * @returns the serialized object
  34017. */
  34018. serialize(parent: any): any;
  34019. }
  34020. }
  34021. declare module BABYLON {
  34022. /**
  34023. * Options allowed during the creation of a sound track.
  34024. */
  34025. export interface ISoundTrackOptions {
  34026. /**
  34027. * The volume the sound track should take during creation
  34028. */
  34029. volume?: number;
  34030. /**
  34031. * Define if the sound track is the main sound track of the scene
  34032. */
  34033. mainTrack?: boolean;
  34034. }
  34035. /**
  34036. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  34037. * It will be also used in a future release to apply effects on a specific track.
  34038. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34039. */
  34040. export class SoundTrack {
  34041. /**
  34042. * The unique identifier of the sound track in the scene.
  34043. */
  34044. id: number;
  34045. /**
  34046. * The list of sounds included in the sound track.
  34047. */
  34048. soundCollection: Array<Sound>;
  34049. private _outputAudioNode;
  34050. private _scene;
  34051. private _isMainTrack;
  34052. private _connectedAnalyser;
  34053. private _options;
  34054. private _isInitialized;
  34055. /**
  34056. * Creates a new sound track.
  34057. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34058. * @param scene Define the scene the sound track belongs to
  34059. * @param options
  34060. */
  34061. constructor(scene: Scene, options?: ISoundTrackOptions);
  34062. private _initializeSoundTrackAudioGraph;
  34063. /**
  34064. * Release the sound track and its associated resources
  34065. */
  34066. dispose(): void;
  34067. /**
  34068. * Adds a sound to this sound track
  34069. * @param sound define the cound to add
  34070. * @ignoreNaming
  34071. */
  34072. AddSound(sound: Sound): void;
  34073. /**
  34074. * Removes a sound to this sound track
  34075. * @param sound define the cound to remove
  34076. * @ignoreNaming
  34077. */
  34078. RemoveSound(sound: Sound): void;
  34079. /**
  34080. * Set a global volume for the full sound track.
  34081. * @param newVolume Define the new volume of the sound track
  34082. */
  34083. setVolume(newVolume: number): void;
  34084. /**
  34085. * Switch the panning model to HRTF:
  34086. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34087. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34088. */
  34089. switchPanningModelToHRTF(): void;
  34090. /**
  34091. * Switch the panning model to Equal Power:
  34092. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34093. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34094. */
  34095. switchPanningModelToEqualPower(): void;
  34096. /**
  34097. * Connect the sound track to an audio analyser allowing some amazing
  34098. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34099. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34100. * @param analyser The analyser to connect to the engine
  34101. */
  34102. connectToAnalyser(analyser: Analyser): void;
  34103. }
  34104. }
  34105. declare module BABYLON {
  34106. interface AbstractScene {
  34107. /**
  34108. * The list of sounds used in the scene.
  34109. */
  34110. sounds: Nullable<Array<Sound>>;
  34111. }
  34112. interface Scene {
  34113. /**
  34114. * @hidden
  34115. * Backing field
  34116. */
  34117. _mainSoundTrack: SoundTrack;
  34118. /**
  34119. * The main sound track played by the scene.
  34120. * It cotains your primary collection of sounds.
  34121. */
  34122. mainSoundTrack: SoundTrack;
  34123. /**
  34124. * The list of sound tracks added to the scene
  34125. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34126. */
  34127. soundTracks: Nullable<Array<SoundTrack>>;
  34128. /**
  34129. * Gets a sound using a given name
  34130. * @param name defines the name to search for
  34131. * @return the found sound or null if not found at all.
  34132. */
  34133. getSoundByName(name: string): Nullable<Sound>;
  34134. /**
  34135. * Gets or sets if audio support is enabled
  34136. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34137. */
  34138. audioEnabled: boolean;
  34139. /**
  34140. * Gets or sets if audio will be output to headphones
  34141. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34142. */
  34143. headphone: boolean;
  34144. }
  34145. /**
  34146. * Defines the sound scene component responsible to manage any sounds
  34147. * in a given scene.
  34148. */
  34149. export class AudioSceneComponent implements ISceneSerializableComponent {
  34150. /**
  34151. * The component name helpfull to identify the component in the list of scene components.
  34152. */
  34153. readonly name: string;
  34154. /**
  34155. * The scene the component belongs to.
  34156. */
  34157. scene: Scene;
  34158. private _audioEnabled;
  34159. /**
  34160. * Gets whether audio is enabled or not.
  34161. * Please use related enable/disable method to switch state.
  34162. */
  34163. readonly audioEnabled: boolean;
  34164. private _headphone;
  34165. /**
  34166. * Gets whether audio is outputing to headphone or not.
  34167. * Please use the according Switch methods to change output.
  34168. */
  34169. readonly headphone: boolean;
  34170. /**
  34171. * Creates a new instance of the component for the given scene
  34172. * @param scene Defines the scene to register the component in
  34173. */
  34174. constructor(scene: Scene);
  34175. /**
  34176. * Registers the component in a given scene
  34177. */
  34178. register(): void;
  34179. /**
  34180. * Rebuilds the elements related to this component in case of
  34181. * context lost for instance.
  34182. */
  34183. rebuild(): void;
  34184. /**
  34185. * Serializes the component data to the specified json object
  34186. * @param serializationObject The object to serialize to
  34187. */
  34188. serialize(serializationObject: any): void;
  34189. /**
  34190. * Adds all the element from the container to the scene
  34191. * @param container the container holding the elements
  34192. */
  34193. addFromContainer(container: AbstractScene): void;
  34194. /**
  34195. * Removes all the elements in the container from the scene
  34196. * @param container contains the elements to remove
  34197. * @param dispose if the removed element should be disposed (default: false)
  34198. */
  34199. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  34200. /**
  34201. * Disposes the component and the associated ressources.
  34202. */
  34203. dispose(): void;
  34204. /**
  34205. * Disables audio in the associated scene.
  34206. */
  34207. disableAudio(): void;
  34208. /**
  34209. * Enables audio in the associated scene.
  34210. */
  34211. enableAudio(): void;
  34212. /**
  34213. * Switch audio to headphone output.
  34214. */
  34215. switchAudioModeForHeadphones(): void;
  34216. /**
  34217. * Switch audio to normal speakers.
  34218. */
  34219. switchAudioModeForNormalSpeakers(): void;
  34220. private _afterRender;
  34221. }
  34222. }
  34223. declare module BABYLON {
  34224. /**
  34225. * Wraps one or more Sound objects and selects one with random weight for playback.
  34226. */
  34227. export class WeightedSound {
  34228. /** When true a Sound will be selected and played when the current playing Sound completes. */
  34229. loop: boolean;
  34230. private _coneInnerAngle;
  34231. private _coneOuterAngle;
  34232. private _volume;
  34233. /** A Sound is currently playing. */
  34234. isPlaying: boolean;
  34235. /** A Sound is currently paused. */
  34236. isPaused: boolean;
  34237. private _sounds;
  34238. private _weights;
  34239. private _currentIndex?;
  34240. /**
  34241. * Creates a new WeightedSound from the list of sounds given.
  34242. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  34243. * @param sounds Array of Sounds that will be selected from.
  34244. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  34245. */
  34246. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  34247. /**
  34248. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  34249. */
  34250. /**
  34251. * The size of cone in degress for a directional sound in which there will be no attenuation.
  34252. */
  34253. directionalConeInnerAngle: number;
  34254. /**
  34255. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34256. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34257. */
  34258. /**
  34259. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34260. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34261. */
  34262. directionalConeOuterAngle: number;
  34263. /**
  34264. * Playback volume.
  34265. */
  34266. /**
  34267. * Playback volume.
  34268. */
  34269. volume: number;
  34270. private _onended;
  34271. /**
  34272. * Suspend playback
  34273. */
  34274. pause(): void;
  34275. /**
  34276. * Stop playback
  34277. */
  34278. stop(): void;
  34279. /**
  34280. * Start playback.
  34281. * @param startOffset Position the clip head at a specific time in seconds.
  34282. */
  34283. play(startOffset?: number): void;
  34284. }
  34285. }
  34286. declare module BABYLON {
  34287. /**
  34288. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  34289. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34290. */
  34291. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  34292. /**
  34293. * Gets the name of the behavior.
  34294. */
  34295. readonly name: string;
  34296. /**
  34297. * The easing function used by animations
  34298. */
  34299. static EasingFunction: BackEase;
  34300. /**
  34301. * The easing mode used by animations
  34302. */
  34303. static EasingMode: number;
  34304. /**
  34305. * The duration of the animation, in milliseconds
  34306. */
  34307. transitionDuration: number;
  34308. /**
  34309. * Length of the distance animated by the transition when lower radius is reached
  34310. */
  34311. lowerRadiusTransitionRange: number;
  34312. /**
  34313. * Length of the distance animated by the transition when upper radius is reached
  34314. */
  34315. upperRadiusTransitionRange: number;
  34316. private _autoTransitionRange;
  34317. /**
  34318. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34319. */
  34320. /**
  34321. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34322. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  34323. */
  34324. autoTransitionRange: boolean;
  34325. private _attachedCamera;
  34326. private _onAfterCheckInputsObserver;
  34327. private _onMeshTargetChangedObserver;
  34328. /**
  34329. * Initializes the behavior.
  34330. */
  34331. init(): void;
  34332. /**
  34333. * Attaches the behavior to its arc rotate camera.
  34334. * @param camera Defines the camera to attach the behavior to
  34335. */
  34336. attach(camera: ArcRotateCamera): void;
  34337. /**
  34338. * Detaches the behavior from its current arc rotate camera.
  34339. */
  34340. detach(): void;
  34341. private _radiusIsAnimating;
  34342. private _radiusBounceTransition;
  34343. private _animatables;
  34344. private _cachedWheelPrecision;
  34345. /**
  34346. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  34347. * @param radiusLimit The limit to check against.
  34348. * @return Bool to indicate if at limit.
  34349. */
  34350. private _isRadiusAtLimit;
  34351. /**
  34352. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  34353. * @param radiusDelta The delta by which to animate to. Can be negative.
  34354. */
  34355. private _applyBoundRadiusAnimation;
  34356. /**
  34357. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  34358. */
  34359. protected _clearAnimationLocks(): void;
  34360. /**
  34361. * Stops and removes all animations that have been applied to the camera
  34362. */
  34363. stopAllAnimations(): void;
  34364. }
  34365. }
  34366. declare module BABYLON {
  34367. /**
  34368. * The framing behavior (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.
  34369. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34370. */
  34371. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  34372. /**
  34373. * Gets the name of the behavior.
  34374. */
  34375. readonly name: string;
  34376. private _mode;
  34377. private _radiusScale;
  34378. private _positionScale;
  34379. private _defaultElevation;
  34380. private _elevationReturnTime;
  34381. private _elevationReturnWaitTime;
  34382. private _zoomStopsAnimation;
  34383. private _framingTime;
  34384. /**
  34385. * The easing function used by animations
  34386. */
  34387. static EasingFunction: ExponentialEase;
  34388. /**
  34389. * The easing mode used by animations
  34390. */
  34391. static EasingMode: number;
  34392. /**
  34393. * Sets the current mode used by the behavior
  34394. */
  34395. /**
  34396. * Gets current mode used by the behavior.
  34397. */
  34398. mode: number;
  34399. /**
  34400. * Sets the scale applied to the radius (1 by default)
  34401. */
  34402. /**
  34403. * Gets the scale applied to the radius
  34404. */
  34405. radiusScale: number;
  34406. /**
  34407. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34408. */
  34409. /**
  34410. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34411. */
  34412. positionScale: number;
  34413. /**
  34414. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34415. * behaviour is triggered, in radians.
  34416. */
  34417. /**
  34418. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34419. * behaviour is triggered, in radians.
  34420. */
  34421. defaultElevation: number;
  34422. /**
  34423. * Sets the time (in milliseconds) taken to return to the default beta position.
  34424. * Negative value indicates camera should not return to default.
  34425. */
  34426. /**
  34427. * Gets the time (in milliseconds) taken to return to the default beta position.
  34428. * Negative value indicates camera should not return to default.
  34429. */
  34430. elevationReturnTime: number;
  34431. /**
  34432. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34433. */
  34434. /**
  34435. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34436. */
  34437. elevationReturnWaitTime: number;
  34438. /**
  34439. * Sets the flag that indicates if user zooming should stop animation.
  34440. */
  34441. /**
  34442. * Gets the flag that indicates if user zooming should stop animation.
  34443. */
  34444. zoomStopsAnimation: boolean;
  34445. /**
  34446. * Sets the transition time when framing the mesh, in milliseconds
  34447. */
  34448. /**
  34449. * Gets the transition time when framing the mesh, in milliseconds
  34450. */
  34451. framingTime: number;
  34452. /**
  34453. * Define if the behavior should automatically change the configured
  34454. * camera limits and sensibilities.
  34455. */
  34456. autoCorrectCameraLimitsAndSensibility: boolean;
  34457. private _onPrePointerObservableObserver;
  34458. private _onAfterCheckInputsObserver;
  34459. private _onMeshTargetChangedObserver;
  34460. private _attachedCamera;
  34461. private _isPointerDown;
  34462. private _lastInteractionTime;
  34463. /**
  34464. * Initializes the behavior.
  34465. */
  34466. init(): void;
  34467. /**
  34468. * Attaches the behavior to its arc rotate camera.
  34469. * @param camera Defines the camera to attach the behavior to
  34470. */
  34471. attach(camera: ArcRotateCamera): void;
  34472. /**
  34473. * Detaches the behavior from its current arc rotate camera.
  34474. */
  34475. detach(): void;
  34476. private _animatables;
  34477. private _betaIsAnimating;
  34478. private _betaTransition;
  34479. private _radiusTransition;
  34480. private _vectorTransition;
  34481. /**
  34482. * Targets the given mesh and updates zoom level accordingly.
  34483. * @param mesh The mesh to target.
  34484. * @param radius Optional. If a cached radius position already exists, overrides default.
  34485. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34486. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34487. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34488. */
  34489. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34490. /**
  34491. * Targets the given mesh with its children and updates zoom level accordingly.
  34492. * @param mesh The mesh to target.
  34493. * @param radius Optional. If a cached radius position already exists, overrides default.
  34494. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34495. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34496. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34497. */
  34498. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34499. /**
  34500. * Targets the given meshes with their children and updates zoom level accordingly.
  34501. * @param meshes The mesh to target.
  34502. * @param radius Optional. If a cached radius position already exists, overrides default.
  34503. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34504. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34505. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34506. */
  34507. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34508. /**
  34509. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  34510. * @param minimumWorld Determines the smaller position of the bounding box extend
  34511. * @param maximumWorld Determines the bigger position of the bounding box extend
  34512. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34513. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34514. */
  34515. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34516. /**
  34517. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  34518. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  34519. * frustum width.
  34520. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  34521. * to fully enclose the mesh in the viewing frustum.
  34522. */
  34523. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  34524. /**
  34525. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  34526. * is automatically returned to its default position (expected to be above ground plane).
  34527. */
  34528. private _maintainCameraAboveGround;
  34529. /**
  34530. * Returns the frustum slope based on the canvas ratio and camera FOV
  34531. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  34532. */
  34533. private _getFrustumSlope;
  34534. /**
  34535. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  34536. */
  34537. private _clearAnimationLocks;
  34538. /**
  34539. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  34540. */
  34541. private _applyUserInteraction;
  34542. /**
  34543. * Stops and removes all animations that have been applied to the camera
  34544. */
  34545. stopAllAnimations(): void;
  34546. /**
  34547. * Gets a value indicating if the user is moving the camera
  34548. */
  34549. readonly isUserIsMoving: boolean;
  34550. /**
  34551. * The camera can move all the way towards the mesh.
  34552. */
  34553. static IgnoreBoundsSizeMode: number;
  34554. /**
  34555. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  34556. */
  34557. static FitFrustumSidesMode: number;
  34558. }
  34559. }
  34560. declare module BABYLON {
  34561. /**
  34562. * Base class for Camera Pointer Inputs.
  34563. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  34564. * for example usage.
  34565. */
  34566. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  34567. /**
  34568. * Defines the camera the input is attached to.
  34569. */
  34570. abstract camera: Camera;
  34571. /**
  34572. * Whether keyboard modifier keys are pressed at time of last mouse event.
  34573. */
  34574. protected _altKey: boolean;
  34575. protected _ctrlKey: boolean;
  34576. protected _metaKey: boolean;
  34577. protected _shiftKey: boolean;
  34578. /**
  34579. * Which mouse buttons were pressed at time of last mouse event.
  34580. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  34581. */
  34582. protected _buttonsPressed: number;
  34583. /**
  34584. * Defines the buttons associated with the input to handle camera move.
  34585. */
  34586. buttons: number[];
  34587. /**
  34588. * Attach the input controls to a specific dom element to get the input from.
  34589. * @param element Defines the element the controls should be listened from
  34590. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34591. */
  34592. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34593. /**
  34594. * Detach the current controls from the specified dom element.
  34595. * @param element Defines the element to stop listening the inputs from
  34596. */
  34597. detachControl(element: Nullable<HTMLElement>): void;
  34598. /**
  34599. * Gets the class name of the current input.
  34600. * @returns the class name
  34601. */
  34602. getClassName(): string;
  34603. /**
  34604. * Get the friendly name associated with the input class.
  34605. * @returns the input friendly name
  34606. */
  34607. getSimpleName(): string;
  34608. /**
  34609. * Called on pointer POINTERDOUBLETAP event.
  34610. * Override this method to provide functionality on POINTERDOUBLETAP event.
  34611. */
  34612. protected onDoubleTap(type: string): void;
  34613. /**
  34614. * Called on pointer POINTERMOVE event if only a single touch is active.
  34615. * Override this method to provide functionality.
  34616. */
  34617. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  34618. /**
  34619. * Called on pointer POINTERMOVE event if multiple touches are active.
  34620. * Override this method to provide functionality.
  34621. */
  34622. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  34623. /**
  34624. * Called on JS contextmenu event.
  34625. * Override this method to provide functionality.
  34626. */
  34627. protected onContextMenu(evt: PointerEvent): void;
  34628. /**
  34629. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  34630. * press.
  34631. * Override this method to provide functionality.
  34632. */
  34633. protected onButtonDown(evt: PointerEvent): void;
  34634. /**
  34635. * Called each time a new POINTERUP event occurs. Ie, for each button
  34636. * release.
  34637. * Override this method to provide functionality.
  34638. */
  34639. protected onButtonUp(evt: PointerEvent): void;
  34640. /**
  34641. * Called when window becomes inactive.
  34642. * Override this method to provide functionality.
  34643. */
  34644. protected onLostFocus(): void;
  34645. private _pointerInput;
  34646. private _observer;
  34647. private _onLostFocus;
  34648. private pointA;
  34649. private pointB;
  34650. }
  34651. }
  34652. declare module BABYLON {
  34653. /**
  34654. * Manage the pointers inputs to control an arc rotate camera.
  34655. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34656. */
  34657. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  34658. /**
  34659. * Defines the camera the input is attached to.
  34660. */
  34661. camera: ArcRotateCamera;
  34662. /**
  34663. * Gets the class name of the current input.
  34664. * @returns the class name
  34665. */
  34666. getClassName(): string;
  34667. /**
  34668. * Defines the buttons associated with the input to handle camera move.
  34669. */
  34670. buttons: number[];
  34671. /**
  34672. * Defines the pointer angular sensibility along the X axis or how fast is
  34673. * the camera rotating.
  34674. */
  34675. angularSensibilityX: number;
  34676. /**
  34677. * Defines the pointer angular sensibility along the Y axis or how fast is
  34678. * the camera rotating.
  34679. */
  34680. angularSensibilityY: number;
  34681. /**
  34682. * Defines the pointer pinch precision or how fast is the camera zooming.
  34683. */
  34684. pinchPrecision: number;
  34685. /**
  34686. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  34687. * from 0.
  34688. * It defines the percentage of current camera.radius to use as delta when
  34689. * pinch zoom is used.
  34690. */
  34691. pinchDeltaPercentage: number;
  34692. /**
  34693. * Defines the pointer panning sensibility or how fast is the camera moving.
  34694. */
  34695. panningSensibility: number;
  34696. /**
  34697. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  34698. */
  34699. multiTouchPanning: boolean;
  34700. /**
  34701. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  34702. * zoom (pinch) through multitouch.
  34703. */
  34704. multiTouchPanAndZoom: boolean;
  34705. /**
  34706. * Revers pinch action direction.
  34707. */
  34708. pinchInwards: boolean;
  34709. private _isPanClick;
  34710. private _twoFingerActivityCount;
  34711. private _isPinching;
  34712. /**
  34713. * Called on pointer POINTERMOVE event if only a single touch is active.
  34714. */
  34715. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  34716. /**
  34717. * Called on pointer POINTERDOUBLETAP event.
  34718. */
  34719. protected onDoubleTap(type: string): void;
  34720. /**
  34721. * Called on pointer POINTERMOVE event if multiple touches are active.
  34722. */
  34723. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  34724. /**
  34725. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  34726. * press.
  34727. */
  34728. protected onButtonDown(evt: PointerEvent): void;
  34729. /**
  34730. * Called each time a new POINTERUP event occurs. Ie, for each button
  34731. * release.
  34732. */
  34733. protected onButtonUp(evt: PointerEvent): void;
  34734. /**
  34735. * Called when window becomes inactive.
  34736. */
  34737. protected onLostFocus(): void;
  34738. }
  34739. }
  34740. declare module BABYLON {
  34741. /**
  34742. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  34743. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34744. */
  34745. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  34746. /**
  34747. * Defines the camera the input is attached to.
  34748. */
  34749. camera: ArcRotateCamera;
  34750. /**
  34751. * Defines the list of key codes associated with the up action (increase alpha)
  34752. */
  34753. keysUp: number[];
  34754. /**
  34755. * Defines the list of key codes associated with the down action (decrease alpha)
  34756. */
  34757. keysDown: number[];
  34758. /**
  34759. * Defines the list of key codes associated with the left action (increase beta)
  34760. */
  34761. keysLeft: number[];
  34762. /**
  34763. * Defines the list of key codes associated with the right action (decrease beta)
  34764. */
  34765. keysRight: number[];
  34766. /**
  34767. * Defines the list of key codes associated with the reset action.
  34768. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  34769. */
  34770. keysReset: number[];
  34771. /**
  34772. * Defines the panning sensibility of the inputs.
  34773. * (How fast is the camera paning)
  34774. */
  34775. panningSensibility: number;
  34776. /**
  34777. * Defines the zooming sensibility of the inputs.
  34778. * (How fast is the camera zooming)
  34779. */
  34780. zoomingSensibility: number;
  34781. /**
  34782. * Defines wether maintaining the alt key down switch the movement mode from
  34783. * orientation to zoom.
  34784. */
  34785. useAltToZoom: boolean;
  34786. /**
  34787. * Rotation speed of the camera
  34788. */
  34789. angularSpeed: number;
  34790. private _keys;
  34791. private _ctrlPressed;
  34792. private _altPressed;
  34793. private _onCanvasBlurObserver;
  34794. private _onKeyboardObserver;
  34795. private _engine;
  34796. private _scene;
  34797. /**
  34798. * Attach the input controls to a specific dom element to get the input from.
  34799. * @param element Defines the element the controls should be listened from
  34800. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34801. */
  34802. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34803. /**
  34804. * Detach the current controls from the specified dom element.
  34805. * @param element Defines the element to stop listening the inputs from
  34806. */
  34807. detachControl(element: Nullable<HTMLElement>): void;
  34808. /**
  34809. * Update the current camera state depending on the inputs that have been used this frame.
  34810. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  34811. */
  34812. checkInputs(): void;
  34813. /**
  34814. * Gets the class name of the current intput.
  34815. * @returns the class name
  34816. */
  34817. getClassName(): string;
  34818. /**
  34819. * Get the friendly name associated with the input class.
  34820. * @returns the input friendly name
  34821. */
  34822. getSimpleName(): string;
  34823. }
  34824. }
  34825. declare module BABYLON {
  34826. /**
  34827. * Manage the mouse wheel inputs to control an arc rotate camera.
  34828. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34829. */
  34830. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  34831. /**
  34832. * Defines the camera the input is attached to.
  34833. */
  34834. camera: ArcRotateCamera;
  34835. /**
  34836. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  34837. */
  34838. wheelPrecision: number;
  34839. /**
  34840. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  34841. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  34842. */
  34843. wheelDeltaPercentage: number;
  34844. private _wheel;
  34845. private _observer;
  34846. /**
  34847. * Attach the input controls to a specific dom element to get the input from.
  34848. * @param element Defines the element the controls should be listened from
  34849. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34850. */
  34851. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34852. /**
  34853. * Detach the current controls from the specified dom element.
  34854. * @param element Defines the element to stop listening the inputs from
  34855. */
  34856. detachControl(element: Nullable<HTMLElement>): void;
  34857. /**
  34858. * Gets the class name of the current intput.
  34859. * @returns the class name
  34860. */
  34861. getClassName(): string;
  34862. /**
  34863. * Get the friendly name associated with the input class.
  34864. * @returns the input friendly name
  34865. */
  34866. getSimpleName(): string;
  34867. }
  34868. }
  34869. declare module BABYLON {
  34870. /**
  34871. * Default Inputs manager for the ArcRotateCamera.
  34872. * It groups all the default supported inputs for ease of use.
  34873. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34874. */
  34875. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  34876. /**
  34877. * Instantiates a new ArcRotateCameraInputsManager.
  34878. * @param camera Defines the camera the inputs belong to
  34879. */
  34880. constructor(camera: ArcRotateCamera);
  34881. /**
  34882. * Add mouse wheel input support to the input manager.
  34883. * @returns the current input manager
  34884. */
  34885. addMouseWheel(): ArcRotateCameraInputsManager;
  34886. /**
  34887. * Add pointers input support to the input manager.
  34888. * @returns the current input manager
  34889. */
  34890. addPointers(): ArcRotateCameraInputsManager;
  34891. /**
  34892. * Add keyboard input support to the input manager.
  34893. * @returns the current input manager
  34894. */
  34895. addKeyboard(): ArcRotateCameraInputsManager;
  34896. }
  34897. }
  34898. declare module BABYLON {
  34899. /**
  34900. * This represents an orbital type of camera.
  34901. *
  34902. * 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.
  34903. * 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.
  34904. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  34905. */
  34906. export class ArcRotateCamera extends TargetCamera {
  34907. /**
  34908. * Defines the rotation angle of the camera along the longitudinal axis.
  34909. */
  34910. alpha: number;
  34911. /**
  34912. * Defines the rotation angle of the camera along the latitudinal axis.
  34913. */
  34914. beta: number;
  34915. /**
  34916. * Defines the radius of the camera from it s target point.
  34917. */
  34918. radius: number;
  34919. protected _target: Vector3;
  34920. protected _targetHost: Nullable<AbstractMesh>;
  34921. /**
  34922. * Defines the target point of the camera.
  34923. * The camera looks towards it form the radius distance.
  34924. */
  34925. target: Vector3;
  34926. /**
  34927. * Define the current local position of the camera in the scene
  34928. */
  34929. position: Vector3;
  34930. /**
  34931. * Current inertia value on the longitudinal axis.
  34932. * The bigger this number the longer it will take for the camera to stop.
  34933. */
  34934. inertialAlphaOffset: number;
  34935. /**
  34936. * Current inertia value on the latitudinal axis.
  34937. * The bigger this number the longer it will take for the camera to stop.
  34938. */
  34939. inertialBetaOffset: number;
  34940. /**
  34941. * Current inertia value on the radius axis.
  34942. * The bigger this number the longer it will take for the camera to stop.
  34943. */
  34944. inertialRadiusOffset: number;
  34945. /**
  34946. * Minimum allowed angle on the longitudinal axis.
  34947. * This can help limiting how the Camera is able to move in the scene.
  34948. */
  34949. lowerAlphaLimit: Nullable<number>;
  34950. /**
  34951. * Maximum allowed angle on the longitudinal axis.
  34952. * This can help limiting how the Camera is able to move in the scene.
  34953. */
  34954. upperAlphaLimit: Nullable<number>;
  34955. /**
  34956. * Minimum allowed angle on the latitudinal axis.
  34957. * This can help limiting how the Camera is able to move in the scene.
  34958. */
  34959. lowerBetaLimit: number;
  34960. /**
  34961. * Maximum allowed angle on the latitudinal axis.
  34962. * This can help limiting how the Camera is able to move in the scene.
  34963. */
  34964. upperBetaLimit: number;
  34965. /**
  34966. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  34967. * This can help limiting how the Camera is able to move in the scene.
  34968. */
  34969. lowerRadiusLimit: Nullable<number>;
  34970. /**
  34971. * Maximum allowed distance of the camera to the target (The camera can not get further).
  34972. * This can help limiting how the Camera is able to move in the scene.
  34973. */
  34974. upperRadiusLimit: Nullable<number>;
  34975. /**
  34976. * Defines the current inertia value used during panning of the camera along the X axis.
  34977. */
  34978. inertialPanningX: number;
  34979. /**
  34980. * Defines the current inertia value used during panning of the camera along the Y axis.
  34981. */
  34982. inertialPanningY: number;
  34983. /**
  34984. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  34985. * Basically if your fingers moves away from more than this distance you will be considered
  34986. * in pinch mode.
  34987. */
  34988. pinchToPanMaxDistance: number;
  34989. /**
  34990. * Defines the maximum distance the camera can pan.
  34991. * This could help keeping the cammera always in your scene.
  34992. */
  34993. panningDistanceLimit: Nullable<number>;
  34994. /**
  34995. * Defines the target of the camera before paning.
  34996. */
  34997. panningOriginTarget: Vector3;
  34998. /**
  34999. * Defines the value of the inertia used during panning.
  35000. * 0 would mean stop inertia and one would mean no decelleration at all.
  35001. */
  35002. panningInertia: number;
  35003. /**
  35004. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  35005. */
  35006. angularSensibilityX: number;
  35007. /**
  35008. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  35009. */
  35010. angularSensibilityY: number;
  35011. /**
  35012. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  35013. */
  35014. pinchPrecision: number;
  35015. /**
  35016. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  35017. * It will be used instead of pinchDeltaPrecision if different from 0.
  35018. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35019. */
  35020. pinchDeltaPercentage: number;
  35021. /**
  35022. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  35023. */
  35024. panningSensibility: number;
  35025. /**
  35026. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  35027. */
  35028. keysUp: number[];
  35029. /**
  35030. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  35031. */
  35032. keysDown: number[];
  35033. /**
  35034. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  35035. */
  35036. keysLeft: number[];
  35037. /**
  35038. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  35039. */
  35040. keysRight: number[];
  35041. /**
  35042. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35043. */
  35044. wheelPrecision: number;
  35045. /**
  35046. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  35047. * It will be used instead of pinchDeltaPrecision if different from 0.
  35048. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35049. */
  35050. wheelDeltaPercentage: number;
  35051. /**
  35052. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  35053. */
  35054. zoomOnFactor: number;
  35055. /**
  35056. * Defines a screen offset for the camera position.
  35057. */
  35058. targetScreenOffset: Vector2;
  35059. /**
  35060. * Allows the camera to be completely reversed.
  35061. * If false the camera can not arrive upside down.
  35062. */
  35063. allowUpsideDown: boolean;
  35064. /**
  35065. * Define if double tap/click is used to restore the previously saved state of the camera.
  35066. */
  35067. useInputToRestoreState: boolean;
  35068. /** @hidden */
  35069. _viewMatrix: Matrix;
  35070. /** @hidden */
  35071. _useCtrlForPanning: boolean;
  35072. /** @hidden */
  35073. _panningMouseButton: number;
  35074. /**
  35075. * Defines the input associated to the camera.
  35076. */
  35077. inputs: ArcRotateCameraInputsManager;
  35078. /** @hidden */
  35079. _reset: () => void;
  35080. /**
  35081. * Defines the allowed panning axis.
  35082. */
  35083. panningAxis: Vector3;
  35084. protected _localDirection: Vector3;
  35085. protected _transformedDirection: Vector3;
  35086. private _bouncingBehavior;
  35087. /**
  35088. * Gets the bouncing behavior of the camera if it has been enabled.
  35089. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35090. */
  35091. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  35092. /**
  35093. * Defines if the bouncing behavior of the camera is enabled on the camera.
  35094. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35095. */
  35096. useBouncingBehavior: boolean;
  35097. private _framingBehavior;
  35098. /**
  35099. * Gets the framing behavior of the camera if it has been enabled.
  35100. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35101. */
  35102. readonly framingBehavior: Nullable<FramingBehavior>;
  35103. /**
  35104. * Defines if the framing behavior of the camera is enabled on the camera.
  35105. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35106. */
  35107. useFramingBehavior: boolean;
  35108. private _autoRotationBehavior;
  35109. /**
  35110. * Gets the auto rotation behavior of the camera if it has been enabled.
  35111. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35112. */
  35113. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  35114. /**
  35115. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  35116. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35117. */
  35118. useAutoRotationBehavior: boolean;
  35119. /**
  35120. * Observable triggered when the mesh target has been changed on the camera.
  35121. */
  35122. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  35123. /**
  35124. * Event raised when the camera is colliding with a mesh.
  35125. */
  35126. onCollide: (collidedMesh: AbstractMesh) => void;
  35127. /**
  35128. * Defines whether the camera should check collision with the objects oh the scene.
  35129. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  35130. */
  35131. checkCollisions: boolean;
  35132. /**
  35133. * Defines the collision radius of the camera.
  35134. * This simulates a sphere around the camera.
  35135. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  35136. */
  35137. collisionRadius: Vector3;
  35138. protected _collider: Collider;
  35139. protected _previousPosition: Vector3;
  35140. protected _collisionVelocity: Vector3;
  35141. protected _newPosition: Vector3;
  35142. protected _previousAlpha: number;
  35143. protected _previousBeta: number;
  35144. protected _previousRadius: number;
  35145. protected _collisionTriggered: boolean;
  35146. protected _targetBoundingCenter: Nullable<Vector3>;
  35147. private _computationVector;
  35148. private _tempAxisVector;
  35149. private _tempAxisRotationMatrix;
  35150. /**
  35151. * Instantiates a new ArcRotateCamera in a given scene
  35152. * @param name Defines the name of the camera
  35153. * @param alpha Defines the camera rotation along the logitudinal axis
  35154. * @param beta Defines the camera rotation along the latitudinal axis
  35155. * @param radius Defines the camera distance from its target
  35156. * @param target Defines the camera target
  35157. * @param scene Defines the scene the camera belongs to
  35158. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  35159. */
  35160. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35161. /** @hidden */
  35162. _initCache(): void;
  35163. /** @hidden */
  35164. _updateCache(ignoreParentClass?: boolean): void;
  35165. protected _getTargetPosition(): Vector3;
  35166. private _storedAlpha;
  35167. private _storedBeta;
  35168. private _storedRadius;
  35169. private _storedTarget;
  35170. /**
  35171. * Stores the current state of the camera (alpha, beta, radius and target)
  35172. * @returns the camera itself
  35173. */
  35174. storeState(): Camera;
  35175. /**
  35176. * @hidden
  35177. * Restored camera state. You must call storeState() first
  35178. */
  35179. _restoreStateValues(): boolean;
  35180. /** @hidden */
  35181. _isSynchronizedViewMatrix(): boolean;
  35182. /**
  35183. * Attached controls to the current camera.
  35184. * @param element Defines the element the controls should be listened from
  35185. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35186. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  35187. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  35188. */
  35189. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  35190. /**
  35191. * Detach the current controls from the camera.
  35192. * The camera will stop reacting to inputs.
  35193. * @param element Defines the element to stop listening the inputs from
  35194. */
  35195. detachControl(element: HTMLElement): void;
  35196. /** @hidden */
  35197. _checkInputs(): void;
  35198. protected _checkLimits(): void;
  35199. /**
  35200. * Rebuilds angles (alpha, beta) and radius from the give position and target
  35201. * @param updateView defines a boolean forcing the camera to update its position with a view matrix computation first (default is true)
  35202. */
  35203. rebuildAnglesAndRadius(updateView?: boolean): void;
  35204. /**
  35205. * Use a position to define the current camera related information like aplha, beta and radius
  35206. * @param position Defines the position to set the camera at
  35207. */
  35208. setPosition(position: Vector3): void;
  35209. /**
  35210. * Defines the target the camera should look at.
  35211. * This will automatically adapt alpha beta and radius to fit within the new target.
  35212. * @param target Defines the new target as a Vector or a mesh
  35213. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  35214. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  35215. */
  35216. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  35217. /** @hidden */
  35218. _getViewMatrix(): Matrix;
  35219. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  35220. /**
  35221. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  35222. * @param meshes Defines the mesh to zoom on
  35223. * @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)
  35224. */
  35225. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  35226. /**
  35227. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  35228. * The target will be changed but the radius
  35229. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  35230. * @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)
  35231. */
  35232. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  35233. min: Vector3;
  35234. max: Vector3;
  35235. distance: number;
  35236. }, doNotUpdateMaxZ?: boolean): void;
  35237. /**
  35238. * @override
  35239. * Override Camera.createRigCamera
  35240. */
  35241. createRigCamera(name: string, cameraIndex: number): Camera;
  35242. /**
  35243. * @hidden
  35244. * @override
  35245. * Override Camera._updateRigCameras
  35246. */
  35247. _updateRigCameras(): void;
  35248. /**
  35249. * Destroy the camera and release the current resources hold by it.
  35250. */
  35251. dispose(): void;
  35252. /**
  35253. * Gets the current object class name.
  35254. * @return the class name
  35255. */
  35256. getClassName(): string;
  35257. }
  35258. }
  35259. declare module BABYLON {
  35260. /**
  35261. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  35262. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35263. */
  35264. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  35265. /**
  35266. * Gets the name of the behavior.
  35267. */
  35268. readonly name: string;
  35269. private _zoomStopsAnimation;
  35270. private _idleRotationSpeed;
  35271. private _idleRotationWaitTime;
  35272. private _idleRotationSpinupTime;
  35273. /**
  35274. * Sets the flag that indicates if user zooming should stop animation.
  35275. */
  35276. /**
  35277. * Gets the flag that indicates if user zooming should stop animation.
  35278. */
  35279. zoomStopsAnimation: boolean;
  35280. /**
  35281. * Sets the default speed at which the camera rotates around the model.
  35282. */
  35283. /**
  35284. * Gets the default speed at which the camera rotates around the model.
  35285. */
  35286. idleRotationSpeed: number;
  35287. /**
  35288. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  35289. */
  35290. /**
  35291. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  35292. */
  35293. idleRotationWaitTime: number;
  35294. /**
  35295. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35296. */
  35297. /**
  35298. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35299. */
  35300. idleRotationSpinupTime: number;
  35301. /**
  35302. * Gets a value indicating if the camera is currently rotating because of this behavior
  35303. */
  35304. readonly rotationInProgress: boolean;
  35305. private _onPrePointerObservableObserver;
  35306. private _onAfterCheckInputsObserver;
  35307. private _attachedCamera;
  35308. private _isPointerDown;
  35309. private _lastFrameTime;
  35310. private _lastInteractionTime;
  35311. private _cameraRotationSpeed;
  35312. /**
  35313. * Initializes the behavior.
  35314. */
  35315. init(): void;
  35316. /**
  35317. * Attaches the behavior to its arc rotate camera.
  35318. * @param camera Defines the camera to attach the behavior to
  35319. */
  35320. attach(camera: ArcRotateCamera): void;
  35321. /**
  35322. * Detaches the behavior from its current arc rotate camera.
  35323. */
  35324. detach(): void;
  35325. /**
  35326. * Returns true if user is scrolling.
  35327. * @return true if user is scrolling.
  35328. */
  35329. private _userIsZooming;
  35330. private _lastFrameRadius;
  35331. private _shouldAnimationStopForInteraction;
  35332. /**
  35333. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35334. */
  35335. private _applyUserInteraction;
  35336. private _userIsMoving;
  35337. }
  35338. }
  35339. declare module BABYLON {
  35340. /**
  35341. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  35342. */
  35343. export class AttachToBoxBehavior implements Behavior<Mesh> {
  35344. private ui;
  35345. /**
  35346. * The name of the behavior
  35347. */
  35348. name: string;
  35349. /**
  35350. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  35351. */
  35352. distanceAwayFromFace: number;
  35353. /**
  35354. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  35355. */
  35356. distanceAwayFromBottomOfFace: number;
  35357. private _faceVectors;
  35358. private _target;
  35359. private _scene;
  35360. private _onRenderObserver;
  35361. private _tmpMatrix;
  35362. private _tmpVector;
  35363. /**
  35364. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  35365. * @param ui The transform node that should be attched to the mesh
  35366. */
  35367. constructor(ui: TransformNode);
  35368. /**
  35369. * Initializes the behavior
  35370. */
  35371. init(): void;
  35372. private _closestFace;
  35373. private _zeroVector;
  35374. private _lookAtTmpMatrix;
  35375. private _lookAtToRef;
  35376. /**
  35377. * Attaches the AttachToBoxBehavior to the passed in mesh
  35378. * @param target The mesh that the specified node will be attached to
  35379. */
  35380. attach(target: Mesh): void;
  35381. /**
  35382. * Detaches the behavior from the mesh
  35383. */
  35384. detach(): void;
  35385. }
  35386. }
  35387. declare module BABYLON {
  35388. /**
  35389. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  35390. */
  35391. export class FadeInOutBehavior implements Behavior<Mesh> {
  35392. /**
  35393. * Time in milliseconds to delay before fading in (Default: 0)
  35394. */
  35395. delay: number;
  35396. /**
  35397. * Time in milliseconds for the mesh to fade in (Default: 300)
  35398. */
  35399. fadeInTime: number;
  35400. private _millisecondsPerFrame;
  35401. private _hovered;
  35402. private _hoverValue;
  35403. private _ownerNode;
  35404. /**
  35405. * Instatiates the FadeInOutBehavior
  35406. */
  35407. constructor();
  35408. /**
  35409. * The name of the behavior
  35410. */
  35411. readonly name: string;
  35412. /**
  35413. * Initializes the behavior
  35414. */
  35415. init(): void;
  35416. /**
  35417. * Attaches the fade behavior on the passed in mesh
  35418. * @param ownerNode The mesh that will be faded in/out once attached
  35419. */
  35420. attach(ownerNode: Mesh): void;
  35421. /**
  35422. * Detaches the behavior from the mesh
  35423. */
  35424. detach(): void;
  35425. /**
  35426. * Triggers the mesh to begin fading in or out
  35427. * @param value if the object should fade in or out (true to fade in)
  35428. */
  35429. fadeIn(value: boolean): void;
  35430. private _update;
  35431. private _setAllVisibility;
  35432. }
  35433. }
  35434. declare module BABYLON {
  35435. /**
  35436. * Class containing a set of static utilities functions for managing Pivots
  35437. * @hidden
  35438. */
  35439. export class PivotTools {
  35440. private static _PivotCached;
  35441. private static _OldPivotPoint;
  35442. private static _PivotTranslation;
  35443. private static _PivotTmpVector;
  35444. /** @hidden */
  35445. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  35446. /** @hidden */
  35447. static _RestorePivotPoint(mesh: AbstractMesh): void;
  35448. }
  35449. }
  35450. declare module BABYLON {
  35451. /**
  35452. * Class containing static functions to help procedurally build meshes
  35453. */
  35454. export class PlaneBuilder {
  35455. /**
  35456. * Creates a plane mesh
  35457. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  35458. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  35459. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  35460. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  35461. * * 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
  35462. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35463. * @param name defines the name of the mesh
  35464. * @param options defines the options used to create the mesh
  35465. * @param scene defines the hosting scene
  35466. * @returns the plane mesh
  35467. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  35468. */
  35469. static CreatePlane(name: string, options: {
  35470. size?: number;
  35471. width?: number;
  35472. height?: number;
  35473. sideOrientation?: number;
  35474. frontUVs?: Vector4;
  35475. backUVs?: Vector4;
  35476. updatable?: boolean;
  35477. sourcePlane?: Plane;
  35478. }, scene: Scene): Mesh;
  35479. }
  35480. }
  35481. declare module BABYLON {
  35482. /**
  35483. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  35484. */
  35485. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  35486. private static _AnyMouseID;
  35487. private _attachedNode;
  35488. private _dragPlane;
  35489. private _scene;
  35490. private _pointerObserver;
  35491. private _beforeRenderObserver;
  35492. private static _planeScene;
  35493. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  35494. /**
  35495. * 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)
  35496. */
  35497. maxDragAngle: number;
  35498. /**
  35499. * @hidden
  35500. */
  35501. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  35502. /**
  35503. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35504. */
  35505. currentDraggingPointerID: number;
  35506. /**
  35507. * The last position where the pointer hit the drag plane in world space
  35508. */
  35509. lastDragPosition: Vector3;
  35510. /**
  35511. * If the behavior is currently in a dragging state
  35512. */
  35513. dragging: boolean;
  35514. /**
  35515. * 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)
  35516. */
  35517. dragDeltaRatio: number;
  35518. /**
  35519. * If the drag plane orientation should be updated during the dragging (Default: true)
  35520. */
  35521. updateDragPlane: boolean;
  35522. private _debugMode;
  35523. private _moving;
  35524. /**
  35525. * Fires each time the attached mesh is dragged with the pointer
  35526. * * delta between last drag position and current drag position in world space
  35527. * * dragDistance along the drag axis
  35528. * * dragPlaneNormal normal of the current drag plane used during the drag
  35529. * * dragPlanePoint in world space where the drag intersects the drag plane
  35530. */
  35531. onDragObservable: Observable<{
  35532. delta: Vector3;
  35533. dragPlanePoint: Vector3;
  35534. dragPlaneNormal: Vector3;
  35535. dragDistance: number;
  35536. pointerId: number;
  35537. }>;
  35538. /**
  35539. * Fires each time a drag begins (eg. mouse down on mesh)
  35540. */
  35541. onDragStartObservable: Observable<{
  35542. dragPlanePoint: Vector3;
  35543. pointerId: number;
  35544. }>;
  35545. /**
  35546. * Fires each time a drag ends (eg. mouse release after drag)
  35547. */
  35548. onDragEndObservable: Observable<{
  35549. dragPlanePoint: Vector3;
  35550. pointerId: number;
  35551. }>;
  35552. /**
  35553. * If the attached mesh should be moved when dragged
  35554. */
  35555. moveAttached: boolean;
  35556. /**
  35557. * If the drag behavior will react to drag events (Default: true)
  35558. */
  35559. enabled: boolean;
  35560. /**
  35561. * If camera controls should be detached during the drag
  35562. */
  35563. detachCameraControls: boolean;
  35564. /**
  35565. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  35566. */
  35567. useObjectOrienationForDragging: boolean;
  35568. private _options;
  35569. /**
  35570. * Creates a pointer drag behavior that can be attached to a mesh
  35571. * @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)
  35572. */
  35573. constructor(options?: {
  35574. dragAxis?: Vector3;
  35575. dragPlaneNormal?: Vector3;
  35576. });
  35577. /**
  35578. * Predicate to determine if it is valid to move the object to a new position when it is moved
  35579. */
  35580. validateDrag: (targetPosition: Vector3) => boolean;
  35581. /**
  35582. * The name of the behavior
  35583. */
  35584. readonly name: string;
  35585. /**
  35586. * Initializes the behavior
  35587. */
  35588. init(): void;
  35589. private _tmpVector;
  35590. private _alternatePickedPoint;
  35591. private _worldDragAxis;
  35592. private _targetPosition;
  35593. private _attachedElement;
  35594. /**
  35595. * Attaches the drag behavior the passed in mesh
  35596. * @param ownerNode The mesh that will be dragged around once attached
  35597. */
  35598. attach(ownerNode: AbstractMesh): void;
  35599. /**
  35600. * Force relase the drag action by code.
  35601. */
  35602. releaseDrag(): void;
  35603. private _startDragRay;
  35604. private _lastPointerRay;
  35605. /**
  35606. * Simulates the start of a pointer drag event on the behavior
  35607. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  35608. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  35609. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  35610. */
  35611. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  35612. private _startDrag;
  35613. private _dragDelta;
  35614. private _moveDrag;
  35615. private _pickWithRayOnDragPlane;
  35616. private _pointA;
  35617. private _pointB;
  35618. private _pointC;
  35619. private _lineA;
  35620. private _lineB;
  35621. private _localAxis;
  35622. private _lookAt;
  35623. private _updateDragPlanePosition;
  35624. /**
  35625. * Detaches the behavior from the mesh
  35626. */
  35627. detach(): void;
  35628. }
  35629. }
  35630. declare module BABYLON {
  35631. /**
  35632. * A behavior that when attached to a mesh will allow the mesh to be scaled
  35633. */
  35634. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  35635. private _dragBehaviorA;
  35636. private _dragBehaviorB;
  35637. private _startDistance;
  35638. private _initialScale;
  35639. private _targetScale;
  35640. private _ownerNode;
  35641. private _sceneRenderObserver;
  35642. /**
  35643. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  35644. */
  35645. constructor();
  35646. /**
  35647. * The name of the behavior
  35648. */
  35649. readonly name: string;
  35650. /**
  35651. * Initializes the behavior
  35652. */
  35653. init(): void;
  35654. private _getCurrentDistance;
  35655. /**
  35656. * Attaches the scale behavior the passed in mesh
  35657. * @param ownerNode The mesh that will be scaled around once attached
  35658. */
  35659. attach(ownerNode: Mesh): void;
  35660. /**
  35661. * Detaches the behavior from the mesh
  35662. */
  35663. detach(): void;
  35664. }
  35665. }
  35666. declare module BABYLON {
  35667. /**
  35668. * 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
  35669. */
  35670. export class SixDofDragBehavior implements Behavior<Mesh> {
  35671. private static _virtualScene;
  35672. private _ownerNode;
  35673. private _sceneRenderObserver;
  35674. private _scene;
  35675. private _targetPosition;
  35676. private _virtualOriginMesh;
  35677. private _virtualDragMesh;
  35678. private _pointerObserver;
  35679. private _moving;
  35680. private _startingOrientation;
  35681. /**
  35682. * 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)
  35683. */
  35684. private zDragFactor;
  35685. /**
  35686. * If the object should rotate to face the drag origin
  35687. */
  35688. rotateDraggedObject: boolean;
  35689. /**
  35690. * If the behavior is currently in a dragging state
  35691. */
  35692. dragging: boolean;
  35693. /**
  35694. * 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)
  35695. */
  35696. dragDeltaRatio: number;
  35697. /**
  35698. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35699. */
  35700. currentDraggingPointerID: number;
  35701. /**
  35702. * If camera controls should be detached during the drag
  35703. */
  35704. detachCameraControls: boolean;
  35705. /**
  35706. * Fires each time a drag starts
  35707. */
  35708. onDragStartObservable: Observable<{}>;
  35709. /**
  35710. * Fires each time a drag ends (eg. mouse release after drag)
  35711. */
  35712. onDragEndObservable: Observable<{}>;
  35713. /**
  35714. * 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
  35715. */
  35716. constructor();
  35717. /**
  35718. * The name of the behavior
  35719. */
  35720. readonly name: string;
  35721. /**
  35722. * Initializes the behavior
  35723. */
  35724. init(): void;
  35725. /**
  35726. * Attaches the scale behavior the passed in mesh
  35727. * @param ownerNode The mesh that will be scaled around once attached
  35728. */
  35729. attach(ownerNode: Mesh): void;
  35730. /**
  35731. * Detaches the behavior from the mesh
  35732. */
  35733. detach(): void;
  35734. }
  35735. }
  35736. declare module BABYLON {
  35737. /**
  35738. * Class used to apply inverse kinematics to bones
  35739. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  35740. */
  35741. export class BoneIKController {
  35742. private static _tmpVecs;
  35743. private static _tmpQuat;
  35744. private static _tmpMats;
  35745. /**
  35746. * Gets or sets the target mesh
  35747. */
  35748. targetMesh: AbstractMesh;
  35749. /** Gets or sets the mesh used as pole */
  35750. poleTargetMesh: AbstractMesh;
  35751. /**
  35752. * Gets or sets the bone used as pole
  35753. */
  35754. poleTargetBone: Nullable<Bone>;
  35755. /**
  35756. * Gets or sets the target position
  35757. */
  35758. targetPosition: Vector3;
  35759. /**
  35760. * Gets or sets the pole target position
  35761. */
  35762. poleTargetPosition: Vector3;
  35763. /**
  35764. * Gets or sets the pole target local offset
  35765. */
  35766. poleTargetLocalOffset: Vector3;
  35767. /**
  35768. * Gets or sets the pole angle
  35769. */
  35770. poleAngle: number;
  35771. /**
  35772. * Gets or sets the mesh associated with the controller
  35773. */
  35774. mesh: AbstractMesh;
  35775. /**
  35776. * 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)
  35777. */
  35778. slerpAmount: number;
  35779. private _bone1Quat;
  35780. private _bone1Mat;
  35781. private _bone2Ang;
  35782. private _bone1;
  35783. private _bone2;
  35784. private _bone1Length;
  35785. private _bone2Length;
  35786. private _maxAngle;
  35787. private _maxReach;
  35788. private _rightHandedSystem;
  35789. private _bendAxis;
  35790. private _slerping;
  35791. private _adjustRoll;
  35792. /**
  35793. * Gets or sets maximum allowed angle
  35794. */
  35795. maxAngle: number;
  35796. /**
  35797. * Creates a new BoneIKController
  35798. * @param mesh defines the mesh to control
  35799. * @param bone defines the bone to control
  35800. * @param options defines options to set up the controller
  35801. */
  35802. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  35803. targetMesh?: AbstractMesh;
  35804. poleTargetMesh?: AbstractMesh;
  35805. poleTargetBone?: Bone;
  35806. poleTargetLocalOffset?: Vector3;
  35807. poleAngle?: number;
  35808. bendAxis?: Vector3;
  35809. maxAngle?: number;
  35810. slerpAmount?: number;
  35811. });
  35812. private _setMaxAngle;
  35813. /**
  35814. * Force the controller to update the bones
  35815. */
  35816. update(): void;
  35817. }
  35818. }
  35819. declare module BABYLON {
  35820. /**
  35821. * Class used to make a bone look toward a point in space
  35822. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  35823. */
  35824. export class BoneLookController {
  35825. private static _tmpVecs;
  35826. private static _tmpQuat;
  35827. private static _tmpMats;
  35828. /**
  35829. * The target Vector3 that the bone will look at
  35830. */
  35831. target: Vector3;
  35832. /**
  35833. * The mesh that the bone is attached to
  35834. */
  35835. mesh: AbstractMesh;
  35836. /**
  35837. * The bone that will be looking to the target
  35838. */
  35839. bone: Bone;
  35840. /**
  35841. * The up axis of the coordinate system that is used when the bone is rotated
  35842. */
  35843. upAxis: Vector3;
  35844. /**
  35845. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  35846. */
  35847. upAxisSpace: Space;
  35848. /**
  35849. * Used to make an adjustment to the yaw of the bone
  35850. */
  35851. adjustYaw: number;
  35852. /**
  35853. * Used to make an adjustment to the pitch of the bone
  35854. */
  35855. adjustPitch: number;
  35856. /**
  35857. * Used to make an adjustment to the roll of the bone
  35858. */
  35859. adjustRoll: number;
  35860. /**
  35861. * 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)
  35862. */
  35863. slerpAmount: number;
  35864. private _minYaw;
  35865. private _maxYaw;
  35866. private _minPitch;
  35867. private _maxPitch;
  35868. private _minYawSin;
  35869. private _minYawCos;
  35870. private _maxYawSin;
  35871. private _maxYawCos;
  35872. private _midYawConstraint;
  35873. private _minPitchTan;
  35874. private _maxPitchTan;
  35875. private _boneQuat;
  35876. private _slerping;
  35877. private _transformYawPitch;
  35878. private _transformYawPitchInv;
  35879. private _firstFrameSkipped;
  35880. private _yawRange;
  35881. private _fowardAxis;
  35882. /**
  35883. * Gets or sets the minimum yaw angle that the bone can look to
  35884. */
  35885. minYaw: number;
  35886. /**
  35887. * Gets or sets the maximum yaw angle that the bone can look to
  35888. */
  35889. maxYaw: number;
  35890. /**
  35891. * Gets or sets the minimum pitch angle that the bone can look to
  35892. */
  35893. minPitch: number;
  35894. /**
  35895. * Gets or sets the maximum pitch angle that the bone can look to
  35896. */
  35897. maxPitch: number;
  35898. /**
  35899. * Create a BoneLookController
  35900. * @param mesh the mesh that the bone belongs to
  35901. * @param bone the bone that will be looking to the target
  35902. * @param target the target Vector3 to look at
  35903. * @param options optional settings:
  35904. * * maxYaw: the maximum angle the bone will yaw to
  35905. * * minYaw: the minimum angle the bone will yaw to
  35906. * * maxPitch: the maximum angle the bone will pitch to
  35907. * * minPitch: the minimum angle the bone will yaw to
  35908. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  35909. * * upAxis: the up axis of the coordinate system
  35910. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  35911. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  35912. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  35913. * * adjustYaw: used to make an adjustment to the yaw of the bone
  35914. * * adjustPitch: used to make an adjustment to the pitch of the bone
  35915. * * adjustRoll: used to make an adjustment to the roll of the bone
  35916. **/
  35917. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  35918. maxYaw?: number;
  35919. minYaw?: number;
  35920. maxPitch?: number;
  35921. minPitch?: number;
  35922. slerpAmount?: number;
  35923. upAxis?: Vector3;
  35924. upAxisSpace?: Space;
  35925. yawAxis?: Vector3;
  35926. pitchAxis?: Vector3;
  35927. adjustYaw?: number;
  35928. adjustPitch?: number;
  35929. adjustRoll?: number;
  35930. });
  35931. /**
  35932. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  35933. */
  35934. update(): void;
  35935. private _getAngleDiff;
  35936. private _getAngleBetween;
  35937. private _isAngleBetween;
  35938. }
  35939. }
  35940. declare module BABYLON {
  35941. /**
  35942. * Manage the gamepad inputs to control an arc rotate camera.
  35943. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35944. */
  35945. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  35946. /**
  35947. * Defines the camera the input is attached to.
  35948. */
  35949. camera: ArcRotateCamera;
  35950. /**
  35951. * Defines the gamepad the input is gathering event from.
  35952. */
  35953. gamepad: Nullable<Gamepad>;
  35954. /**
  35955. * Defines the gamepad rotation sensiblity.
  35956. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  35957. */
  35958. gamepadRotationSensibility: number;
  35959. /**
  35960. * Defines the gamepad move sensiblity.
  35961. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  35962. */
  35963. gamepadMoveSensibility: number;
  35964. private _onGamepadConnectedObserver;
  35965. private _onGamepadDisconnectedObserver;
  35966. /**
  35967. * Attach the input controls to a specific dom element to get the input from.
  35968. * @param element Defines the element the controls should be listened from
  35969. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35970. */
  35971. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35972. /**
  35973. * Detach the current controls from the specified dom element.
  35974. * @param element Defines the element to stop listening the inputs from
  35975. */
  35976. detachControl(element: Nullable<HTMLElement>): void;
  35977. /**
  35978. * Update the current camera state depending on the inputs that have been used this frame.
  35979. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35980. */
  35981. checkInputs(): void;
  35982. /**
  35983. * Gets the class name of the current intput.
  35984. * @returns the class name
  35985. */
  35986. getClassName(): string;
  35987. /**
  35988. * Get the friendly name associated with the input class.
  35989. * @returns the input friendly name
  35990. */
  35991. getSimpleName(): string;
  35992. }
  35993. }
  35994. declare module BABYLON {
  35995. interface ArcRotateCameraInputsManager {
  35996. /**
  35997. * Add orientation input support to the input manager.
  35998. * @returns the current input manager
  35999. */
  36000. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  36001. }
  36002. /**
  36003. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  36004. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36005. */
  36006. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  36007. /**
  36008. * Defines the camera the input is attached to.
  36009. */
  36010. camera: ArcRotateCamera;
  36011. /**
  36012. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  36013. */
  36014. alphaCorrection: number;
  36015. /**
  36016. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  36017. */
  36018. gammaCorrection: number;
  36019. private _alpha;
  36020. private _gamma;
  36021. private _dirty;
  36022. private _deviceOrientationHandler;
  36023. /**
  36024. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  36025. */
  36026. constructor();
  36027. /**
  36028. * Attach the input controls to a specific dom element to get the input from.
  36029. * @param element Defines the element the controls should be listened from
  36030. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36031. */
  36032. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36033. /** @hidden */
  36034. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  36035. /**
  36036. * Update the current camera state depending on the inputs that have been used this frame.
  36037. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36038. */
  36039. checkInputs(): void;
  36040. /**
  36041. * Detach the current controls from the specified dom element.
  36042. * @param element Defines the element to stop listening the inputs from
  36043. */
  36044. detachControl(element: Nullable<HTMLElement>): void;
  36045. /**
  36046. * Gets the class name of the current intput.
  36047. * @returns the class name
  36048. */
  36049. getClassName(): string;
  36050. /**
  36051. * Get the friendly name associated with the input class.
  36052. * @returns the input friendly name
  36053. */
  36054. getSimpleName(): string;
  36055. }
  36056. }
  36057. declare module BABYLON {
  36058. /**
  36059. * Listen to mouse events to control the camera.
  36060. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36061. */
  36062. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  36063. /**
  36064. * Defines the camera the input is attached to.
  36065. */
  36066. camera: FlyCamera;
  36067. /**
  36068. * Defines if touch is enabled. (Default is true.)
  36069. */
  36070. touchEnabled: boolean;
  36071. /**
  36072. * Defines the buttons associated with the input to handle camera rotation.
  36073. */
  36074. buttons: number[];
  36075. /**
  36076. * Assign buttons for Yaw control.
  36077. */
  36078. buttonsYaw: number[];
  36079. /**
  36080. * Assign buttons for Pitch control.
  36081. */
  36082. buttonsPitch: number[];
  36083. /**
  36084. * Assign buttons for Roll control.
  36085. */
  36086. buttonsRoll: number[];
  36087. /**
  36088. * Detect if any button is being pressed while mouse is moved.
  36089. * -1 = Mouse locked.
  36090. * 0 = Left button.
  36091. * 1 = Middle Button.
  36092. * 2 = Right Button.
  36093. */
  36094. activeButton: number;
  36095. /**
  36096. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  36097. * Higher values reduce its sensitivity.
  36098. */
  36099. angularSensibility: number;
  36100. private _mousemoveCallback;
  36101. private _observer;
  36102. private _rollObserver;
  36103. private previousPosition;
  36104. private noPreventDefault;
  36105. private element;
  36106. /**
  36107. * Listen to mouse events to control the camera.
  36108. * @param touchEnabled Define if touch is enabled. (Default is true.)
  36109. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36110. */
  36111. constructor(touchEnabled?: boolean);
  36112. /**
  36113. * Attach the mouse control to the HTML DOM element.
  36114. * @param element Defines the element that listens to the input events.
  36115. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  36116. */
  36117. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36118. /**
  36119. * Detach the current controls from the specified dom element.
  36120. * @param element Defines the element to stop listening the inputs from
  36121. */
  36122. detachControl(element: Nullable<HTMLElement>): void;
  36123. /**
  36124. * Gets the class name of the current input.
  36125. * @returns the class name.
  36126. */
  36127. getClassName(): string;
  36128. /**
  36129. * Get the friendly name associated with the input class.
  36130. * @returns the input's friendly name.
  36131. */
  36132. getSimpleName(): string;
  36133. private _pointerInput;
  36134. private _onMouseMove;
  36135. /**
  36136. * Rotate camera by mouse offset.
  36137. */
  36138. private rotateCamera;
  36139. }
  36140. }
  36141. declare module BABYLON {
  36142. /**
  36143. * Default Inputs manager for the FlyCamera.
  36144. * It groups all the default supported inputs for ease of use.
  36145. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36146. */
  36147. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  36148. /**
  36149. * Instantiates a new FlyCameraInputsManager.
  36150. * @param camera Defines the camera the inputs belong to.
  36151. */
  36152. constructor(camera: FlyCamera);
  36153. /**
  36154. * Add keyboard input support to the input manager.
  36155. * @returns the new FlyCameraKeyboardMoveInput().
  36156. */
  36157. addKeyboard(): FlyCameraInputsManager;
  36158. /**
  36159. * Add mouse input support to the input manager.
  36160. * @param touchEnabled Enable touch screen support.
  36161. * @returns the new FlyCameraMouseInput().
  36162. */
  36163. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  36164. }
  36165. }
  36166. declare module BABYLON {
  36167. /**
  36168. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36169. * such as in a 3D Space Shooter or a Flight Simulator.
  36170. */
  36171. export class FlyCamera extends TargetCamera {
  36172. /**
  36173. * Define the collision ellipsoid of the camera.
  36174. * This is helpful for simulating a camera body, like a player's body.
  36175. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36176. */
  36177. ellipsoid: Vector3;
  36178. /**
  36179. * Define an offset for the position of the ellipsoid around the camera.
  36180. * This can be helpful if the camera is attached away from the player's body center,
  36181. * such as at its head.
  36182. */
  36183. ellipsoidOffset: Vector3;
  36184. /**
  36185. * Enable or disable collisions of the camera with the rest of the scene objects.
  36186. */
  36187. checkCollisions: boolean;
  36188. /**
  36189. * Enable or disable gravity on the camera.
  36190. */
  36191. applyGravity: boolean;
  36192. /**
  36193. * Define the current direction the camera is moving to.
  36194. */
  36195. cameraDirection: Vector3;
  36196. /**
  36197. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  36198. * This overrides and empties cameraRotation.
  36199. */
  36200. rotationQuaternion: Quaternion;
  36201. /**
  36202. * Track Roll to maintain the wanted Rolling when looking around.
  36203. */
  36204. _trackRoll: number;
  36205. /**
  36206. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  36207. */
  36208. rollCorrect: number;
  36209. /**
  36210. * Mimic a banked turn, Rolling the camera when Yawing.
  36211. * It's recommended to use rollCorrect = 10 for faster banking correction.
  36212. */
  36213. bankedTurn: boolean;
  36214. /**
  36215. * Limit in radians for how much Roll banking will add. (Default: 90°)
  36216. */
  36217. bankedTurnLimit: number;
  36218. /**
  36219. * Value of 0 disables the banked Roll.
  36220. * Value of 1 is equal to the Yaw angle in radians.
  36221. */
  36222. bankedTurnMultiplier: number;
  36223. /**
  36224. * The inputs manager loads all the input sources, such as keyboard and mouse.
  36225. */
  36226. inputs: FlyCameraInputsManager;
  36227. /**
  36228. * Gets the input sensibility for mouse input.
  36229. * Higher values reduce sensitivity.
  36230. */
  36231. /**
  36232. * Sets the input sensibility for a mouse input.
  36233. * Higher values reduce sensitivity.
  36234. */
  36235. angularSensibility: number;
  36236. /**
  36237. * Get the keys for camera movement forward.
  36238. */
  36239. /**
  36240. * Set the keys for camera movement forward.
  36241. */
  36242. keysForward: number[];
  36243. /**
  36244. * Get the keys for camera movement backward.
  36245. */
  36246. keysBackward: number[];
  36247. /**
  36248. * Get the keys for camera movement up.
  36249. */
  36250. /**
  36251. * Set the keys for camera movement up.
  36252. */
  36253. keysUp: number[];
  36254. /**
  36255. * Get the keys for camera movement down.
  36256. */
  36257. /**
  36258. * Set the keys for camera movement down.
  36259. */
  36260. keysDown: number[];
  36261. /**
  36262. * Get the keys for camera movement left.
  36263. */
  36264. /**
  36265. * Set the keys for camera movement left.
  36266. */
  36267. keysLeft: number[];
  36268. /**
  36269. * Set the keys for camera movement right.
  36270. */
  36271. /**
  36272. * Set the keys for camera movement right.
  36273. */
  36274. keysRight: number[];
  36275. /**
  36276. * Event raised when the camera collides with a mesh in the scene.
  36277. */
  36278. onCollide: (collidedMesh: AbstractMesh) => void;
  36279. private _collider;
  36280. private _needMoveForGravity;
  36281. private _oldPosition;
  36282. private _diffPosition;
  36283. private _newPosition;
  36284. /** @hidden */
  36285. _localDirection: Vector3;
  36286. /** @hidden */
  36287. _transformedDirection: Vector3;
  36288. /**
  36289. * Instantiates a FlyCamera.
  36290. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36291. * such as in a 3D Space Shooter or a Flight Simulator.
  36292. * @param name Define the name of the camera in the scene.
  36293. * @param position Define the starting position of the camera in the scene.
  36294. * @param scene Define the scene the camera belongs to.
  36295. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  36296. */
  36297. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36298. /**
  36299. * Attach a control to the HTML DOM element.
  36300. * @param element Defines the element that listens to the input events.
  36301. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  36302. */
  36303. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36304. /**
  36305. * Detach a control from the HTML DOM element.
  36306. * The camera will stop reacting to that input.
  36307. * @param element Defines the element that listens to the input events.
  36308. */
  36309. detachControl(element: HTMLElement): void;
  36310. private _collisionMask;
  36311. /**
  36312. * Get the mask that the camera ignores in collision events.
  36313. */
  36314. /**
  36315. * Set the mask that the camera ignores in collision events.
  36316. */
  36317. collisionMask: number;
  36318. /** @hidden */
  36319. _collideWithWorld(displacement: Vector3): void;
  36320. /** @hidden */
  36321. private _onCollisionPositionChange;
  36322. /** @hidden */
  36323. _checkInputs(): void;
  36324. /** @hidden */
  36325. _decideIfNeedsToMove(): boolean;
  36326. /** @hidden */
  36327. _updatePosition(): void;
  36328. /**
  36329. * Restore the Roll to its target value at the rate specified.
  36330. * @param rate - Higher means slower restoring.
  36331. * @hidden
  36332. */
  36333. restoreRoll(rate: number): void;
  36334. /**
  36335. * Destroy the camera and release the current resources held by it.
  36336. */
  36337. dispose(): void;
  36338. /**
  36339. * Get the current object class name.
  36340. * @returns the class name.
  36341. */
  36342. getClassName(): string;
  36343. }
  36344. }
  36345. declare module BABYLON {
  36346. /**
  36347. * Listen to keyboard events to control the camera.
  36348. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36349. */
  36350. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  36351. /**
  36352. * Defines the camera the input is attached to.
  36353. */
  36354. camera: FlyCamera;
  36355. /**
  36356. * The list of keyboard keys used to control the forward move of the camera.
  36357. */
  36358. keysForward: number[];
  36359. /**
  36360. * The list of keyboard keys used to control the backward move of the camera.
  36361. */
  36362. keysBackward: number[];
  36363. /**
  36364. * The list of keyboard keys used to control the forward move of the camera.
  36365. */
  36366. keysUp: number[];
  36367. /**
  36368. * The list of keyboard keys used to control the backward move of the camera.
  36369. */
  36370. keysDown: number[];
  36371. /**
  36372. * The list of keyboard keys used to control the right strafe move of the camera.
  36373. */
  36374. keysRight: number[];
  36375. /**
  36376. * The list of keyboard keys used to control the left strafe move of the camera.
  36377. */
  36378. keysLeft: number[];
  36379. private _keys;
  36380. private _onCanvasBlurObserver;
  36381. private _onKeyboardObserver;
  36382. private _engine;
  36383. private _scene;
  36384. /**
  36385. * Attach the input controls to a specific dom element to get the input from.
  36386. * @param element Defines the element the controls should be listened from
  36387. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36388. */
  36389. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36390. /**
  36391. * Detach the current controls from the specified dom element.
  36392. * @param element Defines the element to stop listening the inputs from
  36393. */
  36394. detachControl(element: Nullable<HTMLElement>): void;
  36395. /**
  36396. * Gets the class name of the current intput.
  36397. * @returns the class name
  36398. */
  36399. getClassName(): string;
  36400. /** @hidden */
  36401. _onLostFocus(e: FocusEvent): void;
  36402. /**
  36403. * Get the friendly name associated with the input class.
  36404. * @returns the input friendly name
  36405. */
  36406. getSimpleName(): string;
  36407. /**
  36408. * Update the current camera state depending on the inputs that have been used this frame.
  36409. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36410. */
  36411. checkInputs(): void;
  36412. }
  36413. }
  36414. declare module BABYLON {
  36415. /**
  36416. * Manage the mouse wheel inputs to control a follow camera.
  36417. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36418. */
  36419. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  36420. /**
  36421. * Defines the camera the input is attached to.
  36422. */
  36423. camera: FollowCamera;
  36424. /**
  36425. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  36426. */
  36427. axisControlRadius: boolean;
  36428. /**
  36429. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  36430. */
  36431. axisControlHeight: boolean;
  36432. /**
  36433. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  36434. */
  36435. axisControlRotation: boolean;
  36436. /**
  36437. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  36438. * relation to mouseWheel events.
  36439. */
  36440. wheelPrecision: number;
  36441. /**
  36442. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36443. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36444. */
  36445. wheelDeltaPercentage: number;
  36446. private _wheel;
  36447. private _observer;
  36448. /**
  36449. * Attach the input controls to a specific dom element to get the input from.
  36450. * @param element Defines the element the controls should be listened from
  36451. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36452. */
  36453. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36454. /**
  36455. * Detach the current controls from the specified dom element.
  36456. * @param element Defines the element to stop listening the inputs from
  36457. */
  36458. detachControl(element: Nullable<HTMLElement>): void;
  36459. /**
  36460. * Gets the class name of the current intput.
  36461. * @returns the class name
  36462. */
  36463. getClassName(): string;
  36464. /**
  36465. * Get the friendly name associated with the input class.
  36466. * @returns the input friendly name
  36467. */
  36468. getSimpleName(): string;
  36469. }
  36470. }
  36471. declare module BABYLON {
  36472. /**
  36473. * Manage the pointers inputs to control an follow camera.
  36474. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36475. */
  36476. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  36477. /**
  36478. * Defines the camera the input is attached to.
  36479. */
  36480. camera: FollowCamera;
  36481. /**
  36482. * Gets the class name of the current input.
  36483. * @returns the class name
  36484. */
  36485. getClassName(): string;
  36486. /**
  36487. * Defines the pointer angular sensibility along the X axis or how fast is
  36488. * the camera rotating.
  36489. * A negative number will reverse the axis direction.
  36490. */
  36491. angularSensibilityX: number;
  36492. /**
  36493. * Defines the pointer angular sensibility along the Y axis or how fast is
  36494. * the camera rotating.
  36495. * A negative number will reverse the axis direction.
  36496. */
  36497. angularSensibilityY: number;
  36498. /**
  36499. * Defines the pointer pinch precision or how fast is the camera zooming.
  36500. * A negative number will reverse the axis direction.
  36501. */
  36502. pinchPrecision: number;
  36503. /**
  36504. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36505. * from 0.
  36506. * It defines the percentage of current camera.radius to use as delta when
  36507. * pinch zoom is used.
  36508. */
  36509. pinchDeltaPercentage: number;
  36510. /**
  36511. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  36512. */
  36513. axisXControlRadius: boolean;
  36514. /**
  36515. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  36516. */
  36517. axisXControlHeight: boolean;
  36518. /**
  36519. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  36520. */
  36521. axisXControlRotation: boolean;
  36522. /**
  36523. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  36524. */
  36525. axisYControlRadius: boolean;
  36526. /**
  36527. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  36528. */
  36529. axisYControlHeight: boolean;
  36530. /**
  36531. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  36532. */
  36533. axisYControlRotation: boolean;
  36534. /**
  36535. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  36536. */
  36537. axisPinchControlRadius: boolean;
  36538. /**
  36539. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  36540. */
  36541. axisPinchControlHeight: boolean;
  36542. /**
  36543. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  36544. */
  36545. axisPinchControlRotation: boolean;
  36546. /**
  36547. * Log error messages if basic misconfiguration has occurred.
  36548. */
  36549. warningEnable: boolean;
  36550. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36551. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36552. private _warningCounter;
  36553. private _warning;
  36554. }
  36555. }
  36556. declare module BABYLON {
  36557. /**
  36558. * Default Inputs manager for the FollowCamera.
  36559. * It groups all the default supported inputs for ease of use.
  36560. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36561. */
  36562. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  36563. /**
  36564. * Instantiates a new FollowCameraInputsManager.
  36565. * @param camera Defines the camera the inputs belong to
  36566. */
  36567. constructor(camera: FollowCamera);
  36568. /**
  36569. * Add keyboard input support to the input manager.
  36570. * @returns the current input manager
  36571. */
  36572. addKeyboard(): FollowCameraInputsManager;
  36573. /**
  36574. * Add mouse wheel input support to the input manager.
  36575. * @returns the current input manager
  36576. */
  36577. addMouseWheel(): FollowCameraInputsManager;
  36578. /**
  36579. * Add pointers input support to the input manager.
  36580. * @returns the current input manager
  36581. */
  36582. addPointers(): FollowCameraInputsManager;
  36583. /**
  36584. * Add orientation input support to the input manager.
  36585. * @returns the current input manager
  36586. */
  36587. addVRDeviceOrientation(): FollowCameraInputsManager;
  36588. }
  36589. }
  36590. declare module BABYLON {
  36591. /**
  36592. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  36593. * an arc rotate version arcFollowCamera are available.
  36594. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36595. */
  36596. export class FollowCamera extends TargetCamera {
  36597. /**
  36598. * Distance the follow camera should follow an object at
  36599. */
  36600. radius: number;
  36601. /**
  36602. * Minimum allowed distance of the camera to the axis of rotation
  36603. * (The camera can not get closer).
  36604. * This can help limiting how the Camera is able to move in the scene.
  36605. */
  36606. lowerRadiusLimit: Nullable<number>;
  36607. /**
  36608. * Maximum allowed distance of the camera to the axis of rotation
  36609. * (The camera can not get further).
  36610. * This can help limiting how the Camera is able to move in the scene.
  36611. */
  36612. upperRadiusLimit: Nullable<number>;
  36613. /**
  36614. * Define a rotation offset between the camera and the object it follows
  36615. */
  36616. rotationOffset: number;
  36617. /**
  36618. * Minimum allowed angle to camera position relative to target object.
  36619. * This can help limiting how the Camera is able to move in the scene.
  36620. */
  36621. lowerRotationOffsetLimit: Nullable<number>;
  36622. /**
  36623. * Maximum allowed angle to camera position relative to target object.
  36624. * This can help limiting how the Camera is able to move in the scene.
  36625. */
  36626. upperRotationOffsetLimit: Nullable<number>;
  36627. /**
  36628. * Define a height offset between the camera and the object it follows.
  36629. * It can help following an object from the top (like a car chaing a plane)
  36630. */
  36631. heightOffset: number;
  36632. /**
  36633. * Minimum allowed height of camera position relative to target object.
  36634. * This can help limiting how the Camera is able to move in the scene.
  36635. */
  36636. lowerHeightOffsetLimit: Nullable<number>;
  36637. /**
  36638. * Maximum allowed height of camera position relative to target object.
  36639. * This can help limiting how the Camera is able to move in the scene.
  36640. */
  36641. upperHeightOffsetLimit: Nullable<number>;
  36642. /**
  36643. * Define how fast the camera can accelerate to follow it s target.
  36644. */
  36645. cameraAcceleration: number;
  36646. /**
  36647. * Define the speed limit of the camera following an object.
  36648. */
  36649. maxCameraSpeed: number;
  36650. /**
  36651. * Define the target of the camera.
  36652. */
  36653. lockedTarget: Nullable<AbstractMesh>;
  36654. /**
  36655. * Defines the input associated with the camera.
  36656. */
  36657. inputs: FollowCameraInputsManager;
  36658. /**
  36659. * Instantiates the follow camera.
  36660. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36661. * @param name Define the name of the camera in the scene
  36662. * @param position Define the position of the camera
  36663. * @param scene Define the scene the camera belong to
  36664. * @param lockedTarget Define the target of the camera
  36665. */
  36666. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  36667. private _follow;
  36668. /**
  36669. * Attached controls to the current camera.
  36670. * @param element Defines the element the controls should be listened from
  36671. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36672. */
  36673. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36674. /**
  36675. * Detach the current controls from the camera.
  36676. * The camera will stop reacting to inputs.
  36677. * @param element Defines the element to stop listening the inputs from
  36678. */
  36679. detachControl(element: HTMLElement): void;
  36680. /** @hidden */
  36681. _checkInputs(): void;
  36682. private _checkLimits;
  36683. /**
  36684. * Gets the camera class name.
  36685. * @returns the class name
  36686. */
  36687. getClassName(): string;
  36688. }
  36689. /**
  36690. * Arc Rotate version of the follow camera.
  36691. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  36692. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36693. */
  36694. export class ArcFollowCamera extends TargetCamera {
  36695. /** The longitudinal angle of the camera */
  36696. alpha: number;
  36697. /** The latitudinal angle of the camera */
  36698. beta: number;
  36699. /** The radius of the camera from its target */
  36700. radius: number;
  36701. /** Define the camera target (the messh it should follow) */
  36702. target: Nullable<AbstractMesh>;
  36703. private _cartesianCoordinates;
  36704. /**
  36705. * Instantiates a new ArcFollowCamera
  36706. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36707. * @param name Define the name of the camera
  36708. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  36709. * @param beta Define the rotation angle of the camera around the elevation axis
  36710. * @param radius Define the radius of the camera from its target point
  36711. * @param target Define the target of the camera
  36712. * @param scene Define the scene the camera belongs to
  36713. */
  36714. constructor(name: string,
  36715. /** The longitudinal angle of the camera */
  36716. alpha: number,
  36717. /** The latitudinal angle of the camera */
  36718. beta: number,
  36719. /** The radius of the camera from its target */
  36720. radius: number,
  36721. /** Define the camera target (the messh it should follow) */
  36722. target: Nullable<AbstractMesh>, scene: Scene);
  36723. private _follow;
  36724. /** @hidden */
  36725. _checkInputs(): void;
  36726. /**
  36727. * Returns the class name of the object.
  36728. * It is mostly used internally for serialization purposes.
  36729. */
  36730. getClassName(): string;
  36731. }
  36732. }
  36733. declare module BABYLON {
  36734. /**
  36735. * Manage the keyboard inputs to control the movement of a follow camera.
  36736. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36737. */
  36738. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  36739. /**
  36740. * Defines the camera the input is attached to.
  36741. */
  36742. camera: FollowCamera;
  36743. /**
  36744. * Defines the list of key codes associated with the up action (increase heightOffset)
  36745. */
  36746. keysHeightOffsetIncr: number[];
  36747. /**
  36748. * Defines the list of key codes associated with the down action (decrease heightOffset)
  36749. */
  36750. keysHeightOffsetDecr: number[];
  36751. /**
  36752. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  36753. */
  36754. keysHeightOffsetModifierAlt: boolean;
  36755. /**
  36756. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  36757. */
  36758. keysHeightOffsetModifierCtrl: boolean;
  36759. /**
  36760. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  36761. */
  36762. keysHeightOffsetModifierShift: boolean;
  36763. /**
  36764. * Defines the list of key codes associated with the left action (increase rotationOffset)
  36765. */
  36766. keysRotationOffsetIncr: number[];
  36767. /**
  36768. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  36769. */
  36770. keysRotationOffsetDecr: number[];
  36771. /**
  36772. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  36773. */
  36774. keysRotationOffsetModifierAlt: boolean;
  36775. /**
  36776. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  36777. */
  36778. keysRotationOffsetModifierCtrl: boolean;
  36779. /**
  36780. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  36781. */
  36782. keysRotationOffsetModifierShift: boolean;
  36783. /**
  36784. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  36785. */
  36786. keysRadiusIncr: number[];
  36787. /**
  36788. * Defines the list of key codes associated with the zoom-out action (increase radius)
  36789. */
  36790. keysRadiusDecr: number[];
  36791. /**
  36792. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  36793. */
  36794. keysRadiusModifierAlt: boolean;
  36795. /**
  36796. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  36797. */
  36798. keysRadiusModifierCtrl: boolean;
  36799. /**
  36800. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  36801. */
  36802. keysRadiusModifierShift: boolean;
  36803. /**
  36804. * Defines the rate of change of heightOffset.
  36805. */
  36806. heightSensibility: number;
  36807. /**
  36808. * Defines the rate of change of rotationOffset.
  36809. */
  36810. rotationSensibility: number;
  36811. /**
  36812. * Defines the rate of change of radius.
  36813. */
  36814. radiusSensibility: number;
  36815. private _keys;
  36816. private _ctrlPressed;
  36817. private _altPressed;
  36818. private _shiftPressed;
  36819. private _onCanvasBlurObserver;
  36820. private _onKeyboardObserver;
  36821. private _engine;
  36822. private _scene;
  36823. /**
  36824. * Attach the input controls to a specific dom element to get the input from.
  36825. * @param element Defines the element the controls should be listened from
  36826. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36827. */
  36828. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36829. /**
  36830. * Detach the current controls from the specified dom element.
  36831. * @param element Defines the element to stop listening the inputs from
  36832. */
  36833. detachControl(element: Nullable<HTMLElement>): void;
  36834. /**
  36835. * Update the current camera state depending on the inputs that have been used this frame.
  36836. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36837. */
  36838. checkInputs(): void;
  36839. /**
  36840. * Gets the class name of the current input.
  36841. * @returns the class name
  36842. */
  36843. getClassName(): string;
  36844. /**
  36845. * Get the friendly name associated with the input class.
  36846. * @returns the input friendly name
  36847. */
  36848. getSimpleName(): string;
  36849. /**
  36850. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36851. * allow modification of the heightOffset value.
  36852. */
  36853. private _modifierHeightOffset;
  36854. /**
  36855. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36856. * allow modification of the rotationOffset value.
  36857. */
  36858. private _modifierRotationOffset;
  36859. /**
  36860. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36861. * allow modification of the radius value.
  36862. */
  36863. private _modifierRadius;
  36864. }
  36865. }
  36866. declare module BABYLON {
  36867. interface FreeCameraInputsManager {
  36868. /**
  36869. * Add orientation input support to the input manager.
  36870. * @returns the current input manager
  36871. */
  36872. addDeviceOrientation(): FreeCameraInputsManager;
  36873. }
  36874. /**
  36875. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  36876. * Screen rotation is taken into account.
  36877. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36878. */
  36879. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  36880. private _camera;
  36881. private _screenOrientationAngle;
  36882. private _constantTranform;
  36883. private _screenQuaternion;
  36884. private _alpha;
  36885. private _beta;
  36886. private _gamma;
  36887. /**
  36888. * Instantiates a new input
  36889. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36890. */
  36891. constructor();
  36892. /**
  36893. * Define the camera controlled by the input.
  36894. */
  36895. camera: FreeCamera;
  36896. /**
  36897. * Attach the input controls to a specific dom element to get the input from.
  36898. * @param element Defines the element the controls should be listened from
  36899. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36900. */
  36901. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36902. private _orientationChanged;
  36903. private _deviceOrientation;
  36904. /**
  36905. * Detach the current controls from the specified dom element.
  36906. * @param element Defines the element to stop listening the inputs from
  36907. */
  36908. detachControl(element: Nullable<HTMLElement>): void;
  36909. /**
  36910. * Update the current camera state depending on the inputs that have been used this frame.
  36911. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36912. */
  36913. checkInputs(): void;
  36914. /**
  36915. * Gets the class name of the current intput.
  36916. * @returns the class name
  36917. */
  36918. getClassName(): string;
  36919. /**
  36920. * Get the friendly name associated with the input class.
  36921. * @returns the input friendly name
  36922. */
  36923. getSimpleName(): string;
  36924. }
  36925. }
  36926. declare module BABYLON {
  36927. /**
  36928. * Manage the gamepad inputs to control a free camera.
  36929. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36930. */
  36931. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  36932. /**
  36933. * Define the camera the input is attached to.
  36934. */
  36935. camera: FreeCamera;
  36936. /**
  36937. * Define the Gamepad controlling the input
  36938. */
  36939. gamepad: Nullable<Gamepad>;
  36940. /**
  36941. * Defines the gamepad rotation sensiblity.
  36942. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36943. */
  36944. gamepadAngularSensibility: number;
  36945. /**
  36946. * Defines the gamepad move sensiblity.
  36947. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36948. */
  36949. gamepadMoveSensibility: number;
  36950. private _onGamepadConnectedObserver;
  36951. private _onGamepadDisconnectedObserver;
  36952. private _cameraTransform;
  36953. private _deltaTransform;
  36954. private _vector3;
  36955. private _vector2;
  36956. /**
  36957. * Attach the input controls to a specific dom element to get the input from.
  36958. * @param element Defines the element the controls should be listened from
  36959. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36960. */
  36961. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36962. /**
  36963. * Detach the current controls from the specified dom element.
  36964. * @param element Defines the element to stop listening the inputs from
  36965. */
  36966. detachControl(element: Nullable<HTMLElement>): void;
  36967. /**
  36968. * Update the current camera state depending on the inputs that have been used this frame.
  36969. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36970. */
  36971. checkInputs(): void;
  36972. /**
  36973. * Gets the class name of the current intput.
  36974. * @returns the class name
  36975. */
  36976. getClassName(): string;
  36977. /**
  36978. * Get the friendly name associated with the input class.
  36979. * @returns the input friendly name
  36980. */
  36981. getSimpleName(): string;
  36982. }
  36983. }
  36984. declare module BABYLON {
  36985. /**
  36986. * Defines the potential axis of a Joystick
  36987. */
  36988. export enum JoystickAxis {
  36989. /** X axis */
  36990. X = 0,
  36991. /** Y axis */
  36992. Y = 1,
  36993. /** Z axis */
  36994. Z = 2
  36995. }
  36996. /**
  36997. * Class used to define virtual joystick (used in touch mode)
  36998. */
  36999. export class VirtualJoystick {
  37000. /**
  37001. * Gets or sets a boolean indicating that left and right values must be inverted
  37002. */
  37003. reverseLeftRight: boolean;
  37004. /**
  37005. * Gets or sets a boolean indicating that up and down values must be inverted
  37006. */
  37007. reverseUpDown: boolean;
  37008. /**
  37009. * Gets the offset value for the position (ie. the change of the position value)
  37010. */
  37011. deltaPosition: Vector3;
  37012. /**
  37013. * Gets a boolean indicating if the virtual joystick was pressed
  37014. */
  37015. pressed: boolean;
  37016. /**
  37017. * Canvas the virtual joystick will render onto, default z-index of this is 5
  37018. */
  37019. static Canvas: Nullable<HTMLCanvasElement>;
  37020. private static _globalJoystickIndex;
  37021. private static vjCanvasContext;
  37022. private static vjCanvasWidth;
  37023. private static vjCanvasHeight;
  37024. private static halfWidth;
  37025. private _action;
  37026. private _axisTargetedByLeftAndRight;
  37027. private _axisTargetedByUpAndDown;
  37028. private _joystickSensibility;
  37029. private _inversedSensibility;
  37030. private _joystickPointerID;
  37031. private _joystickColor;
  37032. private _joystickPointerPos;
  37033. private _joystickPreviousPointerPos;
  37034. private _joystickPointerStartPos;
  37035. private _deltaJoystickVector;
  37036. private _leftJoystick;
  37037. private _touches;
  37038. private _onPointerDownHandlerRef;
  37039. private _onPointerMoveHandlerRef;
  37040. private _onPointerUpHandlerRef;
  37041. private _onResize;
  37042. /**
  37043. * Creates a new virtual joystick
  37044. * @param leftJoystick defines that the joystick is for left hand (false by default)
  37045. */
  37046. constructor(leftJoystick?: boolean);
  37047. /**
  37048. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  37049. * @param newJoystickSensibility defines the new sensibility
  37050. */
  37051. setJoystickSensibility(newJoystickSensibility: number): void;
  37052. private _onPointerDown;
  37053. private _onPointerMove;
  37054. private _onPointerUp;
  37055. /**
  37056. * Change the color of the virtual joystick
  37057. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  37058. */
  37059. setJoystickColor(newColor: string): void;
  37060. /**
  37061. * Defines a callback to call when the joystick is touched
  37062. * @param action defines the callback
  37063. */
  37064. setActionOnTouch(action: () => any): void;
  37065. /**
  37066. * Defines which axis you'd like to control for left & right
  37067. * @param axis defines the axis to use
  37068. */
  37069. setAxisForLeftRight(axis: JoystickAxis): void;
  37070. /**
  37071. * Defines which axis you'd like to control for up & down
  37072. * @param axis defines the axis to use
  37073. */
  37074. setAxisForUpDown(axis: JoystickAxis): void;
  37075. private _drawVirtualJoystick;
  37076. /**
  37077. * Release internal HTML canvas
  37078. */
  37079. releaseCanvas(): void;
  37080. }
  37081. }
  37082. declare module BABYLON {
  37083. interface FreeCameraInputsManager {
  37084. /**
  37085. * Add virtual joystick input support to the input manager.
  37086. * @returns the current input manager
  37087. */
  37088. addVirtualJoystick(): FreeCameraInputsManager;
  37089. }
  37090. /**
  37091. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  37092. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37093. */
  37094. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  37095. /**
  37096. * Defines the camera the input is attached to.
  37097. */
  37098. camera: FreeCamera;
  37099. private _leftjoystick;
  37100. private _rightjoystick;
  37101. /**
  37102. * Gets the left stick of the virtual joystick.
  37103. * @returns The virtual Joystick
  37104. */
  37105. getLeftJoystick(): VirtualJoystick;
  37106. /**
  37107. * Gets the right stick of the virtual joystick.
  37108. * @returns The virtual Joystick
  37109. */
  37110. getRightJoystick(): VirtualJoystick;
  37111. /**
  37112. * Update the current camera state depending on the inputs that have been used this frame.
  37113. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37114. */
  37115. checkInputs(): void;
  37116. /**
  37117. * Attach the input controls to a specific dom element to get the input from.
  37118. * @param element Defines the element the controls should be listened from
  37119. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37120. */
  37121. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37122. /**
  37123. * Detach the current controls from the specified dom element.
  37124. * @param element Defines the element to stop listening the inputs from
  37125. */
  37126. detachControl(element: Nullable<HTMLElement>): void;
  37127. /**
  37128. * Gets the class name of the current intput.
  37129. * @returns the class name
  37130. */
  37131. getClassName(): string;
  37132. /**
  37133. * Get the friendly name associated with the input class.
  37134. * @returns the input friendly name
  37135. */
  37136. getSimpleName(): string;
  37137. }
  37138. }
  37139. declare module BABYLON {
  37140. /**
  37141. * This represents a FPS type of camera controlled by touch.
  37142. * This is like a universal camera minus the Gamepad controls.
  37143. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37144. */
  37145. export class TouchCamera extends FreeCamera {
  37146. /**
  37147. * Defines the touch sensibility for rotation.
  37148. * The higher the faster.
  37149. */
  37150. touchAngularSensibility: number;
  37151. /**
  37152. * Defines the touch sensibility for move.
  37153. * The higher the faster.
  37154. */
  37155. touchMoveSensibility: number;
  37156. /**
  37157. * Instantiates a new touch camera.
  37158. * This represents a FPS type of camera controlled by touch.
  37159. * This is like a universal camera minus the Gamepad controls.
  37160. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37161. * @param name Define the name of the camera in the scene
  37162. * @param position Define the start position of the camera in the scene
  37163. * @param scene Define the scene the camera belongs to
  37164. */
  37165. constructor(name: string, position: Vector3, scene: Scene);
  37166. /**
  37167. * Gets the current object class name.
  37168. * @return the class name
  37169. */
  37170. getClassName(): string;
  37171. /** @hidden */
  37172. _setupInputs(): void;
  37173. }
  37174. }
  37175. declare module BABYLON {
  37176. /**
  37177. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  37178. * being tilted forward or back and left or right.
  37179. */
  37180. export class DeviceOrientationCamera extends FreeCamera {
  37181. private _initialQuaternion;
  37182. private _quaternionCache;
  37183. /**
  37184. * Creates a new device orientation camera
  37185. * @param name The name of the camera
  37186. * @param position The start position camera
  37187. * @param scene The scene the camera belongs to
  37188. */
  37189. constructor(name: string, position: Vector3, scene: Scene);
  37190. /**
  37191. * Gets the current instance class name ("DeviceOrientationCamera").
  37192. * This helps avoiding instanceof at run time.
  37193. * @returns the class name
  37194. */
  37195. getClassName(): string;
  37196. /**
  37197. * @hidden
  37198. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  37199. */
  37200. _checkInputs(): void;
  37201. /**
  37202. * Reset the camera to its default orientation on the specified axis only.
  37203. * @param axis The axis to reset
  37204. */
  37205. resetToCurrentRotation(axis?: Axis): void;
  37206. }
  37207. }
  37208. declare module BABYLON {
  37209. /**
  37210. * 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,
  37211. * which still works and will still be found in many Playgrounds.
  37212. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37213. */
  37214. export class UniversalCamera extends TouchCamera {
  37215. /**
  37216. * Defines the gamepad rotation sensiblity.
  37217. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37218. */
  37219. gamepadAngularSensibility: number;
  37220. /**
  37221. * Defines the gamepad move sensiblity.
  37222. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37223. */
  37224. gamepadMoveSensibility: number;
  37225. /**
  37226. * 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,
  37227. * which still works and will still be found in many Playgrounds.
  37228. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37229. * @param name Define the name of the camera in the scene
  37230. * @param position Define the start position of the camera in the scene
  37231. * @param scene Define the scene the camera belongs to
  37232. */
  37233. constructor(name: string, position: Vector3, scene: Scene);
  37234. /**
  37235. * Gets the current object class name.
  37236. * @return the class name
  37237. */
  37238. getClassName(): string;
  37239. }
  37240. }
  37241. declare module BABYLON {
  37242. /**
  37243. * This represents a FPS type of camera. This is only here for back compat purpose.
  37244. * Please use the UniversalCamera instead as both are identical.
  37245. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37246. */
  37247. export class GamepadCamera extends UniversalCamera {
  37248. /**
  37249. * Instantiates a new Gamepad Camera
  37250. * This represents a FPS type of camera. This is only here for back compat purpose.
  37251. * Please use the UniversalCamera instead as both are identical.
  37252. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37253. * @param name Define the name of the camera in the scene
  37254. * @param position Define the start position of the camera in the scene
  37255. * @param scene Define the scene the camera belongs to
  37256. */
  37257. constructor(name: string, position: Vector3, scene: Scene);
  37258. /**
  37259. * Gets the current object class name.
  37260. * @return the class name
  37261. */
  37262. getClassName(): string;
  37263. }
  37264. }
  37265. declare module BABYLON {
  37266. /** @hidden */
  37267. export var passPixelShader: {
  37268. name: string;
  37269. shader: string;
  37270. };
  37271. }
  37272. declare module BABYLON {
  37273. /** @hidden */
  37274. export var passCubePixelShader: {
  37275. name: string;
  37276. shader: string;
  37277. };
  37278. }
  37279. declare module BABYLON {
  37280. /**
  37281. * PassPostProcess which produces an output the same as it's input
  37282. */
  37283. export class PassPostProcess extends PostProcess {
  37284. /**
  37285. * Creates the PassPostProcess
  37286. * @param name The name of the effect.
  37287. * @param options The required width/height ratio to downsize to before computing the render pass.
  37288. * @param camera The camera to apply the render pass to.
  37289. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37290. * @param engine The engine which the post process will be applied. (default: current engine)
  37291. * @param reusable If the post process can be reused on the same frame. (default: false)
  37292. * @param textureType The type of texture to be used when performing the post processing.
  37293. * @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)
  37294. */
  37295. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37296. }
  37297. /**
  37298. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  37299. */
  37300. export class PassCubePostProcess extends PostProcess {
  37301. private _face;
  37302. /**
  37303. * Gets or sets the cube face to display.
  37304. * * 0 is +X
  37305. * * 1 is -X
  37306. * * 2 is +Y
  37307. * * 3 is -Y
  37308. * * 4 is +Z
  37309. * * 5 is -Z
  37310. */
  37311. face: number;
  37312. /**
  37313. * Creates the PassCubePostProcess
  37314. * @param name The name of the effect.
  37315. * @param options The required width/height ratio to downsize to before computing the render pass.
  37316. * @param camera The camera to apply the render pass to.
  37317. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37318. * @param engine The engine which the post process will be applied. (default: current engine)
  37319. * @param reusable If the post process can be reused on the same frame. (default: false)
  37320. * @param textureType The type of texture to be used when performing the post processing.
  37321. * @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)
  37322. */
  37323. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37324. }
  37325. }
  37326. declare module BABYLON {
  37327. /** @hidden */
  37328. export var anaglyphPixelShader: {
  37329. name: string;
  37330. shader: string;
  37331. };
  37332. }
  37333. declare module BABYLON {
  37334. /**
  37335. * Postprocess used to generate anaglyphic rendering
  37336. */
  37337. export class AnaglyphPostProcess extends PostProcess {
  37338. private _passedProcess;
  37339. /**
  37340. * Creates a new AnaglyphPostProcess
  37341. * @param name defines postprocess name
  37342. * @param options defines creation options or target ratio scale
  37343. * @param rigCameras defines cameras using this postprocess
  37344. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  37345. * @param engine defines hosting engine
  37346. * @param reusable defines if the postprocess will be reused multiple times per frame
  37347. */
  37348. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  37349. }
  37350. }
  37351. declare module BABYLON {
  37352. /**
  37353. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  37354. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37355. */
  37356. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  37357. /**
  37358. * Creates a new AnaglyphArcRotateCamera
  37359. * @param name defines camera name
  37360. * @param alpha defines alpha angle (in radians)
  37361. * @param beta defines beta angle (in radians)
  37362. * @param radius defines radius
  37363. * @param target defines camera target
  37364. * @param interaxialDistance defines distance between each color axis
  37365. * @param scene defines the hosting scene
  37366. */
  37367. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  37368. /**
  37369. * Gets camera class name
  37370. * @returns AnaglyphArcRotateCamera
  37371. */
  37372. getClassName(): string;
  37373. }
  37374. }
  37375. declare module BABYLON {
  37376. /**
  37377. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  37378. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37379. */
  37380. export class AnaglyphFreeCamera extends FreeCamera {
  37381. /**
  37382. * Creates a new AnaglyphFreeCamera
  37383. * @param name defines camera name
  37384. * @param position defines initial position
  37385. * @param interaxialDistance defines distance between each color axis
  37386. * @param scene defines the hosting scene
  37387. */
  37388. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37389. /**
  37390. * Gets camera class name
  37391. * @returns AnaglyphFreeCamera
  37392. */
  37393. getClassName(): string;
  37394. }
  37395. }
  37396. declare module BABYLON {
  37397. /**
  37398. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  37399. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37400. */
  37401. export class AnaglyphGamepadCamera extends GamepadCamera {
  37402. /**
  37403. * Creates a new AnaglyphGamepadCamera
  37404. * @param name defines camera name
  37405. * @param position defines initial position
  37406. * @param interaxialDistance defines distance between each color axis
  37407. * @param scene defines the hosting scene
  37408. */
  37409. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37410. /**
  37411. * Gets camera class name
  37412. * @returns AnaglyphGamepadCamera
  37413. */
  37414. getClassName(): string;
  37415. }
  37416. }
  37417. declare module BABYLON {
  37418. /**
  37419. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  37420. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37421. */
  37422. export class AnaglyphUniversalCamera extends UniversalCamera {
  37423. /**
  37424. * Creates a new AnaglyphUniversalCamera
  37425. * @param name defines camera name
  37426. * @param position defines initial position
  37427. * @param interaxialDistance defines distance between each color axis
  37428. * @param scene defines the hosting scene
  37429. */
  37430. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37431. /**
  37432. * Gets camera class name
  37433. * @returns AnaglyphUniversalCamera
  37434. */
  37435. getClassName(): string;
  37436. }
  37437. }
  37438. declare module BABYLON {
  37439. /** @hidden */
  37440. export var stereoscopicInterlacePixelShader: {
  37441. name: string;
  37442. shader: string;
  37443. };
  37444. }
  37445. declare module BABYLON {
  37446. /**
  37447. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  37448. */
  37449. export class StereoscopicInterlacePostProcess extends PostProcess {
  37450. private _stepSize;
  37451. private _passedProcess;
  37452. /**
  37453. * Initializes a StereoscopicInterlacePostProcess
  37454. * @param name The name of the effect.
  37455. * @param rigCameras The rig cameras to be appled to the post process
  37456. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  37457. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37458. * @param engine The engine which the post process will be applied. (default: current engine)
  37459. * @param reusable If the post process can be reused on the same frame. (default: false)
  37460. */
  37461. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  37462. }
  37463. }
  37464. declare module BABYLON {
  37465. /**
  37466. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  37467. * @see http://doc.babylonjs.com/features/cameras
  37468. */
  37469. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  37470. /**
  37471. * Creates a new StereoscopicArcRotateCamera
  37472. * @param name defines camera name
  37473. * @param alpha defines alpha angle (in radians)
  37474. * @param beta defines beta angle (in radians)
  37475. * @param radius defines radius
  37476. * @param target defines camera target
  37477. * @param interaxialDistance defines distance between each color axis
  37478. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37479. * @param scene defines the hosting scene
  37480. */
  37481. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37482. /**
  37483. * Gets camera class name
  37484. * @returns StereoscopicArcRotateCamera
  37485. */
  37486. getClassName(): string;
  37487. }
  37488. }
  37489. declare module BABYLON {
  37490. /**
  37491. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  37492. * @see http://doc.babylonjs.com/features/cameras
  37493. */
  37494. export class StereoscopicFreeCamera extends FreeCamera {
  37495. /**
  37496. * Creates a new StereoscopicFreeCamera
  37497. * @param name defines camera name
  37498. * @param position defines initial position
  37499. * @param interaxialDistance defines distance between each color axis
  37500. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37501. * @param scene defines the hosting scene
  37502. */
  37503. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37504. /**
  37505. * Gets camera class name
  37506. * @returns StereoscopicFreeCamera
  37507. */
  37508. getClassName(): string;
  37509. }
  37510. }
  37511. declare module BABYLON {
  37512. /**
  37513. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  37514. * @see http://doc.babylonjs.com/features/cameras
  37515. */
  37516. export class StereoscopicGamepadCamera extends GamepadCamera {
  37517. /**
  37518. * Creates a new StereoscopicGamepadCamera
  37519. * @param name defines camera name
  37520. * @param position defines initial position
  37521. * @param interaxialDistance defines distance between each color axis
  37522. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37523. * @param scene defines the hosting scene
  37524. */
  37525. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37526. /**
  37527. * Gets camera class name
  37528. * @returns StereoscopicGamepadCamera
  37529. */
  37530. getClassName(): string;
  37531. }
  37532. }
  37533. declare module BABYLON {
  37534. /**
  37535. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  37536. * @see http://doc.babylonjs.com/features/cameras
  37537. */
  37538. export class StereoscopicUniversalCamera extends UniversalCamera {
  37539. /**
  37540. * Creates a new StereoscopicUniversalCamera
  37541. * @param name defines camera name
  37542. * @param position defines initial position
  37543. * @param interaxialDistance defines distance between each color axis
  37544. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37545. * @param scene defines the hosting scene
  37546. */
  37547. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37548. /**
  37549. * Gets camera class name
  37550. * @returns StereoscopicUniversalCamera
  37551. */
  37552. getClassName(): string;
  37553. }
  37554. }
  37555. declare module BABYLON {
  37556. /**
  37557. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  37558. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  37559. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  37560. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  37561. */
  37562. export class VirtualJoysticksCamera extends FreeCamera {
  37563. /**
  37564. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  37565. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  37566. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  37567. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  37568. * @param name Define the name of the camera in the scene
  37569. * @param position Define the start position of the camera in the scene
  37570. * @param scene Define the scene the camera belongs to
  37571. */
  37572. constructor(name: string, position: Vector3, scene: Scene);
  37573. /**
  37574. * Gets the current object class name.
  37575. * @return the class name
  37576. */
  37577. getClassName(): string;
  37578. }
  37579. }
  37580. declare module BABYLON {
  37581. /**
  37582. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  37583. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37584. */
  37585. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  37586. /**
  37587. * Creates a new VRDeviceOrientationArcRotateCamera
  37588. * @param name defines camera name
  37589. * @param alpha defines the camera rotation along the logitudinal axis
  37590. * @param beta defines the camera rotation along the latitudinal axis
  37591. * @param radius defines the camera distance from its target
  37592. * @param target defines the camera target
  37593. * @param scene defines the scene the camera belongs to
  37594. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37595. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37596. */
  37597. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37598. /**
  37599. * Gets camera class name
  37600. * @returns VRDeviceOrientationArcRotateCamera
  37601. */
  37602. getClassName(): string;
  37603. }
  37604. }
  37605. declare module BABYLON {
  37606. /**
  37607. * Camera used to simulate VR rendering (based on FreeCamera)
  37608. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37609. */
  37610. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  37611. /**
  37612. * Creates a new VRDeviceOrientationFreeCamera
  37613. * @param name defines camera name
  37614. * @param position defines the start position of the camera
  37615. * @param scene defines the scene the camera belongs to
  37616. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37617. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37618. */
  37619. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37620. /**
  37621. * Gets camera class name
  37622. * @returns VRDeviceOrientationFreeCamera
  37623. */
  37624. getClassName(): string;
  37625. }
  37626. }
  37627. declare module BABYLON {
  37628. /**
  37629. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  37630. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37631. */
  37632. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  37633. /**
  37634. * Creates a new VRDeviceOrientationGamepadCamera
  37635. * @param name defines camera name
  37636. * @param position defines the start position of the camera
  37637. * @param scene defines the scene the camera belongs to
  37638. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37639. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37640. */
  37641. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37642. /**
  37643. * Gets camera class name
  37644. * @returns VRDeviceOrientationGamepadCamera
  37645. */
  37646. getClassName(): string;
  37647. }
  37648. }
  37649. declare module BABYLON {
  37650. /**
  37651. * Defines supported buttons for XBox360 compatible gamepads
  37652. */
  37653. export enum Xbox360Button {
  37654. /** A */
  37655. A = 0,
  37656. /** B */
  37657. B = 1,
  37658. /** X */
  37659. X = 2,
  37660. /** Y */
  37661. Y = 3,
  37662. /** Start */
  37663. Start = 4,
  37664. /** Back */
  37665. Back = 5,
  37666. /** Left button */
  37667. LB = 6,
  37668. /** Right button */
  37669. RB = 7,
  37670. /** Left stick */
  37671. LeftStick = 8,
  37672. /** Right stick */
  37673. RightStick = 9
  37674. }
  37675. /** Defines values for XBox360 DPad */
  37676. export enum Xbox360Dpad {
  37677. /** Up */
  37678. Up = 0,
  37679. /** Down */
  37680. Down = 1,
  37681. /** Left */
  37682. Left = 2,
  37683. /** Right */
  37684. Right = 3
  37685. }
  37686. /**
  37687. * Defines a XBox360 gamepad
  37688. */
  37689. export class Xbox360Pad extends Gamepad {
  37690. private _leftTrigger;
  37691. private _rightTrigger;
  37692. private _onlefttriggerchanged;
  37693. private _onrighttriggerchanged;
  37694. private _onbuttondown;
  37695. private _onbuttonup;
  37696. private _ondpaddown;
  37697. private _ondpadup;
  37698. /** Observable raised when a button is pressed */
  37699. onButtonDownObservable: Observable<Xbox360Button>;
  37700. /** Observable raised when a button is released */
  37701. onButtonUpObservable: Observable<Xbox360Button>;
  37702. /** Observable raised when a pad is pressed */
  37703. onPadDownObservable: Observable<Xbox360Dpad>;
  37704. /** Observable raised when a pad is released */
  37705. onPadUpObservable: Observable<Xbox360Dpad>;
  37706. private _buttonA;
  37707. private _buttonB;
  37708. private _buttonX;
  37709. private _buttonY;
  37710. private _buttonBack;
  37711. private _buttonStart;
  37712. private _buttonLB;
  37713. private _buttonRB;
  37714. private _buttonLeftStick;
  37715. private _buttonRightStick;
  37716. private _dPadUp;
  37717. private _dPadDown;
  37718. private _dPadLeft;
  37719. private _dPadRight;
  37720. private _isXboxOnePad;
  37721. /**
  37722. * Creates a new XBox360 gamepad object
  37723. * @param id defines the id of this gamepad
  37724. * @param index defines its index
  37725. * @param gamepad defines the internal HTML gamepad object
  37726. * @param xboxOne defines if it is a XBox One gamepad
  37727. */
  37728. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  37729. /**
  37730. * Defines the callback to call when left trigger is pressed
  37731. * @param callback defines the callback to use
  37732. */
  37733. onlefttriggerchanged(callback: (value: number) => void): void;
  37734. /**
  37735. * Defines the callback to call when right trigger is pressed
  37736. * @param callback defines the callback to use
  37737. */
  37738. onrighttriggerchanged(callback: (value: number) => void): void;
  37739. /**
  37740. * Gets the left trigger value
  37741. */
  37742. /**
  37743. * Sets the left trigger value
  37744. */
  37745. leftTrigger: number;
  37746. /**
  37747. * Gets the right trigger value
  37748. */
  37749. /**
  37750. * Sets the right trigger value
  37751. */
  37752. rightTrigger: number;
  37753. /**
  37754. * Defines the callback to call when a button is pressed
  37755. * @param callback defines the callback to use
  37756. */
  37757. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  37758. /**
  37759. * Defines the callback to call when a button is released
  37760. * @param callback defines the callback to use
  37761. */
  37762. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  37763. /**
  37764. * Defines the callback to call when a pad is pressed
  37765. * @param callback defines the callback to use
  37766. */
  37767. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  37768. /**
  37769. * Defines the callback to call when a pad is released
  37770. * @param callback defines the callback to use
  37771. */
  37772. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  37773. private _setButtonValue;
  37774. private _setDPadValue;
  37775. /**
  37776. * Gets the value of the `A` button
  37777. */
  37778. /**
  37779. * Sets the value of the `A` button
  37780. */
  37781. buttonA: number;
  37782. /**
  37783. * Gets the value of the `B` button
  37784. */
  37785. /**
  37786. * Sets the value of the `B` button
  37787. */
  37788. buttonB: number;
  37789. /**
  37790. * Gets the value of the `X` button
  37791. */
  37792. /**
  37793. * Sets the value of the `X` button
  37794. */
  37795. buttonX: number;
  37796. /**
  37797. * Gets the value of the `Y` button
  37798. */
  37799. /**
  37800. * Sets the value of the `Y` button
  37801. */
  37802. buttonY: number;
  37803. /**
  37804. * Gets the value of the `Start` button
  37805. */
  37806. /**
  37807. * Sets the value of the `Start` button
  37808. */
  37809. buttonStart: number;
  37810. /**
  37811. * Gets the value of the `Back` button
  37812. */
  37813. /**
  37814. * Sets the value of the `Back` button
  37815. */
  37816. buttonBack: number;
  37817. /**
  37818. * Gets the value of the `Left` button
  37819. */
  37820. /**
  37821. * Sets the value of the `Left` button
  37822. */
  37823. buttonLB: number;
  37824. /**
  37825. * Gets the value of the `Right` button
  37826. */
  37827. /**
  37828. * Sets the value of the `Right` button
  37829. */
  37830. buttonRB: number;
  37831. /**
  37832. * Gets the value of the Left joystick
  37833. */
  37834. /**
  37835. * Sets the value of the Left joystick
  37836. */
  37837. buttonLeftStick: number;
  37838. /**
  37839. * Gets the value of the Right joystick
  37840. */
  37841. /**
  37842. * Sets the value of the Right joystick
  37843. */
  37844. buttonRightStick: number;
  37845. /**
  37846. * Gets the value of D-pad up
  37847. */
  37848. /**
  37849. * Sets the value of D-pad up
  37850. */
  37851. dPadUp: number;
  37852. /**
  37853. * Gets the value of D-pad down
  37854. */
  37855. /**
  37856. * Sets the value of D-pad down
  37857. */
  37858. dPadDown: number;
  37859. /**
  37860. * Gets the value of D-pad left
  37861. */
  37862. /**
  37863. * Sets the value of D-pad left
  37864. */
  37865. dPadLeft: number;
  37866. /**
  37867. * Gets the value of D-pad right
  37868. */
  37869. /**
  37870. * Sets the value of D-pad right
  37871. */
  37872. dPadRight: number;
  37873. /**
  37874. * Force the gamepad to synchronize with device values
  37875. */
  37876. update(): void;
  37877. /**
  37878. * Disposes the gamepad
  37879. */
  37880. dispose(): void;
  37881. }
  37882. }
  37883. declare module BABYLON {
  37884. /**
  37885. * Base class of materials working in push mode in babylon JS
  37886. * @hidden
  37887. */
  37888. export class PushMaterial extends Material {
  37889. protected _activeEffect: Effect;
  37890. protected _normalMatrix: Matrix;
  37891. /**
  37892. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  37893. * This means that the material can keep using a previous shader while a new one is being compiled.
  37894. * This is mostly used when shader parallel compilation is supported (true by default)
  37895. */
  37896. allowShaderHotSwapping: boolean;
  37897. constructor(name: string, scene: Scene);
  37898. getEffect(): Effect;
  37899. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  37900. /**
  37901. * Binds the given world matrix to the active effect
  37902. *
  37903. * @param world the matrix to bind
  37904. */
  37905. bindOnlyWorldMatrix(world: Matrix): void;
  37906. /**
  37907. * Binds the given normal matrix to the active effect
  37908. *
  37909. * @param normalMatrix the matrix to bind
  37910. */
  37911. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  37912. bind(world: Matrix, mesh?: Mesh): void;
  37913. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  37914. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  37915. }
  37916. }
  37917. declare module BABYLON {
  37918. /**
  37919. * This groups all the flags used to control the materials channel.
  37920. */
  37921. export class MaterialFlags {
  37922. private static _DiffuseTextureEnabled;
  37923. /**
  37924. * Are diffuse textures enabled in the application.
  37925. */
  37926. static DiffuseTextureEnabled: boolean;
  37927. private static _AmbientTextureEnabled;
  37928. /**
  37929. * Are ambient textures enabled in the application.
  37930. */
  37931. static AmbientTextureEnabled: boolean;
  37932. private static _OpacityTextureEnabled;
  37933. /**
  37934. * Are opacity textures enabled in the application.
  37935. */
  37936. static OpacityTextureEnabled: boolean;
  37937. private static _ReflectionTextureEnabled;
  37938. /**
  37939. * Are reflection textures enabled in the application.
  37940. */
  37941. static ReflectionTextureEnabled: boolean;
  37942. private static _EmissiveTextureEnabled;
  37943. /**
  37944. * Are emissive textures enabled in the application.
  37945. */
  37946. static EmissiveTextureEnabled: boolean;
  37947. private static _SpecularTextureEnabled;
  37948. /**
  37949. * Are specular textures enabled in the application.
  37950. */
  37951. static SpecularTextureEnabled: boolean;
  37952. private static _BumpTextureEnabled;
  37953. /**
  37954. * Are bump textures enabled in the application.
  37955. */
  37956. static BumpTextureEnabled: boolean;
  37957. private static _LightmapTextureEnabled;
  37958. /**
  37959. * Are lightmap textures enabled in the application.
  37960. */
  37961. static LightmapTextureEnabled: boolean;
  37962. private static _RefractionTextureEnabled;
  37963. /**
  37964. * Are refraction textures enabled in the application.
  37965. */
  37966. static RefractionTextureEnabled: boolean;
  37967. private static _ColorGradingTextureEnabled;
  37968. /**
  37969. * Are color grading textures enabled in the application.
  37970. */
  37971. static ColorGradingTextureEnabled: boolean;
  37972. private static _FresnelEnabled;
  37973. /**
  37974. * Are fresnels enabled in the application.
  37975. */
  37976. static FresnelEnabled: boolean;
  37977. private static _ClearCoatTextureEnabled;
  37978. /**
  37979. * Are clear coat textures enabled in the application.
  37980. */
  37981. static ClearCoatTextureEnabled: boolean;
  37982. private static _ClearCoatBumpTextureEnabled;
  37983. /**
  37984. * Are clear coat bump textures enabled in the application.
  37985. */
  37986. static ClearCoatBumpTextureEnabled: boolean;
  37987. private static _ClearCoatTintTextureEnabled;
  37988. /**
  37989. * Are clear coat tint textures enabled in the application.
  37990. */
  37991. static ClearCoatTintTextureEnabled: boolean;
  37992. private static _SheenTextureEnabled;
  37993. /**
  37994. * Are sheen textures enabled in the application.
  37995. */
  37996. static SheenTextureEnabled: boolean;
  37997. private static _AnisotropicTextureEnabled;
  37998. /**
  37999. * Are anisotropic textures enabled in the application.
  38000. */
  38001. static AnisotropicTextureEnabled: boolean;
  38002. }
  38003. }
  38004. declare module BABYLON {
  38005. /** @hidden */
  38006. export var defaultFragmentDeclaration: {
  38007. name: string;
  38008. shader: string;
  38009. };
  38010. }
  38011. declare module BABYLON {
  38012. /** @hidden */
  38013. export var defaultUboDeclaration: {
  38014. name: string;
  38015. shader: string;
  38016. };
  38017. }
  38018. declare module BABYLON {
  38019. /** @hidden */
  38020. export var lightFragmentDeclaration: {
  38021. name: string;
  38022. shader: string;
  38023. };
  38024. }
  38025. declare module BABYLON {
  38026. /** @hidden */
  38027. export var lightUboDeclaration: {
  38028. name: string;
  38029. shader: string;
  38030. };
  38031. }
  38032. declare module BABYLON {
  38033. /** @hidden */
  38034. export var lightsFragmentFunctions: {
  38035. name: string;
  38036. shader: string;
  38037. };
  38038. }
  38039. declare module BABYLON {
  38040. /** @hidden */
  38041. export var shadowsFragmentFunctions: {
  38042. name: string;
  38043. shader: string;
  38044. };
  38045. }
  38046. declare module BABYLON {
  38047. /** @hidden */
  38048. export var fresnelFunction: {
  38049. name: string;
  38050. shader: string;
  38051. };
  38052. }
  38053. declare module BABYLON {
  38054. /** @hidden */
  38055. export var reflectionFunction: {
  38056. name: string;
  38057. shader: string;
  38058. };
  38059. }
  38060. declare module BABYLON {
  38061. /** @hidden */
  38062. export var bumpFragmentFunctions: {
  38063. name: string;
  38064. shader: string;
  38065. };
  38066. }
  38067. declare module BABYLON {
  38068. /** @hidden */
  38069. export var logDepthDeclaration: {
  38070. name: string;
  38071. shader: string;
  38072. };
  38073. }
  38074. declare module BABYLON {
  38075. /** @hidden */
  38076. export var bumpFragment: {
  38077. name: string;
  38078. shader: string;
  38079. };
  38080. }
  38081. declare module BABYLON {
  38082. /** @hidden */
  38083. export var depthPrePass: {
  38084. name: string;
  38085. shader: string;
  38086. };
  38087. }
  38088. declare module BABYLON {
  38089. /** @hidden */
  38090. export var lightFragment: {
  38091. name: string;
  38092. shader: string;
  38093. };
  38094. }
  38095. declare module BABYLON {
  38096. /** @hidden */
  38097. export var logDepthFragment: {
  38098. name: string;
  38099. shader: string;
  38100. };
  38101. }
  38102. declare module BABYLON {
  38103. /** @hidden */
  38104. export var defaultPixelShader: {
  38105. name: string;
  38106. shader: string;
  38107. };
  38108. }
  38109. declare module BABYLON {
  38110. /** @hidden */
  38111. export var defaultVertexDeclaration: {
  38112. name: string;
  38113. shader: string;
  38114. };
  38115. }
  38116. declare module BABYLON {
  38117. /** @hidden */
  38118. export var bumpVertexDeclaration: {
  38119. name: string;
  38120. shader: string;
  38121. };
  38122. }
  38123. declare module BABYLON {
  38124. /** @hidden */
  38125. export var bumpVertex: {
  38126. name: string;
  38127. shader: string;
  38128. };
  38129. }
  38130. declare module BABYLON {
  38131. /** @hidden */
  38132. export var fogVertex: {
  38133. name: string;
  38134. shader: string;
  38135. };
  38136. }
  38137. declare module BABYLON {
  38138. /** @hidden */
  38139. export var shadowsVertex: {
  38140. name: string;
  38141. shader: string;
  38142. };
  38143. }
  38144. declare module BABYLON {
  38145. /** @hidden */
  38146. export var pointCloudVertex: {
  38147. name: string;
  38148. shader: string;
  38149. };
  38150. }
  38151. declare module BABYLON {
  38152. /** @hidden */
  38153. export var logDepthVertex: {
  38154. name: string;
  38155. shader: string;
  38156. };
  38157. }
  38158. declare module BABYLON {
  38159. /** @hidden */
  38160. export var defaultVertexShader: {
  38161. name: string;
  38162. shader: string;
  38163. };
  38164. }
  38165. declare module BABYLON {
  38166. /** @hidden */
  38167. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  38168. MAINUV1: boolean;
  38169. MAINUV2: boolean;
  38170. DIFFUSE: boolean;
  38171. DIFFUSEDIRECTUV: number;
  38172. AMBIENT: boolean;
  38173. AMBIENTDIRECTUV: number;
  38174. OPACITY: boolean;
  38175. OPACITYDIRECTUV: number;
  38176. OPACITYRGB: boolean;
  38177. REFLECTION: boolean;
  38178. EMISSIVE: boolean;
  38179. EMISSIVEDIRECTUV: number;
  38180. SPECULAR: boolean;
  38181. SPECULARDIRECTUV: number;
  38182. BUMP: boolean;
  38183. BUMPDIRECTUV: number;
  38184. PARALLAX: boolean;
  38185. PARALLAXOCCLUSION: boolean;
  38186. SPECULAROVERALPHA: boolean;
  38187. CLIPPLANE: boolean;
  38188. CLIPPLANE2: boolean;
  38189. CLIPPLANE3: boolean;
  38190. CLIPPLANE4: boolean;
  38191. ALPHATEST: boolean;
  38192. DEPTHPREPASS: boolean;
  38193. ALPHAFROMDIFFUSE: boolean;
  38194. POINTSIZE: boolean;
  38195. FOG: boolean;
  38196. SPECULARTERM: boolean;
  38197. DIFFUSEFRESNEL: boolean;
  38198. OPACITYFRESNEL: boolean;
  38199. REFLECTIONFRESNEL: boolean;
  38200. REFRACTIONFRESNEL: boolean;
  38201. EMISSIVEFRESNEL: boolean;
  38202. FRESNEL: boolean;
  38203. NORMAL: boolean;
  38204. UV1: boolean;
  38205. UV2: boolean;
  38206. VERTEXCOLOR: boolean;
  38207. VERTEXALPHA: boolean;
  38208. NUM_BONE_INFLUENCERS: number;
  38209. BonesPerMesh: number;
  38210. BONETEXTURE: boolean;
  38211. INSTANCES: boolean;
  38212. GLOSSINESS: boolean;
  38213. ROUGHNESS: boolean;
  38214. EMISSIVEASILLUMINATION: boolean;
  38215. LINKEMISSIVEWITHDIFFUSE: boolean;
  38216. REFLECTIONFRESNELFROMSPECULAR: boolean;
  38217. LIGHTMAP: boolean;
  38218. LIGHTMAPDIRECTUV: number;
  38219. OBJECTSPACE_NORMALMAP: boolean;
  38220. USELIGHTMAPASSHADOWMAP: boolean;
  38221. REFLECTIONMAP_3D: boolean;
  38222. REFLECTIONMAP_SPHERICAL: boolean;
  38223. REFLECTIONMAP_PLANAR: boolean;
  38224. REFLECTIONMAP_CUBIC: boolean;
  38225. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  38226. REFLECTIONMAP_PROJECTION: boolean;
  38227. REFLECTIONMAP_SKYBOX: boolean;
  38228. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  38229. REFLECTIONMAP_EXPLICIT: boolean;
  38230. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  38231. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  38232. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  38233. INVERTCUBICMAP: boolean;
  38234. LOGARITHMICDEPTH: boolean;
  38235. REFRACTION: boolean;
  38236. REFRACTIONMAP_3D: boolean;
  38237. REFLECTIONOVERALPHA: boolean;
  38238. TWOSIDEDLIGHTING: boolean;
  38239. SHADOWFLOAT: boolean;
  38240. MORPHTARGETS: boolean;
  38241. MORPHTARGETS_NORMAL: boolean;
  38242. MORPHTARGETS_TANGENT: boolean;
  38243. NUM_MORPH_INFLUENCERS: number;
  38244. NONUNIFORMSCALING: boolean;
  38245. PREMULTIPLYALPHA: boolean;
  38246. IMAGEPROCESSING: boolean;
  38247. VIGNETTE: boolean;
  38248. VIGNETTEBLENDMODEMULTIPLY: boolean;
  38249. VIGNETTEBLENDMODEOPAQUE: boolean;
  38250. TONEMAPPING: boolean;
  38251. TONEMAPPING_ACES: boolean;
  38252. CONTRAST: boolean;
  38253. COLORCURVES: boolean;
  38254. COLORGRADING: boolean;
  38255. COLORGRADING3D: boolean;
  38256. SAMPLER3DGREENDEPTH: boolean;
  38257. SAMPLER3DBGRMAP: boolean;
  38258. IMAGEPROCESSINGPOSTPROCESS: boolean;
  38259. MULTIVIEW: boolean;
  38260. /**
  38261. * If the reflection texture on this material is in linear color space
  38262. * @hidden
  38263. */
  38264. IS_REFLECTION_LINEAR: boolean;
  38265. /**
  38266. * If the refraction texture on this material is in linear color space
  38267. * @hidden
  38268. */
  38269. IS_REFRACTION_LINEAR: boolean;
  38270. EXPOSURE: boolean;
  38271. constructor();
  38272. setReflectionMode(modeToEnable: string): void;
  38273. }
  38274. /**
  38275. * This is the default material used in Babylon. It is the best trade off between quality
  38276. * and performances.
  38277. * @see http://doc.babylonjs.com/babylon101/materials
  38278. */
  38279. export class StandardMaterial extends PushMaterial {
  38280. private _diffuseTexture;
  38281. /**
  38282. * The basic texture of the material as viewed under a light.
  38283. */
  38284. diffuseTexture: Nullable<BaseTexture>;
  38285. private _ambientTexture;
  38286. /**
  38287. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  38288. */
  38289. ambientTexture: Nullable<BaseTexture>;
  38290. private _opacityTexture;
  38291. /**
  38292. * Define the transparency of the material from a texture.
  38293. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  38294. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  38295. */
  38296. opacityTexture: Nullable<BaseTexture>;
  38297. private _reflectionTexture;
  38298. /**
  38299. * Define the texture used to display the reflection.
  38300. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38301. */
  38302. reflectionTexture: Nullable<BaseTexture>;
  38303. private _emissiveTexture;
  38304. /**
  38305. * Define texture of the material as if self lit.
  38306. * This will be mixed in the final result even in the absence of light.
  38307. */
  38308. emissiveTexture: Nullable<BaseTexture>;
  38309. private _specularTexture;
  38310. /**
  38311. * Define how the color and intensity of the highlight given by the light in the material.
  38312. */
  38313. specularTexture: Nullable<BaseTexture>;
  38314. private _bumpTexture;
  38315. /**
  38316. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  38317. * 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.
  38318. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  38319. */
  38320. bumpTexture: Nullable<BaseTexture>;
  38321. private _lightmapTexture;
  38322. /**
  38323. * Complex lighting can be computationally expensive to compute at runtime.
  38324. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  38325. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  38326. */
  38327. lightmapTexture: Nullable<BaseTexture>;
  38328. private _refractionTexture;
  38329. /**
  38330. * Define the texture used to display the refraction.
  38331. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38332. */
  38333. refractionTexture: Nullable<BaseTexture>;
  38334. /**
  38335. * The color of the material lit by the environmental background lighting.
  38336. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  38337. */
  38338. ambientColor: Color3;
  38339. /**
  38340. * The basic color of the material as viewed under a light.
  38341. */
  38342. diffuseColor: Color3;
  38343. /**
  38344. * Define how the color and intensity of the highlight given by the light in the material.
  38345. */
  38346. specularColor: Color3;
  38347. /**
  38348. * Define the color of the material as if self lit.
  38349. * This will be mixed in the final result even in the absence of light.
  38350. */
  38351. emissiveColor: Color3;
  38352. /**
  38353. * Defines how sharp are the highlights in the material.
  38354. * The bigger the value the sharper giving a more glossy feeling to the result.
  38355. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  38356. */
  38357. specularPower: number;
  38358. private _useAlphaFromDiffuseTexture;
  38359. /**
  38360. * Does the transparency come from the diffuse texture alpha channel.
  38361. */
  38362. useAlphaFromDiffuseTexture: boolean;
  38363. private _useEmissiveAsIllumination;
  38364. /**
  38365. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  38366. */
  38367. useEmissiveAsIllumination: boolean;
  38368. private _linkEmissiveWithDiffuse;
  38369. /**
  38370. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  38371. * the emissive level when the final color is close to one.
  38372. */
  38373. linkEmissiveWithDiffuse: boolean;
  38374. private _useSpecularOverAlpha;
  38375. /**
  38376. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  38377. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  38378. */
  38379. useSpecularOverAlpha: boolean;
  38380. private _useReflectionOverAlpha;
  38381. /**
  38382. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  38383. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  38384. */
  38385. useReflectionOverAlpha: boolean;
  38386. private _disableLighting;
  38387. /**
  38388. * Does lights from the scene impacts this material.
  38389. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  38390. */
  38391. disableLighting: boolean;
  38392. private _useObjectSpaceNormalMap;
  38393. /**
  38394. * Allows using an object space normal map (instead of tangent space).
  38395. */
  38396. useObjectSpaceNormalMap: boolean;
  38397. private _useParallax;
  38398. /**
  38399. * Is parallax enabled or not.
  38400. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  38401. */
  38402. useParallax: boolean;
  38403. private _useParallaxOcclusion;
  38404. /**
  38405. * Is parallax occlusion enabled or not.
  38406. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  38407. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  38408. */
  38409. useParallaxOcclusion: boolean;
  38410. /**
  38411. * 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.
  38412. */
  38413. parallaxScaleBias: number;
  38414. private _roughness;
  38415. /**
  38416. * Helps to define how blurry the reflections should appears in the material.
  38417. */
  38418. roughness: number;
  38419. /**
  38420. * In case of refraction, define the value of the indice of refraction.
  38421. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38422. */
  38423. indexOfRefraction: number;
  38424. /**
  38425. * Invert the refraction texture alongside the y axis.
  38426. * It can be useful with procedural textures or probe for instance.
  38427. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38428. */
  38429. invertRefractionY: boolean;
  38430. /**
  38431. * Defines the alpha limits in alpha test mode.
  38432. */
  38433. alphaCutOff: number;
  38434. private _useLightmapAsShadowmap;
  38435. /**
  38436. * In case of light mapping, define whether the map contains light or shadow informations.
  38437. */
  38438. useLightmapAsShadowmap: boolean;
  38439. private _diffuseFresnelParameters;
  38440. /**
  38441. * Define the diffuse fresnel parameters of the material.
  38442. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38443. */
  38444. diffuseFresnelParameters: FresnelParameters;
  38445. private _opacityFresnelParameters;
  38446. /**
  38447. * Define the opacity fresnel parameters of the material.
  38448. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38449. */
  38450. opacityFresnelParameters: FresnelParameters;
  38451. private _reflectionFresnelParameters;
  38452. /**
  38453. * Define the reflection fresnel parameters of the material.
  38454. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38455. */
  38456. reflectionFresnelParameters: FresnelParameters;
  38457. private _refractionFresnelParameters;
  38458. /**
  38459. * Define the refraction fresnel parameters of the material.
  38460. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38461. */
  38462. refractionFresnelParameters: FresnelParameters;
  38463. private _emissiveFresnelParameters;
  38464. /**
  38465. * Define the emissive fresnel parameters of the material.
  38466. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38467. */
  38468. emissiveFresnelParameters: FresnelParameters;
  38469. private _useReflectionFresnelFromSpecular;
  38470. /**
  38471. * If true automatically deducts the fresnels values from the material specularity.
  38472. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38473. */
  38474. useReflectionFresnelFromSpecular: boolean;
  38475. private _useGlossinessFromSpecularMapAlpha;
  38476. /**
  38477. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  38478. */
  38479. useGlossinessFromSpecularMapAlpha: boolean;
  38480. private _maxSimultaneousLights;
  38481. /**
  38482. * Defines the maximum number of lights that can be used in the material
  38483. */
  38484. maxSimultaneousLights: number;
  38485. private _invertNormalMapX;
  38486. /**
  38487. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  38488. */
  38489. invertNormalMapX: boolean;
  38490. private _invertNormalMapY;
  38491. /**
  38492. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  38493. */
  38494. invertNormalMapY: boolean;
  38495. private _twoSidedLighting;
  38496. /**
  38497. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  38498. */
  38499. twoSidedLighting: boolean;
  38500. /**
  38501. * Default configuration related to image processing available in the standard Material.
  38502. */
  38503. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  38504. /**
  38505. * Gets the image processing configuration used either in this material.
  38506. */
  38507. /**
  38508. * Sets the Default image processing configuration used either in the this material.
  38509. *
  38510. * If sets to null, the scene one is in use.
  38511. */
  38512. imageProcessingConfiguration: ImageProcessingConfiguration;
  38513. /**
  38514. * Keep track of the image processing observer to allow dispose and replace.
  38515. */
  38516. private _imageProcessingObserver;
  38517. /**
  38518. * Attaches a new image processing configuration to the Standard Material.
  38519. * @param configuration
  38520. */
  38521. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  38522. /**
  38523. * Gets wether the color curves effect is enabled.
  38524. */
  38525. /**
  38526. * Sets wether the color curves effect is enabled.
  38527. */
  38528. cameraColorCurvesEnabled: boolean;
  38529. /**
  38530. * Gets wether the color grading effect is enabled.
  38531. */
  38532. /**
  38533. * Gets wether the color grading effect is enabled.
  38534. */
  38535. cameraColorGradingEnabled: boolean;
  38536. /**
  38537. * Gets wether tonemapping is enabled or not.
  38538. */
  38539. /**
  38540. * Sets wether tonemapping is enabled or not
  38541. */
  38542. cameraToneMappingEnabled: boolean;
  38543. /**
  38544. * The camera exposure used on this material.
  38545. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  38546. * This corresponds to a photographic exposure.
  38547. */
  38548. /**
  38549. * The camera exposure used on this material.
  38550. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  38551. * This corresponds to a photographic exposure.
  38552. */
  38553. cameraExposure: number;
  38554. /**
  38555. * Gets The camera contrast used on this material.
  38556. */
  38557. /**
  38558. * Sets The camera contrast used on this material.
  38559. */
  38560. cameraContrast: number;
  38561. /**
  38562. * Gets the Color Grading 2D Lookup Texture.
  38563. */
  38564. /**
  38565. * Sets the Color Grading 2D Lookup Texture.
  38566. */
  38567. cameraColorGradingTexture: Nullable<BaseTexture>;
  38568. /**
  38569. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  38570. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  38571. * 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;
  38572. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  38573. */
  38574. /**
  38575. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  38576. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  38577. * 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;
  38578. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  38579. */
  38580. cameraColorCurves: Nullable<ColorCurves>;
  38581. /**
  38582. * Custom callback helping to override the default shader used in the material.
  38583. */
  38584. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  38585. protected _renderTargets: SmartArray<RenderTargetTexture>;
  38586. protected _worldViewProjectionMatrix: Matrix;
  38587. protected _globalAmbientColor: Color3;
  38588. protected _useLogarithmicDepth: boolean;
  38589. /**
  38590. * Instantiates a new standard material.
  38591. * This is the default material used in Babylon. It is the best trade off between quality
  38592. * and performances.
  38593. * @see http://doc.babylonjs.com/babylon101/materials
  38594. * @param name Define the name of the material in the scene
  38595. * @param scene Define the scene the material belong to
  38596. */
  38597. constructor(name: string, scene: Scene);
  38598. /**
  38599. * Gets a boolean indicating that current material needs to register RTT
  38600. */
  38601. readonly hasRenderTargetTextures: boolean;
  38602. /**
  38603. * Gets the current class name of the material e.g. "StandardMaterial"
  38604. * Mainly use in serialization.
  38605. * @returns the class name
  38606. */
  38607. getClassName(): string;
  38608. /**
  38609. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  38610. * You can try switching to logarithmic depth.
  38611. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  38612. */
  38613. useLogarithmicDepth: boolean;
  38614. /**
  38615. * Specifies if the material will require alpha blending
  38616. * @returns a boolean specifying if alpha blending is needed
  38617. */
  38618. needAlphaBlending(): boolean;
  38619. /**
  38620. * Specifies if this material should be rendered in alpha test mode
  38621. * @returns a boolean specifying if an alpha test is needed.
  38622. */
  38623. needAlphaTesting(): boolean;
  38624. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  38625. /**
  38626. * Get the texture used for alpha test purpose.
  38627. * @returns the diffuse texture in case of the standard material.
  38628. */
  38629. getAlphaTestTexture(): Nullable<BaseTexture>;
  38630. /**
  38631. * Get if the submesh is ready to be used and all its information available.
  38632. * Child classes can use it to update shaders
  38633. * @param mesh defines the mesh to check
  38634. * @param subMesh defines which submesh to check
  38635. * @param useInstances specifies that instances should be used
  38636. * @returns a boolean indicating that the submesh is ready or not
  38637. */
  38638. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  38639. /**
  38640. * Builds the material UBO layouts.
  38641. * Used internally during the effect preparation.
  38642. */
  38643. buildUniformLayout(): void;
  38644. /**
  38645. * Unbinds the material from the mesh
  38646. */
  38647. unbind(): void;
  38648. /**
  38649. * Binds the submesh to this material by preparing the effect and shader to draw
  38650. * @param world defines the world transformation matrix
  38651. * @param mesh defines the mesh containing the submesh
  38652. * @param subMesh defines the submesh to bind the material to
  38653. */
  38654. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  38655. /**
  38656. * Get the list of animatables in the material.
  38657. * @returns the list of animatables object used in the material
  38658. */
  38659. getAnimatables(): IAnimatable[];
  38660. /**
  38661. * Gets the active textures from the material
  38662. * @returns an array of textures
  38663. */
  38664. getActiveTextures(): BaseTexture[];
  38665. /**
  38666. * Specifies if the material uses a texture
  38667. * @param texture defines the texture to check against the material
  38668. * @returns a boolean specifying if the material uses the texture
  38669. */
  38670. hasTexture(texture: BaseTexture): boolean;
  38671. /**
  38672. * Disposes the material
  38673. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  38674. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  38675. */
  38676. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  38677. /**
  38678. * Makes a duplicate of the material, and gives it a new name
  38679. * @param name defines the new name for the duplicated material
  38680. * @returns the cloned material
  38681. */
  38682. clone(name: string): StandardMaterial;
  38683. /**
  38684. * Serializes this material in a JSON representation
  38685. * @returns the serialized material object
  38686. */
  38687. serialize(): any;
  38688. /**
  38689. * Creates a standard material from parsed material data
  38690. * @param source defines the JSON representation of the material
  38691. * @param scene defines the hosting scene
  38692. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  38693. * @returns a new standard material
  38694. */
  38695. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  38696. /**
  38697. * Are diffuse textures enabled in the application.
  38698. */
  38699. static DiffuseTextureEnabled: boolean;
  38700. /**
  38701. * Are ambient textures enabled in the application.
  38702. */
  38703. static AmbientTextureEnabled: boolean;
  38704. /**
  38705. * Are opacity textures enabled in the application.
  38706. */
  38707. static OpacityTextureEnabled: boolean;
  38708. /**
  38709. * Are reflection textures enabled in the application.
  38710. */
  38711. static ReflectionTextureEnabled: boolean;
  38712. /**
  38713. * Are emissive textures enabled in the application.
  38714. */
  38715. static EmissiveTextureEnabled: boolean;
  38716. /**
  38717. * Are specular textures enabled in the application.
  38718. */
  38719. static SpecularTextureEnabled: boolean;
  38720. /**
  38721. * Are bump textures enabled in the application.
  38722. */
  38723. static BumpTextureEnabled: boolean;
  38724. /**
  38725. * Are lightmap textures enabled in the application.
  38726. */
  38727. static LightmapTextureEnabled: boolean;
  38728. /**
  38729. * Are refraction textures enabled in the application.
  38730. */
  38731. static RefractionTextureEnabled: boolean;
  38732. /**
  38733. * Are color grading textures enabled in the application.
  38734. */
  38735. static ColorGradingTextureEnabled: boolean;
  38736. /**
  38737. * Are fresnels enabled in the application.
  38738. */
  38739. static FresnelEnabled: boolean;
  38740. }
  38741. }
  38742. declare module BABYLON {
  38743. /**
  38744. * A class extending Texture allowing drawing on a texture
  38745. * @see http://doc.babylonjs.com/how_to/dynamictexture
  38746. */
  38747. export class DynamicTexture extends Texture {
  38748. private _generateMipMaps;
  38749. private _canvas;
  38750. private _context;
  38751. private _engine;
  38752. /**
  38753. * Creates a DynamicTexture
  38754. * @param name defines the name of the texture
  38755. * @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
  38756. * @param scene defines the scene where you want the texture
  38757. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  38758. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  38759. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  38760. */
  38761. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  38762. /**
  38763. * Get the current class name of the texture useful for serialization or dynamic coding.
  38764. * @returns "DynamicTexture"
  38765. */
  38766. getClassName(): string;
  38767. /**
  38768. * Gets the current state of canRescale
  38769. */
  38770. readonly canRescale: boolean;
  38771. private _recreate;
  38772. /**
  38773. * Scales the texture
  38774. * @param ratio the scale factor to apply to both width and height
  38775. */
  38776. scale(ratio: number): void;
  38777. /**
  38778. * Resizes the texture
  38779. * @param width the new width
  38780. * @param height the new height
  38781. */
  38782. scaleTo(width: number, height: number): void;
  38783. /**
  38784. * Gets the context of the canvas used by the texture
  38785. * @returns the canvas context of the dynamic texture
  38786. */
  38787. getContext(): CanvasRenderingContext2D;
  38788. /**
  38789. * Clears the texture
  38790. */
  38791. clear(): void;
  38792. /**
  38793. * Updates the texture
  38794. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  38795. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  38796. */
  38797. update(invertY?: boolean, premulAlpha?: boolean): void;
  38798. /**
  38799. * Draws text onto the texture
  38800. * @param text defines the text to be drawn
  38801. * @param x defines the placement of the text from the left
  38802. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  38803. * @param font defines the font to be used with font-style, font-size, font-name
  38804. * @param color defines the color used for the text
  38805. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  38806. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  38807. * @param update defines whether texture is immediately update (default is true)
  38808. */
  38809. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  38810. /**
  38811. * Clones the texture
  38812. * @returns the clone of the texture.
  38813. */
  38814. clone(): DynamicTexture;
  38815. /**
  38816. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  38817. * @returns a serialized dynamic texture object
  38818. */
  38819. serialize(): any;
  38820. /** @hidden */
  38821. _rebuild(): void;
  38822. }
  38823. }
  38824. declare module BABYLON {
  38825. /** @hidden */
  38826. export var imageProcessingPixelShader: {
  38827. name: string;
  38828. shader: string;
  38829. };
  38830. }
  38831. declare module BABYLON {
  38832. /**
  38833. * ImageProcessingPostProcess
  38834. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  38835. */
  38836. export class ImageProcessingPostProcess extends PostProcess {
  38837. /**
  38838. * Default configuration related to image processing available in the PBR Material.
  38839. */
  38840. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  38841. /**
  38842. * Gets the image processing configuration used either in this material.
  38843. */
  38844. /**
  38845. * Sets the Default image processing configuration used either in the this material.
  38846. *
  38847. * If sets to null, the scene one is in use.
  38848. */
  38849. imageProcessingConfiguration: ImageProcessingConfiguration;
  38850. /**
  38851. * Keep track of the image processing observer to allow dispose and replace.
  38852. */
  38853. private _imageProcessingObserver;
  38854. /**
  38855. * Attaches a new image processing configuration to the PBR Material.
  38856. * @param configuration
  38857. */
  38858. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  38859. /**
  38860. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  38861. */
  38862. /**
  38863. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  38864. */
  38865. colorCurves: Nullable<ColorCurves>;
  38866. /**
  38867. * Gets wether the color curves effect is enabled.
  38868. */
  38869. /**
  38870. * Sets wether the color curves effect is enabled.
  38871. */
  38872. colorCurvesEnabled: boolean;
  38873. /**
  38874. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  38875. */
  38876. /**
  38877. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  38878. */
  38879. colorGradingTexture: Nullable<BaseTexture>;
  38880. /**
  38881. * Gets wether the color grading effect is enabled.
  38882. */
  38883. /**
  38884. * Gets wether the color grading effect is enabled.
  38885. */
  38886. colorGradingEnabled: boolean;
  38887. /**
  38888. * Gets exposure used in the effect.
  38889. */
  38890. /**
  38891. * Sets exposure used in the effect.
  38892. */
  38893. exposure: number;
  38894. /**
  38895. * Gets wether tonemapping is enabled or not.
  38896. */
  38897. /**
  38898. * Sets wether tonemapping is enabled or not
  38899. */
  38900. toneMappingEnabled: boolean;
  38901. /**
  38902. * Gets the type of tone mapping effect.
  38903. */
  38904. /**
  38905. * Sets the type of tone mapping effect.
  38906. */
  38907. toneMappingType: number;
  38908. /**
  38909. * Gets contrast used in the effect.
  38910. */
  38911. /**
  38912. * Sets contrast used in the effect.
  38913. */
  38914. contrast: number;
  38915. /**
  38916. * Gets Vignette stretch size.
  38917. */
  38918. /**
  38919. * Sets Vignette stretch size.
  38920. */
  38921. vignetteStretch: number;
  38922. /**
  38923. * Gets Vignette centre X Offset.
  38924. */
  38925. /**
  38926. * Sets Vignette centre X Offset.
  38927. */
  38928. vignetteCentreX: number;
  38929. /**
  38930. * Gets Vignette centre Y Offset.
  38931. */
  38932. /**
  38933. * Sets Vignette centre Y Offset.
  38934. */
  38935. vignetteCentreY: number;
  38936. /**
  38937. * Gets Vignette weight or intensity of the vignette effect.
  38938. */
  38939. /**
  38940. * Sets Vignette weight or intensity of the vignette effect.
  38941. */
  38942. vignetteWeight: number;
  38943. /**
  38944. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  38945. * if vignetteEnabled is set to true.
  38946. */
  38947. /**
  38948. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  38949. * if vignetteEnabled is set to true.
  38950. */
  38951. vignetteColor: Color4;
  38952. /**
  38953. * Gets Camera field of view used by the Vignette effect.
  38954. */
  38955. /**
  38956. * Sets Camera field of view used by the Vignette effect.
  38957. */
  38958. vignetteCameraFov: number;
  38959. /**
  38960. * Gets the vignette blend mode allowing different kind of effect.
  38961. */
  38962. /**
  38963. * Sets the vignette blend mode allowing different kind of effect.
  38964. */
  38965. vignetteBlendMode: number;
  38966. /**
  38967. * Gets wether the vignette effect is enabled.
  38968. */
  38969. /**
  38970. * Sets wether the vignette effect is enabled.
  38971. */
  38972. vignetteEnabled: boolean;
  38973. private _fromLinearSpace;
  38974. /**
  38975. * Gets wether the input of the processing is in Gamma or Linear Space.
  38976. */
  38977. /**
  38978. * Sets wether the input of the processing is in Gamma or Linear Space.
  38979. */
  38980. fromLinearSpace: boolean;
  38981. /**
  38982. * Defines cache preventing GC.
  38983. */
  38984. private _defines;
  38985. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  38986. /**
  38987. * "ImageProcessingPostProcess"
  38988. * @returns "ImageProcessingPostProcess"
  38989. */
  38990. getClassName(): string;
  38991. protected _updateParameters(): void;
  38992. dispose(camera?: Camera): void;
  38993. }
  38994. }
  38995. declare module BABYLON {
  38996. /**
  38997. * Class containing static functions to help procedurally build meshes
  38998. */
  38999. export class GroundBuilder {
  39000. /**
  39001. * Creates a ground mesh
  39002. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  39003. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  39004. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39005. * @param name defines the name of the mesh
  39006. * @param options defines the options used to create the mesh
  39007. * @param scene defines the hosting scene
  39008. * @returns the ground mesh
  39009. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  39010. */
  39011. static CreateGround(name: string, options: {
  39012. width?: number;
  39013. height?: number;
  39014. subdivisions?: number;
  39015. subdivisionsX?: number;
  39016. subdivisionsY?: number;
  39017. updatable?: boolean;
  39018. }, scene: any): Mesh;
  39019. /**
  39020. * Creates a tiled ground mesh
  39021. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  39022. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  39023. * * 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
  39024. * * 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
  39025. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39026. * @param name defines the name of the mesh
  39027. * @param options defines the options used to create the mesh
  39028. * @param scene defines the hosting scene
  39029. * @returns the tiled ground mesh
  39030. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  39031. */
  39032. static CreateTiledGround(name: string, options: {
  39033. xmin: number;
  39034. zmin: number;
  39035. xmax: number;
  39036. zmax: number;
  39037. subdivisions?: {
  39038. w: number;
  39039. h: number;
  39040. };
  39041. precision?: {
  39042. w: number;
  39043. h: number;
  39044. };
  39045. updatable?: boolean;
  39046. }, scene: Scene): Mesh;
  39047. /**
  39048. * Creates a ground mesh from a height map
  39049. * * The parameter `url` sets the URL of the height map image resource.
  39050. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  39051. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  39052. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  39053. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  39054. * * 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.
  39055. * * 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).
  39056. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  39057. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39058. * @param name defines the name of the mesh
  39059. * @param url defines the url to the height map
  39060. * @param options defines the options used to create the mesh
  39061. * @param scene defines the hosting scene
  39062. * @returns the ground mesh
  39063. * @see https://doc.babylonjs.com/babylon101/height_map
  39064. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  39065. */
  39066. static CreateGroundFromHeightMap(name: string, url: string, options: {
  39067. width?: number;
  39068. height?: number;
  39069. subdivisions?: number;
  39070. minHeight?: number;
  39071. maxHeight?: number;
  39072. colorFilter?: Color3;
  39073. alphaFilter?: number;
  39074. updatable?: boolean;
  39075. onReady?: (mesh: GroundMesh) => void;
  39076. }, scene: Scene): GroundMesh;
  39077. }
  39078. }
  39079. declare module BABYLON {
  39080. /**
  39081. * Class containing static functions to help procedurally build meshes
  39082. */
  39083. export class TorusBuilder {
  39084. /**
  39085. * Creates a torus mesh
  39086. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  39087. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  39088. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  39089. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39090. * * 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
  39091. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39092. * @param name defines the name of the mesh
  39093. * @param options defines the options used to create the mesh
  39094. * @param scene defines the hosting scene
  39095. * @returns the torus mesh
  39096. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  39097. */
  39098. static CreateTorus(name: string, options: {
  39099. diameter?: number;
  39100. thickness?: number;
  39101. tessellation?: number;
  39102. updatable?: boolean;
  39103. sideOrientation?: number;
  39104. frontUVs?: Vector4;
  39105. backUVs?: Vector4;
  39106. }, scene: any): Mesh;
  39107. }
  39108. }
  39109. declare module BABYLON {
  39110. /**
  39111. * Class containing static functions to help procedurally build meshes
  39112. */
  39113. export class CylinderBuilder {
  39114. /**
  39115. * Creates a cylinder or a cone mesh
  39116. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  39117. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  39118. * * 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.
  39119. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  39120. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  39121. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  39122. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  39123. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  39124. * * 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).
  39125. * * 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
  39126. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  39127. * * 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
  39128. * * 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.
  39129. * * If `enclose` is false, a ring surface is one element.
  39130. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  39131. * * 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
  39132. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39133. * * 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
  39134. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39135. * @param name defines the name of the mesh
  39136. * @param options defines the options used to create the mesh
  39137. * @param scene defines the hosting scene
  39138. * @returns the cylinder mesh
  39139. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  39140. */
  39141. static CreateCylinder(name: string, options: {
  39142. height?: number;
  39143. diameterTop?: number;
  39144. diameterBottom?: number;
  39145. diameter?: number;
  39146. tessellation?: number;
  39147. subdivisions?: number;
  39148. arc?: number;
  39149. faceColors?: Color4[];
  39150. faceUV?: Vector4[];
  39151. updatable?: boolean;
  39152. hasRings?: boolean;
  39153. enclose?: boolean;
  39154. sideOrientation?: number;
  39155. frontUVs?: Vector4;
  39156. backUVs?: Vector4;
  39157. }, scene: any): Mesh;
  39158. }
  39159. }
  39160. declare module BABYLON {
  39161. /**
  39162. * Manager for handling gamepads
  39163. */
  39164. export class GamepadManager {
  39165. private _scene?;
  39166. private _babylonGamepads;
  39167. private _oneGamepadConnected;
  39168. /** @hidden */
  39169. _isMonitoring: boolean;
  39170. private _gamepadEventSupported;
  39171. private _gamepadSupport;
  39172. /**
  39173. * observable to be triggered when the gamepad controller has been connected
  39174. */
  39175. onGamepadConnectedObservable: Observable<Gamepad>;
  39176. /**
  39177. * observable to be triggered when the gamepad controller has been disconnected
  39178. */
  39179. onGamepadDisconnectedObservable: Observable<Gamepad>;
  39180. private _onGamepadConnectedEvent;
  39181. private _onGamepadDisconnectedEvent;
  39182. /**
  39183. * Initializes the gamepad manager
  39184. * @param _scene BabylonJS scene
  39185. */
  39186. constructor(_scene?: Scene | undefined);
  39187. /**
  39188. * The gamepads in the game pad manager
  39189. */
  39190. readonly gamepads: Gamepad[];
  39191. /**
  39192. * Get the gamepad controllers based on type
  39193. * @param type The type of gamepad controller
  39194. * @returns Nullable gamepad
  39195. */
  39196. getGamepadByType(type?: number): Nullable<Gamepad>;
  39197. /**
  39198. * Disposes the gamepad manager
  39199. */
  39200. dispose(): void;
  39201. private _addNewGamepad;
  39202. private _startMonitoringGamepads;
  39203. private _stopMonitoringGamepads;
  39204. /** @hidden */
  39205. _checkGamepadsStatus(): void;
  39206. private _updateGamepadObjects;
  39207. }
  39208. }
  39209. declare module BABYLON {
  39210. interface Scene {
  39211. /** @hidden */
  39212. _gamepadManager: Nullable<GamepadManager>;
  39213. /**
  39214. * Gets the gamepad manager associated with the scene
  39215. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  39216. */
  39217. gamepadManager: GamepadManager;
  39218. }
  39219. /**
  39220. * Interface representing a free camera inputs manager
  39221. */
  39222. interface FreeCameraInputsManager {
  39223. /**
  39224. * Adds gamepad input support to the FreeCameraInputsManager.
  39225. * @returns the FreeCameraInputsManager
  39226. */
  39227. addGamepad(): FreeCameraInputsManager;
  39228. }
  39229. /**
  39230. * Interface representing an arc rotate camera inputs manager
  39231. */
  39232. interface ArcRotateCameraInputsManager {
  39233. /**
  39234. * Adds gamepad input support to the ArcRotateCamera InputManager.
  39235. * @returns the camera inputs manager
  39236. */
  39237. addGamepad(): ArcRotateCameraInputsManager;
  39238. }
  39239. /**
  39240. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  39241. */
  39242. export class GamepadSystemSceneComponent implements ISceneComponent {
  39243. /**
  39244. * The component name helpfull to identify the component in the list of scene components.
  39245. */
  39246. readonly name: string;
  39247. /**
  39248. * The scene the component belongs to.
  39249. */
  39250. scene: Scene;
  39251. /**
  39252. * Creates a new instance of the component for the given scene
  39253. * @param scene Defines the scene to register the component in
  39254. */
  39255. constructor(scene: Scene);
  39256. /**
  39257. * Registers the component in a given scene
  39258. */
  39259. register(): void;
  39260. /**
  39261. * Rebuilds the elements related to this component in case of
  39262. * context lost for instance.
  39263. */
  39264. rebuild(): void;
  39265. /**
  39266. * Disposes the component and the associated ressources
  39267. */
  39268. dispose(): void;
  39269. private _beforeCameraUpdate;
  39270. }
  39271. }
  39272. declare module BABYLON {
  39273. /**
  39274. * Options to modify the vr teleportation behavior.
  39275. */
  39276. export interface VRTeleportationOptions {
  39277. /**
  39278. * The name of the mesh which should be used as the teleportation floor. (default: null)
  39279. */
  39280. floorMeshName?: string;
  39281. /**
  39282. * A list of meshes to be used as the teleportation floor. (default: empty)
  39283. */
  39284. floorMeshes?: Mesh[];
  39285. }
  39286. /**
  39287. * Options to modify the vr experience helper's behavior.
  39288. */
  39289. export interface VRExperienceHelperOptions extends WebVROptions {
  39290. /**
  39291. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  39292. */
  39293. createDeviceOrientationCamera?: boolean;
  39294. /**
  39295. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  39296. */
  39297. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  39298. /**
  39299. * Uses the main button on the controller to toggle the laser casted. (default: true)
  39300. */
  39301. laserToggle?: boolean;
  39302. /**
  39303. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  39304. */
  39305. floorMeshes?: Mesh[];
  39306. /**
  39307. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  39308. */
  39309. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  39310. }
  39311. /**
  39312. * Event containing information after VR has been entered
  39313. */
  39314. export class OnAfterEnteringVRObservableEvent {
  39315. /**
  39316. * If entering vr was successful
  39317. */
  39318. success: boolean;
  39319. }
  39320. /**
  39321. * Helps to quickly add VR support to an existing scene.
  39322. * See http://doc.babylonjs.com/how_to/webvr_helper
  39323. */
  39324. export class VRExperienceHelper {
  39325. /** Options to modify the vr experience helper's behavior. */
  39326. webVROptions: VRExperienceHelperOptions;
  39327. private _scene;
  39328. private _position;
  39329. private _btnVR;
  39330. private _btnVRDisplayed;
  39331. private _webVRsupported;
  39332. private _webVRready;
  39333. private _webVRrequesting;
  39334. private _webVRpresenting;
  39335. private _hasEnteredVR;
  39336. private _fullscreenVRpresenting;
  39337. private _canvas;
  39338. private _webVRCamera;
  39339. private _vrDeviceOrientationCamera;
  39340. private _deviceOrientationCamera;
  39341. private _existingCamera;
  39342. private _onKeyDown;
  39343. private _onVrDisplayPresentChange;
  39344. private _onVRDisplayChanged;
  39345. private _onVRRequestPresentStart;
  39346. private _onVRRequestPresentComplete;
  39347. /**
  39348. * Observable raised right before entering VR.
  39349. */
  39350. onEnteringVRObservable: Observable<VRExperienceHelper>;
  39351. /**
  39352. * Observable raised when entering VR has completed.
  39353. */
  39354. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  39355. /**
  39356. * Observable raised when exiting VR.
  39357. */
  39358. onExitingVRObservable: Observable<VRExperienceHelper>;
  39359. /**
  39360. * Observable raised when controller mesh is loaded.
  39361. */
  39362. onControllerMeshLoadedObservable: Observable<WebVRController>;
  39363. /** Return this.onEnteringVRObservable
  39364. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  39365. */
  39366. readonly onEnteringVR: Observable<VRExperienceHelper>;
  39367. /** Return this.onExitingVRObservable
  39368. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  39369. */
  39370. readonly onExitingVR: Observable<VRExperienceHelper>;
  39371. /** Return this.onControllerMeshLoadedObservable
  39372. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  39373. */
  39374. readonly onControllerMeshLoaded: Observable<WebVRController>;
  39375. private _rayLength;
  39376. private _useCustomVRButton;
  39377. private _teleportationRequested;
  39378. private _teleportActive;
  39379. private _floorMeshName;
  39380. private _floorMeshesCollection;
  39381. private _rotationAllowed;
  39382. private _teleportBackwardsVector;
  39383. private _teleportationTarget;
  39384. private _isDefaultTeleportationTarget;
  39385. private _postProcessMove;
  39386. private _teleportationFillColor;
  39387. private _teleportationBorderColor;
  39388. private _rotationAngle;
  39389. private _haloCenter;
  39390. private _cameraGazer;
  39391. private _padSensibilityUp;
  39392. private _padSensibilityDown;
  39393. private _leftController;
  39394. private _rightController;
  39395. /**
  39396. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  39397. */
  39398. onNewMeshSelected: Observable<AbstractMesh>;
  39399. /**
  39400. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  39401. */
  39402. onNewMeshPicked: Observable<PickingInfo>;
  39403. private _circleEase;
  39404. /**
  39405. * Observable raised before camera teleportation
  39406. */
  39407. onBeforeCameraTeleport: Observable<Vector3>;
  39408. /**
  39409. * Observable raised after camera teleportation
  39410. */
  39411. onAfterCameraTeleport: Observable<Vector3>;
  39412. /**
  39413. * Observable raised when current selected mesh gets unselected
  39414. */
  39415. onSelectedMeshUnselected: Observable<AbstractMesh>;
  39416. private _raySelectionPredicate;
  39417. /**
  39418. * To be optionaly changed by user to define custom ray selection
  39419. */
  39420. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  39421. /**
  39422. * To be optionaly changed by user to define custom selection logic (after ray selection)
  39423. */
  39424. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  39425. /**
  39426. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  39427. */
  39428. teleportationEnabled: boolean;
  39429. private _defaultHeight;
  39430. private _teleportationInitialized;
  39431. private _interactionsEnabled;
  39432. private _interactionsRequested;
  39433. private _displayGaze;
  39434. private _displayLaserPointer;
  39435. /**
  39436. * The mesh used to display where the user is going to teleport.
  39437. */
  39438. /**
  39439. * Sets the mesh to be used to display where the user is going to teleport.
  39440. */
  39441. teleportationTarget: Mesh;
  39442. /**
  39443. * 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
  39444. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  39445. * See http://doc.babylonjs.com/resources/baking_transformations
  39446. */
  39447. gazeTrackerMesh: Mesh;
  39448. /**
  39449. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  39450. */
  39451. updateGazeTrackerScale: boolean;
  39452. /**
  39453. * If the gaze trackers color should be updated when selecting meshes
  39454. */
  39455. updateGazeTrackerColor: boolean;
  39456. /**
  39457. * The gaze tracking mesh corresponding to the left controller
  39458. */
  39459. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  39460. /**
  39461. * The gaze tracking mesh corresponding to the right controller
  39462. */
  39463. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  39464. /**
  39465. * If the ray of the gaze should be displayed.
  39466. */
  39467. /**
  39468. * Sets if the ray of the gaze should be displayed.
  39469. */
  39470. displayGaze: boolean;
  39471. /**
  39472. * If the ray of the LaserPointer should be displayed.
  39473. */
  39474. /**
  39475. * Sets if the ray of the LaserPointer should be displayed.
  39476. */
  39477. displayLaserPointer: boolean;
  39478. /**
  39479. * The deviceOrientationCamera used as the camera when not in VR.
  39480. */
  39481. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  39482. /**
  39483. * Based on the current WebVR support, returns the current VR camera used.
  39484. */
  39485. readonly currentVRCamera: Nullable<Camera>;
  39486. /**
  39487. * The webVRCamera which is used when in VR.
  39488. */
  39489. readonly webVRCamera: WebVRFreeCamera;
  39490. /**
  39491. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  39492. */
  39493. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  39494. private readonly _teleportationRequestInitiated;
  39495. /**
  39496. * Defines wether or not Pointer lock should be requested when switching to
  39497. * full screen.
  39498. */
  39499. requestPointerLockOnFullScreen: boolean;
  39500. /**
  39501. * Instantiates a VRExperienceHelper.
  39502. * Helps to quickly add VR support to an existing scene.
  39503. * @param scene The scene the VRExperienceHelper belongs to.
  39504. * @param webVROptions Options to modify the vr experience helper's behavior.
  39505. */
  39506. constructor(scene: Scene,
  39507. /** Options to modify the vr experience helper's behavior. */
  39508. webVROptions?: VRExperienceHelperOptions);
  39509. private _onDefaultMeshLoaded;
  39510. private _onResize;
  39511. private _onFullscreenChange;
  39512. /**
  39513. * Gets a value indicating if we are currently in VR mode.
  39514. */
  39515. readonly isInVRMode: boolean;
  39516. private onVrDisplayPresentChange;
  39517. private onVRDisplayChanged;
  39518. private moveButtonToBottomRight;
  39519. private displayVRButton;
  39520. private updateButtonVisibility;
  39521. private _cachedAngularSensibility;
  39522. /**
  39523. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  39524. * Otherwise, will use the fullscreen API.
  39525. */
  39526. enterVR(): void;
  39527. /**
  39528. * Attempt to exit VR, or fullscreen.
  39529. */
  39530. exitVR(): void;
  39531. /**
  39532. * The position of the vr experience helper.
  39533. */
  39534. /**
  39535. * Sets the position of the vr experience helper.
  39536. */
  39537. position: Vector3;
  39538. /**
  39539. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  39540. */
  39541. enableInteractions(): void;
  39542. private readonly _noControllerIsActive;
  39543. private beforeRender;
  39544. private _isTeleportationFloor;
  39545. /**
  39546. * Adds a floor mesh to be used for teleportation.
  39547. * @param floorMesh the mesh to be used for teleportation.
  39548. */
  39549. addFloorMesh(floorMesh: Mesh): void;
  39550. /**
  39551. * Removes a floor mesh from being used for teleportation.
  39552. * @param floorMesh the mesh to be removed.
  39553. */
  39554. removeFloorMesh(floorMesh: Mesh): void;
  39555. /**
  39556. * Enables interactions and teleportation using the VR controllers and gaze.
  39557. * @param vrTeleportationOptions options to modify teleportation behavior.
  39558. */
  39559. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  39560. private _onNewGamepadConnected;
  39561. private _tryEnableInteractionOnController;
  39562. private _onNewGamepadDisconnected;
  39563. private _enableInteractionOnController;
  39564. private _checkTeleportWithRay;
  39565. private _checkRotate;
  39566. private _checkTeleportBackwards;
  39567. private _enableTeleportationOnController;
  39568. private _createTeleportationCircles;
  39569. private _displayTeleportationTarget;
  39570. private _hideTeleportationTarget;
  39571. private _rotateCamera;
  39572. private _moveTeleportationSelectorTo;
  39573. private _workingVector;
  39574. private _workingQuaternion;
  39575. private _workingMatrix;
  39576. /**
  39577. * Teleports the users feet to the desired location
  39578. * @param location The location where the user's feet should be placed
  39579. */
  39580. teleportCamera(location: Vector3): void;
  39581. private _convertNormalToDirectionOfRay;
  39582. private _castRayAndSelectObject;
  39583. private _notifySelectedMeshUnselected;
  39584. /**
  39585. * Sets the color of the laser ray from the vr controllers.
  39586. * @param color new color for the ray.
  39587. */
  39588. changeLaserColor(color: Color3): void;
  39589. /**
  39590. * Sets the color of the ray from the vr headsets gaze.
  39591. * @param color new color for the ray.
  39592. */
  39593. changeGazeColor(color: Color3): void;
  39594. /**
  39595. * Exits VR and disposes of the vr experience helper
  39596. */
  39597. dispose(): void;
  39598. /**
  39599. * Gets the name of the VRExperienceHelper class
  39600. * @returns "VRExperienceHelper"
  39601. */
  39602. getClassName(): string;
  39603. }
  39604. }
  39605. declare module BABYLON {
  39606. /**
  39607. * Manages an XRSession
  39608. * @see https://doc.babylonjs.com/how_to/webxr
  39609. */
  39610. export class WebXRSessionManager implements IDisposable {
  39611. private scene;
  39612. /**
  39613. * Fires every time a new xrFrame arrives which can be used to update the camera
  39614. */
  39615. onXRFrameObservable: Observable<any>;
  39616. /**
  39617. * Fires when the xr session is ended either by the device or manually done
  39618. */
  39619. onXRSessionEnded: Observable<any>;
  39620. /** @hidden */
  39621. _xrSession: XRSession;
  39622. /** @hidden */
  39623. _frameOfReference: XRFrameOfReference;
  39624. /** @hidden */
  39625. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  39626. /** @hidden */
  39627. _currentXRFrame: Nullable<XRFrame>;
  39628. private _xrNavigator;
  39629. private _xrDevice;
  39630. private _tmpMatrix;
  39631. /**
  39632. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  39633. * @param scene The scene which the session should be created for
  39634. */
  39635. constructor(scene: Scene);
  39636. /**
  39637. * Initializes the manager
  39638. * After initialization enterXR can be called to start an XR session
  39639. * @returns Promise which resolves after it is initialized
  39640. */
  39641. initializeAsync(): Promise<void>;
  39642. /**
  39643. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  39644. * @param sessionCreationOptions xr options to create the session with
  39645. * @param frameOfReferenceType option to configure how the xr pose is expressed
  39646. * @returns Promise which resolves after it enters XR
  39647. */
  39648. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  39649. /**
  39650. * Stops the xrSession and restores the renderloop
  39651. * @returns Promise which resolves after it exits XR
  39652. */
  39653. exitXRAsync(): Promise<void>;
  39654. /**
  39655. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  39656. * @param ray ray to cast into the environment
  39657. * @returns Promise which resolves with a collision point in the environment if it exists
  39658. */
  39659. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  39660. /**
  39661. * Checks if a session would be supported for the creation options specified
  39662. * @param options creation options to check if they are supported
  39663. * @returns true if supported
  39664. */
  39665. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  39666. /**
  39667. * @hidden
  39668. * Converts the render layer of xrSession to a render target
  39669. * @param session session to create render target for
  39670. * @param scene scene the new render target should be created for
  39671. */
  39672. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  39673. /**
  39674. * Disposes of the session manager
  39675. */
  39676. dispose(): void;
  39677. }
  39678. }
  39679. declare module BABYLON {
  39680. /**
  39681. * WebXR Camera which holds the views for the xrSession
  39682. * @see https://doc.babylonjs.com/how_to/webxr
  39683. */
  39684. export class WebXRCamera extends FreeCamera {
  39685. private static _TmpMatrix;
  39686. /**
  39687. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  39688. * @param name the name of the camera
  39689. * @param scene the scene to add the camera to
  39690. */
  39691. constructor(name: string, scene: Scene);
  39692. private _updateNumberOfRigCameras;
  39693. /** @hidden */
  39694. _updateForDualEyeDebugging(pupilDistance?: number): void;
  39695. /**
  39696. * Updates the cameras position from the current pose information of the XR session
  39697. * @param xrSessionManager the session containing pose information
  39698. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  39699. */
  39700. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  39701. }
  39702. }
  39703. declare module BABYLON {
  39704. /**
  39705. * States of the webXR experience
  39706. */
  39707. export enum WebXRState {
  39708. /**
  39709. * Transitioning to being in XR mode
  39710. */
  39711. ENTERING_XR = 0,
  39712. /**
  39713. * Transitioning to non XR mode
  39714. */
  39715. EXITING_XR = 1,
  39716. /**
  39717. * In XR mode and presenting
  39718. */
  39719. IN_XR = 2,
  39720. /**
  39721. * Not entered XR mode
  39722. */
  39723. NOT_IN_XR = 3
  39724. }
  39725. /**
  39726. * Helper class used to enable XR
  39727. * @see https://doc.babylonjs.com/how_to/webxr
  39728. */
  39729. export class WebXRExperienceHelper implements IDisposable {
  39730. private scene;
  39731. /**
  39732. * 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
  39733. */
  39734. container: AbstractMesh;
  39735. /**
  39736. * Camera used to render xr content
  39737. */
  39738. camera: WebXRCamera;
  39739. /**
  39740. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  39741. */
  39742. state: WebXRState;
  39743. private _setState;
  39744. private static _TmpVector;
  39745. /**
  39746. * Fires when the state of the experience helper has changed
  39747. */
  39748. onStateChangedObservable: Observable<WebXRState>;
  39749. /** @hidden */
  39750. _sessionManager: WebXRSessionManager;
  39751. private _nonVRCamera;
  39752. private _originalSceneAutoClear;
  39753. private _supported;
  39754. /**
  39755. * Creates the experience helper
  39756. * @param scene the scene to attach the experience helper to
  39757. * @returns a promise for the experience helper
  39758. */
  39759. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  39760. /**
  39761. * Creates a WebXRExperienceHelper
  39762. * @param scene The scene the helper should be created in
  39763. */
  39764. private constructor();
  39765. /**
  39766. * Exits XR mode and returns the scene to its original state
  39767. * @returns promise that resolves after xr mode has exited
  39768. */
  39769. exitXRAsync(): Promise<void>;
  39770. /**
  39771. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  39772. * @param sessionCreationOptions options for the XR session
  39773. * @param frameOfReference frame of reference of the XR session
  39774. * @returns promise that resolves after xr mode has entered
  39775. */
  39776. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  39777. /**
  39778. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  39779. * @param ray ray to cast into the environment
  39780. * @returns Promise which resolves with a collision point in the environment if it exists
  39781. */
  39782. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  39783. /**
  39784. * Updates the global position of the camera by moving the camera's container
  39785. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  39786. * @param position The desired global position of the camera
  39787. */
  39788. setPositionOfCameraUsingContainer(position: Vector3): void;
  39789. /**
  39790. * Rotates the xr camera by rotating the camera's container around the camera's position
  39791. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  39792. * @param rotation the desired quaternion rotation to apply to the camera
  39793. */
  39794. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  39795. /**
  39796. * Checks if the creation options are supported by the xr session
  39797. * @param options creation options
  39798. * @returns true if supported
  39799. */
  39800. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  39801. /**
  39802. * Disposes of the experience helper
  39803. */
  39804. dispose(): void;
  39805. }
  39806. }
  39807. declare module BABYLON {
  39808. /**
  39809. * Button which can be used to enter a different mode of XR
  39810. */
  39811. export class WebXREnterExitUIButton {
  39812. /** button element */
  39813. element: HTMLElement;
  39814. /** XR initialization options for the button */
  39815. initializationOptions: XRSessionCreationOptions;
  39816. /**
  39817. * Creates a WebXREnterExitUIButton
  39818. * @param element button element
  39819. * @param initializationOptions XR initialization options for the button
  39820. */
  39821. constructor(
  39822. /** button element */
  39823. element: HTMLElement,
  39824. /** XR initialization options for the button */
  39825. initializationOptions: XRSessionCreationOptions);
  39826. /**
  39827. * Overwritable function which can be used to update the button's visuals when the state changes
  39828. * @param activeButton the current active button in the UI
  39829. */
  39830. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  39831. }
  39832. /**
  39833. * Options to create the webXR UI
  39834. */
  39835. export class WebXREnterExitUIOptions {
  39836. /**
  39837. * Context to enter xr with
  39838. */
  39839. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  39840. /**
  39841. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  39842. */
  39843. customButtons?: Array<WebXREnterExitUIButton>;
  39844. }
  39845. /**
  39846. * UI to allow the user to enter/exit XR mode
  39847. */
  39848. export class WebXREnterExitUI implements IDisposable {
  39849. private scene;
  39850. private _overlay;
  39851. private _buttons;
  39852. private _activeButton;
  39853. /**
  39854. * Fired every time the active button is changed.
  39855. *
  39856. * When xr is entered via a button that launches xr that button will be the callback parameter
  39857. *
  39858. * When exiting xr the callback parameter will be null)
  39859. */
  39860. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  39861. /**
  39862. * Creates UI to allow the user to enter/exit XR mode
  39863. * @param scene the scene to add the ui to
  39864. * @param helper the xr experience helper to enter/exit xr with
  39865. * @param options options to configure the UI
  39866. * @returns the created ui
  39867. */
  39868. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  39869. private constructor();
  39870. private _updateButtons;
  39871. /**
  39872. * Disposes of the object
  39873. */
  39874. dispose(): void;
  39875. }
  39876. }
  39877. declare module BABYLON {
  39878. /**
  39879. * Represents an XR input
  39880. */
  39881. export class WebXRController {
  39882. /**
  39883. * 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
  39884. */
  39885. grip?: AbstractMesh;
  39886. /**
  39887. * Pointer which can be used to select objects or attach a visible laser to
  39888. */
  39889. pointer: AbstractMesh;
  39890. /**
  39891. * Creates the controller
  39892. * @see https://doc.babylonjs.com/how_to/webxr
  39893. * @param scene the scene which the controller should be associated to
  39894. */
  39895. constructor(scene: Scene);
  39896. /**
  39897. * Disposes of the object
  39898. */
  39899. dispose(): void;
  39900. }
  39901. /**
  39902. * XR input used to track XR inputs such as controllers/rays
  39903. */
  39904. export class WebXRInput implements IDisposable {
  39905. private helper;
  39906. /**
  39907. * XR controllers being tracked
  39908. */
  39909. controllers: Array<WebXRController>;
  39910. private _tmpMatrix;
  39911. private _frameObserver;
  39912. /**
  39913. * Initializes the WebXRInput
  39914. * @param helper experience helper which the input should be created for
  39915. */
  39916. constructor(helper: WebXRExperienceHelper);
  39917. /**
  39918. * Disposes of the object
  39919. */
  39920. dispose(): void;
  39921. }
  39922. }
  39923. declare module BABYLON {
  39924. /**
  39925. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  39926. */
  39927. export class WebXRManagedOutputCanvas implements IDisposable {
  39928. private _canvas;
  39929. /**
  39930. * xrpresent context of the canvas which can be used to display/mirror xr content
  39931. */
  39932. canvasContext: Nullable<WebGLRenderingContext>;
  39933. /**
  39934. * Initializes the canvas to be added/removed upon entering/exiting xr
  39935. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  39936. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  39937. */
  39938. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  39939. /**
  39940. * Disposes of the object
  39941. */
  39942. dispose(): void;
  39943. private _setManagedOutputCanvas;
  39944. private _addCanvas;
  39945. private _removeCanvas;
  39946. }
  39947. }
  39948. declare module BABYLON {
  39949. /**
  39950. * Contains an array of blocks representing the octree
  39951. */
  39952. export interface IOctreeContainer<T> {
  39953. /**
  39954. * Blocks within the octree
  39955. */
  39956. blocks: Array<OctreeBlock<T>>;
  39957. }
  39958. /**
  39959. * Class used to store a cell in an octree
  39960. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39961. */
  39962. export class OctreeBlock<T> {
  39963. /**
  39964. * Gets the content of the current block
  39965. */
  39966. entries: T[];
  39967. /**
  39968. * Gets the list of block children
  39969. */
  39970. blocks: Array<OctreeBlock<T>>;
  39971. private _depth;
  39972. private _maxDepth;
  39973. private _capacity;
  39974. private _minPoint;
  39975. private _maxPoint;
  39976. private _boundingVectors;
  39977. private _creationFunc;
  39978. /**
  39979. * Creates a new block
  39980. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  39981. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  39982. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  39983. * @param depth defines the current depth of this block in the octree
  39984. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  39985. * @param creationFunc defines a callback to call when an element is added to the block
  39986. */
  39987. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  39988. /**
  39989. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  39990. */
  39991. readonly capacity: number;
  39992. /**
  39993. * Gets the minimum vector (in world space) of the block's bounding box
  39994. */
  39995. readonly minPoint: Vector3;
  39996. /**
  39997. * Gets the maximum vector (in world space) of the block's bounding box
  39998. */
  39999. readonly maxPoint: Vector3;
  40000. /**
  40001. * Add a new element to this block
  40002. * @param entry defines the element to add
  40003. */
  40004. addEntry(entry: T): void;
  40005. /**
  40006. * Remove an element from this block
  40007. * @param entry defines the element to remove
  40008. */
  40009. removeEntry(entry: T): void;
  40010. /**
  40011. * Add an array of elements to this block
  40012. * @param entries defines the array of elements to add
  40013. */
  40014. addEntries(entries: T[]): void;
  40015. /**
  40016. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  40017. * @param frustumPlanes defines the frustum planes to test
  40018. * @param selection defines the array to store current content if selection is positive
  40019. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40020. */
  40021. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40022. /**
  40023. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  40024. * @param sphereCenter defines the bounding sphere center
  40025. * @param sphereRadius defines the bounding sphere radius
  40026. * @param selection defines the array to store current content if selection is positive
  40027. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40028. */
  40029. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40030. /**
  40031. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  40032. * @param ray defines the ray to test with
  40033. * @param selection defines the array to store current content if selection is positive
  40034. */
  40035. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  40036. /**
  40037. * Subdivide the content into child blocks (this block will then be empty)
  40038. */
  40039. createInnerBlocks(): void;
  40040. /**
  40041. * @hidden
  40042. */
  40043. 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;
  40044. }
  40045. }
  40046. declare module BABYLON {
  40047. /**
  40048. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  40049. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40050. */
  40051. export class Octree<T> {
  40052. /** 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.) */
  40053. maxDepth: number;
  40054. /**
  40055. * Blocks within the octree containing objects
  40056. */
  40057. blocks: Array<OctreeBlock<T>>;
  40058. /**
  40059. * Content stored in the octree
  40060. */
  40061. dynamicContent: T[];
  40062. private _maxBlockCapacity;
  40063. private _selectionContent;
  40064. private _creationFunc;
  40065. /**
  40066. * Creates a octree
  40067. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40068. * @param creationFunc function to be used to instatiate the octree
  40069. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  40070. * @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.)
  40071. */
  40072. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  40073. /** 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.) */
  40074. maxDepth?: number);
  40075. /**
  40076. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  40077. * @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);
  40078. * @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);
  40079. * @param entries meshes to be added to the octree blocks
  40080. */
  40081. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  40082. /**
  40083. * Adds a mesh to the octree
  40084. * @param entry Mesh to add to the octree
  40085. */
  40086. addMesh(entry: T): void;
  40087. /**
  40088. * Remove an element from the octree
  40089. * @param entry defines the element to remove
  40090. */
  40091. removeMesh(entry: T): void;
  40092. /**
  40093. * Selects an array of meshes within the frustum
  40094. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  40095. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  40096. * @returns array of meshes within the frustum
  40097. */
  40098. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  40099. /**
  40100. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  40101. * @param sphereCenter defines the bounding sphere center
  40102. * @param sphereRadius defines the bounding sphere radius
  40103. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40104. * @returns an array of objects that intersect the sphere
  40105. */
  40106. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  40107. /**
  40108. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  40109. * @param ray defines the ray to test with
  40110. * @returns array of intersected objects
  40111. */
  40112. intersectsRay(ray: Ray): SmartArray<T>;
  40113. /**
  40114. * Adds a mesh into the octree block if it intersects the block
  40115. */
  40116. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  40117. /**
  40118. * Adds a submesh into the octree block if it intersects the block
  40119. */
  40120. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  40121. }
  40122. }
  40123. declare module BABYLON {
  40124. interface Scene {
  40125. /**
  40126. * @hidden
  40127. * Backing Filed
  40128. */
  40129. _selectionOctree: Octree<AbstractMesh>;
  40130. /**
  40131. * Gets the octree used to boost mesh selection (picking)
  40132. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40133. */
  40134. selectionOctree: Octree<AbstractMesh>;
  40135. /**
  40136. * Creates or updates the octree used to boost selection (picking)
  40137. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40138. * @param maxCapacity defines the maximum capacity per leaf
  40139. * @param maxDepth defines the maximum depth of the octree
  40140. * @returns an octree of AbstractMesh
  40141. */
  40142. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  40143. }
  40144. interface AbstractMesh {
  40145. /**
  40146. * @hidden
  40147. * Backing Field
  40148. */
  40149. _submeshesOctree: Octree<SubMesh>;
  40150. /**
  40151. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  40152. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  40153. * @param maxCapacity defines the maximum size of each block (64 by default)
  40154. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  40155. * @returns the new octree
  40156. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  40157. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40158. */
  40159. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  40160. }
  40161. /**
  40162. * Defines the octree scene component responsible to manage any octrees
  40163. * in a given scene.
  40164. */
  40165. export class OctreeSceneComponent {
  40166. /**
  40167. * The component name helpfull to identify the component in the list of scene components.
  40168. */
  40169. readonly name: string;
  40170. /**
  40171. * The scene the component belongs to.
  40172. */
  40173. scene: Scene;
  40174. /**
  40175. * Indicates if the meshes have been checked to make sure they are isEnabled()
  40176. */
  40177. readonly checksIsEnabled: boolean;
  40178. /**
  40179. * Creates a new instance of the component for the given scene
  40180. * @param scene Defines the scene to register the component in
  40181. */
  40182. constructor(scene: Scene);
  40183. /**
  40184. * Registers the component in a given scene
  40185. */
  40186. register(): void;
  40187. /**
  40188. * Return the list of active meshes
  40189. * @returns the list of active meshes
  40190. */
  40191. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  40192. /**
  40193. * Return the list of active sub meshes
  40194. * @param mesh The mesh to get the candidates sub meshes from
  40195. * @returns the list of active sub meshes
  40196. */
  40197. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  40198. private _tempRay;
  40199. /**
  40200. * Return the list of sub meshes intersecting with a given local ray
  40201. * @param mesh defines the mesh to find the submesh for
  40202. * @param localRay defines the ray in local space
  40203. * @returns the list of intersecting sub meshes
  40204. */
  40205. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  40206. /**
  40207. * Return the list of sub meshes colliding with a collider
  40208. * @param mesh defines the mesh to find the submesh for
  40209. * @param collider defines the collider to evaluate the collision against
  40210. * @returns the list of colliding sub meshes
  40211. */
  40212. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  40213. /**
  40214. * Rebuilds the elements related to this component in case of
  40215. * context lost for instance.
  40216. */
  40217. rebuild(): void;
  40218. /**
  40219. * Disposes the component and the associated ressources.
  40220. */
  40221. dispose(): void;
  40222. }
  40223. }
  40224. declare module BABYLON {
  40225. /**
  40226. * Class containing static functions to help procedurally build meshes
  40227. */
  40228. export class LinesBuilder {
  40229. /**
  40230. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  40231. * * 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
  40232. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  40233. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  40234. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  40235. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  40236. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  40237. * * 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
  40238. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  40239. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40240. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  40241. * @param name defines the name of the new line system
  40242. * @param options defines the options used to create the line system
  40243. * @param scene defines the hosting scene
  40244. * @returns a new line system mesh
  40245. */
  40246. static CreateLineSystem(name: string, options: {
  40247. lines: Vector3[][];
  40248. updatable?: boolean;
  40249. instance?: Nullable<LinesMesh>;
  40250. colors?: Nullable<Color4[][]>;
  40251. useVertexAlpha?: boolean;
  40252. }, scene: Nullable<Scene>): LinesMesh;
  40253. /**
  40254. * Creates a line mesh
  40255. * 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
  40256. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  40257. * * The parameter `points` is an array successive Vector3
  40258. * * 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
  40259. * * The optional parameter `colors` is an array of successive Color4, one per line point
  40260. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  40261. * * When updating an instance, remember that only point positions can change, not the number of points
  40262. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40263. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  40264. * @param name defines the name of the new line system
  40265. * @param options defines the options used to create the line system
  40266. * @param scene defines the hosting scene
  40267. * @returns a new line mesh
  40268. */
  40269. static CreateLines(name: string, options: {
  40270. points: Vector3[];
  40271. updatable?: boolean;
  40272. instance?: Nullable<LinesMesh>;
  40273. colors?: Color4[];
  40274. useVertexAlpha?: boolean;
  40275. }, scene?: Nullable<Scene>): LinesMesh;
  40276. /**
  40277. * Creates a dashed line mesh
  40278. * * 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
  40279. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  40280. * * The parameter `points` is an array successive Vector3
  40281. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  40282. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  40283. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  40284. * * 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
  40285. * * When updating an instance, remember that only point positions can change, not the number of points
  40286. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40287. * @param name defines the name of the mesh
  40288. * @param options defines the options used to create the mesh
  40289. * @param scene defines the hosting scene
  40290. * @returns the dashed line mesh
  40291. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  40292. */
  40293. static CreateDashedLines(name: string, options: {
  40294. points: Vector3[];
  40295. dashSize?: number;
  40296. gapSize?: number;
  40297. dashNb?: number;
  40298. updatable?: boolean;
  40299. instance?: LinesMesh;
  40300. }, scene?: Nullable<Scene>): LinesMesh;
  40301. }
  40302. }
  40303. declare module BABYLON {
  40304. /**
  40305. * Renders a layer on top of an existing scene
  40306. */
  40307. export class UtilityLayerRenderer implements IDisposable {
  40308. /** the original scene that will be rendered on top of */
  40309. originalScene: Scene;
  40310. private _pointerCaptures;
  40311. private _lastPointerEvents;
  40312. private static _DefaultUtilityLayer;
  40313. private static _DefaultKeepDepthUtilityLayer;
  40314. /**
  40315. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  40316. */
  40317. pickUtilitySceneFirst: boolean;
  40318. /**
  40319. * 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)
  40320. */
  40321. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  40322. /**
  40323. * 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)
  40324. */
  40325. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  40326. /**
  40327. * The scene that is rendered on top of the original scene
  40328. */
  40329. utilityLayerScene: Scene;
  40330. /**
  40331. * If the utility layer should automatically be rendered on top of existing scene
  40332. */
  40333. shouldRender: boolean;
  40334. /**
  40335. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  40336. */
  40337. onlyCheckPointerDownEvents: boolean;
  40338. /**
  40339. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  40340. */
  40341. processAllEvents: boolean;
  40342. /**
  40343. * Observable raised when the pointer move from the utility layer scene to the main scene
  40344. */
  40345. onPointerOutObservable: Observable<number>;
  40346. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  40347. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  40348. private _afterRenderObserver;
  40349. private _sceneDisposeObserver;
  40350. private _originalPointerObserver;
  40351. /**
  40352. * Instantiates a UtilityLayerRenderer
  40353. * @param originalScene the original scene that will be rendered on top of
  40354. * @param handleEvents boolean indicating if the utility layer should handle events
  40355. */
  40356. constructor(
  40357. /** the original scene that will be rendered on top of */
  40358. originalScene: Scene, handleEvents?: boolean);
  40359. private _notifyObservers;
  40360. /**
  40361. * Renders the utility layers scene on top of the original scene
  40362. */
  40363. render(): void;
  40364. /**
  40365. * Disposes of the renderer
  40366. */
  40367. dispose(): void;
  40368. private _updateCamera;
  40369. }
  40370. }
  40371. declare module BABYLON {
  40372. /**
  40373. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  40374. */
  40375. export class Gizmo implements IDisposable {
  40376. /** The utility layer the gizmo will be added to */
  40377. gizmoLayer: UtilityLayerRenderer;
  40378. /**
  40379. * The root mesh of the gizmo
  40380. */
  40381. _rootMesh: Mesh;
  40382. private _attachedMesh;
  40383. /**
  40384. * Ratio for the scale of the gizmo (Default: 1)
  40385. */
  40386. scaleRatio: number;
  40387. private _tmpMatrix;
  40388. /**
  40389. * If a custom mesh has been set (Default: false)
  40390. */
  40391. protected _customMeshSet: boolean;
  40392. /**
  40393. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  40394. * * When set, interactions will be enabled
  40395. */
  40396. attachedMesh: Nullable<AbstractMesh>;
  40397. /**
  40398. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  40399. * @param mesh The mesh to replace the default mesh of the gizmo
  40400. */
  40401. setCustomMesh(mesh: Mesh): void;
  40402. /**
  40403. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  40404. */
  40405. updateGizmoRotationToMatchAttachedMesh: boolean;
  40406. /**
  40407. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  40408. */
  40409. updateGizmoPositionToMatchAttachedMesh: boolean;
  40410. /**
  40411. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  40412. */
  40413. protected _updateScale: boolean;
  40414. protected _interactionsEnabled: boolean;
  40415. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  40416. private _beforeRenderObserver;
  40417. /**
  40418. * Creates a gizmo
  40419. * @param gizmoLayer The utility layer the gizmo will be added to
  40420. */
  40421. constructor(
  40422. /** The utility layer the gizmo will be added to */
  40423. gizmoLayer?: UtilityLayerRenderer);
  40424. private _tempVector;
  40425. /**
  40426. * @hidden
  40427. * Updates the gizmo to match the attached mesh's position/rotation
  40428. */
  40429. protected _update(): void;
  40430. /**
  40431. * Disposes of the gizmo
  40432. */
  40433. dispose(): void;
  40434. }
  40435. }
  40436. declare module BABYLON {
  40437. /**
  40438. * Single axis drag gizmo
  40439. */
  40440. export class AxisDragGizmo extends Gizmo {
  40441. /**
  40442. * Drag behavior responsible for the gizmos dragging interactions
  40443. */
  40444. dragBehavior: PointerDragBehavior;
  40445. private _pointerObserver;
  40446. /**
  40447. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  40448. */
  40449. snapDistance: number;
  40450. /**
  40451. * Event that fires each time the gizmo snaps to a new location.
  40452. * * snapDistance is the the change in distance
  40453. */
  40454. onSnapObservable: Observable<{
  40455. snapDistance: number;
  40456. }>;
  40457. /** @hidden */
  40458. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  40459. /** @hidden */
  40460. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  40461. /**
  40462. * Creates an AxisDragGizmo
  40463. * @param gizmoLayer The utility layer the gizmo will be added to
  40464. * @param dragAxis The axis which the gizmo will be able to drag on
  40465. * @param color The color of the gizmo
  40466. */
  40467. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  40468. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  40469. /**
  40470. * Disposes of the gizmo
  40471. */
  40472. dispose(): void;
  40473. }
  40474. }
  40475. declare module BABYLON.Debug {
  40476. /**
  40477. * The Axes viewer will show 3 axes in a specific point in space
  40478. */
  40479. export class AxesViewer {
  40480. private _xAxis;
  40481. private _yAxis;
  40482. private _zAxis;
  40483. private _scaleLinesFactor;
  40484. private _instanced;
  40485. /**
  40486. * Gets the hosting scene
  40487. */
  40488. scene: Scene;
  40489. /**
  40490. * Gets or sets a number used to scale line length
  40491. */
  40492. scaleLines: number;
  40493. /** Gets the node hierarchy used to render x-axis */
  40494. readonly xAxis: TransformNode;
  40495. /** Gets the node hierarchy used to render y-axis */
  40496. readonly yAxis: TransformNode;
  40497. /** Gets the node hierarchy used to render z-axis */
  40498. readonly zAxis: TransformNode;
  40499. /**
  40500. * Creates a new AxesViewer
  40501. * @param scene defines the hosting scene
  40502. * @param scaleLines defines a number used to scale line length (1 by default)
  40503. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  40504. * @param xAxis defines the node hierarchy used to render the x-axis
  40505. * @param yAxis defines the node hierarchy used to render the y-axis
  40506. * @param zAxis defines the node hierarchy used to render the z-axis
  40507. */
  40508. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  40509. /**
  40510. * Force the viewer to update
  40511. * @param position defines the position of the viewer
  40512. * @param xaxis defines the x axis of the viewer
  40513. * @param yaxis defines the y axis of the viewer
  40514. * @param zaxis defines the z axis of the viewer
  40515. */
  40516. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  40517. /**
  40518. * Creates an instance of this axes viewer.
  40519. * @returns a new axes viewer with instanced meshes
  40520. */
  40521. createInstance(): AxesViewer;
  40522. /** Releases resources */
  40523. dispose(): void;
  40524. private static _SetRenderingGroupId;
  40525. }
  40526. }
  40527. declare module BABYLON.Debug {
  40528. /**
  40529. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  40530. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  40531. */
  40532. export class BoneAxesViewer extends AxesViewer {
  40533. /**
  40534. * Gets or sets the target mesh where to display the axes viewer
  40535. */
  40536. mesh: Nullable<Mesh>;
  40537. /**
  40538. * Gets or sets the target bone where to display the axes viewer
  40539. */
  40540. bone: Nullable<Bone>;
  40541. /** Gets current position */
  40542. pos: Vector3;
  40543. /** Gets direction of X axis */
  40544. xaxis: Vector3;
  40545. /** Gets direction of Y axis */
  40546. yaxis: Vector3;
  40547. /** Gets direction of Z axis */
  40548. zaxis: Vector3;
  40549. /**
  40550. * Creates a new BoneAxesViewer
  40551. * @param scene defines the hosting scene
  40552. * @param bone defines the target bone
  40553. * @param mesh defines the target mesh
  40554. * @param scaleLines defines a scaling factor for line length (1 by default)
  40555. */
  40556. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  40557. /**
  40558. * Force the viewer to update
  40559. */
  40560. update(): void;
  40561. /** Releases resources */
  40562. dispose(): void;
  40563. }
  40564. }
  40565. declare module BABYLON {
  40566. /**
  40567. * Interface used to define scene explorer extensibility option
  40568. */
  40569. export interface IExplorerExtensibilityOption {
  40570. /**
  40571. * Define the option label
  40572. */
  40573. label: string;
  40574. /**
  40575. * Defines the action to execute on click
  40576. */
  40577. action: (entity: any) => void;
  40578. }
  40579. /**
  40580. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  40581. */
  40582. export interface IExplorerExtensibilityGroup {
  40583. /**
  40584. * Defines a predicate to test if a given type mut be extended
  40585. */
  40586. predicate: (entity: any) => boolean;
  40587. /**
  40588. * Gets the list of options added to a type
  40589. */
  40590. entries: IExplorerExtensibilityOption[];
  40591. }
  40592. /**
  40593. * Interface used to define the options to use to create the Inspector
  40594. */
  40595. export interface IInspectorOptions {
  40596. /**
  40597. * Display in overlay mode (default: false)
  40598. */
  40599. overlay?: boolean;
  40600. /**
  40601. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  40602. */
  40603. globalRoot?: HTMLElement;
  40604. /**
  40605. * Display the Scene explorer
  40606. */
  40607. showExplorer?: boolean;
  40608. /**
  40609. * Display the property inspector
  40610. */
  40611. showInspector?: boolean;
  40612. /**
  40613. * Display in embed mode (both panes on the right)
  40614. */
  40615. embedMode?: boolean;
  40616. /**
  40617. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  40618. */
  40619. handleResize?: boolean;
  40620. /**
  40621. * Allow the panes to popup (default: true)
  40622. */
  40623. enablePopup?: boolean;
  40624. /**
  40625. * Allow the panes to be closed by users (default: true)
  40626. */
  40627. enableClose?: boolean;
  40628. /**
  40629. * Optional list of extensibility entries
  40630. */
  40631. explorerExtensibility?: IExplorerExtensibilityGroup[];
  40632. /**
  40633. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  40634. */
  40635. inspectorURL?: string;
  40636. }
  40637. interface Scene {
  40638. /**
  40639. * @hidden
  40640. * Backing field
  40641. */
  40642. _debugLayer: DebugLayer;
  40643. /**
  40644. * Gets the debug layer (aka Inspector) associated with the scene
  40645. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40646. */
  40647. debugLayer: DebugLayer;
  40648. }
  40649. /**
  40650. * The debug layer (aka Inspector) is the go to tool in order to better understand
  40651. * what is happening in your scene
  40652. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40653. */
  40654. export class DebugLayer {
  40655. /**
  40656. * Define the url to get the inspector script from.
  40657. * By default it uses the babylonjs CDN.
  40658. * @ignoreNaming
  40659. */
  40660. static InspectorURL: string;
  40661. private _scene;
  40662. private BJSINSPECTOR;
  40663. /**
  40664. * Observable triggered when a property is changed through the inspector.
  40665. */
  40666. onPropertyChangedObservable: Observable<{
  40667. object: any;
  40668. property: string;
  40669. value: any;
  40670. initialValue: any;
  40671. }>;
  40672. /**
  40673. * Instantiates a new debug layer.
  40674. * The debug layer (aka Inspector) is the go to tool in order to better understand
  40675. * what is happening in your scene
  40676. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40677. * @param scene Defines the scene to inspect
  40678. */
  40679. constructor(scene: Scene);
  40680. /** Creates the inspector window. */
  40681. private _createInspector;
  40682. /**
  40683. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  40684. * @param entity defines the entity to select
  40685. * @param lineContainerTitle defines the specific block to highlight
  40686. */
  40687. select(entity: any, lineContainerTitle?: string): void;
  40688. /** Get the inspector from bundle or global */
  40689. private _getGlobalInspector;
  40690. /**
  40691. * Get if the inspector is visible or not.
  40692. * @returns true if visible otherwise, false
  40693. */
  40694. isVisible(): boolean;
  40695. /**
  40696. * Hide the inspector and close its window.
  40697. */
  40698. hide(): void;
  40699. /**
  40700. * Launch the debugLayer.
  40701. * @param config Define the configuration of the inspector
  40702. * @return a promise fulfilled when the debug layer is visible
  40703. */
  40704. show(config?: IInspectorOptions): Promise<DebugLayer>;
  40705. }
  40706. }
  40707. declare module BABYLON {
  40708. /**
  40709. * Class containing static functions to help procedurally build meshes
  40710. */
  40711. export class BoxBuilder {
  40712. /**
  40713. * Creates a box mesh
  40714. * * The parameter `size` sets the size (float) of each box side (default 1)
  40715. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  40716. * * 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)
  40717. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  40718. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40719. * * 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
  40720. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40721. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  40722. * @param name defines the name of the mesh
  40723. * @param options defines the options used to create the mesh
  40724. * @param scene defines the hosting scene
  40725. * @returns the box mesh
  40726. */
  40727. static CreateBox(name: string, options: {
  40728. size?: number;
  40729. width?: number;
  40730. height?: number;
  40731. depth?: number;
  40732. faceUV?: Vector4[];
  40733. faceColors?: Color4[];
  40734. sideOrientation?: number;
  40735. frontUVs?: Vector4;
  40736. backUVs?: Vector4;
  40737. updatable?: boolean;
  40738. }, scene?: Nullable<Scene>): Mesh;
  40739. }
  40740. }
  40741. declare module BABYLON {
  40742. /**
  40743. * Class containing static functions to help procedurally build meshes
  40744. */
  40745. export class SphereBuilder {
  40746. /**
  40747. * Creates a sphere mesh
  40748. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  40749. * * 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`)
  40750. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  40751. * * 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
  40752. * * 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)
  40753. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40754. * * 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
  40755. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40756. * @param name defines the name of the mesh
  40757. * @param options defines the options used to create the mesh
  40758. * @param scene defines the hosting scene
  40759. * @returns the sphere mesh
  40760. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  40761. */
  40762. static CreateSphere(name: string, options: {
  40763. segments?: number;
  40764. diameter?: number;
  40765. diameterX?: number;
  40766. diameterY?: number;
  40767. diameterZ?: number;
  40768. arc?: number;
  40769. slice?: number;
  40770. sideOrientation?: number;
  40771. frontUVs?: Vector4;
  40772. backUVs?: Vector4;
  40773. updatable?: boolean;
  40774. }, scene: any): Mesh;
  40775. }
  40776. }
  40777. declare module BABYLON.Debug {
  40778. /**
  40779. * Used to show the physics impostor around the specific mesh
  40780. */
  40781. export class PhysicsViewer {
  40782. /** @hidden */
  40783. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  40784. /** @hidden */
  40785. protected _meshes: Array<Nullable<AbstractMesh>>;
  40786. /** @hidden */
  40787. protected _scene: Nullable<Scene>;
  40788. /** @hidden */
  40789. protected _numMeshes: number;
  40790. /** @hidden */
  40791. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  40792. private _renderFunction;
  40793. private _utilityLayer;
  40794. private _debugBoxMesh;
  40795. private _debugSphereMesh;
  40796. private _debugMaterial;
  40797. private _debugMeshMeshes;
  40798. /**
  40799. * Creates a new PhysicsViewer
  40800. * @param scene defines the hosting scene
  40801. */
  40802. constructor(scene: Scene);
  40803. /** @hidden */
  40804. protected _updateDebugMeshes(): void;
  40805. /**
  40806. * Renders a specified physic impostor
  40807. * @param impostor defines the impostor to render
  40808. * @param targetMesh defines the mesh represented by the impostor
  40809. * @returns the new debug mesh used to render the impostor
  40810. */
  40811. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  40812. /**
  40813. * Hides a specified physic impostor
  40814. * @param impostor defines the impostor to hide
  40815. */
  40816. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  40817. private _getDebugMaterial;
  40818. private _getDebugBoxMesh;
  40819. private _getDebugSphereMesh;
  40820. private _getDebugMeshMesh;
  40821. private _getDebugMesh;
  40822. /** Releases all resources */
  40823. dispose(): void;
  40824. }
  40825. }
  40826. declare module BABYLON {
  40827. /**
  40828. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  40829. * in order to better appreciate the issue one might have.
  40830. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  40831. */
  40832. export class RayHelper {
  40833. /**
  40834. * Defines the ray we are currently tryin to visualize.
  40835. */
  40836. ray: Nullable<Ray>;
  40837. private _renderPoints;
  40838. private _renderLine;
  40839. private _renderFunction;
  40840. private _scene;
  40841. private _updateToMeshFunction;
  40842. private _attachedToMesh;
  40843. private _meshSpaceDirection;
  40844. private _meshSpaceOrigin;
  40845. /**
  40846. * Helper function to create a colored helper in a scene in one line.
  40847. * @param ray Defines the ray we are currently tryin to visualize
  40848. * @param scene Defines the scene the ray is used in
  40849. * @param color Defines the color we want to see the ray in
  40850. * @returns The newly created ray helper.
  40851. */
  40852. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  40853. /**
  40854. * Instantiate a new ray helper.
  40855. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  40856. * in order to better appreciate the issue one might have.
  40857. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  40858. * @param ray Defines the ray we are currently tryin to visualize
  40859. */
  40860. constructor(ray: Ray);
  40861. /**
  40862. * Shows the ray we are willing to debug.
  40863. * @param scene Defines the scene the ray needs to be rendered in
  40864. * @param color Defines the color the ray needs to be rendered in
  40865. */
  40866. show(scene: Scene, color?: Color3): void;
  40867. /**
  40868. * Hides the ray we are debugging.
  40869. */
  40870. hide(): void;
  40871. private _render;
  40872. /**
  40873. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  40874. * @param mesh Defines the mesh we want the helper attached to
  40875. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  40876. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  40877. * @param length Defines the length of the ray
  40878. */
  40879. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  40880. /**
  40881. * Detach the ray helper from the mesh it has previously been attached to.
  40882. */
  40883. detachFromMesh(): void;
  40884. private _updateToMesh;
  40885. /**
  40886. * Dispose the helper and release its associated resources.
  40887. */
  40888. dispose(): void;
  40889. }
  40890. }
  40891. declare module BABYLON.Debug {
  40892. /**
  40893. * Class used to render a debug view of a given skeleton
  40894. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  40895. */
  40896. export class SkeletonViewer {
  40897. /** defines the skeleton to render */
  40898. skeleton: Skeleton;
  40899. /** defines the mesh attached to the skeleton */
  40900. mesh: AbstractMesh;
  40901. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  40902. autoUpdateBonesMatrices: boolean;
  40903. /** defines the rendering group id to use with the viewer */
  40904. renderingGroupId: number;
  40905. /** Gets or sets the color used to render the skeleton */
  40906. color: Color3;
  40907. private _scene;
  40908. private _debugLines;
  40909. private _debugMesh;
  40910. private _isEnabled;
  40911. private _renderFunction;
  40912. private _utilityLayer;
  40913. /**
  40914. * Returns the mesh used to render the bones
  40915. */
  40916. readonly debugMesh: Nullable<LinesMesh>;
  40917. /**
  40918. * Creates a new SkeletonViewer
  40919. * @param skeleton defines the skeleton to render
  40920. * @param mesh defines the mesh attached to the skeleton
  40921. * @param scene defines the hosting scene
  40922. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  40923. * @param renderingGroupId defines the rendering group id to use with the viewer
  40924. */
  40925. constructor(
  40926. /** defines the skeleton to render */
  40927. skeleton: Skeleton,
  40928. /** defines the mesh attached to the skeleton */
  40929. mesh: AbstractMesh, scene: Scene,
  40930. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  40931. autoUpdateBonesMatrices?: boolean,
  40932. /** defines the rendering group id to use with the viewer */
  40933. renderingGroupId?: number);
  40934. /** Gets or sets a boolean indicating if the viewer is enabled */
  40935. isEnabled: boolean;
  40936. private _getBonePosition;
  40937. private _getLinesForBonesWithLength;
  40938. private _getLinesForBonesNoLength;
  40939. /** Update the viewer to sync with current skeleton state */
  40940. update(): void;
  40941. /** Release associated resources */
  40942. dispose(): void;
  40943. }
  40944. }
  40945. declare module BABYLON {
  40946. /**
  40947. * Options to create the null engine
  40948. */
  40949. export class NullEngineOptions {
  40950. /**
  40951. * Render width (Default: 512)
  40952. */
  40953. renderWidth: number;
  40954. /**
  40955. * Render height (Default: 256)
  40956. */
  40957. renderHeight: number;
  40958. /**
  40959. * Texture size (Default: 512)
  40960. */
  40961. textureSize: number;
  40962. /**
  40963. * If delta time between frames should be constant
  40964. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40965. */
  40966. deterministicLockstep: boolean;
  40967. /**
  40968. * Maximum about of steps between frames (Default: 4)
  40969. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40970. */
  40971. lockstepMaxSteps: number;
  40972. }
  40973. /**
  40974. * The null engine class provides support for headless version of babylon.js.
  40975. * This can be used in server side scenario or for testing purposes
  40976. */
  40977. export class NullEngine extends Engine {
  40978. private _options;
  40979. /**
  40980. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40981. */
  40982. isDeterministicLockStep(): boolean;
  40983. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  40984. getLockstepMaxSteps(): number;
  40985. /**
  40986. * Sets hardware scaling, used to save performance if needed
  40987. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  40988. */
  40989. getHardwareScalingLevel(): number;
  40990. constructor(options?: NullEngineOptions);
  40991. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  40992. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  40993. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  40994. getRenderWidth(useScreen?: boolean): number;
  40995. getRenderHeight(useScreen?: boolean): number;
  40996. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  40997. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  40998. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  40999. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  41000. bindSamplers(effect: Effect): void;
  41001. enableEffect(effect: Effect): void;
  41002. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  41003. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  41004. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  41005. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  41006. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  41007. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  41008. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  41009. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  41010. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  41011. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  41012. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  41013. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  41014. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  41015. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  41016. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  41017. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41018. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41019. setFloat(uniform: WebGLUniformLocation, value: number): void;
  41020. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  41021. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  41022. setBool(uniform: WebGLUniformLocation, bool: number): void;
  41023. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  41024. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  41025. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  41026. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  41027. bindBuffers(vertexBuffers: {
  41028. [key: string]: VertexBuffer;
  41029. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  41030. wipeCaches(bruteForce?: boolean): void;
  41031. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  41032. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  41033. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  41034. /** @hidden */
  41035. _createTexture(): WebGLTexture;
  41036. /** @hidden */
  41037. _releaseTexture(texture: InternalTexture): void;
  41038. 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;
  41039. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  41040. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  41041. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  41042. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  41043. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  41044. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  41045. areAllEffectsReady(): boolean;
  41046. /**
  41047. * @hidden
  41048. * Get the current error code of the webGL context
  41049. * @returns the error code
  41050. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  41051. */
  41052. getError(): number;
  41053. /** @hidden */
  41054. _getUnpackAlignement(): number;
  41055. /** @hidden */
  41056. _unpackFlipY(value: boolean): void;
  41057. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  41058. /**
  41059. * Updates a dynamic vertex buffer.
  41060. * @param vertexBuffer the vertex buffer to update
  41061. * @param data the data used to update the vertex buffer
  41062. * @param byteOffset the byte offset of the data (optional)
  41063. * @param byteLength the byte length of the data (optional)
  41064. */
  41065. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  41066. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  41067. /** @hidden */
  41068. _bindTexture(channel: number, texture: InternalTexture): void;
  41069. /** @hidden */
  41070. _releaseBuffer(buffer: WebGLBuffer): boolean;
  41071. releaseEffects(): void;
  41072. displayLoadingUI(): void;
  41073. hideLoadingUI(): void;
  41074. /** @hidden */
  41075. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41076. /** @hidden */
  41077. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41078. /** @hidden */
  41079. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41080. /** @hidden */
  41081. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  41082. }
  41083. }
  41084. declare module BABYLON {
  41085. /** @hidden */
  41086. export class _OcclusionDataStorage {
  41087. /** @hidden */
  41088. occlusionInternalRetryCounter: number;
  41089. /** @hidden */
  41090. isOcclusionQueryInProgress: boolean;
  41091. /** @hidden */
  41092. isOccluded: boolean;
  41093. /** @hidden */
  41094. occlusionRetryCount: number;
  41095. /** @hidden */
  41096. occlusionType: number;
  41097. /** @hidden */
  41098. occlusionQueryAlgorithmType: number;
  41099. }
  41100. interface Engine {
  41101. /**
  41102. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  41103. * @return the new query
  41104. */
  41105. createQuery(): WebGLQuery;
  41106. /**
  41107. * Delete and release a webGL query
  41108. * @param query defines the query to delete
  41109. * @return the current engine
  41110. */
  41111. deleteQuery(query: WebGLQuery): Engine;
  41112. /**
  41113. * Check if a given query has resolved and got its value
  41114. * @param query defines the query to check
  41115. * @returns true if the query got its value
  41116. */
  41117. isQueryResultAvailable(query: WebGLQuery): boolean;
  41118. /**
  41119. * Gets the value of a given query
  41120. * @param query defines the query to check
  41121. * @returns the value of the query
  41122. */
  41123. getQueryResult(query: WebGLQuery): number;
  41124. /**
  41125. * Initiates an occlusion query
  41126. * @param algorithmType defines the algorithm to use
  41127. * @param query defines the query to use
  41128. * @returns the current engine
  41129. * @see http://doc.babylonjs.com/features/occlusionquery
  41130. */
  41131. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  41132. /**
  41133. * Ends an occlusion query
  41134. * @see http://doc.babylonjs.com/features/occlusionquery
  41135. * @param algorithmType defines the algorithm to use
  41136. * @returns the current engine
  41137. */
  41138. endOcclusionQuery(algorithmType: number): Engine;
  41139. /**
  41140. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  41141. * Please note that only one query can be issued at a time
  41142. * @returns a time token used to track the time span
  41143. */
  41144. startTimeQuery(): Nullable<_TimeToken>;
  41145. /**
  41146. * Ends a time query
  41147. * @param token defines the token used to measure the time span
  41148. * @returns the time spent (in ns)
  41149. */
  41150. endTimeQuery(token: _TimeToken): int;
  41151. /** @hidden */
  41152. _currentNonTimestampToken: Nullable<_TimeToken>;
  41153. /** @hidden */
  41154. _createTimeQuery(): WebGLQuery;
  41155. /** @hidden */
  41156. _deleteTimeQuery(query: WebGLQuery): void;
  41157. /** @hidden */
  41158. _getGlAlgorithmType(algorithmType: number): number;
  41159. /** @hidden */
  41160. _getTimeQueryResult(query: WebGLQuery): any;
  41161. /** @hidden */
  41162. _getTimeQueryAvailability(query: WebGLQuery): any;
  41163. }
  41164. interface AbstractMesh {
  41165. /**
  41166. * Backing filed
  41167. * @hidden
  41168. */
  41169. __occlusionDataStorage: _OcclusionDataStorage;
  41170. /**
  41171. * Access property
  41172. * @hidden
  41173. */
  41174. _occlusionDataStorage: _OcclusionDataStorage;
  41175. /**
  41176. * 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.
  41177. * The default value is -1 which means don't break the query and wait till the result
  41178. * @see http://doc.babylonjs.com/features/occlusionquery
  41179. */
  41180. occlusionRetryCount: number;
  41181. /**
  41182. * 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:
  41183. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  41184. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  41185. * * 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.
  41186. * @see http://doc.babylonjs.com/features/occlusionquery
  41187. */
  41188. occlusionType: number;
  41189. /**
  41190. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  41191. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  41192. * * 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.
  41193. * @see http://doc.babylonjs.com/features/occlusionquery
  41194. */
  41195. occlusionQueryAlgorithmType: number;
  41196. /**
  41197. * 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
  41198. * @see http://doc.babylonjs.com/features/occlusionquery
  41199. */
  41200. isOccluded: boolean;
  41201. /**
  41202. * Flag to check the progress status of the query
  41203. * @see http://doc.babylonjs.com/features/occlusionquery
  41204. */
  41205. isOcclusionQueryInProgress: boolean;
  41206. }
  41207. }
  41208. declare module BABYLON {
  41209. /** @hidden */
  41210. export var _forceTransformFeedbackToBundle: boolean;
  41211. interface Engine {
  41212. /**
  41213. * Creates a webGL transform feedback object
  41214. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  41215. * @returns the webGL transform feedback object
  41216. */
  41217. createTransformFeedback(): WebGLTransformFeedback;
  41218. /**
  41219. * Delete a webGL transform feedback object
  41220. * @param value defines the webGL transform feedback object to delete
  41221. */
  41222. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  41223. /**
  41224. * Bind a webGL transform feedback object to the webgl context
  41225. * @param value defines the webGL transform feedback object to bind
  41226. */
  41227. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  41228. /**
  41229. * Begins a transform feedback operation
  41230. * @param usePoints defines if points or triangles must be used
  41231. */
  41232. beginTransformFeedback(usePoints: boolean): void;
  41233. /**
  41234. * Ends a transform feedback operation
  41235. */
  41236. endTransformFeedback(): void;
  41237. /**
  41238. * Specify the varyings to use with transform feedback
  41239. * @param program defines the associated webGL program
  41240. * @param value defines the list of strings representing the varying names
  41241. */
  41242. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  41243. /**
  41244. * Bind a webGL buffer for a transform feedback operation
  41245. * @param value defines the webGL buffer to bind
  41246. */
  41247. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  41248. }
  41249. }
  41250. declare module BABYLON {
  41251. /**
  41252. * Gather the list of clipboard event types as constants.
  41253. */
  41254. export class ClipboardEventTypes {
  41255. /**
  41256. * The clipboard event is fired when a copy command is active (pressed).
  41257. */
  41258. static readonly COPY: number;
  41259. /**
  41260. * The clipboard event is fired when a cut command is active (pressed).
  41261. */
  41262. static readonly CUT: number;
  41263. /**
  41264. * The clipboard event is fired when a paste command is active (pressed).
  41265. */
  41266. static readonly PASTE: number;
  41267. }
  41268. /**
  41269. * This class is used to store clipboard related info for the onClipboardObservable event.
  41270. */
  41271. export class ClipboardInfo {
  41272. /**
  41273. * Defines the type of event (BABYLON.ClipboardEventTypes)
  41274. */
  41275. type: number;
  41276. /**
  41277. * Defines the related dom event
  41278. */
  41279. event: ClipboardEvent;
  41280. /**
  41281. *Creates an instance of ClipboardInfo.
  41282. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  41283. * @param event Defines the related dom event
  41284. */
  41285. constructor(
  41286. /**
  41287. * Defines the type of event (BABYLON.ClipboardEventTypes)
  41288. */
  41289. type: number,
  41290. /**
  41291. * Defines the related dom event
  41292. */
  41293. event: ClipboardEvent);
  41294. /**
  41295. * Get the clipboard event's type from the keycode.
  41296. * @param keyCode Defines the keyCode for the current keyboard event.
  41297. * @return {number}
  41298. */
  41299. static GetTypeFromCharacter(keyCode: number): number;
  41300. }
  41301. }
  41302. declare module BABYLON {
  41303. /**
  41304. * Class used to represent data loading progression
  41305. */
  41306. export class SceneLoaderProgressEvent {
  41307. /** defines if data length to load can be evaluated */
  41308. readonly lengthComputable: boolean;
  41309. /** defines the loaded data length */
  41310. readonly loaded: number;
  41311. /** defines the data length to load */
  41312. readonly total: number;
  41313. /**
  41314. * Create a new progress event
  41315. * @param lengthComputable defines if data length to load can be evaluated
  41316. * @param loaded defines the loaded data length
  41317. * @param total defines the data length to load
  41318. */
  41319. constructor(
  41320. /** defines if data length to load can be evaluated */
  41321. lengthComputable: boolean,
  41322. /** defines the loaded data length */
  41323. loaded: number,
  41324. /** defines the data length to load */
  41325. total: number);
  41326. /**
  41327. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  41328. * @param event defines the source event
  41329. * @returns a new SceneLoaderProgressEvent
  41330. */
  41331. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  41332. }
  41333. /**
  41334. * Interface used by SceneLoader plugins to define supported file extensions
  41335. */
  41336. export interface ISceneLoaderPluginExtensions {
  41337. /**
  41338. * Defines the list of supported extensions
  41339. */
  41340. [extension: string]: {
  41341. isBinary: boolean;
  41342. };
  41343. }
  41344. /**
  41345. * Interface used by SceneLoader plugin factory
  41346. */
  41347. export interface ISceneLoaderPluginFactory {
  41348. /**
  41349. * Defines the name of the factory
  41350. */
  41351. name: string;
  41352. /**
  41353. * Function called to create a new plugin
  41354. * @return the new plugin
  41355. */
  41356. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  41357. /**
  41358. * Boolean indicating if the plugin can direct load specific data
  41359. */
  41360. canDirectLoad?: (data: string) => boolean;
  41361. }
  41362. /**
  41363. * Interface used to define a SceneLoader plugin
  41364. */
  41365. export interface ISceneLoaderPlugin {
  41366. /**
  41367. * The friendly name of this plugin.
  41368. */
  41369. name: string;
  41370. /**
  41371. * The file extensions supported by this plugin.
  41372. */
  41373. extensions: string | ISceneLoaderPluginExtensions;
  41374. /**
  41375. * Import meshes into a scene.
  41376. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41377. * @param scene The scene to import into
  41378. * @param data The data to import
  41379. * @param rootUrl The root url for scene and resources
  41380. * @param meshes The meshes array to import into
  41381. * @param particleSystems The particle systems array to import into
  41382. * @param skeletons The skeletons array to import into
  41383. * @param onError The callback when import fails
  41384. * @returns True if successful or false otherwise
  41385. */
  41386. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  41387. /**
  41388. * Load into a scene.
  41389. * @param scene The scene to load into
  41390. * @param data The data to import
  41391. * @param rootUrl The root url for scene and resources
  41392. * @param onError The callback when import fails
  41393. * @returns true if successful or false otherwise
  41394. */
  41395. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  41396. /**
  41397. * The callback that returns true if the data can be directly loaded.
  41398. */
  41399. canDirectLoad?: (data: string) => boolean;
  41400. /**
  41401. * The callback that allows custom handling of the root url based on the response url.
  41402. */
  41403. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41404. /**
  41405. * Load into an asset container.
  41406. * @param scene The scene to load into
  41407. * @param data The data to import
  41408. * @param rootUrl The root url for scene and resources
  41409. * @param onError The callback when import fails
  41410. * @returns The loaded asset container
  41411. */
  41412. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  41413. }
  41414. /**
  41415. * Interface used to define an async SceneLoader plugin
  41416. */
  41417. export interface ISceneLoaderPluginAsync {
  41418. /**
  41419. * The friendly name of this plugin.
  41420. */
  41421. name: string;
  41422. /**
  41423. * The file extensions supported by this plugin.
  41424. */
  41425. extensions: string | ISceneLoaderPluginExtensions;
  41426. /**
  41427. * Import meshes into a scene.
  41428. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41429. * @param scene The scene to import into
  41430. * @param data The data to import
  41431. * @param rootUrl The root url for scene and resources
  41432. * @param onProgress The callback when the load progresses
  41433. * @param fileName Defines the name of the file to load
  41434. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  41435. */
  41436. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  41437. meshes: AbstractMesh[];
  41438. particleSystems: IParticleSystem[];
  41439. skeletons: Skeleton[];
  41440. animationGroups: AnimationGroup[];
  41441. }>;
  41442. /**
  41443. * Load into a scene.
  41444. * @param scene The scene to load into
  41445. * @param data The data to import
  41446. * @param rootUrl The root url for scene and resources
  41447. * @param onProgress The callback when the load progresses
  41448. * @param fileName Defines the name of the file to load
  41449. * @returns Nothing
  41450. */
  41451. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  41452. /**
  41453. * The callback that returns true if the data can be directly loaded.
  41454. */
  41455. canDirectLoad?: (data: string) => boolean;
  41456. /**
  41457. * The callback that allows custom handling of the root url based on the response url.
  41458. */
  41459. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41460. /**
  41461. * Load into an asset container.
  41462. * @param scene The scene to load into
  41463. * @param data The data to import
  41464. * @param rootUrl The root url for scene and resources
  41465. * @param onProgress The callback when the load progresses
  41466. * @param fileName Defines the name of the file to load
  41467. * @returns The loaded asset container
  41468. */
  41469. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  41470. }
  41471. /**
  41472. * Class used to load scene from various file formats using registered plugins
  41473. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  41474. */
  41475. export class SceneLoader {
  41476. /**
  41477. * No logging while loading
  41478. */
  41479. static readonly NO_LOGGING: number;
  41480. /**
  41481. * Minimal logging while loading
  41482. */
  41483. static readonly MINIMAL_LOGGING: number;
  41484. /**
  41485. * Summary logging while loading
  41486. */
  41487. static readonly SUMMARY_LOGGING: number;
  41488. /**
  41489. * Detailled logging while loading
  41490. */
  41491. static readonly DETAILED_LOGGING: number;
  41492. /**
  41493. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  41494. */
  41495. static ForceFullSceneLoadingForIncremental: boolean;
  41496. /**
  41497. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  41498. */
  41499. static ShowLoadingScreen: boolean;
  41500. /**
  41501. * Defines the current logging level (while loading the scene)
  41502. * @ignorenaming
  41503. */
  41504. static loggingLevel: number;
  41505. /**
  41506. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  41507. */
  41508. static CleanBoneMatrixWeights: boolean;
  41509. /**
  41510. * Event raised when a plugin is used to load a scene
  41511. */
  41512. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  41513. private static _registeredPlugins;
  41514. private static _getDefaultPlugin;
  41515. private static _getPluginForExtension;
  41516. private static _getPluginForDirectLoad;
  41517. private static _getPluginForFilename;
  41518. private static _getDirectLoad;
  41519. private static _loadData;
  41520. private static _getFileInfo;
  41521. /**
  41522. * Gets a plugin that can load the given extension
  41523. * @param extension defines the extension to load
  41524. * @returns a plugin or null if none works
  41525. */
  41526. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  41527. /**
  41528. * Gets a boolean indicating that the given extension can be loaded
  41529. * @param extension defines the extension to load
  41530. * @returns true if the extension is supported
  41531. */
  41532. static IsPluginForExtensionAvailable(extension: string): boolean;
  41533. /**
  41534. * Adds a new plugin to the list of registered plugins
  41535. * @param plugin defines the plugin to add
  41536. */
  41537. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  41538. /**
  41539. * Import meshes into a scene
  41540. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41541. * @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)
  41542. * @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)
  41543. * @param scene the instance of BABYLON.Scene to append to
  41544. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  41545. * @param onProgress a callback with a progress event for each file being loaded
  41546. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41547. * @param pluginExtension the extension used to determine the plugin
  41548. * @returns The loaded plugin
  41549. */
  41550. 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>;
  41551. /**
  41552. * Import meshes into a scene
  41553. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41554. * @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)
  41555. * @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)
  41556. * @param scene the instance of BABYLON.Scene to append to
  41557. * @param onProgress a callback with a progress event for each file being loaded
  41558. * @param pluginExtension the extension used to determine the plugin
  41559. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  41560. */
  41561. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  41562. meshes: AbstractMesh[];
  41563. particleSystems: IParticleSystem[];
  41564. skeletons: Skeleton[];
  41565. animationGroups: AnimationGroup[];
  41566. }>;
  41567. /**
  41568. * Load a scene
  41569. * @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)
  41570. * @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)
  41571. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41572. * @param onSuccess a callback with the scene when import succeeds
  41573. * @param onProgress a callback with a progress event for each file being loaded
  41574. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41575. * @param pluginExtension the extension used to determine the plugin
  41576. * @returns The loaded plugin
  41577. */
  41578. 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>;
  41579. /**
  41580. * Load a scene
  41581. * @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)
  41582. * @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)
  41583. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41584. * @param onProgress a callback with a progress event for each file being loaded
  41585. * @param pluginExtension the extension used to determine the plugin
  41586. * @returns The loaded scene
  41587. */
  41588. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41589. /**
  41590. * Append a scene
  41591. * @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)
  41592. * @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)
  41593. * @param scene is the instance of BABYLON.Scene to append to
  41594. * @param onSuccess a callback with the scene when import succeeds
  41595. * @param onProgress a callback with a progress event for each file being loaded
  41596. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41597. * @param pluginExtension the extension used to determine the plugin
  41598. * @returns The loaded plugin
  41599. */
  41600. 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>;
  41601. /**
  41602. * Append a scene
  41603. * @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)
  41604. * @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)
  41605. * @param scene is the instance of BABYLON.Scene to append to
  41606. * @param onProgress a callback with a progress event for each file being loaded
  41607. * @param pluginExtension the extension used to determine the plugin
  41608. * @returns The given scene
  41609. */
  41610. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41611. /**
  41612. * Load a scene into an asset container
  41613. * @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)
  41614. * @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)
  41615. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41616. * @param onSuccess a callback with the scene when import succeeds
  41617. * @param onProgress a callback with a progress event for each file being loaded
  41618. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41619. * @param pluginExtension the extension used to determine the plugin
  41620. * @returns The loaded plugin
  41621. */
  41622. 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>;
  41623. /**
  41624. * Load a scene into an asset container
  41625. * @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)
  41626. * @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)
  41627. * @param scene is the instance of Scene to append to
  41628. * @param onProgress a callback with a progress event for each file being loaded
  41629. * @param pluginExtension the extension used to determine the plugin
  41630. * @returns The loaded asset container
  41631. */
  41632. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  41633. }
  41634. }
  41635. declare module BABYLON {
  41636. /**
  41637. * Google Daydream controller
  41638. */
  41639. export class DaydreamController extends WebVRController {
  41640. /**
  41641. * Base Url for the controller model.
  41642. */
  41643. static MODEL_BASE_URL: string;
  41644. /**
  41645. * File name for the controller model.
  41646. */
  41647. static MODEL_FILENAME: string;
  41648. /**
  41649. * Gamepad Id prefix used to identify Daydream Controller.
  41650. */
  41651. static readonly GAMEPAD_ID_PREFIX: string;
  41652. /**
  41653. * Creates a new DaydreamController from a gamepad
  41654. * @param vrGamepad the gamepad that the controller should be created from
  41655. */
  41656. constructor(vrGamepad: any);
  41657. /**
  41658. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41659. * @param scene scene in which to add meshes
  41660. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41661. */
  41662. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41663. /**
  41664. * Called once for each button that changed state since the last frame
  41665. * @param buttonIdx Which button index changed
  41666. * @param state New state of the button
  41667. * @param changes Which properties on the state changed since last frame
  41668. */
  41669. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41670. }
  41671. }
  41672. declare module BABYLON {
  41673. /**
  41674. * Gear VR Controller
  41675. */
  41676. export class GearVRController extends WebVRController {
  41677. /**
  41678. * Base Url for the controller model.
  41679. */
  41680. static MODEL_BASE_URL: string;
  41681. /**
  41682. * File name for the controller model.
  41683. */
  41684. static MODEL_FILENAME: string;
  41685. /**
  41686. * Gamepad Id prefix used to identify this controller.
  41687. */
  41688. static readonly GAMEPAD_ID_PREFIX: string;
  41689. private readonly _buttonIndexToObservableNameMap;
  41690. /**
  41691. * Creates a new GearVRController from a gamepad
  41692. * @param vrGamepad the gamepad that the controller should be created from
  41693. */
  41694. constructor(vrGamepad: any);
  41695. /**
  41696. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41697. * @param scene scene in which to add meshes
  41698. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41699. */
  41700. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41701. /**
  41702. * Called once for each button that changed state since the last frame
  41703. * @param buttonIdx Which button index changed
  41704. * @param state New state of the button
  41705. * @param changes Which properties on the state changed since last frame
  41706. */
  41707. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41708. }
  41709. }
  41710. declare module BABYLON {
  41711. /**
  41712. * Generic Controller
  41713. */
  41714. export class GenericController extends WebVRController {
  41715. /**
  41716. * Base Url for the controller model.
  41717. */
  41718. static readonly MODEL_BASE_URL: string;
  41719. /**
  41720. * File name for the controller model.
  41721. */
  41722. static readonly MODEL_FILENAME: string;
  41723. /**
  41724. * Creates a new GenericController from a gamepad
  41725. * @param vrGamepad the gamepad that the controller should be created from
  41726. */
  41727. constructor(vrGamepad: any);
  41728. /**
  41729. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41730. * @param scene scene in which to add meshes
  41731. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41732. */
  41733. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41734. /**
  41735. * Called once for each button that changed state since the last frame
  41736. * @param buttonIdx Which button index changed
  41737. * @param state New state of the button
  41738. * @param changes Which properties on the state changed since last frame
  41739. */
  41740. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41741. }
  41742. }
  41743. declare module BABYLON {
  41744. /**
  41745. * Oculus Touch Controller
  41746. */
  41747. export class OculusTouchController extends WebVRController {
  41748. /**
  41749. * Base Url for the controller model.
  41750. */
  41751. static MODEL_BASE_URL: string;
  41752. /**
  41753. * File name for the left controller model.
  41754. */
  41755. static MODEL_LEFT_FILENAME: string;
  41756. /**
  41757. * File name for the right controller model.
  41758. */
  41759. static MODEL_RIGHT_FILENAME: string;
  41760. /**
  41761. * Fired when the secondary trigger on this controller is modified
  41762. */
  41763. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  41764. /**
  41765. * Fired when the thumb rest on this controller is modified
  41766. */
  41767. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  41768. /**
  41769. * Creates a new OculusTouchController from a gamepad
  41770. * @param vrGamepad the gamepad that the controller should be created from
  41771. */
  41772. constructor(vrGamepad: any);
  41773. /**
  41774. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41775. * @param scene scene in which to add meshes
  41776. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41777. */
  41778. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41779. /**
  41780. * Fired when the A button on this controller is modified
  41781. */
  41782. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41783. /**
  41784. * Fired when the B button on this controller is modified
  41785. */
  41786. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41787. /**
  41788. * Fired when the X button on this controller is modified
  41789. */
  41790. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41791. /**
  41792. * Fired when the Y button on this controller is modified
  41793. */
  41794. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41795. /**
  41796. * Called once for each button that changed state since the last frame
  41797. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  41798. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  41799. * 2) secondary trigger (same)
  41800. * 3) A (right) X (left), touch, pressed = value
  41801. * 4) B / Y
  41802. * 5) thumb rest
  41803. * @param buttonIdx Which button index changed
  41804. * @param state New state of the button
  41805. * @param changes Which properties on the state changed since last frame
  41806. */
  41807. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41808. }
  41809. }
  41810. declare module BABYLON {
  41811. /**
  41812. * Vive Controller
  41813. */
  41814. export class ViveController extends WebVRController {
  41815. /**
  41816. * Base Url for the controller model.
  41817. */
  41818. static MODEL_BASE_URL: string;
  41819. /**
  41820. * File name for the controller model.
  41821. */
  41822. static MODEL_FILENAME: string;
  41823. /**
  41824. * Creates a new ViveController from a gamepad
  41825. * @param vrGamepad the gamepad that the controller should be created from
  41826. */
  41827. constructor(vrGamepad: any);
  41828. /**
  41829. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41830. * @param scene scene in which to add meshes
  41831. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41832. */
  41833. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41834. /**
  41835. * Fired when the left button on this controller is modified
  41836. */
  41837. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41838. /**
  41839. * Fired when the right button on this controller is modified
  41840. */
  41841. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41842. /**
  41843. * Fired when the menu button on this controller is modified
  41844. */
  41845. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41846. /**
  41847. * Called once for each button that changed state since the last frame
  41848. * Vive mapping:
  41849. * 0: touchpad
  41850. * 1: trigger
  41851. * 2: left AND right buttons
  41852. * 3: menu button
  41853. * @param buttonIdx Which button index changed
  41854. * @param state New state of the button
  41855. * @param changes Which properties on the state changed since last frame
  41856. */
  41857. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41858. }
  41859. }
  41860. declare module BABYLON {
  41861. /**
  41862. * Defines the WindowsMotionController object that the state of the windows motion controller
  41863. */
  41864. export class WindowsMotionController extends WebVRController {
  41865. /**
  41866. * The base url used to load the left and right controller models
  41867. */
  41868. static MODEL_BASE_URL: string;
  41869. /**
  41870. * The name of the left controller model file
  41871. */
  41872. static MODEL_LEFT_FILENAME: string;
  41873. /**
  41874. * The name of the right controller model file
  41875. */
  41876. static MODEL_RIGHT_FILENAME: string;
  41877. /**
  41878. * The controller name prefix for this controller type
  41879. */
  41880. static readonly GAMEPAD_ID_PREFIX: string;
  41881. /**
  41882. * The controller id pattern for this controller type
  41883. */
  41884. private static readonly GAMEPAD_ID_PATTERN;
  41885. private _loadedMeshInfo;
  41886. private readonly _mapping;
  41887. /**
  41888. * Fired when the trackpad on this controller is clicked
  41889. */
  41890. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  41891. /**
  41892. * Fired when the trackpad on this controller is modified
  41893. */
  41894. onTrackpadValuesChangedObservable: Observable<StickValues>;
  41895. /**
  41896. * The current x and y values of this controller's trackpad
  41897. */
  41898. trackpad: StickValues;
  41899. /**
  41900. * Creates a new WindowsMotionController from a gamepad
  41901. * @param vrGamepad the gamepad that the controller should be created from
  41902. */
  41903. constructor(vrGamepad: any);
  41904. /**
  41905. * Fired when the trigger on this controller is modified
  41906. */
  41907. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41908. /**
  41909. * Fired when the menu button on this controller is modified
  41910. */
  41911. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41912. /**
  41913. * Fired when the grip button on this controller is modified
  41914. */
  41915. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41916. /**
  41917. * Fired when the thumbstick button on this controller is modified
  41918. */
  41919. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41920. /**
  41921. * Fired when the touchpad button on this controller is modified
  41922. */
  41923. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41924. /**
  41925. * Fired when the touchpad values on this controller are modified
  41926. */
  41927. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  41928. private _updateTrackpad;
  41929. /**
  41930. * Called once per frame by the engine.
  41931. */
  41932. update(): void;
  41933. /**
  41934. * Called once for each button that changed state since the last frame
  41935. * @param buttonIdx Which button index changed
  41936. * @param state New state of the button
  41937. * @param changes Which properties on the state changed since last frame
  41938. */
  41939. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41940. /**
  41941. * Moves the buttons on the controller mesh based on their current state
  41942. * @param buttonName the name of the button to move
  41943. * @param buttonValue the value of the button which determines the buttons new position
  41944. */
  41945. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  41946. /**
  41947. * Moves the axis on the controller mesh based on its current state
  41948. * @param axis the index of the axis
  41949. * @param axisValue the value of the axis which determines the meshes new position
  41950. * @hidden
  41951. */
  41952. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  41953. /**
  41954. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41955. * @param scene scene in which to add meshes
  41956. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41957. */
  41958. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  41959. /**
  41960. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  41961. * can be transformed by button presses and axes values, based on this._mapping.
  41962. *
  41963. * @param scene scene in which the meshes exist
  41964. * @param meshes list of meshes that make up the controller model to process
  41965. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  41966. */
  41967. private processModel;
  41968. private createMeshInfo;
  41969. /**
  41970. * Gets the ray of the controller in the direction the controller is pointing
  41971. * @param length the length the resulting ray should be
  41972. * @returns a ray in the direction the controller is pointing
  41973. */
  41974. getForwardRay(length?: number): Ray;
  41975. /**
  41976. * Disposes of the controller
  41977. */
  41978. dispose(): void;
  41979. }
  41980. }
  41981. declare module BABYLON {
  41982. /**
  41983. * Single axis scale gizmo
  41984. */
  41985. export class AxisScaleGizmo extends Gizmo {
  41986. private _coloredMaterial;
  41987. /**
  41988. * Drag behavior responsible for the gizmos dragging interactions
  41989. */
  41990. dragBehavior: PointerDragBehavior;
  41991. private _pointerObserver;
  41992. /**
  41993. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41994. */
  41995. snapDistance: number;
  41996. /**
  41997. * Event that fires each time the gizmo snaps to a new location.
  41998. * * snapDistance is the the change in distance
  41999. */
  42000. onSnapObservable: Observable<{
  42001. snapDistance: number;
  42002. }>;
  42003. /**
  42004. * If the scaling operation should be done on all axis (default: false)
  42005. */
  42006. uniformScaling: boolean;
  42007. /**
  42008. * Creates an AxisScaleGizmo
  42009. * @param gizmoLayer The utility layer the gizmo will be added to
  42010. * @param dragAxis The axis which the gizmo will be able to scale on
  42011. * @param color The color of the gizmo
  42012. */
  42013. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  42014. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42015. /**
  42016. * Disposes of the gizmo
  42017. */
  42018. dispose(): void;
  42019. /**
  42020. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42021. * @param mesh The mesh to replace the default mesh of the gizmo
  42022. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  42023. */
  42024. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  42025. }
  42026. }
  42027. declare module BABYLON {
  42028. /**
  42029. * Bounding box gizmo
  42030. */
  42031. export class BoundingBoxGizmo extends Gizmo {
  42032. private _lineBoundingBox;
  42033. private _rotateSpheresParent;
  42034. private _scaleBoxesParent;
  42035. private _boundingDimensions;
  42036. private _renderObserver;
  42037. private _pointerObserver;
  42038. private _scaleDragSpeed;
  42039. private _tmpQuaternion;
  42040. private _tmpVector;
  42041. private _tmpRotationMatrix;
  42042. /**
  42043. * 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)
  42044. */
  42045. ignoreChildren: boolean;
  42046. /**
  42047. * 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)
  42048. */
  42049. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  42050. /**
  42051. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  42052. */
  42053. rotationSphereSize: number;
  42054. /**
  42055. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  42056. */
  42057. scaleBoxSize: number;
  42058. /**
  42059. * 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)
  42060. */
  42061. fixedDragMeshScreenSize: boolean;
  42062. /**
  42063. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  42064. */
  42065. fixedDragMeshScreenSizeDistanceFactor: number;
  42066. /**
  42067. * Fired when a rotation sphere or scale box is dragged
  42068. */
  42069. onDragStartObservable: Observable<{}>;
  42070. /**
  42071. * Fired when a scale box is dragged
  42072. */
  42073. onScaleBoxDragObservable: Observable<{}>;
  42074. /**
  42075. * Fired when a scale box drag is ended
  42076. */
  42077. onScaleBoxDragEndObservable: Observable<{}>;
  42078. /**
  42079. * Fired when a rotation sphere is dragged
  42080. */
  42081. onRotationSphereDragObservable: Observable<{}>;
  42082. /**
  42083. * Fired when a rotation sphere drag is ended
  42084. */
  42085. onRotationSphereDragEndObservable: Observable<{}>;
  42086. /**
  42087. * 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)
  42088. */
  42089. scalePivot: Nullable<Vector3>;
  42090. private _anchorMesh;
  42091. private _existingMeshScale;
  42092. private _dragMesh;
  42093. private pointerDragBehavior;
  42094. private coloredMaterial;
  42095. private hoverColoredMaterial;
  42096. /**
  42097. * Sets the color of the bounding box gizmo
  42098. * @param color the color to set
  42099. */
  42100. setColor(color: Color3): void;
  42101. /**
  42102. * Creates an BoundingBoxGizmo
  42103. * @param gizmoLayer The utility layer the gizmo will be added to
  42104. * @param color The color of the gizmo
  42105. */
  42106. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  42107. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42108. private _selectNode;
  42109. /**
  42110. * Updates the bounding box information for the Gizmo
  42111. */
  42112. updateBoundingBox(): void;
  42113. private _updateRotationSpheres;
  42114. private _updateScaleBoxes;
  42115. /**
  42116. * Enables rotation on the specified axis and disables rotation on the others
  42117. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  42118. */
  42119. setEnabledRotationAxis(axis: string): void;
  42120. /**
  42121. * Enables/disables scaling
  42122. * @param enable if scaling should be enabled
  42123. */
  42124. setEnabledScaling(enable: boolean): void;
  42125. private _updateDummy;
  42126. /**
  42127. * Enables a pointer drag behavior on the bounding box of the gizmo
  42128. */
  42129. enableDragBehavior(): void;
  42130. /**
  42131. * Disposes of the gizmo
  42132. */
  42133. dispose(): void;
  42134. /**
  42135. * 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)
  42136. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  42137. * @returns the bounding box mesh with the passed in mesh as a child
  42138. */
  42139. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  42140. /**
  42141. * CustomMeshes are not supported by this gizmo
  42142. * @param mesh The mesh to replace the default mesh of the gizmo
  42143. */
  42144. setCustomMesh(mesh: Mesh): void;
  42145. }
  42146. }
  42147. declare module BABYLON {
  42148. /**
  42149. * Single plane rotation gizmo
  42150. */
  42151. export class PlaneRotationGizmo extends Gizmo {
  42152. /**
  42153. * Drag behavior responsible for the gizmos dragging interactions
  42154. */
  42155. dragBehavior: PointerDragBehavior;
  42156. private _pointerObserver;
  42157. /**
  42158. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  42159. */
  42160. snapDistance: number;
  42161. /**
  42162. * Event that fires each time the gizmo snaps to a new location.
  42163. * * snapDistance is the the change in distance
  42164. */
  42165. onSnapObservable: Observable<{
  42166. snapDistance: number;
  42167. }>;
  42168. /**
  42169. * Creates a PlaneRotationGizmo
  42170. * @param gizmoLayer The utility layer the gizmo will be added to
  42171. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  42172. * @param color The color of the gizmo
  42173. * @param tessellation Amount of tessellation to be used when creating rotation circles
  42174. */
  42175. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  42176. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42177. /**
  42178. * Disposes of the gizmo
  42179. */
  42180. dispose(): void;
  42181. }
  42182. }
  42183. declare module BABYLON {
  42184. /**
  42185. * Gizmo that enables rotating a mesh along 3 axis
  42186. */
  42187. export class RotationGizmo extends Gizmo {
  42188. /**
  42189. * Internal gizmo used for interactions on the x axis
  42190. */
  42191. xGizmo: PlaneRotationGizmo;
  42192. /**
  42193. * Internal gizmo used for interactions on the y axis
  42194. */
  42195. yGizmo: PlaneRotationGizmo;
  42196. /**
  42197. * Internal gizmo used for interactions on the z axis
  42198. */
  42199. zGizmo: PlaneRotationGizmo;
  42200. /** Fires an event when any of it's sub gizmos are dragged */
  42201. onDragStartObservable: Observable<{}>;
  42202. /** Fires an event when any of it's sub gizmos are released from dragging */
  42203. onDragEndObservable: Observable<{}>;
  42204. attachedMesh: Nullable<AbstractMesh>;
  42205. /**
  42206. * Creates a RotationGizmo
  42207. * @param gizmoLayer The utility layer the gizmo will be added to
  42208. * @param tessellation Amount of tessellation to be used when creating rotation circles
  42209. */
  42210. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  42211. updateGizmoRotationToMatchAttachedMesh: boolean;
  42212. /**
  42213. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42214. */
  42215. snapDistance: number;
  42216. /**
  42217. * Ratio for the scale of the gizmo (Default: 1)
  42218. */
  42219. scaleRatio: number;
  42220. /**
  42221. * Disposes of the gizmo
  42222. */
  42223. dispose(): void;
  42224. /**
  42225. * CustomMeshes are not supported by this gizmo
  42226. * @param mesh The mesh to replace the default mesh of the gizmo
  42227. */
  42228. setCustomMesh(mesh: Mesh): void;
  42229. }
  42230. }
  42231. declare module BABYLON {
  42232. /**
  42233. * Gizmo that enables dragging a mesh along 3 axis
  42234. */
  42235. export class PositionGizmo extends Gizmo {
  42236. /**
  42237. * Internal gizmo used for interactions on the x axis
  42238. */
  42239. xGizmo: AxisDragGizmo;
  42240. /**
  42241. * Internal gizmo used for interactions on the y axis
  42242. */
  42243. yGizmo: AxisDragGizmo;
  42244. /**
  42245. * Internal gizmo used for interactions on the z axis
  42246. */
  42247. zGizmo: AxisDragGizmo;
  42248. /** Fires an event when any of it's sub gizmos are dragged */
  42249. onDragStartObservable: Observable<{}>;
  42250. /** Fires an event when any of it's sub gizmos are released from dragging */
  42251. onDragEndObservable: Observable<{}>;
  42252. attachedMesh: Nullable<AbstractMesh>;
  42253. /**
  42254. * Creates a PositionGizmo
  42255. * @param gizmoLayer The utility layer the gizmo will be added to
  42256. */
  42257. constructor(gizmoLayer?: UtilityLayerRenderer);
  42258. updateGizmoRotationToMatchAttachedMesh: boolean;
  42259. /**
  42260. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42261. */
  42262. snapDistance: number;
  42263. /**
  42264. * Ratio for the scale of the gizmo (Default: 1)
  42265. */
  42266. scaleRatio: number;
  42267. /**
  42268. * Disposes of the gizmo
  42269. */
  42270. dispose(): void;
  42271. /**
  42272. * CustomMeshes are not supported by this gizmo
  42273. * @param mesh The mesh to replace the default mesh of the gizmo
  42274. */
  42275. setCustomMesh(mesh: Mesh): void;
  42276. }
  42277. }
  42278. declare module BABYLON {
  42279. /**
  42280. * Class containing static functions to help procedurally build meshes
  42281. */
  42282. export class PolyhedronBuilder {
  42283. /**
  42284. * Creates a polyhedron mesh
  42285. * * 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
  42286. * * The parameter `size` (positive float, default 1) sets the polygon size
  42287. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  42288. * * 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`
  42289. * * 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
  42290. * * 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)`)
  42291. * * 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
  42292. * * 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
  42293. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42294. * * 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
  42295. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42296. * @param name defines the name of the mesh
  42297. * @param options defines the options used to create the mesh
  42298. * @param scene defines the hosting scene
  42299. * @returns the polyhedron mesh
  42300. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  42301. */
  42302. static CreatePolyhedron(name: string, options: {
  42303. type?: number;
  42304. size?: number;
  42305. sizeX?: number;
  42306. sizeY?: number;
  42307. sizeZ?: number;
  42308. custom?: any;
  42309. faceUV?: Vector4[];
  42310. faceColors?: Color4[];
  42311. flat?: boolean;
  42312. updatable?: boolean;
  42313. sideOrientation?: number;
  42314. frontUVs?: Vector4;
  42315. backUVs?: Vector4;
  42316. }, scene: Scene): Mesh;
  42317. }
  42318. }
  42319. declare module BABYLON {
  42320. /**
  42321. * Gizmo that enables scaling a mesh along 3 axis
  42322. */
  42323. export class ScaleGizmo extends Gizmo {
  42324. /**
  42325. * Internal gizmo used for interactions on the x axis
  42326. */
  42327. xGizmo: AxisScaleGizmo;
  42328. /**
  42329. * Internal gizmo used for interactions on the y axis
  42330. */
  42331. yGizmo: AxisScaleGizmo;
  42332. /**
  42333. * Internal gizmo used for interactions on the z axis
  42334. */
  42335. zGizmo: AxisScaleGizmo;
  42336. /**
  42337. * Internal gizmo used to scale all axis equally
  42338. */
  42339. uniformScaleGizmo: AxisScaleGizmo;
  42340. /** Fires an event when any of it's sub gizmos are dragged */
  42341. onDragStartObservable: Observable<{}>;
  42342. /** Fires an event when any of it's sub gizmos are released from dragging */
  42343. onDragEndObservable: Observable<{}>;
  42344. attachedMesh: Nullable<AbstractMesh>;
  42345. /**
  42346. * Creates a ScaleGizmo
  42347. * @param gizmoLayer The utility layer the gizmo will be added to
  42348. */
  42349. constructor(gizmoLayer?: UtilityLayerRenderer);
  42350. updateGizmoRotationToMatchAttachedMesh: boolean;
  42351. /**
  42352. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42353. */
  42354. snapDistance: number;
  42355. /**
  42356. * Ratio for the scale of the gizmo (Default: 1)
  42357. */
  42358. scaleRatio: number;
  42359. /**
  42360. * Disposes of the gizmo
  42361. */
  42362. dispose(): void;
  42363. }
  42364. }
  42365. declare module BABYLON {
  42366. /**
  42367. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  42368. */
  42369. export class GizmoManager implements IDisposable {
  42370. private scene;
  42371. /**
  42372. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  42373. */
  42374. gizmos: {
  42375. positionGizmo: Nullable<PositionGizmo>;
  42376. rotationGizmo: Nullable<RotationGizmo>;
  42377. scaleGizmo: Nullable<ScaleGizmo>;
  42378. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  42379. };
  42380. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  42381. clearGizmoOnEmptyPointerEvent: boolean;
  42382. /** Fires an event when the manager is attached to a mesh */
  42383. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  42384. private _gizmosEnabled;
  42385. private _pointerObserver;
  42386. private _attachedMesh;
  42387. private _boundingBoxColor;
  42388. private _defaultUtilityLayer;
  42389. private _defaultKeepDepthUtilityLayer;
  42390. /**
  42391. * When bounding box gizmo is enabled, this can be used to track drag/end events
  42392. */
  42393. boundingBoxDragBehavior: SixDofDragBehavior;
  42394. /**
  42395. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  42396. */
  42397. attachableMeshes: Nullable<Array<AbstractMesh>>;
  42398. /**
  42399. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  42400. */
  42401. usePointerToAttachGizmos: boolean;
  42402. /**
  42403. * Instatiates a gizmo manager
  42404. * @param scene the scene to overlay the gizmos on top of
  42405. */
  42406. constructor(scene: Scene);
  42407. /**
  42408. * Attaches a set of gizmos to the specified mesh
  42409. * @param mesh The mesh the gizmo's should be attached to
  42410. */
  42411. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  42412. /**
  42413. * If the position gizmo is enabled
  42414. */
  42415. positionGizmoEnabled: boolean;
  42416. /**
  42417. * If the rotation gizmo is enabled
  42418. */
  42419. rotationGizmoEnabled: boolean;
  42420. /**
  42421. * If the scale gizmo is enabled
  42422. */
  42423. scaleGizmoEnabled: boolean;
  42424. /**
  42425. * If the boundingBox gizmo is enabled
  42426. */
  42427. boundingBoxGizmoEnabled: boolean;
  42428. /**
  42429. * Disposes of the gizmo manager
  42430. */
  42431. dispose(): void;
  42432. }
  42433. }
  42434. declare module BABYLON {
  42435. /**
  42436. * Gizmo that enables viewing a light
  42437. */
  42438. export class LightGizmo extends Gizmo {
  42439. private _box;
  42440. /**
  42441. * Creates a LightGizmo
  42442. * @param gizmoLayer The utility layer the gizmo will be added to
  42443. */
  42444. constructor(gizmoLayer?: UtilityLayerRenderer);
  42445. private _light;
  42446. /**
  42447. * The light that the gizmo is attached to
  42448. */
  42449. light: Nullable<Light>;
  42450. /**
  42451. * @hidden
  42452. * Updates the gizmo to match the attached mesh's position/rotation
  42453. */
  42454. protected _update(): void;
  42455. }
  42456. }
  42457. declare module BABYLON {
  42458. /** @hidden */
  42459. export var backgroundFragmentDeclaration: {
  42460. name: string;
  42461. shader: string;
  42462. };
  42463. }
  42464. declare module BABYLON {
  42465. /** @hidden */
  42466. export var backgroundUboDeclaration: {
  42467. name: string;
  42468. shader: string;
  42469. };
  42470. }
  42471. declare module BABYLON {
  42472. /** @hidden */
  42473. export var backgroundPixelShader: {
  42474. name: string;
  42475. shader: string;
  42476. };
  42477. }
  42478. declare module BABYLON {
  42479. /** @hidden */
  42480. export var backgroundVertexDeclaration: {
  42481. name: string;
  42482. shader: string;
  42483. };
  42484. }
  42485. declare module BABYLON {
  42486. /** @hidden */
  42487. export var backgroundVertexShader: {
  42488. name: string;
  42489. shader: string;
  42490. };
  42491. }
  42492. declare module BABYLON {
  42493. /**
  42494. * Background material used to create an efficient environement around your scene.
  42495. */
  42496. export class BackgroundMaterial extends PushMaterial {
  42497. /**
  42498. * Standard reflectance value at parallel view angle.
  42499. */
  42500. static StandardReflectance0: number;
  42501. /**
  42502. * Standard reflectance value at grazing angle.
  42503. */
  42504. static StandardReflectance90: number;
  42505. protected _primaryColor: Color3;
  42506. /**
  42507. * Key light Color (multiply against the environement texture)
  42508. */
  42509. primaryColor: Color3;
  42510. protected __perceptualColor: Nullable<Color3>;
  42511. /**
  42512. * Experimental Internal Use Only.
  42513. *
  42514. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  42515. * This acts as a helper to set the primary color to a more "human friendly" value.
  42516. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  42517. * output color as close as possible from the chosen value.
  42518. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  42519. * part of lighting setup.)
  42520. */
  42521. _perceptualColor: Nullable<Color3>;
  42522. protected _primaryColorShadowLevel: float;
  42523. /**
  42524. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  42525. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  42526. */
  42527. primaryColorShadowLevel: float;
  42528. protected _primaryColorHighlightLevel: float;
  42529. /**
  42530. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  42531. * The primary color is used at the level chosen to define what the white area would look.
  42532. */
  42533. primaryColorHighlightLevel: float;
  42534. protected _reflectionTexture: Nullable<BaseTexture>;
  42535. /**
  42536. * Reflection Texture used in the material.
  42537. * Should be author in a specific way for the best result (refer to the documentation).
  42538. */
  42539. reflectionTexture: Nullable<BaseTexture>;
  42540. protected _reflectionBlur: float;
  42541. /**
  42542. * Reflection Texture level of blur.
  42543. *
  42544. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  42545. * texture twice.
  42546. */
  42547. reflectionBlur: float;
  42548. protected _diffuseTexture: Nullable<BaseTexture>;
  42549. /**
  42550. * Diffuse Texture used in the material.
  42551. * Should be author in a specific way for the best result (refer to the documentation).
  42552. */
  42553. diffuseTexture: Nullable<BaseTexture>;
  42554. protected _shadowLights: Nullable<IShadowLight[]>;
  42555. /**
  42556. * Specify the list of lights casting shadow on the material.
  42557. * All scene shadow lights will be included if null.
  42558. */
  42559. shadowLights: Nullable<IShadowLight[]>;
  42560. protected _shadowLevel: float;
  42561. /**
  42562. * Helps adjusting the shadow to a softer level if required.
  42563. * 0 means black shadows and 1 means no shadows.
  42564. */
  42565. shadowLevel: float;
  42566. protected _sceneCenter: Vector3;
  42567. /**
  42568. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  42569. * It is usually zero but might be interesting to modify according to your setup.
  42570. */
  42571. sceneCenter: Vector3;
  42572. protected _opacityFresnel: boolean;
  42573. /**
  42574. * This helps specifying that the material is falling off to the sky box at grazing angle.
  42575. * This helps ensuring a nice transition when the camera goes under the ground.
  42576. */
  42577. opacityFresnel: boolean;
  42578. protected _reflectionFresnel: boolean;
  42579. /**
  42580. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  42581. * This helps adding a mirror texture on the ground.
  42582. */
  42583. reflectionFresnel: boolean;
  42584. protected _reflectionFalloffDistance: number;
  42585. /**
  42586. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  42587. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  42588. */
  42589. reflectionFalloffDistance: number;
  42590. protected _reflectionAmount: number;
  42591. /**
  42592. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  42593. */
  42594. reflectionAmount: number;
  42595. protected _reflectionReflectance0: number;
  42596. /**
  42597. * This specifies the weight of the reflection at grazing angle.
  42598. */
  42599. reflectionReflectance0: number;
  42600. protected _reflectionReflectance90: number;
  42601. /**
  42602. * This specifies the weight of the reflection at a perpendicular point of view.
  42603. */
  42604. reflectionReflectance90: number;
  42605. /**
  42606. * Sets the reflection reflectance fresnel values according to the default standard
  42607. * empirically know to work well :-)
  42608. */
  42609. reflectionStandardFresnelWeight: number;
  42610. protected _useRGBColor: boolean;
  42611. /**
  42612. * Helps to directly use the maps channels instead of their level.
  42613. */
  42614. useRGBColor: boolean;
  42615. protected _enableNoise: boolean;
  42616. /**
  42617. * This helps reducing the banding effect that could occur on the background.
  42618. */
  42619. enableNoise: boolean;
  42620. /**
  42621. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  42622. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  42623. * Recommended to be keep at 1.0 except for special cases.
  42624. */
  42625. fovMultiplier: number;
  42626. private _fovMultiplier;
  42627. /**
  42628. * Enable the FOV adjustment feature controlled by fovMultiplier.
  42629. */
  42630. useEquirectangularFOV: boolean;
  42631. private _maxSimultaneousLights;
  42632. /**
  42633. * Number of Simultaneous lights allowed on the material.
  42634. */
  42635. maxSimultaneousLights: int;
  42636. /**
  42637. * Default configuration related to image processing available in the Background Material.
  42638. */
  42639. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42640. /**
  42641. * Keep track of the image processing observer to allow dispose and replace.
  42642. */
  42643. private _imageProcessingObserver;
  42644. /**
  42645. * Attaches a new image processing configuration to the PBR Material.
  42646. * @param configuration (if null the scene configuration will be use)
  42647. */
  42648. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  42649. /**
  42650. * Gets the image processing configuration used either in this material.
  42651. */
  42652. /**
  42653. * Sets the Default image processing configuration used either in the this material.
  42654. *
  42655. * If sets to null, the scene one is in use.
  42656. */
  42657. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  42658. /**
  42659. * Gets wether the color curves effect is enabled.
  42660. */
  42661. /**
  42662. * Sets wether the color curves effect is enabled.
  42663. */
  42664. cameraColorCurvesEnabled: boolean;
  42665. /**
  42666. * Gets wether the color grading effect is enabled.
  42667. */
  42668. /**
  42669. * Gets wether the color grading effect is enabled.
  42670. */
  42671. cameraColorGradingEnabled: boolean;
  42672. /**
  42673. * Gets wether tonemapping is enabled or not.
  42674. */
  42675. /**
  42676. * Sets wether tonemapping is enabled or not
  42677. */
  42678. cameraToneMappingEnabled: boolean;
  42679. /**
  42680. * The camera exposure used on this material.
  42681. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  42682. * This corresponds to a photographic exposure.
  42683. */
  42684. /**
  42685. * The camera exposure used on this material.
  42686. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  42687. * This corresponds to a photographic exposure.
  42688. */
  42689. cameraExposure: float;
  42690. /**
  42691. * Gets The camera contrast used on this material.
  42692. */
  42693. /**
  42694. * Sets The camera contrast used on this material.
  42695. */
  42696. cameraContrast: float;
  42697. /**
  42698. * Gets the Color Grading 2D Lookup Texture.
  42699. */
  42700. /**
  42701. * Sets the Color Grading 2D Lookup Texture.
  42702. */
  42703. cameraColorGradingTexture: Nullable<BaseTexture>;
  42704. /**
  42705. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  42706. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  42707. * 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;
  42708. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  42709. */
  42710. /**
  42711. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  42712. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  42713. * 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;
  42714. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  42715. */
  42716. cameraColorCurves: Nullable<ColorCurves>;
  42717. /**
  42718. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  42719. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  42720. */
  42721. switchToBGR: boolean;
  42722. private _renderTargets;
  42723. private _reflectionControls;
  42724. private _white;
  42725. private _primaryShadowColor;
  42726. private _primaryHighlightColor;
  42727. /**
  42728. * Instantiates a Background Material in the given scene
  42729. * @param name The friendly name of the material
  42730. * @param scene The scene to add the material to
  42731. */
  42732. constructor(name: string, scene: Scene);
  42733. /**
  42734. * Gets a boolean indicating that current material needs to register RTT
  42735. */
  42736. readonly hasRenderTargetTextures: boolean;
  42737. /**
  42738. * The entire material has been created in order to prevent overdraw.
  42739. * @returns false
  42740. */
  42741. needAlphaTesting(): boolean;
  42742. /**
  42743. * The entire material has been created in order to prevent overdraw.
  42744. * @returns true if blending is enable
  42745. */
  42746. needAlphaBlending(): boolean;
  42747. /**
  42748. * Checks wether the material is ready to be rendered for a given mesh.
  42749. * @param mesh The mesh to render
  42750. * @param subMesh The submesh to check against
  42751. * @param useInstances Specify wether or not the material is used with instances
  42752. * @returns true if all the dependencies are ready (Textures, Effects...)
  42753. */
  42754. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  42755. /**
  42756. * Compute the primary color according to the chosen perceptual color.
  42757. */
  42758. private _computePrimaryColorFromPerceptualColor;
  42759. /**
  42760. * Compute the highlights and shadow colors according to their chosen levels.
  42761. */
  42762. private _computePrimaryColors;
  42763. /**
  42764. * Build the uniform buffer used in the material.
  42765. */
  42766. buildUniformLayout(): void;
  42767. /**
  42768. * Unbind the material.
  42769. */
  42770. unbind(): void;
  42771. /**
  42772. * Bind only the world matrix to the material.
  42773. * @param world The world matrix to bind.
  42774. */
  42775. bindOnlyWorldMatrix(world: Matrix): void;
  42776. /**
  42777. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  42778. * @param world The world matrix to bind.
  42779. * @param subMesh The submesh to bind for.
  42780. */
  42781. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  42782. /**
  42783. * Dispose the material.
  42784. * @param forceDisposeEffect Force disposal of the associated effect.
  42785. * @param forceDisposeTextures Force disposal of the associated textures.
  42786. */
  42787. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  42788. /**
  42789. * Clones the material.
  42790. * @param name The cloned name.
  42791. * @returns The cloned material.
  42792. */
  42793. clone(name: string): BackgroundMaterial;
  42794. /**
  42795. * Serializes the current material to its JSON representation.
  42796. * @returns The JSON representation.
  42797. */
  42798. serialize(): any;
  42799. /**
  42800. * Gets the class name of the material
  42801. * @returns "BackgroundMaterial"
  42802. */
  42803. getClassName(): string;
  42804. /**
  42805. * Parse a JSON input to create back a background material.
  42806. * @param source The JSON data to parse
  42807. * @param scene The scene to create the parsed material in
  42808. * @param rootUrl The root url of the assets the material depends upon
  42809. * @returns the instantiated BackgroundMaterial.
  42810. */
  42811. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  42812. }
  42813. }
  42814. declare module BABYLON {
  42815. /**
  42816. * Represents the different options available during the creation of
  42817. * a Environment helper.
  42818. *
  42819. * This can control the default ground, skybox and image processing setup of your scene.
  42820. */
  42821. export interface IEnvironmentHelperOptions {
  42822. /**
  42823. * Specifies wether or not to create a ground.
  42824. * True by default.
  42825. */
  42826. createGround: boolean;
  42827. /**
  42828. * Specifies the ground size.
  42829. * 15 by default.
  42830. */
  42831. groundSize: number;
  42832. /**
  42833. * The texture used on the ground for the main color.
  42834. * Comes from the BabylonJS CDN by default.
  42835. *
  42836. * Remarks: Can be either a texture or a url.
  42837. */
  42838. groundTexture: string | BaseTexture;
  42839. /**
  42840. * The color mixed in the ground texture by default.
  42841. * BabylonJS clearColor by default.
  42842. */
  42843. groundColor: Color3;
  42844. /**
  42845. * Specifies the ground opacity.
  42846. * 1 by default.
  42847. */
  42848. groundOpacity: number;
  42849. /**
  42850. * Enables the ground to receive shadows.
  42851. * True by default.
  42852. */
  42853. enableGroundShadow: boolean;
  42854. /**
  42855. * Helps preventing the shadow to be fully black on the ground.
  42856. * 0.5 by default.
  42857. */
  42858. groundShadowLevel: number;
  42859. /**
  42860. * Creates a mirror texture attach to the ground.
  42861. * false by default.
  42862. */
  42863. enableGroundMirror: boolean;
  42864. /**
  42865. * Specifies the ground mirror size ratio.
  42866. * 0.3 by default as the default kernel is 64.
  42867. */
  42868. groundMirrorSizeRatio: number;
  42869. /**
  42870. * Specifies the ground mirror blur kernel size.
  42871. * 64 by default.
  42872. */
  42873. groundMirrorBlurKernel: number;
  42874. /**
  42875. * Specifies the ground mirror visibility amount.
  42876. * 1 by default
  42877. */
  42878. groundMirrorAmount: number;
  42879. /**
  42880. * Specifies the ground mirror reflectance weight.
  42881. * This uses the standard weight of the background material to setup the fresnel effect
  42882. * of the mirror.
  42883. * 1 by default.
  42884. */
  42885. groundMirrorFresnelWeight: number;
  42886. /**
  42887. * Specifies the ground mirror Falloff distance.
  42888. * This can helps reducing the size of the reflection.
  42889. * 0 by Default.
  42890. */
  42891. groundMirrorFallOffDistance: number;
  42892. /**
  42893. * Specifies the ground mirror texture type.
  42894. * Unsigned Int by Default.
  42895. */
  42896. groundMirrorTextureType: number;
  42897. /**
  42898. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  42899. * the shown objects.
  42900. */
  42901. groundYBias: number;
  42902. /**
  42903. * Specifies wether or not to create a skybox.
  42904. * True by default.
  42905. */
  42906. createSkybox: boolean;
  42907. /**
  42908. * Specifies the skybox size.
  42909. * 20 by default.
  42910. */
  42911. skyboxSize: number;
  42912. /**
  42913. * The texture used on the skybox for the main color.
  42914. * Comes from the BabylonJS CDN by default.
  42915. *
  42916. * Remarks: Can be either a texture or a url.
  42917. */
  42918. skyboxTexture: string | BaseTexture;
  42919. /**
  42920. * The color mixed in the skybox texture by default.
  42921. * BabylonJS clearColor by default.
  42922. */
  42923. skyboxColor: Color3;
  42924. /**
  42925. * The background rotation around the Y axis of the scene.
  42926. * This helps aligning the key lights of your scene with the background.
  42927. * 0 by default.
  42928. */
  42929. backgroundYRotation: number;
  42930. /**
  42931. * Compute automatically the size of the elements to best fit with the scene.
  42932. */
  42933. sizeAuto: boolean;
  42934. /**
  42935. * Default position of the rootMesh if autoSize is not true.
  42936. */
  42937. rootPosition: Vector3;
  42938. /**
  42939. * Sets up the image processing in the scene.
  42940. * true by default.
  42941. */
  42942. setupImageProcessing: boolean;
  42943. /**
  42944. * The texture used as your environment texture in the scene.
  42945. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  42946. *
  42947. * Remarks: Can be either a texture or a url.
  42948. */
  42949. environmentTexture: string | BaseTexture;
  42950. /**
  42951. * The value of the exposure to apply to the scene.
  42952. * 0.6 by default if setupImageProcessing is true.
  42953. */
  42954. cameraExposure: number;
  42955. /**
  42956. * The value of the contrast to apply to the scene.
  42957. * 1.6 by default if setupImageProcessing is true.
  42958. */
  42959. cameraContrast: number;
  42960. /**
  42961. * Specifies wether or not tonemapping should be enabled in the scene.
  42962. * true by default if setupImageProcessing is true.
  42963. */
  42964. toneMappingEnabled: boolean;
  42965. }
  42966. /**
  42967. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  42968. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  42969. * It also helps with the default setup of your imageProcessing configuration.
  42970. */
  42971. export class EnvironmentHelper {
  42972. /**
  42973. * Default ground texture URL.
  42974. */
  42975. private static _groundTextureCDNUrl;
  42976. /**
  42977. * Default skybox texture URL.
  42978. */
  42979. private static _skyboxTextureCDNUrl;
  42980. /**
  42981. * Default environment texture URL.
  42982. */
  42983. private static _environmentTextureCDNUrl;
  42984. /**
  42985. * Creates the default options for the helper.
  42986. */
  42987. private static _getDefaultOptions;
  42988. private _rootMesh;
  42989. /**
  42990. * Gets the root mesh created by the helper.
  42991. */
  42992. readonly rootMesh: Mesh;
  42993. private _skybox;
  42994. /**
  42995. * Gets the skybox created by the helper.
  42996. */
  42997. readonly skybox: Nullable<Mesh>;
  42998. private _skyboxTexture;
  42999. /**
  43000. * Gets the skybox texture created by the helper.
  43001. */
  43002. readonly skyboxTexture: Nullable<BaseTexture>;
  43003. private _skyboxMaterial;
  43004. /**
  43005. * Gets the skybox material created by the helper.
  43006. */
  43007. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  43008. private _ground;
  43009. /**
  43010. * Gets the ground mesh created by the helper.
  43011. */
  43012. readonly ground: Nullable<Mesh>;
  43013. private _groundTexture;
  43014. /**
  43015. * Gets the ground texture created by the helper.
  43016. */
  43017. readonly groundTexture: Nullable<BaseTexture>;
  43018. private _groundMirror;
  43019. /**
  43020. * Gets the ground mirror created by the helper.
  43021. */
  43022. readonly groundMirror: Nullable<MirrorTexture>;
  43023. /**
  43024. * Gets the ground mirror render list to helps pushing the meshes
  43025. * you wish in the ground reflection.
  43026. */
  43027. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  43028. private _groundMaterial;
  43029. /**
  43030. * Gets the ground material created by the helper.
  43031. */
  43032. readonly groundMaterial: Nullable<BackgroundMaterial>;
  43033. /**
  43034. * Stores the creation options.
  43035. */
  43036. private readonly _scene;
  43037. private _options;
  43038. /**
  43039. * This observable will be notified with any error during the creation of the environment,
  43040. * mainly texture creation errors.
  43041. */
  43042. onErrorObservable: Observable<{
  43043. message?: string;
  43044. exception?: any;
  43045. }>;
  43046. /**
  43047. * constructor
  43048. * @param options Defines the options we want to customize the helper
  43049. * @param scene The scene to add the material to
  43050. */
  43051. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  43052. /**
  43053. * Updates the background according to the new options
  43054. * @param options
  43055. */
  43056. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  43057. /**
  43058. * Sets the primary color of all the available elements.
  43059. * @param color the main color to affect to the ground and the background
  43060. */
  43061. setMainColor(color: Color3): void;
  43062. /**
  43063. * Setup the image processing according to the specified options.
  43064. */
  43065. private _setupImageProcessing;
  43066. /**
  43067. * Setup the environment texture according to the specified options.
  43068. */
  43069. private _setupEnvironmentTexture;
  43070. /**
  43071. * Setup the background according to the specified options.
  43072. */
  43073. private _setupBackground;
  43074. /**
  43075. * Get the scene sizes according to the setup.
  43076. */
  43077. private _getSceneSize;
  43078. /**
  43079. * Setup the ground according to the specified options.
  43080. */
  43081. private _setupGround;
  43082. /**
  43083. * Setup the ground material according to the specified options.
  43084. */
  43085. private _setupGroundMaterial;
  43086. /**
  43087. * Setup the ground diffuse texture according to the specified options.
  43088. */
  43089. private _setupGroundDiffuseTexture;
  43090. /**
  43091. * Setup the ground mirror texture according to the specified options.
  43092. */
  43093. private _setupGroundMirrorTexture;
  43094. /**
  43095. * Setup the ground to receive the mirror texture.
  43096. */
  43097. private _setupMirrorInGroundMaterial;
  43098. /**
  43099. * Setup the skybox according to the specified options.
  43100. */
  43101. private _setupSkybox;
  43102. /**
  43103. * Setup the skybox material according to the specified options.
  43104. */
  43105. private _setupSkyboxMaterial;
  43106. /**
  43107. * Setup the skybox reflection texture according to the specified options.
  43108. */
  43109. private _setupSkyboxReflectionTexture;
  43110. private _errorHandler;
  43111. /**
  43112. * Dispose all the elements created by the Helper.
  43113. */
  43114. dispose(): void;
  43115. }
  43116. }
  43117. declare module BABYLON {
  43118. /**
  43119. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  43120. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  43121. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  43122. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  43123. */
  43124. export class PhotoDome extends TransformNode {
  43125. private _useDirectMapping;
  43126. /**
  43127. * The texture being displayed on the sphere
  43128. */
  43129. protected _photoTexture: Texture;
  43130. /**
  43131. * Gets or sets the texture being displayed on the sphere
  43132. */
  43133. photoTexture: Texture;
  43134. /**
  43135. * Observable raised when an error occured while loading the 360 image
  43136. */
  43137. onLoadErrorObservable: Observable<string>;
  43138. /**
  43139. * The skybox material
  43140. */
  43141. protected _material: BackgroundMaterial;
  43142. /**
  43143. * The surface used for the skybox
  43144. */
  43145. protected _mesh: Mesh;
  43146. /**
  43147. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43148. * Also see the options.resolution property.
  43149. */
  43150. fovMultiplier: number;
  43151. /**
  43152. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  43153. * @param name Element's name, child elements will append suffixes for their own names.
  43154. * @param urlsOfPhoto defines the url of the photo to display
  43155. * @param options defines an object containing optional or exposed sub element properties
  43156. * @param onError defines a callback called when an error occured while loading the texture
  43157. */
  43158. constructor(name: string, urlOfPhoto: string, options: {
  43159. resolution?: number;
  43160. size?: number;
  43161. useDirectMapping?: boolean;
  43162. faceForward?: boolean;
  43163. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  43164. /**
  43165. * Releases resources associated with this node.
  43166. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  43167. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  43168. */
  43169. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  43170. }
  43171. }
  43172. declare module BABYLON {
  43173. /**
  43174. * Class used to host texture specific utilities
  43175. */
  43176. export class BRDFTextureTools {
  43177. /**
  43178. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  43179. * @param texture the texture to expand.
  43180. */
  43181. private static _ExpandDefaultBRDFTexture;
  43182. /**
  43183. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  43184. * @param scene defines the hosting scene
  43185. * @returns the environment BRDF texture
  43186. */
  43187. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  43188. private static _environmentBRDFBase64Texture;
  43189. }
  43190. }
  43191. declare module BABYLON {
  43192. /**
  43193. * @hidden
  43194. */
  43195. export interface IMaterialClearCoatDefines {
  43196. CLEARCOAT: boolean;
  43197. CLEARCOAT_DEFAULTIOR: boolean;
  43198. CLEARCOAT_TEXTURE: boolean;
  43199. CLEARCOAT_TEXTUREDIRECTUV: number;
  43200. CLEARCOAT_BUMP: boolean;
  43201. CLEARCOAT_BUMPDIRECTUV: number;
  43202. CLEARCOAT_TINT: boolean;
  43203. CLEARCOAT_TINT_TEXTURE: boolean;
  43204. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  43205. /** @hidden */
  43206. _areTexturesDirty: boolean;
  43207. }
  43208. /**
  43209. * Define the code related to the clear coat parameters of the pbr material.
  43210. */
  43211. export class PBRClearCoatConfiguration {
  43212. /**
  43213. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  43214. * The default fits with a polyurethane material.
  43215. */
  43216. private static readonly _DefaultIndiceOfRefraction;
  43217. private _isEnabled;
  43218. /**
  43219. * Defines if the clear coat is enabled in the material.
  43220. */
  43221. isEnabled: boolean;
  43222. /**
  43223. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  43224. */
  43225. intensity: number;
  43226. /**
  43227. * Defines the clear coat layer roughness.
  43228. */
  43229. roughness: number;
  43230. private _indiceOfRefraction;
  43231. /**
  43232. * Defines the indice of refraction of the clear coat.
  43233. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  43234. * The default fits with a polyurethane material.
  43235. * Changing the default value is more performance intensive.
  43236. */
  43237. indiceOfRefraction: number;
  43238. private _texture;
  43239. /**
  43240. * Stores the clear coat values in a texture.
  43241. */
  43242. texture: Nullable<BaseTexture>;
  43243. private _bumpTexture;
  43244. /**
  43245. * Define the clear coat specific bump texture.
  43246. */
  43247. bumpTexture: Nullable<BaseTexture>;
  43248. private _isTintEnabled;
  43249. /**
  43250. * Defines if the clear coat tint is enabled in the material.
  43251. */
  43252. isTintEnabled: boolean;
  43253. /**
  43254. * Defines if the clear coat tint is enabled in the material.
  43255. * This is only use if tint is enabled
  43256. */
  43257. tintColor: Color3;
  43258. /**
  43259. * Defines if the distance at which the tint color should be found in the
  43260. * clear coat media.
  43261. * This is only use if tint is enabled
  43262. */
  43263. tintColorAtDistance: number;
  43264. /**
  43265. * Defines the clear coat layer thickness.
  43266. * This is only use if tint is enabled
  43267. */
  43268. tintThickness: number;
  43269. private _tintTexture;
  43270. /**
  43271. * Stores the clear tint values in a texture.
  43272. * rgb is tint
  43273. * a is a thickness factor
  43274. */
  43275. tintTexture: Nullable<BaseTexture>;
  43276. /** @hidden */
  43277. private _internalMarkAllSubMeshesAsTexturesDirty;
  43278. /** @hidden */
  43279. _markAllSubMeshesAsTexturesDirty(): void;
  43280. /**
  43281. * Instantiate a new istance of clear coat configuration.
  43282. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  43283. */
  43284. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  43285. /**
  43286. * Specifies that the submesh is ready to be used.
  43287. * @param defines the list of "defines" to update.
  43288. * @param scene defines the scene the material belongs to.
  43289. * @param engine defines the engine the material belongs to.
  43290. * @param disableBumpMap defines wether the material disables bump or not.
  43291. * @returns - boolean indicating that the submesh is ready or not.
  43292. */
  43293. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  43294. /**
  43295. * Checks to see if a texture is used in the material.
  43296. * @param defines the list of "defines" to update.
  43297. * @param scene defines the scene to the material belongs to.
  43298. */
  43299. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  43300. /**
  43301. * Binds the material data.
  43302. * @param uniformBuffer defines the Uniform buffer to fill in.
  43303. * @param scene defines the scene the material belongs to.
  43304. * @param engine defines the engine the material belongs to.
  43305. * @param disableBumpMap defines wether the material disables bump or not.
  43306. * @param isFrozen defines wether the material is frozen or not.
  43307. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  43308. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  43309. */
  43310. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  43311. /**
  43312. * Checks to see if a texture is used in the material.
  43313. * @param texture - Base texture to use.
  43314. * @returns - Boolean specifying if a texture is used in the material.
  43315. */
  43316. hasTexture(texture: BaseTexture): boolean;
  43317. /**
  43318. * Returns an array of the actively used textures.
  43319. * @param activeTextures Array of BaseTextures
  43320. */
  43321. getActiveTextures(activeTextures: BaseTexture[]): void;
  43322. /**
  43323. * Returns the animatable textures.
  43324. * @param animatables Array of animatable textures.
  43325. */
  43326. getAnimatables(animatables: IAnimatable[]): void;
  43327. /**
  43328. * Disposes the resources of the material.
  43329. * @param forceDisposeTextures - Forces the disposal of all textures.
  43330. */
  43331. dispose(forceDisposeTextures?: boolean): void;
  43332. /**
  43333. * Get the current class name of the texture useful for serialization or dynamic coding.
  43334. * @returns "PBRClearCoatConfiguration"
  43335. */
  43336. getClassName(): string;
  43337. /**
  43338. * Add fallbacks to the effect fallbacks list.
  43339. * @param defines defines the Base texture to use.
  43340. * @param fallbacks defines the current fallback list.
  43341. * @param currentRank defines the current fallback rank.
  43342. * @returns the new fallback rank.
  43343. */
  43344. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  43345. /**
  43346. * Add the required uniforms to the current list.
  43347. * @param uniforms defines the current uniform list.
  43348. */
  43349. static AddUniforms(uniforms: string[]): void;
  43350. /**
  43351. * Add the required samplers to the current list.
  43352. * @param samplers defines the current sampler list.
  43353. */
  43354. static AddSamplers(samplers: string[]): void;
  43355. /**
  43356. * Add the required uniforms to the current buffer.
  43357. * @param uniformBuffer defines the current uniform buffer.
  43358. */
  43359. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  43360. /**
  43361. * Makes a duplicate of the current configuration into another one.
  43362. * @param clearCoatConfiguration define the config where to copy the info
  43363. */
  43364. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  43365. /**
  43366. * Serializes this clear coat configuration.
  43367. * @returns - An object with the serialized config.
  43368. */
  43369. serialize(): any;
  43370. /**
  43371. * Parses a Clear Coat Configuration from a serialized object.
  43372. * @param source - Serialized object.
  43373. */
  43374. parse(source: any): void;
  43375. }
  43376. }
  43377. declare module BABYLON {
  43378. /**
  43379. * @hidden
  43380. */
  43381. export interface IMaterialAnisotropicDefines {
  43382. ANISOTROPIC: boolean;
  43383. ANISOTROPIC_TEXTURE: boolean;
  43384. ANISOTROPIC_TEXTUREDIRECTUV: number;
  43385. MAINUV1: boolean;
  43386. _areTexturesDirty: boolean;
  43387. _needUVs: boolean;
  43388. }
  43389. /**
  43390. * Define the code related to the anisotropic parameters of the pbr material.
  43391. */
  43392. export class PBRAnisotropicConfiguration {
  43393. private _isEnabled;
  43394. /**
  43395. * Defines if the anisotropy is enabled in the material.
  43396. */
  43397. isEnabled: boolean;
  43398. /**
  43399. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  43400. */
  43401. intensity: number;
  43402. /**
  43403. * Defines if the effect is along the tangents, bitangents or in between.
  43404. * By default, the effect is "strectching" the highlights along the tangents.
  43405. */
  43406. direction: Vector2;
  43407. private _texture;
  43408. /**
  43409. * Stores the anisotropy values in a texture.
  43410. * rg is direction (like normal from -1 to 1)
  43411. * b is a intensity
  43412. */
  43413. texture: Nullable<BaseTexture>;
  43414. /** @hidden */
  43415. private _internalMarkAllSubMeshesAsTexturesDirty;
  43416. /** @hidden */
  43417. _markAllSubMeshesAsTexturesDirty(): void;
  43418. /**
  43419. * Instantiate a new istance of anisotropy configuration.
  43420. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  43421. */
  43422. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  43423. /**
  43424. * Specifies that the submesh is ready to be used.
  43425. * @param defines the list of "defines" to update.
  43426. * @param scene defines the scene the material belongs to.
  43427. * @returns - boolean indicating that the submesh is ready or not.
  43428. */
  43429. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  43430. /**
  43431. * Checks to see if a texture is used in the material.
  43432. * @param defines the list of "defines" to update.
  43433. * @param mesh the mesh we are preparing the defines for.
  43434. * @param scene defines the scene the material belongs to.
  43435. */
  43436. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  43437. /**
  43438. * Binds the material data.
  43439. * @param uniformBuffer defines the Uniform buffer to fill in.
  43440. * @param scene defines the scene the material belongs to.
  43441. * @param isFrozen defines wether the material is frozen or not.
  43442. */
  43443. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  43444. /**
  43445. * Checks to see if a texture is used in the material.
  43446. * @param texture - Base texture to use.
  43447. * @returns - Boolean specifying if a texture is used in the material.
  43448. */
  43449. hasTexture(texture: BaseTexture): boolean;
  43450. /**
  43451. * Returns an array of the actively used textures.
  43452. * @param activeTextures Array of BaseTextures
  43453. */
  43454. getActiveTextures(activeTextures: BaseTexture[]): void;
  43455. /**
  43456. * Returns the animatable textures.
  43457. * @param animatables Array of animatable textures.
  43458. */
  43459. getAnimatables(animatables: IAnimatable[]): void;
  43460. /**
  43461. * Disposes the resources of the material.
  43462. * @param forceDisposeTextures - Forces the disposal of all textures.
  43463. */
  43464. dispose(forceDisposeTextures?: boolean): void;
  43465. /**
  43466. * Get the current class name of the texture useful for serialization or dynamic coding.
  43467. * @returns "PBRAnisotropicConfiguration"
  43468. */
  43469. getClassName(): string;
  43470. /**
  43471. * Add fallbacks to the effect fallbacks list.
  43472. * @param defines defines the Base texture to use.
  43473. * @param fallbacks defines the current fallback list.
  43474. * @param currentRank defines the current fallback rank.
  43475. * @returns the new fallback rank.
  43476. */
  43477. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  43478. /**
  43479. * Add the required uniforms to the current list.
  43480. * @param uniforms defines the current uniform list.
  43481. */
  43482. static AddUniforms(uniforms: string[]): void;
  43483. /**
  43484. * Add the required uniforms to the current buffer.
  43485. * @param uniformBuffer defines the current uniform buffer.
  43486. */
  43487. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  43488. /**
  43489. * Add the required samplers to the current list.
  43490. * @param samplers defines the current sampler list.
  43491. */
  43492. static AddSamplers(samplers: string[]): void;
  43493. /**
  43494. * Makes a duplicate of the current configuration into another one.
  43495. * @param anisotropicConfiguration define the config where to copy the info
  43496. */
  43497. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  43498. /**
  43499. * Serializes this anisotropy configuration.
  43500. * @returns - An object with the serialized config.
  43501. */
  43502. serialize(): any;
  43503. /**
  43504. * Parses a anisotropy Configuration from a serialized object.
  43505. * @param source - Serialized object.
  43506. */
  43507. parse(source: any): void;
  43508. }
  43509. }
  43510. declare module BABYLON {
  43511. /**
  43512. * @hidden
  43513. */
  43514. export interface IMaterialBRDFDefines {
  43515. BRDF_V_HEIGHT_CORRELATED: boolean;
  43516. MS_BRDF_ENERGY_CONSERVATION: boolean;
  43517. /** @hidden */
  43518. _areMiscDirty: boolean;
  43519. }
  43520. /**
  43521. * Define the code related to the BRDF parameters of the pbr material.
  43522. */
  43523. export class PBRBRDFConfiguration {
  43524. /**
  43525. * Default value used for the energy conservation.
  43526. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  43527. */
  43528. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  43529. /**
  43530. * Default value used for the Smith Visibility Height Correlated mode.
  43531. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  43532. */
  43533. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  43534. private _useEnergyConservation;
  43535. /**
  43536. * Defines if the material uses energy conservation.
  43537. */
  43538. useEnergyConservation: boolean;
  43539. private _useSmithVisibilityHeightCorrelated;
  43540. /**
  43541. * LEGACY Mode set to false
  43542. * Defines if the material uses height smith correlated visibility term.
  43543. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  43544. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  43545. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  43546. * Not relying on height correlated will also disable energy conservation.
  43547. */
  43548. useSmithVisibilityHeightCorrelated: boolean;
  43549. /** @hidden */
  43550. private _internalMarkAllSubMeshesAsMiscDirty;
  43551. /** @hidden */
  43552. _markAllSubMeshesAsMiscDirty(): void;
  43553. /**
  43554. * Instantiate a new istance of clear coat configuration.
  43555. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  43556. */
  43557. constructor(markAllSubMeshesAsMiscDirty: () => void);
  43558. /**
  43559. * Checks to see if a texture is used in the material.
  43560. * @param defines the list of "defines" to update.
  43561. */
  43562. prepareDefines(defines: IMaterialBRDFDefines): void;
  43563. /**
  43564. * Get the current class name of the texture useful for serialization or dynamic coding.
  43565. * @returns "PBRClearCoatConfiguration"
  43566. */
  43567. getClassName(): string;
  43568. /**
  43569. * Makes a duplicate of the current configuration into another one.
  43570. * @param brdfConfiguration define the config where to copy the info
  43571. */
  43572. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  43573. /**
  43574. * Serializes this BRDF configuration.
  43575. * @returns - An object with the serialized config.
  43576. */
  43577. serialize(): any;
  43578. /**
  43579. * Parses a BRDF Configuration from a serialized object.
  43580. * @param source - Serialized object.
  43581. */
  43582. parse(source: any): void;
  43583. }
  43584. }
  43585. declare module BABYLON {
  43586. /**
  43587. * @hidden
  43588. */
  43589. export interface IMaterialSheenDefines {
  43590. SHEEN: boolean;
  43591. SHEEN_TEXTURE: boolean;
  43592. SHEEN_TEXTUREDIRECTUV: number;
  43593. SHEEN_LINKWITHALBEDO: boolean;
  43594. /** @hidden */
  43595. _areTexturesDirty: boolean;
  43596. }
  43597. /**
  43598. * Define the code related to the Sheen parameters of the pbr material.
  43599. */
  43600. export class PBRSheenConfiguration {
  43601. private _isEnabled;
  43602. /**
  43603. * Defines if the material uses sheen.
  43604. */
  43605. isEnabled: boolean;
  43606. private _linkSheenWithAlbedo;
  43607. /**
  43608. * Defines if the sheen is linked to the sheen color.
  43609. */
  43610. linkSheenWithAlbedo: boolean;
  43611. /**
  43612. * Defines the sheen intensity.
  43613. */
  43614. intensity: number;
  43615. /**
  43616. * Defines the sheen color.
  43617. */
  43618. color: Color3;
  43619. private _texture;
  43620. /**
  43621. * Stores the sheen tint values in a texture.
  43622. * rgb is tint
  43623. * a is a intensity
  43624. */
  43625. texture: Nullable<BaseTexture>;
  43626. /** @hidden */
  43627. private _internalMarkAllSubMeshesAsTexturesDirty;
  43628. /** @hidden */
  43629. _markAllSubMeshesAsTexturesDirty(): void;
  43630. /**
  43631. * Instantiate a new istance of clear coat configuration.
  43632. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  43633. */
  43634. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  43635. /**
  43636. * Specifies that the submesh is ready to be used.
  43637. * @param defines the list of "defines" to update.
  43638. * @param scene defines the scene the material belongs to.
  43639. * @returns - boolean indicating that the submesh is ready or not.
  43640. */
  43641. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  43642. /**
  43643. * Checks to see if a texture is used in the material.
  43644. * @param defines the list of "defines" to update.
  43645. * @param scene defines the scene the material belongs to.
  43646. */
  43647. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  43648. /**
  43649. * Binds the material data.
  43650. * @param uniformBuffer defines the Uniform buffer to fill in.
  43651. * @param scene defines the scene the material belongs to.
  43652. * @param isFrozen defines wether the material is frozen or not.
  43653. */
  43654. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  43655. /**
  43656. * Checks to see if a texture is used in the material.
  43657. * @param texture - Base texture to use.
  43658. * @returns - Boolean specifying if a texture is used in the material.
  43659. */
  43660. hasTexture(texture: BaseTexture): boolean;
  43661. /**
  43662. * Returns an array of the actively used textures.
  43663. * @param activeTextures Array of BaseTextures
  43664. */
  43665. getActiveTextures(activeTextures: BaseTexture[]): void;
  43666. /**
  43667. * Returns the animatable textures.
  43668. * @param animatables Array of animatable textures.
  43669. */
  43670. getAnimatables(animatables: IAnimatable[]): void;
  43671. /**
  43672. * Disposes the resources of the material.
  43673. * @param forceDisposeTextures - Forces the disposal of all textures.
  43674. */
  43675. dispose(forceDisposeTextures?: boolean): void;
  43676. /**
  43677. * Get the current class name of the texture useful for serialization or dynamic coding.
  43678. * @returns "PBRSheenConfiguration"
  43679. */
  43680. getClassName(): string;
  43681. /**
  43682. * Add fallbacks to the effect fallbacks list.
  43683. * @param defines defines the Base texture to use.
  43684. * @param fallbacks defines the current fallback list.
  43685. * @param currentRank defines the current fallback rank.
  43686. * @returns the new fallback rank.
  43687. */
  43688. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  43689. /**
  43690. * Add the required uniforms to the current list.
  43691. * @param uniforms defines the current uniform list.
  43692. */
  43693. static AddUniforms(uniforms: string[]): void;
  43694. /**
  43695. * Add the required uniforms to the current buffer.
  43696. * @param uniformBuffer defines the current uniform buffer.
  43697. */
  43698. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  43699. /**
  43700. * Add the required samplers to the current list.
  43701. * @param samplers defines the current sampler list.
  43702. */
  43703. static AddSamplers(samplers: string[]): void;
  43704. /**
  43705. * Makes a duplicate of the current configuration into another one.
  43706. * @param sheenConfiguration define the config where to copy the info
  43707. */
  43708. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  43709. /**
  43710. * Serializes this BRDF configuration.
  43711. * @returns - An object with the serialized config.
  43712. */
  43713. serialize(): any;
  43714. /**
  43715. * Parses a Sheen Configuration from a serialized object.
  43716. * @param source - Serialized object.
  43717. */
  43718. parse(source: any): void;
  43719. }
  43720. }
  43721. declare module BABYLON {
  43722. /** @hidden */
  43723. export var pbrFragmentDeclaration: {
  43724. name: string;
  43725. shader: string;
  43726. };
  43727. }
  43728. declare module BABYLON {
  43729. /** @hidden */
  43730. export var pbrUboDeclaration: {
  43731. name: string;
  43732. shader: string;
  43733. };
  43734. }
  43735. declare module BABYLON {
  43736. /** @hidden */
  43737. export var pbrFragmentExtraDeclaration: {
  43738. name: string;
  43739. shader: string;
  43740. };
  43741. }
  43742. declare module BABYLON {
  43743. /** @hidden */
  43744. export var pbrFragmentSamplersDeclaration: {
  43745. name: string;
  43746. shader: string;
  43747. };
  43748. }
  43749. declare module BABYLON {
  43750. /** @hidden */
  43751. export var pbrHelperFunctions: {
  43752. name: string;
  43753. shader: string;
  43754. };
  43755. }
  43756. declare module BABYLON {
  43757. /** @hidden */
  43758. export var harmonicsFunctions: {
  43759. name: string;
  43760. shader: string;
  43761. };
  43762. }
  43763. declare module BABYLON {
  43764. /** @hidden */
  43765. export var pbrDirectLightingSetupFunctions: {
  43766. name: string;
  43767. shader: string;
  43768. };
  43769. }
  43770. declare module BABYLON {
  43771. /** @hidden */
  43772. export var pbrDirectLightingFalloffFunctions: {
  43773. name: string;
  43774. shader: string;
  43775. };
  43776. }
  43777. declare module BABYLON {
  43778. /** @hidden */
  43779. export var pbrBRDFFunctions: {
  43780. name: string;
  43781. shader: string;
  43782. };
  43783. }
  43784. declare module BABYLON {
  43785. /** @hidden */
  43786. export var pbrDirectLightingFunctions: {
  43787. name: string;
  43788. shader: string;
  43789. };
  43790. }
  43791. declare module BABYLON {
  43792. /** @hidden */
  43793. export var pbrIBLFunctions: {
  43794. name: string;
  43795. shader: string;
  43796. };
  43797. }
  43798. declare module BABYLON {
  43799. /** @hidden */
  43800. export var pbrDebug: {
  43801. name: string;
  43802. shader: string;
  43803. };
  43804. }
  43805. declare module BABYLON {
  43806. /** @hidden */
  43807. export var pbrPixelShader: {
  43808. name: string;
  43809. shader: string;
  43810. };
  43811. }
  43812. declare module BABYLON {
  43813. /** @hidden */
  43814. export var pbrVertexDeclaration: {
  43815. name: string;
  43816. shader: string;
  43817. };
  43818. }
  43819. declare module BABYLON {
  43820. /** @hidden */
  43821. export var pbrVertexShader: {
  43822. name: string;
  43823. shader: string;
  43824. };
  43825. }
  43826. declare module BABYLON {
  43827. /**
  43828. * The Physically based material base class of BJS.
  43829. *
  43830. * This offers the main features of a standard PBR material.
  43831. * For more information, please refer to the documentation :
  43832. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  43833. */
  43834. export abstract class PBRBaseMaterial extends PushMaterial {
  43835. /**
  43836. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  43837. */
  43838. static readonly PBRMATERIAL_OPAQUE: number;
  43839. /**
  43840. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  43841. */
  43842. static readonly PBRMATERIAL_ALPHATEST: number;
  43843. /**
  43844. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  43845. */
  43846. static readonly PBRMATERIAL_ALPHABLEND: number;
  43847. /**
  43848. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  43849. * They are also discarded below the alpha cutoff threshold to improve performances.
  43850. */
  43851. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  43852. /**
  43853. * Defines the default value of how much AO map is occluding the analytical lights
  43854. * (point spot...).
  43855. */
  43856. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  43857. /**
  43858. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  43859. */
  43860. static readonly LIGHTFALLOFF_PHYSICAL: number;
  43861. /**
  43862. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  43863. * to enhance interoperability with other engines.
  43864. */
  43865. static readonly LIGHTFALLOFF_GLTF: number;
  43866. /**
  43867. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  43868. * to enhance interoperability with other materials.
  43869. */
  43870. static readonly LIGHTFALLOFF_STANDARD: number;
  43871. /**
  43872. * Intensity of the direct lights e.g. the four lights available in your scene.
  43873. * This impacts both the direct diffuse and specular highlights.
  43874. */
  43875. protected _directIntensity: number;
  43876. /**
  43877. * Intensity of the emissive part of the material.
  43878. * This helps controlling the emissive effect without modifying the emissive color.
  43879. */
  43880. protected _emissiveIntensity: number;
  43881. /**
  43882. * Intensity of the environment e.g. how much the environment will light the object
  43883. * either through harmonics for rough material or through the refelction for shiny ones.
  43884. */
  43885. protected _environmentIntensity: number;
  43886. /**
  43887. * This is a special control allowing the reduction of the specular highlights coming from the
  43888. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  43889. */
  43890. protected _specularIntensity: number;
  43891. /**
  43892. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  43893. */
  43894. private _lightingInfos;
  43895. /**
  43896. * Debug Control allowing disabling the bump map on this material.
  43897. */
  43898. protected _disableBumpMap: boolean;
  43899. /**
  43900. * AKA Diffuse Texture in standard nomenclature.
  43901. */
  43902. protected _albedoTexture: BaseTexture;
  43903. /**
  43904. * AKA Occlusion Texture in other nomenclature.
  43905. */
  43906. protected _ambientTexture: BaseTexture;
  43907. /**
  43908. * AKA Occlusion Texture Intensity in other nomenclature.
  43909. */
  43910. protected _ambientTextureStrength: number;
  43911. /**
  43912. * Defines how much the AO map is occluding the analytical lights (point spot...).
  43913. * 1 means it completely occludes it
  43914. * 0 mean it has no impact
  43915. */
  43916. protected _ambientTextureImpactOnAnalyticalLights: number;
  43917. /**
  43918. * Stores the alpha values in a texture.
  43919. */
  43920. protected _opacityTexture: BaseTexture;
  43921. /**
  43922. * Stores the reflection values in a texture.
  43923. */
  43924. protected _reflectionTexture: BaseTexture;
  43925. /**
  43926. * Stores the refraction values in a texture.
  43927. */
  43928. protected _refractionTexture: BaseTexture;
  43929. /**
  43930. * Stores the emissive values in a texture.
  43931. */
  43932. protected _emissiveTexture: BaseTexture;
  43933. /**
  43934. * AKA Specular texture in other nomenclature.
  43935. */
  43936. protected _reflectivityTexture: BaseTexture;
  43937. /**
  43938. * Used to switch from specular/glossiness to metallic/roughness workflow.
  43939. */
  43940. protected _metallicTexture: BaseTexture;
  43941. /**
  43942. * Specifies the metallic scalar of the metallic/roughness workflow.
  43943. * Can also be used to scale the metalness values of the metallic texture.
  43944. */
  43945. protected _metallic: Nullable<number>;
  43946. /**
  43947. * Specifies the roughness scalar of the metallic/roughness workflow.
  43948. * Can also be used to scale the roughness values of the metallic texture.
  43949. */
  43950. protected _roughness: Nullable<number>;
  43951. /**
  43952. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  43953. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  43954. */
  43955. protected _microSurfaceTexture: BaseTexture;
  43956. /**
  43957. * Stores surface normal data used to displace a mesh in a texture.
  43958. */
  43959. protected _bumpTexture: BaseTexture;
  43960. /**
  43961. * Stores the pre-calculated light information of a mesh in a texture.
  43962. */
  43963. protected _lightmapTexture: BaseTexture;
  43964. /**
  43965. * The color of a material in ambient lighting.
  43966. */
  43967. protected _ambientColor: Color3;
  43968. /**
  43969. * AKA Diffuse Color in other nomenclature.
  43970. */
  43971. protected _albedoColor: Color3;
  43972. /**
  43973. * AKA Specular Color in other nomenclature.
  43974. */
  43975. protected _reflectivityColor: Color3;
  43976. /**
  43977. * The color applied when light is reflected from a material.
  43978. */
  43979. protected _reflectionColor: Color3;
  43980. /**
  43981. * The color applied when light is emitted from a material.
  43982. */
  43983. protected _emissiveColor: Color3;
  43984. /**
  43985. * AKA Glossiness in other nomenclature.
  43986. */
  43987. protected _microSurface: number;
  43988. /**
  43989. * source material index of refraction (IOR)' / 'destination material IOR.
  43990. */
  43991. protected _indexOfRefraction: number;
  43992. /**
  43993. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  43994. */
  43995. protected _invertRefractionY: boolean;
  43996. /**
  43997. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  43998. * Materials half opaque for instance using refraction could benefit from this control.
  43999. */
  44000. protected _linkRefractionWithTransparency: boolean;
  44001. /**
  44002. * Specifies that the material will use the light map as a show map.
  44003. */
  44004. protected _useLightmapAsShadowmap: boolean;
  44005. /**
  44006. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  44007. * makes the reflect vector face the model (under horizon).
  44008. */
  44009. protected _useHorizonOcclusion: boolean;
  44010. /**
  44011. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  44012. * too much the area relying on ambient texture to define their ambient occlusion.
  44013. */
  44014. protected _useRadianceOcclusion: boolean;
  44015. /**
  44016. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  44017. */
  44018. protected _useAlphaFromAlbedoTexture: boolean;
  44019. /**
  44020. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  44021. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  44022. */
  44023. protected _useSpecularOverAlpha: boolean;
  44024. /**
  44025. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  44026. */
  44027. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  44028. /**
  44029. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  44030. */
  44031. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  44032. /**
  44033. * Specifies if the metallic texture contains the roughness information in its green channel.
  44034. */
  44035. protected _useRoughnessFromMetallicTextureGreen: boolean;
  44036. /**
  44037. * Specifies if the metallic texture contains the metallness information in its blue channel.
  44038. */
  44039. protected _useMetallnessFromMetallicTextureBlue: boolean;
  44040. /**
  44041. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  44042. */
  44043. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  44044. /**
  44045. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  44046. */
  44047. protected _useAmbientInGrayScale: boolean;
  44048. /**
  44049. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  44050. * The material will try to infer what glossiness each pixel should be.
  44051. */
  44052. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  44053. /**
  44054. * Defines the falloff type used in this material.
  44055. * It by default is Physical.
  44056. */
  44057. protected _lightFalloff: number;
  44058. /**
  44059. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  44060. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  44061. */
  44062. protected _useRadianceOverAlpha: boolean;
  44063. /**
  44064. * Allows using an object space normal map (instead of tangent space).
  44065. */
  44066. protected _useObjectSpaceNormalMap: boolean;
  44067. /**
  44068. * Allows using the bump map in parallax mode.
  44069. */
  44070. protected _useParallax: boolean;
  44071. /**
  44072. * Allows using the bump map in parallax occlusion mode.
  44073. */
  44074. protected _useParallaxOcclusion: boolean;
  44075. /**
  44076. * Controls the scale bias of the parallax mode.
  44077. */
  44078. protected _parallaxScaleBias: number;
  44079. /**
  44080. * If sets to true, disables all the lights affecting the material.
  44081. */
  44082. protected _disableLighting: boolean;
  44083. /**
  44084. * Number of Simultaneous lights allowed on the material.
  44085. */
  44086. protected _maxSimultaneousLights: number;
  44087. /**
  44088. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  44089. */
  44090. protected _invertNormalMapX: boolean;
  44091. /**
  44092. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  44093. */
  44094. protected _invertNormalMapY: boolean;
  44095. /**
  44096. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  44097. */
  44098. protected _twoSidedLighting: boolean;
  44099. /**
  44100. * Defines the alpha limits in alpha test mode.
  44101. */
  44102. protected _alphaCutOff: number;
  44103. /**
  44104. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  44105. */
  44106. protected _forceAlphaTest: boolean;
  44107. /**
  44108. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44109. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  44110. */
  44111. protected _useAlphaFresnel: boolean;
  44112. /**
  44113. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44114. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  44115. */
  44116. protected _useLinearAlphaFresnel: boolean;
  44117. /**
  44118. * The transparency mode of the material.
  44119. */
  44120. protected _transparencyMode: Nullable<number>;
  44121. /**
  44122. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  44123. * from cos thetav and roughness:
  44124. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  44125. */
  44126. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  44127. /**
  44128. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  44129. */
  44130. protected _forceIrradianceInFragment: boolean;
  44131. /**
  44132. * Force normal to face away from face.
  44133. */
  44134. protected _forceNormalForward: boolean;
  44135. /**
  44136. * Enables specular anti aliasing in the PBR shader.
  44137. * It will both interacts on the Geometry for analytical and IBL lighting.
  44138. * It also prefilter the roughness map based on the bump values.
  44139. */
  44140. protected _enableSpecularAntiAliasing: boolean;
  44141. /**
  44142. * Default configuration related to image processing available in the PBR Material.
  44143. */
  44144. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44145. /**
  44146. * Keep track of the image processing observer to allow dispose and replace.
  44147. */
  44148. private _imageProcessingObserver;
  44149. /**
  44150. * Attaches a new image processing configuration to the PBR Material.
  44151. * @param configuration
  44152. */
  44153. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  44154. /**
  44155. * Stores the available render targets.
  44156. */
  44157. private _renderTargets;
  44158. /**
  44159. * Sets the global ambient color for the material used in lighting calculations.
  44160. */
  44161. private _globalAmbientColor;
  44162. /**
  44163. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  44164. */
  44165. private _useLogarithmicDepth;
  44166. /**
  44167. * If set to true, no lighting calculations will be applied.
  44168. */
  44169. private _unlit;
  44170. private _debugMode;
  44171. /**
  44172. * @hidden
  44173. * This is reserved for the inspector.
  44174. * Defines the material debug mode.
  44175. * It helps seeing only some components of the material while troubleshooting.
  44176. */
  44177. debugMode: number;
  44178. /**
  44179. * @hidden
  44180. * This is reserved for the inspector.
  44181. * Specify from where on screen the debug mode should start.
  44182. * The value goes from -1 (full screen) to 1 (not visible)
  44183. * It helps with side by side comparison against the final render
  44184. * This defaults to -1
  44185. */
  44186. private debugLimit;
  44187. /**
  44188. * @hidden
  44189. * This is reserved for the inspector.
  44190. * As the default viewing range might not be enough (if the ambient is really small for instance)
  44191. * You can use the factor to better multiply the final value.
  44192. */
  44193. private debugFactor;
  44194. /**
  44195. * Defines the clear coat layer parameters for the material.
  44196. */
  44197. readonly clearCoat: PBRClearCoatConfiguration;
  44198. /**
  44199. * Defines the anisotropic parameters for the material.
  44200. */
  44201. readonly anisotropy: PBRAnisotropicConfiguration;
  44202. /**
  44203. * Defines the BRDF parameters for the material.
  44204. */
  44205. readonly brdf: PBRBRDFConfiguration;
  44206. /**
  44207. * Defines the Sheen parameters for the material.
  44208. */
  44209. readonly sheen: PBRSheenConfiguration;
  44210. /**
  44211. * Instantiates a new PBRMaterial instance.
  44212. *
  44213. * @param name The material name
  44214. * @param scene The scene the material will be use in.
  44215. */
  44216. constructor(name: string, scene: Scene);
  44217. /**
  44218. * Gets a boolean indicating that current material needs to register RTT
  44219. */
  44220. readonly hasRenderTargetTextures: boolean;
  44221. /**
  44222. * Gets the name of the material class.
  44223. */
  44224. getClassName(): string;
  44225. /**
  44226. * Gets the name of the material shader.
  44227. * @returns - string that specifies the shader program of the material.
  44228. */
  44229. getShaderName(): string;
  44230. /**
  44231. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  44232. */
  44233. /**
  44234. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  44235. */
  44236. useLogarithmicDepth: boolean;
  44237. /**
  44238. * Gets the current transparency mode.
  44239. */
  44240. /**
  44241. * Sets the transparency mode of the material.
  44242. *
  44243. * | Value | Type | Description |
  44244. * | ----- | ----------------------------------- | ----------- |
  44245. * | 0 | OPAQUE | |
  44246. * | 1 | ALPHATEST | |
  44247. * | 2 | ALPHABLEND | |
  44248. * | 3 | ALPHATESTANDBLEND | |
  44249. *
  44250. */
  44251. transparencyMode: Nullable<number>;
  44252. /**
  44253. * Returns true if alpha blending should be disabled.
  44254. */
  44255. private readonly _disableAlphaBlending;
  44256. /**
  44257. * Specifies whether or not this material should be rendered in alpha blend mode.
  44258. */
  44259. needAlphaBlending(): boolean;
  44260. /**
  44261. * Specifies if the mesh will require alpha blending.
  44262. * @param mesh - BJS mesh.
  44263. */
  44264. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  44265. /**
  44266. * Specifies whether or not this material should be rendered in alpha test mode.
  44267. */
  44268. needAlphaTesting(): boolean;
  44269. /**
  44270. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  44271. */
  44272. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  44273. /**
  44274. * Gets the texture used for the alpha test.
  44275. */
  44276. getAlphaTestTexture(): BaseTexture;
  44277. /**
  44278. * Specifies that the submesh is ready to be used.
  44279. * @param mesh - BJS mesh.
  44280. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  44281. * @param useInstances - Specifies that instances should be used.
  44282. * @returns - boolean indicating that the submesh is ready or not.
  44283. */
  44284. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  44285. /**
  44286. * Specifies if the material uses metallic roughness workflow.
  44287. * @returns boolean specifiying if the material uses metallic roughness workflow.
  44288. */
  44289. isMetallicWorkflow(): boolean;
  44290. private _prepareEffect;
  44291. private _prepareDefines;
  44292. /**
  44293. * Force shader compilation
  44294. */
  44295. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  44296. clipPlane: boolean;
  44297. }>): void;
  44298. /**
  44299. * Initializes the uniform buffer layout for the shader.
  44300. */
  44301. buildUniformLayout(): void;
  44302. /**
  44303. * Unbinds the textures.
  44304. */
  44305. unbind(): void;
  44306. /**
  44307. * Binds the submesh data.
  44308. * @param world - The world matrix.
  44309. * @param mesh - The BJS mesh.
  44310. * @param subMesh - A submesh of the BJS mesh.
  44311. */
  44312. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  44313. /**
  44314. * Returns the animatable textures.
  44315. * @returns - Array of animatable textures.
  44316. */
  44317. getAnimatables(): IAnimatable[];
  44318. /**
  44319. * Returns the texture used for reflections.
  44320. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  44321. */
  44322. private _getReflectionTexture;
  44323. /**
  44324. * Returns the texture used for refraction or null if none is used.
  44325. * @returns - Refection texture if present. If no refraction texture and refraction
  44326. * is linked with transparency, returns environment texture. Otherwise, returns null.
  44327. */
  44328. private _getRefractionTexture;
  44329. /**
  44330. * Returns an array of the actively used textures.
  44331. * @returns - Array of BaseTextures
  44332. */
  44333. getActiveTextures(): BaseTexture[];
  44334. /**
  44335. * Checks to see if a texture is used in the material.
  44336. * @param texture - Base texture to use.
  44337. * @returns - Boolean specifying if a texture is used in the material.
  44338. */
  44339. hasTexture(texture: BaseTexture): boolean;
  44340. /**
  44341. * Disposes the resources of the material.
  44342. * @param forceDisposeEffect - Forces the disposal of effects.
  44343. * @param forceDisposeTextures - Forces the disposal of all textures.
  44344. */
  44345. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  44346. }
  44347. }
  44348. declare module BABYLON {
  44349. /**
  44350. * The Physically based material of BJS.
  44351. *
  44352. * This offers the main features of a standard PBR material.
  44353. * For more information, please refer to the documentation :
  44354. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  44355. */
  44356. export class PBRMaterial extends PBRBaseMaterial {
  44357. /**
  44358. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  44359. */
  44360. static readonly PBRMATERIAL_OPAQUE: number;
  44361. /**
  44362. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  44363. */
  44364. static readonly PBRMATERIAL_ALPHATEST: number;
  44365. /**
  44366. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44367. */
  44368. static readonly PBRMATERIAL_ALPHABLEND: number;
  44369. /**
  44370. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44371. * They are also discarded below the alpha cutoff threshold to improve performances.
  44372. */
  44373. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  44374. /**
  44375. * Defines the default value of how much AO map is occluding the analytical lights
  44376. * (point spot...).
  44377. */
  44378. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  44379. /**
  44380. * Intensity of the direct lights e.g. the four lights available in your scene.
  44381. * This impacts both the direct diffuse and specular highlights.
  44382. */
  44383. directIntensity: number;
  44384. /**
  44385. * Intensity of the emissive part of the material.
  44386. * This helps controlling the emissive effect without modifying the emissive color.
  44387. */
  44388. emissiveIntensity: number;
  44389. /**
  44390. * Intensity of the environment e.g. how much the environment will light the object
  44391. * either through harmonics for rough material or through the refelction for shiny ones.
  44392. */
  44393. environmentIntensity: number;
  44394. /**
  44395. * This is a special control allowing the reduction of the specular highlights coming from the
  44396. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  44397. */
  44398. specularIntensity: number;
  44399. /**
  44400. * Debug Control allowing disabling the bump map on this material.
  44401. */
  44402. disableBumpMap: boolean;
  44403. /**
  44404. * AKA Diffuse Texture in standard nomenclature.
  44405. */
  44406. albedoTexture: BaseTexture;
  44407. /**
  44408. * AKA Occlusion Texture in other nomenclature.
  44409. */
  44410. ambientTexture: BaseTexture;
  44411. /**
  44412. * AKA Occlusion Texture Intensity in other nomenclature.
  44413. */
  44414. ambientTextureStrength: number;
  44415. /**
  44416. * Defines how much the AO map is occluding the analytical lights (point spot...).
  44417. * 1 means it completely occludes it
  44418. * 0 mean it has no impact
  44419. */
  44420. ambientTextureImpactOnAnalyticalLights: number;
  44421. /**
  44422. * Stores the alpha values in a texture.
  44423. */
  44424. opacityTexture: BaseTexture;
  44425. /**
  44426. * Stores the reflection values in a texture.
  44427. */
  44428. reflectionTexture: Nullable<BaseTexture>;
  44429. /**
  44430. * Stores the emissive values in a texture.
  44431. */
  44432. emissiveTexture: BaseTexture;
  44433. /**
  44434. * AKA Specular texture in other nomenclature.
  44435. */
  44436. reflectivityTexture: BaseTexture;
  44437. /**
  44438. * Used to switch from specular/glossiness to metallic/roughness workflow.
  44439. */
  44440. metallicTexture: BaseTexture;
  44441. /**
  44442. * Specifies the metallic scalar of the metallic/roughness workflow.
  44443. * Can also be used to scale the metalness values of the metallic texture.
  44444. */
  44445. metallic: Nullable<number>;
  44446. /**
  44447. * Specifies the roughness scalar of the metallic/roughness workflow.
  44448. * Can also be used to scale the roughness values of the metallic texture.
  44449. */
  44450. roughness: Nullable<number>;
  44451. /**
  44452. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  44453. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  44454. */
  44455. microSurfaceTexture: BaseTexture;
  44456. /**
  44457. * Stores surface normal data used to displace a mesh in a texture.
  44458. */
  44459. bumpTexture: BaseTexture;
  44460. /**
  44461. * Stores the pre-calculated light information of a mesh in a texture.
  44462. */
  44463. lightmapTexture: BaseTexture;
  44464. /**
  44465. * Stores the refracted light information in a texture.
  44466. */
  44467. refractionTexture: BaseTexture;
  44468. /**
  44469. * The color of a material in ambient lighting.
  44470. */
  44471. ambientColor: Color3;
  44472. /**
  44473. * AKA Diffuse Color in other nomenclature.
  44474. */
  44475. albedoColor: Color3;
  44476. /**
  44477. * AKA Specular Color in other nomenclature.
  44478. */
  44479. reflectivityColor: Color3;
  44480. /**
  44481. * The color reflected from the material.
  44482. */
  44483. reflectionColor: Color3;
  44484. /**
  44485. * The color emitted from the material.
  44486. */
  44487. emissiveColor: Color3;
  44488. /**
  44489. * AKA Glossiness in other nomenclature.
  44490. */
  44491. microSurface: number;
  44492. /**
  44493. * source material index of refraction (IOR)' / 'destination material IOR.
  44494. */
  44495. indexOfRefraction: number;
  44496. /**
  44497. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  44498. */
  44499. invertRefractionY: boolean;
  44500. /**
  44501. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  44502. * Materials half opaque for instance using refraction could benefit from this control.
  44503. */
  44504. linkRefractionWithTransparency: boolean;
  44505. /**
  44506. * If true, the light map contains occlusion information instead of lighting info.
  44507. */
  44508. useLightmapAsShadowmap: boolean;
  44509. /**
  44510. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  44511. */
  44512. useAlphaFromAlbedoTexture: boolean;
  44513. /**
  44514. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  44515. */
  44516. forceAlphaTest: boolean;
  44517. /**
  44518. * Defines the alpha limits in alpha test mode.
  44519. */
  44520. alphaCutOff: number;
  44521. /**
  44522. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  44523. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  44524. */
  44525. useSpecularOverAlpha: boolean;
  44526. /**
  44527. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  44528. */
  44529. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  44530. /**
  44531. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  44532. */
  44533. useRoughnessFromMetallicTextureAlpha: boolean;
  44534. /**
  44535. * Specifies if the metallic texture contains the roughness information in its green channel.
  44536. */
  44537. useRoughnessFromMetallicTextureGreen: boolean;
  44538. /**
  44539. * Specifies if the metallic texture contains the metallness information in its blue channel.
  44540. */
  44541. useMetallnessFromMetallicTextureBlue: boolean;
  44542. /**
  44543. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  44544. */
  44545. useAmbientOcclusionFromMetallicTextureRed: boolean;
  44546. /**
  44547. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  44548. */
  44549. useAmbientInGrayScale: boolean;
  44550. /**
  44551. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  44552. * The material will try to infer what glossiness each pixel should be.
  44553. */
  44554. useAutoMicroSurfaceFromReflectivityMap: boolean;
  44555. /**
  44556. * BJS is using an harcoded light falloff based on a manually sets up range.
  44557. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  44558. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  44559. */
  44560. /**
  44561. * BJS is using an harcoded light falloff based on a manually sets up range.
  44562. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  44563. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  44564. */
  44565. usePhysicalLightFalloff: boolean;
  44566. /**
  44567. * In order to support the falloff compatibility with gltf, a special mode has been added
  44568. * to reproduce the gltf light falloff.
  44569. */
  44570. /**
  44571. * In order to support the falloff compatibility with gltf, a special mode has been added
  44572. * to reproduce the gltf light falloff.
  44573. */
  44574. useGLTFLightFalloff: boolean;
  44575. /**
  44576. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  44577. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  44578. */
  44579. useRadianceOverAlpha: boolean;
  44580. /**
  44581. * Allows using an object space normal map (instead of tangent space).
  44582. */
  44583. useObjectSpaceNormalMap: boolean;
  44584. /**
  44585. * Allows using the bump map in parallax mode.
  44586. */
  44587. useParallax: boolean;
  44588. /**
  44589. * Allows using the bump map in parallax occlusion mode.
  44590. */
  44591. useParallaxOcclusion: boolean;
  44592. /**
  44593. * Controls the scale bias of the parallax mode.
  44594. */
  44595. parallaxScaleBias: number;
  44596. /**
  44597. * If sets to true, disables all the lights affecting the material.
  44598. */
  44599. disableLighting: boolean;
  44600. /**
  44601. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  44602. */
  44603. forceIrradianceInFragment: boolean;
  44604. /**
  44605. * Number of Simultaneous lights allowed on the material.
  44606. */
  44607. maxSimultaneousLights: number;
  44608. /**
  44609. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  44610. */
  44611. invertNormalMapX: boolean;
  44612. /**
  44613. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  44614. */
  44615. invertNormalMapY: boolean;
  44616. /**
  44617. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  44618. */
  44619. twoSidedLighting: boolean;
  44620. /**
  44621. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44622. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  44623. */
  44624. useAlphaFresnel: boolean;
  44625. /**
  44626. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44627. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  44628. */
  44629. useLinearAlphaFresnel: boolean;
  44630. /**
  44631. * Let user defines the brdf lookup texture used for IBL.
  44632. * A default 8bit version is embedded but you could point at :
  44633. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  44634. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  44635. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  44636. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  44637. */
  44638. environmentBRDFTexture: Nullable<BaseTexture>;
  44639. /**
  44640. * Force normal to face away from face.
  44641. */
  44642. forceNormalForward: boolean;
  44643. /**
  44644. * Enables specular anti aliasing in the PBR shader.
  44645. * It will both interacts on the Geometry for analytical and IBL lighting.
  44646. * It also prefilter the roughness map based on the bump values.
  44647. */
  44648. enableSpecularAntiAliasing: boolean;
  44649. /**
  44650. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  44651. * makes the reflect vector face the model (under horizon).
  44652. */
  44653. useHorizonOcclusion: boolean;
  44654. /**
  44655. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  44656. * too much the area relying on ambient texture to define their ambient occlusion.
  44657. */
  44658. useRadianceOcclusion: boolean;
  44659. /**
  44660. * If set to true, no lighting calculations will be applied.
  44661. */
  44662. unlit: boolean;
  44663. /**
  44664. * Gets the image processing configuration used either in this material.
  44665. */
  44666. /**
  44667. * Sets the Default image processing configuration used either in the this material.
  44668. *
  44669. * If sets to null, the scene one is in use.
  44670. */
  44671. imageProcessingConfiguration: ImageProcessingConfiguration;
  44672. /**
  44673. * Gets wether the color curves effect is enabled.
  44674. */
  44675. /**
  44676. * Sets wether the color curves effect is enabled.
  44677. */
  44678. cameraColorCurvesEnabled: boolean;
  44679. /**
  44680. * Gets wether the color grading effect is enabled.
  44681. */
  44682. /**
  44683. * Gets wether the color grading effect is enabled.
  44684. */
  44685. cameraColorGradingEnabled: boolean;
  44686. /**
  44687. * Gets wether tonemapping is enabled or not.
  44688. */
  44689. /**
  44690. * Sets wether tonemapping is enabled or not
  44691. */
  44692. cameraToneMappingEnabled: boolean;
  44693. /**
  44694. * The camera exposure used on this material.
  44695. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44696. * This corresponds to a photographic exposure.
  44697. */
  44698. /**
  44699. * The camera exposure used on this material.
  44700. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44701. * This corresponds to a photographic exposure.
  44702. */
  44703. cameraExposure: number;
  44704. /**
  44705. * Gets The camera contrast used on this material.
  44706. */
  44707. /**
  44708. * Sets The camera contrast used on this material.
  44709. */
  44710. cameraContrast: number;
  44711. /**
  44712. * Gets the Color Grading 2D Lookup Texture.
  44713. */
  44714. /**
  44715. * Sets the Color Grading 2D Lookup Texture.
  44716. */
  44717. cameraColorGradingTexture: Nullable<BaseTexture>;
  44718. /**
  44719. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44720. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44721. * 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;
  44722. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44723. */
  44724. /**
  44725. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44726. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44727. * 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;
  44728. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44729. */
  44730. cameraColorCurves: Nullable<ColorCurves>;
  44731. /**
  44732. * Instantiates a new PBRMaterial instance.
  44733. *
  44734. * @param name The material name
  44735. * @param scene The scene the material will be use in.
  44736. */
  44737. constructor(name: string, scene: Scene);
  44738. /**
  44739. * Returns the name of this material class.
  44740. */
  44741. getClassName(): string;
  44742. /**
  44743. * Makes a duplicate of the current material.
  44744. * @param name - name to use for the new material.
  44745. */
  44746. clone(name: string): PBRMaterial;
  44747. /**
  44748. * Serializes this PBR Material.
  44749. * @returns - An object with the serialized material.
  44750. */
  44751. serialize(): any;
  44752. /**
  44753. * Parses a PBR Material from a serialized object.
  44754. * @param source - Serialized object.
  44755. * @param scene - BJS scene instance.
  44756. * @param rootUrl - url for the scene object
  44757. * @returns - PBRMaterial
  44758. */
  44759. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  44760. }
  44761. }
  44762. declare module BABYLON {
  44763. /**
  44764. * Direct draw surface info
  44765. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  44766. */
  44767. export interface DDSInfo {
  44768. /**
  44769. * Width of the texture
  44770. */
  44771. width: number;
  44772. /**
  44773. * Width of the texture
  44774. */
  44775. height: number;
  44776. /**
  44777. * Number of Mipmaps for the texture
  44778. * @see https://en.wikipedia.org/wiki/Mipmap
  44779. */
  44780. mipmapCount: number;
  44781. /**
  44782. * If the textures format is a known fourCC format
  44783. * @see https://www.fourcc.org/
  44784. */
  44785. isFourCC: boolean;
  44786. /**
  44787. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  44788. */
  44789. isRGB: boolean;
  44790. /**
  44791. * If the texture is a lumincance format
  44792. */
  44793. isLuminance: boolean;
  44794. /**
  44795. * If this is a cube texture
  44796. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  44797. */
  44798. isCube: boolean;
  44799. /**
  44800. * If the texture is a compressed format eg. FOURCC_DXT1
  44801. */
  44802. isCompressed: boolean;
  44803. /**
  44804. * The dxgiFormat of the texture
  44805. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  44806. */
  44807. dxgiFormat: number;
  44808. /**
  44809. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  44810. */
  44811. textureType: number;
  44812. /**
  44813. * Sphericle polynomial created for the dds texture
  44814. */
  44815. sphericalPolynomial?: SphericalPolynomial;
  44816. }
  44817. /**
  44818. * Class used to provide DDS decompression tools
  44819. */
  44820. export class DDSTools {
  44821. /**
  44822. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  44823. */
  44824. static StoreLODInAlphaChannel: boolean;
  44825. /**
  44826. * Gets DDS information from an array buffer
  44827. * @param arrayBuffer defines the array buffer to read data from
  44828. * @returns the DDS information
  44829. */
  44830. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  44831. private static _FloatView;
  44832. private static _Int32View;
  44833. private static _ToHalfFloat;
  44834. private static _FromHalfFloat;
  44835. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  44836. private static _GetHalfFloatRGBAArrayBuffer;
  44837. private static _GetFloatRGBAArrayBuffer;
  44838. private static _GetFloatAsUIntRGBAArrayBuffer;
  44839. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  44840. private static _GetRGBAArrayBuffer;
  44841. private static _ExtractLongWordOrder;
  44842. private static _GetRGBArrayBuffer;
  44843. private static _GetLuminanceArrayBuffer;
  44844. /**
  44845. * Uploads DDS Levels to a Babylon Texture
  44846. * @hidden
  44847. */
  44848. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  44849. }
  44850. interface Engine {
  44851. /**
  44852. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  44853. * @param rootUrl defines the url where the file to load is located
  44854. * @param scene defines the current scene
  44855. * @param lodScale defines scale to apply to the mip map selection
  44856. * @param lodOffset defines offset to apply to the mip map selection
  44857. * @param onLoad defines an optional callback raised when the texture is loaded
  44858. * @param onError defines an optional callback raised if there is an issue to load the texture
  44859. * @param format defines the format of the data
  44860. * @param forcedExtension defines the extension to use to pick the right loader
  44861. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  44862. * @returns the cube texture as an InternalTexture
  44863. */
  44864. 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;
  44865. }
  44866. }
  44867. declare module BABYLON {
  44868. /**
  44869. * Implementation of the DDS Texture Loader.
  44870. * @hidden
  44871. */
  44872. export class _DDSTextureLoader implements IInternalTextureLoader {
  44873. /**
  44874. * Defines wether the loader supports cascade loading the different faces.
  44875. */
  44876. readonly supportCascades: boolean;
  44877. /**
  44878. * This returns if the loader support the current file information.
  44879. * @param extension defines the file extension of the file being loaded
  44880. * @param textureFormatInUse defines the current compressed format in use iun the engine
  44881. * @param fallback defines the fallback internal texture if any
  44882. * @param isBase64 defines whether the texture is encoded as a base64
  44883. * @param isBuffer defines whether the texture data are stored as a buffer
  44884. * @returns true if the loader can load the specified file
  44885. */
  44886. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  44887. /**
  44888. * Transform the url before loading if required.
  44889. * @param rootUrl the url of the texture
  44890. * @param textureFormatInUse defines the current compressed format in use iun the engine
  44891. * @returns the transformed texture
  44892. */
  44893. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  44894. /**
  44895. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  44896. * @param rootUrl the url of the texture
  44897. * @param textureFormatInUse defines the current compressed format in use iun the engine
  44898. * @returns the fallback texture
  44899. */
  44900. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  44901. /**
  44902. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  44903. * @param data contains the texture data
  44904. * @param texture defines the BabylonJS internal texture
  44905. * @param createPolynomials will be true if polynomials have been requested
  44906. * @param onLoad defines the callback to trigger once the texture is ready
  44907. * @param onError defines the callback to trigger in case of error
  44908. */
  44909. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  44910. /**
  44911. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  44912. * @param data contains the texture data
  44913. * @param texture defines the BabylonJS internal texture
  44914. * @param callback defines the method to call once ready to upload
  44915. */
  44916. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  44917. }
  44918. }
  44919. declare module BABYLON {
  44920. /** @hidden */
  44921. export var rgbdEncodePixelShader: {
  44922. name: string;
  44923. shader: string;
  44924. };
  44925. }
  44926. declare module BABYLON {
  44927. /** @hidden */
  44928. export var rgbdDecodePixelShader: {
  44929. name: string;
  44930. shader: string;
  44931. };
  44932. }
  44933. declare module BABYLON {
  44934. /**
  44935. * Raw texture data and descriptor sufficient for WebGL texture upload
  44936. */
  44937. export interface EnvironmentTextureInfo {
  44938. /**
  44939. * Version of the environment map
  44940. */
  44941. version: number;
  44942. /**
  44943. * Width of image
  44944. */
  44945. width: number;
  44946. /**
  44947. * Irradiance information stored in the file.
  44948. */
  44949. irradiance: any;
  44950. /**
  44951. * Specular information stored in the file.
  44952. */
  44953. specular: any;
  44954. }
  44955. /**
  44956. * Sets of helpers addressing the serialization and deserialization of environment texture
  44957. * stored in a BabylonJS env file.
  44958. * Those files are usually stored as .env files.
  44959. */
  44960. export class EnvironmentTextureTools {
  44961. /**
  44962. * Magic number identifying the env file.
  44963. */
  44964. private static _MagicBytes;
  44965. /**
  44966. * Gets the environment info from an env file.
  44967. * @param data The array buffer containing the .env bytes.
  44968. * @returns the environment file info (the json header) if successfully parsed.
  44969. */
  44970. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  44971. /**
  44972. * Creates an environment texture from a loaded cube texture.
  44973. * @param texture defines the cube texture to convert in env file
  44974. * @return a promise containing the environment data if succesfull.
  44975. */
  44976. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  44977. /**
  44978. * Creates a JSON representation of the spherical data.
  44979. * @param texture defines the texture containing the polynomials
  44980. * @return the JSON representation of the spherical info
  44981. */
  44982. private static _CreateEnvTextureIrradiance;
  44983. /**
  44984. * Uploads the texture info contained in the env file to the GPU.
  44985. * @param texture defines the internal texture to upload to
  44986. * @param arrayBuffer defines the buffer cotaining the data to load
  44987. * @param info defines the texture info retrieved through the GetEnvInfo method
  44988. * @returns a promise
  44989. */
  44990. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  44991. /**
  44992. * Uploads the levels of image data to the GPU.
  44993. * @param texture defines the internal texture to upload to
  44994. * @param imageData defines the array buffer views of image data [mipmap][face]
  44995. * @returns a promise
  44996. */
  44997. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  44998. /**
  44999. * Uploads spherical polynomials information to the texture.
  45000. * @param texture defines the texture we are trying to upload the information to
  45001. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  45002. */
  45003. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  45004. /** @hidden */
  45005. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  45006. }
  45007. }
  45008. declare module BABYLON {
  45009. /**
  45010. * Implementation of the ENV Texture Loader.
  45011. * @hidden
  45012. */
  45013. export class _ENVTextureLoader implements IInternalTextureLoader {
  45014. /**
  45015. * Defines wether the loader supports cascade loading the different faces.
  45016. */
  45017. readonly supportCascades: boolean;
  45018. /**
  45019. * This returns if the loader support the current file information.
  45020. * @param extension defines the file extension of the file being loaded
  45021. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45022. * @param fallback defines the fallback internal texture if any
  45023. * @param isBase64 defines whether the texture is encoded as a base64
  45024. * @param isBuffer defines whether the texture data are stored as a buffer
  45025. * @returns true if the loader can load the specified file
  45026. */
  45027. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  45028. /**
  45029. * Transform the url before loading if required.
  45030. * @param rootUrl the url of the texture
  45031. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45032. * @returns the transformed texture
  45033. */
  45034. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  45035. /**
  45036. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  45037. * @param rootUrl the url of the texture
  45038. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45039. * @returns the fallback texture
  45040. */
  45041. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  45042. /**
  45043. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  45044. * @param data contains the texture data
  45045. * @param texture defines the BabylonJS internal texture
  45046. * @param createPolynomials will be true if polynomials have been requested
  45047. * @param onLoad defines the callback to trigger once the texture is ready
  45048. * @param onError defines the callback to trigger in case of error
  45049. */
  45050. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  45051. /**
  45052. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  45053. * @param data contains the texture data
  45054. * @param texture defines the BabylonJS internal texture
  45055. * @param callback defines the method to call once ready to upload
  45056. */
  45057. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  45058. }
  45059. }
  45060. declare module BABYLON {
  45061. /**
  45062. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  45063. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  45064. */
  45065. export class KhronosTextureContainer {
  45066. /** contents of the KTX container file */
  45067. arrayBuffer: any;
  45068. private static HEADER_LEN;
  45069. private static COMPRESSED_2D;
  45070. private static COMPRESSED_3D;
  45071. private static TEX_2D;
  45072. private static TEX_3D;
  45073. /**
  45074. * Gets the openGL type
  45075. */
  45076. glType: number;
  45077. /**
  45078. * Gets the openGL type size
  45079. */
  45080. glTypeSize: number;
  45081. /**
  45082. * Gets the openGL format
  45083. */
  45084. glFormat: number;
  45085. /**
  45086. * Gets the openGL internal format
  45087. */
  45088. glInternalFormat: number;
  45089. /**
  45090. * Gets the base internal format
  45091. */
  45092. glBaseInternalFormat: number;
  45093. /**
  45094. * Gets image width in pixel
  45095. */
  45096. pixelWidth: number;
  45097. /**
  45098. * Gets image height in pixel
  45099. */
  45100. pixelHeight: number;
  45101. /**
  45102. * Gets image depth in pixels
  45103. */
  45104. pixelDepth: number;
  45105. /**
  45106. * Gets the number of array elements
  45107. */
  45108. numberOfArrayElements: number;
  45109. /**
  45110. * Gets the number of faces
  45111. */
  45112. numberOfFaces: number;
  45113. /**
  45114. * Gets the number of mipmap levels
  45115. */
  45116. numberOfMipmapLevels: number;
  45117. /**
  45118. * Gets the bytes of key value data
  45119. */
  45120. bytesOfKeyValueData: number;
  45121. /**
  45122. * Gets the load type
  45123. */
  45124. loadType: number;
  45125. /**
  45126. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  45127. */
  45128. isInvalid: boolean;
  45129. /**
  45130. * Creates a new KhronosTextureContainer
  45131. * @param arrayBuffer contents of the KTX container file
  45132. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  45133. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  45134. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  45135. */
  45136. constructor(
  45137. /** contents of the KTX container file */
  45138. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  45139. /**
  45140. * Uploads KTX content to a Babylon Texture.
  45141. * It is assumed that the texture has already been created & is currently bound
  45142. * @hidden
  45143. */
  45144. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  45145. private _upload2DCompressedLevels;
  45146. }
  45147. }
  45148. declare module BABYLON {
  45149. /**
  45150. * Implementation of the KTX Texture Loader.
  45151. * @hidden
  45152. */
  45153. export class _KTXTextureLoader implements IInternalTextureLoader {
  45154. /**
  45155. * Defines wether the loader supports cascade loading the different faces.
  45156. */
  45157. readonly supportCascades: boolean;
  45158. /**
  45159. * This returns if the loader support the current file information.
  45160. * @param extension defines the file extension of the file being loaded
  45161. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45162. * @param fallback defines the fallback internal texture if any
  45163. * @param isBase64 defines whether the texture is encoded as a base64
  45164. * @param isBuffer defines whether the texture data are stored as a buffer
  45165. * @returns true if the loader can load the specified file
  45166. */
  45167. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  45168. /**
  45169. * Transform the url before loading if required.
  45170. * @param rootUrl the url of the texture
  45171. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45172. * @returns the transformed texture
  45173. */
  45174. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  45175. /**
  45176. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  45177. * @param rootUrl the url of the texture
  45178. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45179. * @returns the fallback texture
  45180. */
  45181. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  45182. /**
  45183. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  45184. * @param data contains the texture data
  45185. * @param texture defines the BabylonJS internal texture
  45186. * @param createPolynomials will be true if polynomials have been requested
  45187. * @param onLoad defines the callback to trigger once the texture is ready
  45188. * @param onError defines the callback to trigger in case of error
  45189. */
  45190. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  45191. /**
  45192. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  45193. * @param data contains the texture data
  45194. * @param texture defines the BabylonJS internal texture
  45195. * @param callback defines the method to call once ready to upload
  45196. */
  45197. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  45198. }
  45199. }
  45200. declare module BABYLON {
  45201. /** @hidden */
  45202. export var _forceSceneHelpersToBundle: boolean;
  45203. interface Scene {
  45204. /**
  45205. * Creates a default light for the scene.
  45206. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  45207. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  45208. */
  45209. createDefaultLight(replace?: boolean): void;
  45210. /**
  45211. * Creates a default camera for the scene.
  45212. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  45213. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  45214. * @param replace has default false, when true replaces the active camera in the scene
  45215. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  45216. */
  45217. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  45218. /**
  45219. * Creates a default camera and a default light.
  45220. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  45221. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  45222. * @param replace has the default false, when true replaces the active camera/light in the scene
  45223. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  45224. */
  45225. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  45226. /**
  45227. * Creates a new sky box
  45228. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  45229. * @param environmentTexture defines the texture to use as environment texture
  45230. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  45231. * @param scale defines the overall scale of the skybox
  45232. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  45233. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  45234. * @returns a new mesh holding the sky box
  45235. */
  45236. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  45237. /**
  45238. * Creates a new environment
  45239. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  45240. * @param options defines the options you can use to configure the environment
  45241. * @returns the new EnvironmentHelper
  45242. */
  45243. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  45244. /**
  45245. * Creates a new VREXperienceHelper
  45246. * @see http://doc.babylonjs.com/how_to/webvr_helper
  45247. * @param webVROptions defines the options used to create the new VREXperienceHelper
  45248. * @returns a new VREXperienceHelper
  45249. */
  45250. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  45251. /**
  45252. * Creates a new XREXperienceHelper
  45253. * @see http://doc.babylonjs.com/how_to/webxr
  45254. * @returns a promise for a new XREXperienceHelper
  45255. */
  45256. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  45257. }
  45258. }
  45259. declare module BABYLON {
  45260. /**
  45261. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  45262. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  45263. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  45264. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  45265. */
  45266. export class VideoDome extends TransformNode {
  45267. /**
  45268. * Define the video source as a Monoscopic panoramic 360 video.
  45269. */
  45270. static readonly MODE_MONOSCOPIC: number;
  45271. /**
  45272. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  45273. */
  45274. static readonly MODE_TOPBOTTOM: number;
  45275. /**
  45276. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  45277. */
  45278. static readonly MODE_SIDEBYSIDE: number;
  45279. private _useDirectMapping;
  45280. /**
  45281. * The video texture being displayed on the sphere
  45282. */
  45283. protected _videoTexture: VideoTexture;
  45284. /**
  45285. * Gets the video texture being displayed on the sphere
  45286. */
  45287. readonly videoTexture: VideoTexture;
  45288. /**
  45289. * The skybox material
  45290. */
  45291. protected _material: BackgroundMaterial;
  45292. /**
  45293. * The surface used for the skybox
  45294. */
  45295. protected _mesh: Mesh;
  45296. /**
  45297. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45298. * Also see the options.resolution property.
  45299. */
  45300. fovMultiplier: number;
  45301. private _videoMode;
  45302. /**
  45303. * Gets or set the current video mode for the video. It can be:
  45304. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  45305. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  45306. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  45307. */
  45308. videoMode: number;
  45309. /**
  45310. * Oberserver used in Stereoscopic VR Mode.
  45311. */
  45312. private _onBeforeCameraRenderObserver;
  45313. /**
  45314. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  45315. * @param name Element's name, child elements will append suffixes for their own names.
  45316. * @param urlsOrVideo defines the url(s) or the video element to use
  45317. * @param options An object containing optional or exposed sub element properties
  45318. */
  45319. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  45320. resolution?: number;
  45321. clickToPlay?: boolean;
  45322. autoPlay?: boolean;
  45323. loop?: boolean;
  45324. size?: number;
  45325. poster?: string;
  45326. faceForward?: boolean;
  45327. useDirectMapping?: boolean;
  45328. }, scene: Scene);
  45329. private _changeVideoMode;
  45330. /**
  45331. * Releases resources associated with this node.
  45332. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  45333. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  45334. */
  45335. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  45336. }
  45337. }
  45338. declare module BABYLON {
  45339. /**
  45340. * This class can be used to get instrumentation data from a Babylon engine
  45341. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  45342. */
  45343. export class EngineInstrumentation implements IDisposable {
  45344. /**
  45345. * Define the instrumented engine.
  45346. */
  45347. engine: Engine;
  45348. private _captureGPUFrameTime;
  45349. private _gpuFrameTimeToken;
  45350. private _gpuFrameTime;
  45351. private _captureShaderCompilationTime;
  45352. private _shaderCompilationTime;
  45353. private _onBeginFrameObserver;
  45354. private _onEndFrameObserver;
  45355. private _onBeforeShaderCompilationObserver;
  45356. private _onAfterShaderCompilationObserver;
  45357. /**
  45358. * Gets the perf counter used for GPU frame time
  45359. */
  45360. readonly gpuFrameTimeCounter: PerfCounter;
  45361. /**
  45362. * Gets the GPU frame time capture status
  45363. */
  45364. /**
  45365. * Enable or disable the GPU frame time capture
  45366. */
  45367. captureGPUFrameTime: boolean;
  45368. /**
  45369. * Gets the perf counter used for shader compilation time
  45370. */
  45371. readonly shaderCompilationTimeCounter: PerfCounter;
  45372. /**
  45373. * Gets the shader compilation time capture status
  45374. */
  45375. /**
  45376. * Enable or disable the shader compilation time capture
  45377. */
  45378. captureShaderCompilationTime: boolean;
  45379. /**
  45380. * Instantiates a new engine instrumentation.
  45381. * This class can be used to get instrumentation data from a Babylon engine
  45382. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  45383. * @param engine Defines the engine to instrument
  45384. */
  45385. constructor(
  45386. /**
  45387. * Define the instrumented engine.
  45388. */
  45389. engine: Engine);
  45390. /**
  45391. * Dispose and release associated resources.
  45392. */
  45393. dispose(): void;
  45394. }
  45395. }
  45396. declare module BABYLON {
  45397. /**
  45398. * This class can be used to get instrumentation data from a Babylon engine
  45399. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  45400. */
  45401. export class SceneInstrumentation implements IDisposable {
  45402. /**
  45403. * Defines the scene to instrument
  45404. */
  45405. scene: Scene;
  45406. private _captureActiveMeshesEvaluationTime;
  45407. private _activeMeshesEvaluationTime;
  45408. private _captureRenderTargetsRenderTime;
  45409. private _renderTargetsRenderTime;
  45410. private _captureFrameTime;
  45411. private _frameTime;
  45412. private _captureRenderTime;
  45413. private _renderTime;
  45414. private _captureInterFrameTime;
  45415. private _interFrameTime;
  45416. private _captureParticlesRenderTime;
  45417. private _particlesRenderTime;
  45418. private _captureSpritesRenderTime;
  45419. private _spritesRenderTime;
  45420. private _capturePhysicsTime;
  45421. private _physicsTime;
  45422. private _captureAnimationsTime;
  45423. private _animationsTime;
  45424. private _captureCameraRenderTime;
  45425. private _cameraRenderTime;
  45426. private _onBeforeActiveMeshesEvaluationObserver;
  45427. private _onAfterActiveMeshesEvaluationObserver;
  45428. private _onBeforeRenderTargetsRenderObserver;
  45429. private _onAfterRenderTargetsRenderObserver;
  45430. private _onAfterRenderObserver;
  45431. private _onBeforeDrawPhaseObserver;
  45432. private _onAfterDrawPhaseObserver;
  45433. private _onBeforeAnimationsObserver;
  45434. private _onBeforeParticlesRenderingObserver;
  45435. private _onAfterParticlesRenderingObserver;
  45436. private _onBeforeSpritesRenderingObserver;
  45437. private _onAfterSpritesRenderingObserver;
  45438. private _onBeforePhysicsObserver;
  45439. private _onAfterPhysicsObserver;
  45440. private _onAfterAnimationsObserver;
  45441. private _onBeforeCameraRenderObserver;
  45442. private _onAfterCameraRenderObserver;
  45443. /**
  45444. * Gets the perf counter used for active meshes evaluation time
  45445. */
  45446. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  45447. /**
  45448. * Gets the active meshes evaluation time capture status
  45449. */
  45450. /**
  45451. * Enable or disable the active meshes evaluation time capture
  45452. */
  45453. captureActiveMeshesEvaluationTime: boolean;
  45454. /**
  45455. * Gets the perf counter used for render targets render time
  45456. */
  45457. readonly renderTargetsRenderTimeCounter: PerfCounter;
  45458. /**
  45459. * Gets the render targets render time capture status
  45460. */
  45461. /**
  45462. * Enable or disable the render targets render time capture
  45463. */
  45464. captureRenderTargetsRenderTime: boolean;
  45465. /**
  45466. * Gets the perf counter used for particles render time
  45467. */
  45468. readonly particlesRenderTimeCounter: PerfCounter;
  45469. /**
  45470. * Gets the particles render time capture status
  45471. */
  45472. /**
  45473. * Enable or disable the particles render time capture
  45474. */
  45475. captureParticlesRenderTime: boolean;
  45476. /**
  45477. * Gets the perf counter used for sprites render time
  45478. */
  45479. readonly spritesRenderTimeCounter: PerfCounter;
  45480. /**
  45481. * Gets the sprites render time capture status
  45482. */
  45483. /**
  45484. * Enable or disable the sprites render time capture
  45485. */
  45486. captureSpritesRenderTime: boolean;
  45487. /**
  45488. * Gets the perf counter used for physics time
  45489. */
  45490. readonly physicsTimeCounter: PerfCounter;
  45491. /**
  45492. * Gets the physics time capture status
  45493. */
  45494. /**
  45495. * Enable or disable the physics time capture
  45496. */
  45497. capturePhysicsTime: boolean;
  45498. /**
  45499. * Gets the perf counter used for animations time
  45500. */
  45501. readonly animationsTimeCounter: PerfCounter;
  45502. /**
  45503. * Gets the animations time capture status
  45504. */
  45505. /**
  45506. * Enable or disable the animations time capture
  45507. */
  45508. captureAnimationsTime: boolean;
  45509. /**
  45510. * Gets the perf counter used for frame time capture
  45511. */
  45512. readonly frameTimeCounter: PerfCounter;
  45513. /**
  45514. * Gets the frame time capture status
  45515. */
  45516. /**
  45517. * Enable or disable the frame time capture
  45518. */
  45519. captureFrameTime: boolean;
  45520. /**
  45521. * Gets the perf counter used for inter-frames time capture
  45522. */
  45523. readonly interFrameTimeCounter: PerfCounter;
  45524. /**
  45525. * Gets the inter-frames time capture status
  45526. */
  45527. /**
  45528. * Enable or disable the inter-frames time capture
  45529. */
  45530. captureInterFrameTime: boolean;
  45531. /**
  45532. * Gets the perf counter used for render time capture
  45533. */
  45534. readonly renderTimeCounter: PerfCounter;
  45535. /**
  45536. * Gets the render time capture status
  45537. */
  45538. /**
  45539. * Enable or disable the render time capture
  45540. */
  45541. captureRenderTime: boolean;
  45542. /**
  45543. * Gets the perf counter used for camera render time capture
  45544. */
  45545. readonly cameraRenderTimeCounter: PerfCounter;
  45546. /**
  45547. * Gets the camera render time capture status
  45548. */
  45549. /**
  45550. * Enable or disable the camera render time capture
  45551. */
  45552. captureCameraRenderTime: boolean;
  45553. /**
  45554. * Gets the perf counter used for draw calls
  45555. */
  45556. readonly drawCallsCounter: PerfCounter;
  45557. /**
  45558. * Gets the perf counter used for texture collisions
  45559. */
  45560. readonly textureCollisionsCounter: PerfCounter;
  45561. /**
  45562. * Instantiates a new scene instrumentation.
  45563. * This class can be used to get instrumentation data from a Babylon engine
  45564. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  45565. * @param scene Defines the scene to instrument
  45566. */
  45567. constructor(
  45568. /**
  45569. * Defines the scene to instrument
  45570. */
  45571. scene: Scene);
  45572. /**
  45573. * Dispose and release associated resources.
  45574. */
  45575. dispose(): void;
  45576. }
  45577. }
  45578. declare module BABYLON {
  45579. /** @hidden */
  45580. export var glowMapGenerationPixelShader: {
  45581. name: string;
  45582. shader: string;
  45583. };
  45584. }
  45585. declare module BABYLON {
  45586. /** @hidden */
  45587. export var glowMapGenerationVertexShader: {
  45588. name: string;
  45589. shader: string;
  45590. };
  45591. }
  45592. declare module BABYLON {
  45593. /**
  45594. * Effect layer options. This helps customizing the behaviour
  45595. * of the effect layer.
  45596. */
  45597. export interface IEffectLayerOptions {
  45598. /**
  45599. * Multiplication factor apply to the canvas size to compute the render target size
  45600. * used to generated the objects (the smaller the faster).
  45601. */
  45602. mainTextureRatio: number;
  45603. /**
  45604. * Enforces a fixed size texture to ensure effect stability across devices.
  45605. */
  45606. mainTextureFixedSize?: number;
  45607. /**
  45608. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  45609. */
  45610. alphaBlendingMode: number;
  45611. /**
  45612. * The camera attached to the layer.
  45613. */
  45614. camera: Nullable<Camera>;
  45615. /**
  45616. * The rendering group to draw the layer in.
  45617. */
  45618. renderingGroupId: number;
  45619. }
  45620. /**
  45621. * The effect layer Helps adding post process effect blended with the main pass.
  45622. *
  45623. * This can be for instance use to generate glow or higlight effects on the scene.
  45624. *
  45625. * The effect layer class can not be used directly and is intented to inherited from to be
  45626. * customized per effects.
  45627. */
  45628. export abstract class EffectLayer {
  45629. private _vertexBuffers;
  45630. private _indexBuffer;
  45631. private _cachedDefines;
  45632. private _effectLayerMapGenerationEffect;
  45633. private _effectLayerOptions;
  45634. private _mergeEffect;
  45635. protected _scene: Scene;
  45636. protected _engine: Engine;
  45637. protected _maxSize: number;
  45638. protected _mainTextureDesiredSize: ISize;
  45639. protected _mainTexture: RenderTargetTexture;
  45640. protected _shouldRender: boolean;
  45641. protected _postProcesses: PostProcess[];
  45642. protected _textures: BaseTexture[];
  45643. protected _emissiveTextureAndColor: {
  45644. texture: Nullable<BaseTexture>;
  45645. color: Color4;
  45646. };
  45647. /**
  45648. * The name of the layer
  45649. */
  45650. name: string;
  45651. /**
  45652. * The clear color of the texture used to generate the glow map.
  45653. */
  45654. neutralColor: Color4;
  45655. /**
  45656. * Specifies wether the highlight layer is enabled or not.
  45657. */
  45658. isEnabled: boolean;
  45659. /**
  45660. * Gets the camera attached to the layer.
  45661. */
  45662. readonly camera: Nullable<Camera>;
  45663. /**
  45664. * Gets the rendering group id the layer should render in.
  45665. */
  45666. readonly renderingGroupId: number;
  45667. /**
  45668. * An event triggered when the effect layer has been disposed.
  45669. */
  45670. onDisposeObservable: Observable<EffectLayer>;
  45671. /**
  45672. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  45673. */
  45674. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  45675. /**
  45676. * An event triggered when the generated texture is being merged in the scene.
  45677. */
  45678. onBeforeComposeObservable: Observable<EffectLayer>;
  45679. /**
  45680. * An event triggered when the generated texture has been merged in the scene.
  45681. */
  45682. onAfterComposeObservable: Observable<EffectLayer>;
  45683. /**
  45684. * An event triggered when the efffect layer changes its size.
  45685. */
  45686. onSizeChangedObservable: Observable<EffectLayer>;
  45687. /** @hidden */
  45688. static _SceneComponentInitialization: (scene: Scene) => void;
  45689. /**
  45690. * Instantiates a new effect Layer and references it in the scene.
  45691. * @param name The name of the layer
  45692. * @param scene The scene to use the layer in
  45693. */
  45694. constructor(
  45695. /** The Friendly of the effect in the scene */
  45696. name: string, scene: Scene);
  45697. /**
  45698. * Get the effect name of the layer.
  45699. * @return The effect name
  45700. */
  45701. abstract getEffectName(): string;
  45702. /**
  45703. * Checks for the readiness of the element composing the layer.
  45704. * @param subMesh the mesh to check for
  45705. * @param useInstances specify wether or not to use instances to render the mesh
  45706. * @return true if ready otherwise, false
  45707. */
  45708. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  45709. /**
  45710. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  45711. * @returns true if the effect requires stencil during the main canvas render pass.
  45712. */
  45713. abstract needStencil(): boolean;
  45714. /**
  45715. * Create the merge effect. This is the shader use to blit the information back
  45716. * to the main canvas at the end of the scene rendering.
  45717. * @returns The effect containing the shader used to merge the effect on the main canvas
  45718. */
  45719. protected abstract _createMergeEffect(): Effect;
  45720. /**
  45721. * Creates the render target textures and post processes used in the effect layer.
  45722. */
  45723. protected abstract _createTextureAndPostProcesses(): void;
  45724. /**
  45725. * Implementation specific of rendering the generating effect on the main canvas.
  45726. * @param effect The effect used to render through
  45727. */
  45728. protected abstract _internalRender(effect: Effect): void;
  45729. /**
  45730. * Sets the required values for both the emissive texture and and the main color.
  45731. */
  45732. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  45733. /**
  45734. * Free any resources and references associated to a mesh.
  45735. * Internal use
  45736. * @param mesh The mesh to free.
  45737. */
  45738. abstract _disposeMesh(mesh: Mesh): void;
  45739. /**
  45740. * Serializes this layer (Glow or Highlight for example)
  45741. * @returns a serialized layer object
  45742. */
  45743. abstract serialize?(): any;
  45744. /**
  45745. * Initializes the effect layer with the required options.
  45746. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  45747. */
  45748. protected _init(options: Partial<IEffectLayerOptions>): void;
  45749. /**
  45750. * Generates the index buffer of the full screen quad blending to the main canvas.
  45751. */
  45752. private _generateIndexBuffer;
  45753. /**
  45754. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  45755. */
  45756. private _genrateVertexBuffer;
  45757. /**
  45758. * Sets the main texture desired size which is the closest power of two
  45759. * of the engine canvas size.
  45760. */
  45761. private _setMainTextureSize;
  45762. /**
  45763. * Creates the main texture for the effect layer.
  45764. */
  45765. protected _createMainTexture(): void;
  45766. /**
  45767. * Adds specific effects defines.
  45768. * @param defines The defines to add specifics to.
  45769. */
  45770. protected _addCustomEffectDefines(defines: string[]): void;
  45771. /**
  45772. * Checks for the readiness of the element composing the layer.
  45773. * @param subMesh the mesh to check for
  45774. * @param useInstances specify wether or not to use instances to render the mesh
  45775. * @param emissiveTexture the associated emissive texture used to generate the glow
  45776. * @return true if ready otherwise, false
  45777. */
  45778. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  45779. /**
  45780. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  45781. */
  45782. render(): void;
  45783. /**
  45784. * Determine if a given mesh will be used in the current effect.
  45785. * @param mesh mesh to test
  45786. * @returns true if the mesh will be used
  45787. */
  45788. hasMesh(mesh: AbstractMesh): boolean;
  45789. /**
  45790. * Returns true if the layer contains information to display, otherwise false.
  45791. * @returns true if the glow layer should be rendered
  45792. */
  45793. shouldRender(): boolean;
  45794. /**
  45795. * Returns true if the mesh should render, otherwise false.
  45796. * @param mesh The mesh to render
  45797. * @returns true if it should render otherwise false
  45798. */
  45799. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  45800. /**
  45801. * Returns true if the mesh can be rendered, otherwise false.
  45802. * @param mesh The mesh to render
  45803. * @param material The material used on the mesh
  45804. * @returns true if it can be rendered otherwise false
  45805. */
  45806. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  45807. /**
  45808. * Returns true if the mesh should render, otherwise false.
  45809. * @param mesh The mesh to render
  45810. * @returns true if it should render otherwise false
  45811. */
  45812. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  45813. /**
  45814. * Renders the submesh passed in parameter to the generation map.
  45815. */
  45816. protected _renderSubMesh(subMesh: SubMesh): void;
  45817. /**
  45818. * Rebuild the required buffers.
  45819. * @hidden Internal use only.
  45820. */
  45821. _rebuild(): void;
  45822. /**
  45823. * Dispose only the render target textures and post process.
  45824. */
  45825. private _disposeTextureAndPostProcesses;
  45826. /**
  45827. * Dispose the highlight layer and free resources.
  45828. */
  45829. dispose(): void;
  45830. /**
  45831. * Gets the class name of the effect layer
  45832. * @returns the string with the class name of the effect layer
  45833. */
  45834. getClassName(): string;
  45835. /**
  45836. * Creates an effect layer from parsed effect layer data
  45837. * @param parsedEffectLayer defines effect layer data
  45838. * @param scene defines the current scene
  45839. * @param rootUrl defines the root URL containing the effect layer information
  45840. * @returns a parsed effect Layer
  45841. */
  45842. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  45843. }
  45844. }
  45845. declare module BABYLON {
  45846. interface AbstractScene {
  45847. /**
  45848. * The list of effect layers (highlights/glow) added to the scene
  45849. * @see http://doc.babylonjs.com/how_to/highlight_layer
  45850. * @see http://doc.babylonjs.com/how_to/glow_layer
  45851. */
  45852. effectLayers: Array<EffectLayer>;
  45853. /**
  45854. * Removes the given effect layer from this scene.
  45855. * @param toRemove defines the effect layer to remove
  45856. * @returns the index of the removed effect layer
  45857. */
  45858. removeEffectLayer(toRemove: EffectLayer): number;
  45859. /**
  45860. * Adds the given effect layer to this scene
  45861. * @param newEffectLayer defines the effect layer to add
  45862. */
  45863. addEffectLayer(newEffectLayer: EffectLayer): void;
  45864. }
  45865. /**
  45866. * Defines the layer scene component responsible to manage any effect layers
  45867. * in a given scene.
  45868. */
  45869. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  45870. /**
  45871. * The component name helpfull to identify the component in the list of scene components.
  45872. */
  45873. readonly name: string;
  45874. /**
  45875. * The scene the component belongs to.
  45876. */
  45877. scene: Scene;
  45878. private _engine;
  45879. private _renderEffects;
  45880. private _needStencil;
  45881. private _previousStencilState;
  45882. /**
  45883. * Creates a new instance of the component for the given scene
  45884. * @param scene Defines the scene to register the component in
  45885. */
  45886. constructor(scene: Scene);
  45887. /**
  45888. * Registers the component in a given scene
  45889. */
  45890. register(): void;
  45891. /**
  45892. * Rebuilds the elements related to this component in case of
  45893. * context lost for instance.
  45894. */
  45895. rebuild(): void;
  45896. /**
  45897. * Serializes the component data to the specified json object
  45898. * @param serializationObject The object to serialize to
  45899. */
  45900. serialize(serializationObject: any): void;
  45901. /**
  45902. * Adds all the element from the container to the scene
  45903. * @param container the container holding the elements
  45904. */
  45905. addFromContainer(container: AbstractScene): void;
  45906. /**
  45907. * Removes all the elements in the container from the scene
  45908. * @param container contains the elements to remove
  45909. * @param dispose if the removed element should be disposed (default: false)
  45910. */
  45911. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  45912. /**
  45913. * Disposes the component and the associated ressources.
  45914. */
  45915. dispose(): void;
  45916. private _isReadyForMesh;
  45917. private _renderMainTexture;
  45918. private _setStencil;
  45919. private _setStencilBack;
  45920. private _draw;
  45921. private _drawCamera;
  45922. private _drawRenderingGroup;
  45923. }
  45924. }
  45925. declare module BABYLON {
  45926. /** @hidden */
  45927. export var glowMapMergePixelShader: {
  45928. name: string;
  45929. shader: string;
  45930. };
  45931. }
  45932. declare module BABYLON {
  45933. /** @hidden */
  45934. export var glowMapMergeVertexShader: {
  45935. name: string;
  45936. shader: string;
  45937. };
  45938. }
  45939. declare module BABYLON {
  45940. interface AbstractScene {
  45941. /**
  45942. * Return a the first highlight layer of the scene with a given name.
  45943. * @param name The name of the highlight layer to look for.
  45944. * @return The highlight layer if found otherwise null.
  45945. */
  45946. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  45947. }
  45948. /**
  45949. * Glow layer options. This helps customizing the behaviour
  45950. * of the glow layer.
  45951. */
  45952. export interface IGlowLayerOptions {
  45953. /**
  45954. * Multiplication factor apply to the canvas size to compute the render target size
  45955. * used to generated the glowing objects (the smaller the faster).
  45956. */
  45957. mainTextureRatio: number;
  45958. /**
  45959. * Enforces a fixed size texture to ensure resize independant blur.
  45960. */
  45961. mainTextureFixedSize?: number;
  45962. /**
  45963. * How big is the kernel of the blur texture.
  45964. */
  45965. blurKernelSize: number;
  45966. /**
  45967. * The camera attached to the layer.
  45968. */
  45969. camera: Nullable<Camera>;
  45970. /**
  45971. * Enable MSAA by chosing the number of samples.
  45972. */
  45973. mainTextureSamples?: number;
  45974. /**
  45975. * The rendering group to draw the layer in.
  45976. */
  45977. renderingGroupId: number;
  45978. }
  45979. /**
  45980. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  45981. *
  45982. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  45983. * glowy meshes to your scene.
  45984. *
  45985. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  45986. */
  45987. export class GlowLayer extends EffectLayer {
  45988. /**
  45989. * Effect Name of the layer.
  45990. */
  45991. static readonly EffectName: string;
  45992. /**
  45993. * The default blur kernel size used for the glow.
  45994. */
  45995. static DefaultBlurKernelSize: number;
  45996. /**
  45997. * The default texture size ratio used for the glow.
  45998. */
  45999. static DefaultTextureRatio: number;
  46000. /**
  46001. * Sets the kernel size of the blur.
  46002. */
  46003. /**
  46004. * Gets the kernel size of the blur.
  46005. */
  46006. blurKernelSize: number;
  46007. /**
  46008. * Sets the glow intensity.
  46009. */
  46010. /**
  46011. * Gets the glow intensity.
  46012. */
  46013. intensity: number;
  46014. private _options;
  46015. private _intensity;
  46016. private _horizontalBlurPostprocess1;
  46017. private _verticalBlurPostprocess1;
  46018. private _horizontalBlurPostprocess2;
  46019. private _verticalBlurPostprocess2;
  46020. private _blurTexture1;
  46021. private _blurTexture2;
  46022. private _postProcesses1;
  46023. private _postProcesses2;
  46024. private _includedOnlyMeshes;
  46025. private _excludedMeshes;
  46026. /**
  46027. * Callback used to let the user override the color selection on a per mesh basis
  46028. */
  46029. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  46030. /**
  46031. * Callback used to let the user override the texture selection on a per mesh basis
  46032. */
  46033. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  46034. /**
  46035. * Instantiates a new glow Layer and references it to the scene.
  46036. * @param name The name of the layer
  46037. * @param scene The scene to use the layer in
  46038. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  46039. */
  46040. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  46041. /**
  46042. * Get the effect name of the layer.
  46043. * @return The effect name
  46044. */
  46045. getEffectName(): string;
  46046. /**
  46047. * Create the merge effect. This is the shader use to blit the information back
  46048. * to the main canvas at the end of the scene rendering.
  46049. */
  46050. protected _createMergeEffect(): Effect;
  46051. /**
  46052. * Creates the render target textures and post processes used in the glow layer.
  46053. */
  46054. protected _createTextureAndPostProcesses(): void;
  46055. /**
  46056. * Checks for the readiness of the element composing the layer.
  46057. * @param subMesh the mesh to check for
  46058. * @param useInstances specify wether or not to use instances to render the mesh
  46059. * @param emissiveTexture the associated emissive texture used to generate the glow
  46060. * @return true if ready otherwise, false
  46061. */
  46062. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46063. /**
  46064. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46065. */
  46066. needStencil(): boolean;
  46067. /**
  46068. * Returns true if the mesh can be rendered, otherwise false.
  46069. * @param mesh The mesh to render
  46070. * @param material The material used on the mesh
  46071. * @returns true if it can be rendered otherwise false
  46072. */
  46073. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  46074. /**
  46075. * Implementation specific of rendering the generating effect on the main canvas.
  46076. * @param effect The effect used to render through
  46077. */
  46078. protected _internalRender(effect: Effect): void;
  46079. /**
  46080. * Sets the required values for both the emissive texture and and the main color.
  46081. */
  46082. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46083. /**
  46084. * Returns true if the mesh should render, otherwise false.
  46085. * @param mesh The mesh to render
  46086. * @returns true if it should render otherwise false
  46087. */
  46088. protected _shouldRenderMesh(mesh: Mesh): boolean;
  46089. /**
  46090. * Adds specific effects defines.
  46091. * @param defines The defines to add specifics to.
  46092. */
  46093. protected _addCustomEffectDefines(defines: string[]): void;
  46094. /**
  46095. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  46096. * @param mesh The mesh to exclude from the glow layer
  46097. */
  46098. addExcludedMesh(mesh: Mesh): void;
  46099. /**
  46100. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  46101. * @param mesh The mesh to remove
  46102. */
  46103. removeExcludedMesh(mesh: Mesh): void;
  46104. /**
  46105. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  46106. * @param mesh The mesh to include in the glow layer
  46107. */
  46108. addIncludedOnlyMesh(mesh: Mesh): void;
  46109. /**
  46110. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  46111. * @param mesh The mesh to remove
  46112. */
  46113. removeIncludedOnlyMesh(mesh: Mesh): void;
  46114. /**
  46115. * Determine if a given mesh will be used in the glow layer
  46116. * @param mesh The mesh to test
  46117. * @returns true if the mesh will be highlighted by the current glow layer
  46118. */
  46119. hasMesh(mesh: AbstractMesh): boolean;
  46120. /**
  46121. * Free any resources and references associated to a mesh.
  46122. * Internal use
  46123. * @param mesh The mesh to free.
  46124. * @hidden
  46125. */
  46126. _disposeMesh(mesh: Mesh): void;
  46127. /**
  46128. * Gets the class name of the effect layer
  46129. * @returns the string with the class name of the effect layer
  46130. */
  46131. getClassName(): string;
  46132. /**
  46133. * Serializes this glow layer
  46134. * @returns a serialized glow layer object
  46135. */
  46136. serialize(): any;
  46137. /**
  46138. * Creates a Glow Layer from parsed glow layer data
  46139. * @param parsedGlowLayer defines glow layer data
  46140. * @param scene defines the current scene
  46141. * @param rootUrl defines the root URL containing the glow layer information
  46142. * @returns a parsed Glow Layer
  46143. */
  46144. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  46145. }
  46146. }
  46147. declare module BABYLON {
  46148. /** @hidden */
  46149. export var glowBlurPostProcessPixelShader: {
  46150. name: string;
  46151. shader: string;
  46152. };
  46153. }
  46154. declare module BABYLON {
  46155. interface AbstractScene {
  46156. /**
  46157. * Return a the first highlight layer of the scene with a given name.
  46158. * @param name The name of the highlight layer to look for.
  46159. * @return The highlight layer if found otherwise null.
  46160. */
  46161. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  46162. }
  46163. /**
  46164. * Highlight layer options. This helps customizing the behaviour
  46165. * of the highlight layer.
  46166. */
  46167. export interface IHighlightLayerOptions {
  46168. /**
  46169. * Multiplication factor apply to the canvas size to compute the render target size
  46170. * used to generated the glowing objects (the smaller the faster).
  46171. */
  46172. mainTextureRatio: number;
  46173. /**
  46174. * Enforces a fixed size texture to ensure resize independant blur.
  46175. */
  46176. mainTextureFixedSize?: number;
  46177. /**
  46178. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  46179. * of the picture to blur (the smaller the faster).
  46180. */
  46181. blurTextureSizeRatio: number;
  46182. /**
  46183. * How big in texel of the blur texture is the vertical blur.
  46184. */
  46185. blurVerticalSize: number;
  46186. /**
  46187. * How big in texel of the blur texture is the horizontal blur.
  46188. */
  46189. blurHorizontalSize: number;
  46190. /**
  46191. * Alpha blending mode used to apply the blur. Default is combine.
  46192. */
  46193. alphaBlendingMode: number;
  46194. /**
  46195. * The camera attached to the layer.
  46196. */
  46197. camera: Nullable<Camera>;
  46198. /**
  46199. * Should we display highlight as a solid stroke?
  46200. */
  46201. isStroke?: boolean;
  46202. /**
  46203. * The rendering group to draw the layer in.
  46204. */
  46205. renderingGroupId: number;
  46206. }
  46207. /**
  46208. * The highlight layer Helps adding a glow effect around a mesh.
  46209. *
  46210. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  46211. * glowy meshes to your scene.
  46212. *
  46213. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  46214. */
  46215. export class HighlightLayer extends EffectLayer {
  46216. name: string;
  46217. /**
  46218. * Effect Name of the highlight layer.
  46219. */
  46220. static readonly EffectName: string;
  46221. /**
  46222. * The neutral color used during the preparation of the glow effect.
  46223. * This is black by default as the blend operation is a blend operation.
  46224. */
  46225. static NeutralColor: Color4;
  46226. /**
  46227. * Stencil value used for glowing meshes.
  46228. */
  46229. static GlowingMeshStencilReference: number;
  46230. /**
  46231. * Stencil value used for the other meshes in the scene.
  46232. */
  46233. static NormalMeshStencilReference: number;
  46234. /**
  46235. * Specifies whether or not the inner glow is ACTIVE in the layer.
  46236. */
  46237. innerGlow: boolean;
  46238. /**
  46239. * Specifies whether or not the outer glow is ACTIVE in the layer.
  46240. */
  46241. outerGlow: boolean;
  46242. /**
  46243. * Specifies the horizontal size of the blur.
  46244. */
  46245. /**
  46246. * Gets the horizontal size of the blur.
  46247. */
  46248. blurHorizontalSize: number;
  46249. /**
  46250. * Specifies the vertical size of the blur.
  46251. */
  46252. /**
  46253. * Gets the vertical size of the blur.
  46254. */
  46255. blurVerticalSize: number;
  46256. /**
  46257. * An event triggered when the highlight layer is being blurred.
  46258. */
  46259. onBeforeBlurObservable: Observable<HighlightLayer>;
  46260. /**
  46261. * An event triggered when the highlight layer has been blurred.
  46262. */
  46263. onAfterBlurObservable: Observable<HighlightLayer>;
  46264. private _instanceGlowingMeshStencilReference;
  46265. private _options;
  46266. private _downSamplePostprocess;
  46267. private _horizontalBlurPostprocess;
  46268. private _verticalBlurPostprocess;
  46269. private _blurTexture;
  46270. private _meshes;
  46271. private _excludedMeshes;
  46272. /**
  46273. * Instantiates a new highlight Layer and references it to the scene..
  46274. * @param name The name of the layer
  46275. * @param scene The scene to use the layer in
  46276. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  46277. */
  46278. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  46279. /**
  46280. * Get the effect name of the layer.
  46281. * @return The effect name
  46282. */
  46283. getEffectName(): string;
  46284. /**
  46285. * Create the merge effect. This is the shader use to blit the information back
  46286. * to the main canvas at the end of the scene rendering.
  46287. */
  46288. protected _createMergeEffect(): Effect;
  46289. /**
  46290. * Creates the render target textures and post processes used in the highlight layer.
  46291. */
  46292. protected _createTextureAndPostProcesses(): void;
  46293. /**
  46294. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46295. */
  46296. needStencil(): boolean;
  46297. /**
  46298. * Checks for the readiness of the element composing the layer.
  46299. * @param subMesh the mesh to check for
  46300. * @param useInstances specify wether or not to use instances to render the mesh
  46301. * @param emissiveTexture the associated emissive texture used to generate the glow
  46302. * @return true if ready otherwise, false
  46303. */
  46304. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46305. /**
  46306. * Implementation specific of rendering the generating effect on the main canvas.
  46307. * @param effect The effect used to render through
  46308. */
  46309. protected _internalRender(effect: Effect): void;
  46310. /**
  46311. * Returns true if the layer contains information to display, otherwise false.
  46312. */
  46313. shouldRender(): boolean;
  46314. /**
  46315. * Returns true if the mesh should render, otherwise false.
  46316. * @param mesh The mesh to render
  46317. * @returns true if it should render otherwise false
  46318. */
  46319. protected _shouldRenderMesh(mesh: Mesh): boolean;
  46320. /**
  46321. * Sets the required values for both the emissive texture and and the main color.
  46322. */
  46323. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46324. /**
  46325. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  46326. * @param mesh The mesh to exclude from the highlight layer
  46327. */
  46328. addExcludedMesh(mesh: Mesh): void;
  46329. /**
  46330. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  46331. * @param mesh The mesh to highlight
  46332. */
  46333. removeExcludedMesh(mesh: Mesh): void;
  46334. /**
  46335. * Determine if a given mesh will be highlighted by the current HighlightLayer
  46336. * @param mesh mesh to test
  46337. * @returns true if the mesh will be highlighted by the current HighlightLayer
  46338. */
  46339. hasMesh(mesh: AbstractMesh): boolean;
  46340. /**
  46341. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  46342. * @param mesh The mesh to highlight
  46343. * @param color The color of the highlight
  46344. * @param glowEmissiveOnly Extract the glow from the emissive texture
  46345. */
  46346. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  46347. /**
  46348. * Remove a mesh from the highlight layer in order to make it stop glowing.
  46349. * @param mesh The mesh to highlight
  46350. */
  46351. removeMesh(mesh: Mesh): void;
  46352. /**
  46353. * Force the stencil to the normal expected value for none glowing parts
  46354. */
  46355. private _defaultStencilReference;
  46356. /**
  46357. * Free any resources and references associated to a mesh.
  46358. * Internal use
  46359. * @param mesh The mesh to free.
  46360. * @hidden
  46361. */
  46362. _disposeMesh(mesh: Mesh): void;
  46363. /**
  46364. * Dispose the highlight layer and free resources.
  46365. */
  46366. dispose(): void;
  46367. /**
  46368. * Gets the class name of the effect layer
  46369. * @returns the string with the class name of the effect layer
  46370. */
  46371. getClassName(): string;
  46372. /**
  46373. * Serializes this Highlight layer
  46374. * @returns a serialized Highlight layer object
  46375. */
  46376. serialize(): any;
  46377. /**
  46378. * Creates a Highlight layer from parsed Highlight layer data
  46379. * @param parsedHightlightLayer defines the Highlight layer data
  46380. * @param scene defines the current scene
  46381. * @param rootUrl defines the root URL containing the Highlight layer information
  46382. * @returns a parsed Highlight layer
  46383. */
  46384. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  46385. }
  46386. }
  46387. declare module BABYLON {
  46388. /** @hidden */
  46389. export var lensFlarePixelShader: {
  46390. name: string;
  46391. shader: string;
  46392. };
  46393. }
  46394. declare module BABYLON {
  46395. /** @hidden */
  46396. export var lensFlareVertexShader: {
  46397. name: string;
  46398. shader: string;
  46399. };
  46400. }
  46401. declare module BABYLON {
  46402. /**
  46403. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  46404. * It is usually composed of several `lensFlare`.
  46405. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46406. */
  46407. export class LensFlareSystem {
  46408. /**
  46409. * Define the name of the lens flare system
  46410. */
  46411. name: string;
  46412. /**
  46413. * List of lens flares used in this system.
  46414. */
  46415. lensFlares: LensFlare[];
  46416. /**
  46417. * Define a limit from the border the lens flare can be visible.
  46418. */
  46419. borderLimit: number;
  46420. /**
  46421. * Define a viewport border we do not want to see the lens flare in.
  46422. */
  46423. viewportBorder: number;
  46424. /**
  46425. * Define a predicate which could limit the list of meshes able to occlude the effect.
  46426. */
  46427. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  46428. /**
  46429. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  46430. */
  46431. layerMask: number;
  46432. /**
  46433. * Define the id of the lens flare system in the scene.
  46434. * (equal to name by default)
  46435. */
  46436. id: string;
  46437. private _scene;
  46438. private _emitter;
  46439. private _vertexBuffers;
  46440. private _indexBuffer;
  46441. private _effect;
  46442. private _positionX;
  46443. private _positionY;
  46444. private _isEnabled;
  46445. /** @hidden */
  46446. static _SceneComponentInitialization: (scene: Scene) => void;
  46447. /**
  46448. * Instantiates a lens flare system.
  46449. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  46450. * It is usually composed of several `lensFlare`.
  46451. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46452. * @param name Define the name of the lens flare system in the scene
  46453. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  46454. * @param scene Define the scene the lens flare system belongs to
  46455. */
  46456. constructor(
  46457. /**
  46458. * Define the name of the lens flare system
  46459. */
  46460. name: string, emitter: any, scene: Scene);
  46461. /**
  46462. * Define if the lens flare system is enabled.
  46463. */
  46464. isEnabled: boolean;
  46465. /**
  46466. * Get the scene the effects belongs to.
  46467. * @returns the scene holding the lens flare system
  46468. */
  46469. getScene(): Scene;
  46470. /**
  46471. * Get the emitter of the lens flare system.
  46472. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  46473. * @returns the emitter of the lens flare system
  46474. */
  46475. getEmitter(): any;
  46476. /**
  46477. * Set the emitter of the lens flare system.
  46478. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  46479. * @param newEmitter Define the new emitter of the system
  46480. */
  46481. setEmitter(newEmitter: any): void;
  46482. /**
  46483. * Get the lens flare system emitter position.
  46484. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  46485. * @returns the position
  46486. */
  46487. getEmitterPosition(): Vector3;
  46488. /**
  46489. * @hidden
  46490. */
  46491. computeEffectivePosition(globalViewport: Viewport): boolean;
  46492. /** @hidden */
  46493. _isVisible(): boolean;
  46494. /**
  46495. * @hidden
  46496. */
  46497. render(): boolean;
  46498. /**
  46499. * Dispose and release the lens flare with its associated resources.
  46500. */
  46501. dispose(): void;
  46502. /**
  46503. * Parse a lens flare system from a JSON repressentation
  46504. * @param parsedLensFlareSystem Define the JSON to parse
  46505. * @param scene Define the scene the parsed system should be instantiated in
  46506. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  46507. * @returns the parsed system
  46508. */
  46509. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  46510. /**
  46511. * Serialize the current Lens Flare System into a JSON representation.
  46512. * @returns the serialized JSON
  46513. */
  46514. serialize(): any;
  46515. }
  46516. }
  46517. declare module BABYLON {
  46518. /**
  46519. * This represents one of the lens effect in a `lensFlareSystem`.
  46520. * It controls one of the indiviual texture used in the effect.
  46521. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46522. */
  46523. export class LensFlare {
  46524. /**
  46525. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  46526. */
  46527. size: number;
  46528. /**
  46529. * 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.
  46530. */
  46531. position: number;
  46532. /**
  46533. * Define the lens color.
  46534. */
  46535. color: Color3;
  46536. /**
  46537. * Define the lens texture.
  46538. */
  46539. texture: Nullable<Texture>;
  46540. /**
  46541. * Define the alpha mode to render this particular lens.
  46542. */
  46543. alphaMode: number;
  46544. private _system;
  46545. /**
  46546. * Creates a new Lens Flare.
  46547. * This represents one of the lens effect in a `lensFlareSystem`.
  46548. * It controls one of the indiviual texture used in the effect.
  46549. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46550. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  46551. * @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.
  46552. * @param color Define the lens color
  46553. * @param imgUrl Define the lens texture url
  46554. * @param system Define the `lensFlareSystem` this flare is part of
  46555. * @returns The newly created Lens Flare
  46556. */
  46557. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  46558. /**
  46559. * Instantiates a new Lens Flare.
  46560. * This represents one of the lens effect in a `lensFlareSystem`.
  46561. * It controls one of the indiviual texture used in the effect.
  46562. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46563. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  46564. * @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.
  46565. * @param color Define the lens color
  46566. * @param imgUrl Define the lens texture url
  46567. * @param system Define the `lensFlareSystem` this flare is part of
  46568. */
  46569. constructor(
  46570. /**
  46571. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  46572. */
  46573. size: number,
  46574. /**
  46575. * 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.
  46576. */
  46577. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  46578. /**
  46579. * Dispose and release the lens flare with its associated resources.
  46580. */
  46581. dispose(): void;
  46582. }
  46583. }
  46584. declare module BABYLON {
  46585. interface AbstractScene {
  46586. /**
  46587. * The list of lens flare system added to the scene
  46588. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46589. */
  46590. lensFlareSystems: Array<LensFlareSystem>;
  46591. /**
  46592. * Removes the given lens flare system from this scene.
  46593. * @param toRemove The lens flare system to remove
  46594. * @returns The index of the removed lens flare system
  46595. */
  46596. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  46597. /**
  46598. * Adds the given lens flare system to this scene
  46599. * @param newLensFlareSystem The lens flare system to add
  46600. */
  46601. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  46602. /**
  46603. * Gets a lens flare system using its name
  46604. * @param name defines the name to look for
  46605. * @returns the lens flare system or null if not found
  46606. */
  46607. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  46608. /**
  46609. * Gets a lens flare system using its id
  46610. * @param id defines the id to look for
  46611. * @returns the lens flare system or null if not found
  46612. */
  46613. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  46614. }
  46615. /**
  46616. * Defines the lens flare scene component responsible to manage any lens flares
  46617. * in a given scene.
  46618. */
  46619. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  46620. /**
  46621. * The component name helpfull to identify the component in the list of scene components.
  46622. */
  46623. readonly name: string;
  46624. /**
  46625. * The scene the component belongs to.
  46626. */
  46627. scene: Scene;
  46628. /**
  46629. * Creates a new instance of the component for the given scene
  46630. * @param scene Defines the scene to register the component in
  46631. */
  46632. constructor(scene: Scene);
  46633. /**
  46634. * Registers the component in a given scene
  46635. */
  46636. register(): void;
  46637. /**
  46638. * Rebuilds the elements related to this component in case of
  46639. * context lost for instance.
  46640. */
  46641. rebuild(): void;
  46642. /**
  46643. * Adds all the element from the container to the scene
  46644. * @param container the container holding the elements
  46645. */
  46646. addFromContainer(container: AbstractScene): void;
  46647. /**
  46648. * Removes all the elements in the container from the scene
  46649. * @param container contains the elements to remove
  46650. * @param dispose if the removed element should be disposed (default: false)
  46651. */
  46652. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  46653. /**
  46654. * Serializes the component data to the specified json object
  46655. * @param serializationObject The object to serialize to
  46656. */
  46657. serialize(serializationObject: any): void;
  46658. /**
  46659. * Disposes the component and the associated ressources.
  46660. */
  46661. dispose(): void;
  46662. private _draw;
  46663. }
  46664. }
  46665. declare module BABYLON {
  46666. /**
  46667. * Defines the shadow generator component responsible to manage any shadow generators
  46668. * in a given scene.
  46669. */
  46670. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  46671. /**
  46672. * The component name helpfull to identify the component in the list of scene components.
  46673. */
  46674. readonly name: string;
  46675. /**
  46676. * The scene the component belongs to.
  46677. */
  46678. scene: Scene;
  46679. /**
  46680. * Creates a new instance of the component for the given scene
  46681. * @param scene Defines the scene to register the component in
  46682. */
  46683. constructor(scene: Scene);
  46684. /**
  46685. * Registers the component in a given scene
  46686. */
  46687. register(): void;
  46688. /**
  46689. * Rebuilds the elements related to this component in case of
  46690. * context lost for instance.
  46691. */
  46692. rebuild(): void;
  46693. /**
  46694. * Serializes the component data to the specified json object
  46695. * @param serializationObject The object to serialize to
  46696. */
  46697. serialize(serializationObject: any): void;
  46698. /**
  46699. * Adds all the element from the container to the scene
  46700. * @param container the container holding the elements
  46701. */
  46702. addFromContainer(container: AbstractScene): void;
  46703. /**
  46704. * Removes all the elements in the container from the scene
  46705. * @param container contains the elements to remove
  46706. * @param dispose if the removed element should be disposed (default: false)
  46707. */
  46708. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  46709. /**
  46710. * Rebuilds the elements related to this component in case of
  46711. * context lost for instance.
  46712. */
  46713. dispose(): void;
  46714. private _gatherRenderTargets;
  46715. }
  46716. }
  46717. declare module BABYLON {
  46718. /**
  46719. * A directional light is defined by a direction (what a surprise!).
  46720. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  46721. * 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.
  46722. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46723. */
  46724. export class DirectionalLight extends ShadowLight {
  46725. private _shadowFrustumSize;
  46726. /**
  46727. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  46728. */
  46729. /**
  46730. * Specifies a fix frustum size for the shadow generation.
  46731. */
  46732. shadowFrustumSize: number;
  46733. private _shadowOrthoScale;
  46734. /**
  46735. * Gets the shadow projection scale against the optimal computed one.
  46736. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46737. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46738. */
  46739. /**
  46740. * Sets the shadow projection scale against the optimal computed one.
  46741. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46742. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46743. */
  46744. shadowOrthoScale: number;
  46745. /**
  46746. * Automatically compute the projection matrix to best fit (including all the casters)
  46747. * on each frame.
  46748. */
  46749. autoUpdateExtends: boolean;
  46750. private _orthoLeft;
  46751. private _orthoRight;
  46752. private _orthoTop;
  46753. private _orthoBottom;
  46754. /**
  46755. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  46756. * The directional light is emitted from everywhere in the given direction.
  46757. * It can cast shadows.
  46758. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46759. * @param name The friendly name of the light
  46760. * @param direction The direction of the light
  46761. * @param scene The scene the light belongs to
  46762. */
  46763. constructor(name: string, direction: Vector3, scene: Scene);
  46764. /**
  46765. * Returns the string "DirectionalLight".
  46766. * @return The class name
  46767. */
  46768. getClassName(): string;
  46769. /**
  46770. * Returns the integer 1.
  46771. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46772. */
  46773. getTypeID(): number;
  46774. /**
  46775. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  46776. * Returns the DirectionalLight Shadow projection matrix.
  46777. */
  46778. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46779. /**
  46780. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  46781. * Returns the DirectionalLight Shadow projection matrix.
  46782. */
  46783. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  46784. /**
  46785. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  46786. * Returns the DirectionalLight Shadow projection matrix.
  46787. */
  46788. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46789. protected _buildUniformLayout(): void;
  46790. /**
  46791. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  46792. * @param effect The effect to update
  46793. * @param lightIndex The index of the light in the effect to update
  46794. * @returns The directional light
  46795. */
  46796. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  46797. /**
  46798. * Gets the minZ used for shadow according to both the scene and the light.
  46799. *
  46800. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46801. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46802. * @param activeCamera The camera we are returning the min for
  46803. * @returns the depth min z
  46804. */
  46805. getDepthMinZ(activeCamera: Camera): number;
  46806. /**
  46807. * Gets the maxZ used for shadow according to both the scene and the light.
  46808. *
  46809. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46810. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46811. * @param activeCamera The camera we are returning the max for
  46812. * @returns the depth max z
  46813. */
  46814. getDepthMaxZ(activeCamera: Camera): number;
  46815. /**
  46816. * Prepares the list of defines specific to the light type.
  46817. * @param defines the list of defines
  46818. * @param lightIndex defines the index of the light for the effect
  46819. */
  46820. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46821. }
  46822. }
  46823. declare module BABYLON {
  46824. /**
  46825. * A point light is a light defined by an unique point in world space.
  46826. * The light is emitted in every direction from this point.
  46827. * A good example of a point light is a standard light bulb.
  46828. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46829. */
  46830. export class PointLight extends ShadowLight {
  46831. private _shadowAngle;
  46832. /**
  46833. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46834. * This specifies what angle the shadow will use to be created.
  46835. *
  46836. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  46837. */
  46838. /**
  46839. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46840. * This specifies what angle the shadow will use to be created.
  46841. *
  46842. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  46843. */
  46844. shadowAngle: number;
  46845. /**
  46846. * Gets the direction if it has been set.
  46847. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46848. */
  46849. /**
  46850. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46851. */
  46852. direction: Vector3;
  46853. /**
  46854. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  46855. * A PointLight emits the light in every direction.
  46856. * It can cast shadows.
  46857. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  46858. * ```javascript
  46859. * var pointLight = new PointLight("pl", camera.position, scene);
  46860. * ```
  46861. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46862. * @param name The light friendly name
  46863. * @param position The position of the point light in the scene
  46864. * @param scene The scene the lights belongs to
  46865. */
  46866. constructor(name: string, position: Vector3, scene: Scene);
  46867. /**
  46868. * Returns the string "PointLight"
  46869. * @returns the class name
  46870. */
  46871. getClassName(): string;
  46872. /**
  46873. * Returns the integer 0.
  46874. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46875. */
  46876. getTypeID(): number;
  46877. /**
  46878. * Specifies wether or not the shadowmap should be a cube texture.
  46879. * @returns true if the shadowmap needs to be a cube texture.
  46880. */
  46881. needCube(): boolean;
  46882. /**
  46883. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  46884. * @param faceIndex The index of the face we are computed the direction to generate shadow
  46885. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  46886. */
  46887. getShadowDirection(faceIndex?: number): Vector3;
  46888. /**
  46889. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  46890. * - fov = PI / 2
  46891. * - aspect ratio : 1.0
  46892. * - z-near and far equal to the active camera minZ and maxZ.
  46893. * Returns the PointLight.
  46894. */
  46895. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46896. protected _buildUniformLayout(): void;
  46897. /**
  46898. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  46899. * @param effect The effect to update
  46900. * @param lightIndex The index of the light in the effect to update
  46901. * @returns The point light
  46902. */
  46903. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  46904. /**
  46905. * Prepares the list of defines specific to the light type.
  46906. * @param defines the list of defines
  46907. * @param lightIndex defines the index of the light for the effect
  46908. */
  46909. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46910. }
  46911. }
  46912. declare module BABYLON {
  46913. /**
  46914. * A spot light is defined by a position, a direction, an angle, and an exponent.
  46915. * These values define a cone of light starting from the position, emitting toward the direction.
  46916. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  46917. * and the exponent defines the speed of the decay of the light with distance (reach).
  46918. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46919. */
  46920. export class SpotLight extends ShadowLight {
  46921. private _angle;
  46922. private _innerAngle;
  46923. private _cosHalfAngle;
  46924. private _lightAngleScale;
  46925. private _lightAngleOffset;
  46926. /**
  46927. * Gets the cone angle of the spot light in Radians.
  46928. */
  46929. /**
  46930. * Sets the cone angle of the spot light in Radians.
  46931. */
  46932. angle: number;
  46933. /**
  46934. * Only used in gltf falloff mode, this defines the angle where
  46935. * the directional falloff will start before cutting at angle which could be seen
  46936. * as outer angle.
  46937. */
  46938. /**
  46939. * Only used in gltf falloff mode, this defines the angle where
  46940. * the directional falloff will start before cutting at angle which could be seen
  46941. * as outer angle.
  46942. */
  46943. innerAngle: number;
  46944. private _shadowAngleScale;
  46945. /**
  46946. * Allows scaling the angle of the light for shadow generation only.
  46947. */
  46948. /**
  46949. * Allows scaling the angle of the light for shadow generation only.
  46950. */
  46951. shadowAngleScale: number;
  46952. /**
  46953. * The light decay speed with the distance from the emission spot.
  46954. */
  46955. exponent: number;
  46956. private _projectionTextureMatrix;
  46957. /**
  46958. * Allows reading the projecton texture
  46959. */
  46960. readonly projectionTextureMatrix: Matrix;
  46961. protected _projectionTextureLightNear: number;
  46962. /**
  46963. * Gets the near clip of the Spotlight for texture projection.
  46964. */
  46965. /**
  46966. * Sets the near clip of the Spotlight for texture projection.
  46967. */
  46968. projectionTextureLightNear: number;
  46969. protected _projectionTextureLightFar: number;
  46970. /**
  46971. * Gets the far clip of the Spotlight for texture projection.
  46972. */
  46973. /**
  46974. * Sets the far clip of the Spotlight for texture projection.
  46975. */
  46976. projectionTextureLightFar: number;
  46977. protected _projectionTextureUpDirection: Vector3;
  46978. /**
  46979. * Gets the Up vector of the Spotlight for texture projection.
  46980. */
  46981. /**
  46982. * Sets the Up vector of the Spotlight for texture projection.
  46983. */
  46984. projectionTextureUpDirection: Vector3;
  46985. private _projectionTexture;
  46986. /**
  46987. * Gets the projection texture of the light.
  46988. */
  46989. /**
  46990. * Sets the projection texture of the light.
  46991. */
  46992. projectionTexture: Nullable<BaseTexture>;
  46993. private _projectionTextureViewLightDirty;
  46994. private _projectionTextureProjectionLightDirty;
  46995. private _projectionTextureDirty;
  46996. private _projectionTextureViewTargetVector;
  46997. private _projectionTextureViewLightMatrix;
  46998. private _projectionTextureProjectionLightMatrix;
  46999. private _projectionTextureScalingMatrix;
  47000. /**
  47001. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  47002. * It can cast shadows.
  47003. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47004. * @param name The light friendly name
  47005. * @param position The position of the spot light in the scene
  47006. * @param direction The direction of the light in the scene
  47007. * @param angle The cone angle of the light in Radians
  47008. * @param exponent The light decay speed with the distance from the emission spot
  47009. * @param scene The scene the lights belongs to
  47010. */
  47011. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  47012. /**
  47013. * Returns the string "SpotLight".
  47014. * @returns the class name
  47015. */
  47016. getClassName(): string;
  47017. /**
  47018. * Returns the integer 2.
  47019. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47020. */
  47021. getTypeID(): number;
  47022. /**
  47023. * Overrides the direction setter to recompute the projection texture view light Matrix.
  47024. */
  47025. protected _setDirection(value: Vector3): void;
  47026. /**
  47027. * Overrides the position setter to recompute the projection texture view light Matrix.
  47028. */
  47029. protected _setPosition(value: Vector3): void;
  47030. /**
  47031. * 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.
  47032. * Returns the SpotLight.
  47033. */
  47034. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47035. protected _computeProjectionTextureViewLightMatrix(): void;
  47036. protected _computeProjectionTextureProjectionLightMatrix(): void;
  47037. /**
  47038. * Main function for light texture projection matrix computing.
  47039. */
  47040. protected _computeProjectionTextureMatrix(): void;
  47041. protected _buildUniformLayout(): void;
  47042. private _computeAngleValues;
  47043. /**
  47044. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  47045. * @param effect The effect to update
  47046. * @param lightIndex The index of the light in the effect to update
  47047. * @returns The spot light
  47048. */
  47049. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  47050. /**
  47051. * Disposes the light and the associated resources.
  47052. */
  47053. dispose(): void;
  47054. /**
  47055. * Prepares the list of defines specific to the light type.
  47056. * @param defines the list of defines
  47057. * @param lightIndex defines the index of the light for the effect
  47058. */
  47059. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47060. }
  47061. }
  47062. declare module BABYLON {
  47063. /**
  47064. * Header information of HDR texture files.
  47065. */
  47066. export interface HDRInfo {
  47067. /**
  47068. * The height of the texture in pixels.
  47069. */
  47070. height: number;
  47071. /**
  47072. * The width of the texture in pixels.
  47073. */
  47074. width: number;
  47075. /**
  47076. * The index of the beginning of the data in the binary file.
  47077. */
  47078. dataPosition: number;
  47079. }
  47080. /**
  47081. * This groups tools to convert HDR texture to native colors array.
  47082. */
  47083. export class HDRTools {
  47084. private static Ldexp;
  47085. private static Rgbe2float;
  47086. private static readStringLine;
  47087. /**
  47088. * Reads header information from an RGBE texture stored in a native array.
  47089. * More information on this format are available here:
  47090. * https://en.wikipedia.org/wiki/RGBE_image_format
  47091. *
  47092. * @param uint8array The binary file stored in native array.
  47093. * @return The header information.
  47094. */
  47095. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  47096. /**
  47097. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  47098. * This RGBE texture needs to store the information as a panorama.
  47099. *
  47100. * More information on this format are available here:
  47101. * https://en.wikipedia.org/wiki/RGBE_image_format
  47102. *
  47103. * @param buffer The binary file stored in an array buffer.
  47104. * @param size The expected size of the extracted cubemap.
  47105. * @return The Cube Map information.
  47106. */
  47107. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  47108. /**
  47109. * Returns the pixels data extracted from an RGBE texture.
  47110. * This pixels will be stored left to right up to down in the R G B order in one array.
  47111. *
  47112. * More information on this format are available here:
  47113. * https://en.wikipedia.org/wiki/RGBE_image_format
  47114. *
  47115. * @param uint8array The binary file stored in an array buffer.
  47116. * @param hdrInfo The header information of the file.
  47117. * @return The pixels data in RGB right to left up to down order.
  47118. */
  47119. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  47120. private static RGBE_ReadPixels_RLE;
  47121. }
  47122. }
  47123. declare module BABYLON {
  47124. /**
  47125. * This represents a texture coming from an HDR input.
  47126. *
  47127. * The only supported format is currently panorama picture stored in RGBE format.
  47128. * Example of such files can be found on HDRLib: http://hdrlib.com/
  47129. */
  47130. export class HDRCubeTexture extends BaseTexture {
  47131. private static _facesMapping;
  47132. private _generateHarmonics;
  47133. private _noMipmap;
  47134. private _textureMatrix;
  47135. private _size;
  47136. private _onLoad;
  47137. private _onError;
  47138. /**
  47139. * The texture URL.
  47140. */
  47141. url: string;
  47142. /**
  47143. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  47144. */
  47145. coordinatesMode: number;
  47146. protected _isBlocking: boolean;
  47147. /**
  47148. * Sets wether or not the texture is blocking during loading.
  47149. */
  47150. /**
  47151. * Gets wether or not the texture is blocking during loading.
  47152. */
  47153. isBlocking: boolean;
  47154. protected _rotationY: number;
  47155. /**
  47156. * Sets texture matrix rotation angle around Y axis in radians.
  47157. */
  47158. /**
  47159. * Gets texture matrix rotation angle around Y axis radians.
  47160. */
  47161. rotationY: number;
  47162. /**
  47163. * Gets or sets the center of the bounding box associated with the cube texture
  47164. * It must define where the camera used to render the texture was set
  47165. */
  47166. boundingBoxPosition: Vector3;
  47167. private _boundingBoxSize;
  47168. /**
  47169. * Gets or sets the size of the bounding box associated with the cube texture
  47170. * When defined, the cubemap will switch to local mode
  47171. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  47172. * @example https://www.babylonjs-playground.com/#RNASML
  47173. */
  47174. boundingBoxSize: Vector3;
  47175. /**
  47176. * Instantiates an HDRTexture from the following parameters.
  47177. *
  47178. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  47179. * @param scene The scene the texture will be used in
  47180. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  47181. * @param noMipmap Forces to not generate the mipmap if true
  47182. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  47183. * @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)
  47184. * @param reserved Reserved flag for internal use.
  47185. */
  47186. 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>);
  47187. /**
  47188. * Get the current class name of the texture useful for serialization or dynamic coding.
  47189. * @returns "HDRCubeTexture"
  47190. */
  47191. getClassName(): string;
  47192. /**
  47193. * Occurs when the file is raw .hdr file.
  47194. */
  47195. private loadTexture;
  47196. clone(): HDRCubeTexture;
  47197. delayLoad(): void;
  47198. /**
  47199. * Get the texture reflection matrix used to rotate/transform the reflection.
  47200. * @returns the reflection matrix
  47201. */
  47202. getReflectionTextureMatrix(): Matrix;
  47203. /**
  47204. * Set the texture reflection matrix used to rotate/transform the reflection.
  47205. * @param value Define the reflection matrix to set
  47206. */
  47207. setReflectionTextureMatrix(value: Matrix): void;
  47208. /**
  47209. * Parses a JSON representation of an HDR Texture in order to create the texture
  47210. * @param parsedTexture Define the JSON representation
  47211. * @param scene Define the scene the texture should be created in
  47212. * @param rootUrl Define the root url in case we need to load relative dependencies
  47213. * @returns the newly created texture after parsing
  47214. */
  47215. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  47216. serialize(): any;
  47217. }
  47218. }
  47219. declare module BABYLON {
  47220. /**
  47221. * Class used to control physics engine
  47222. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  47223. */
  47224. export class PhysicsEngine implements IPhysicsEngine {
  47225. private _physicsPlugin;
  47226. /**
  47227. * Global value used to control the smallest number supported by the simulation
  47228. */
  47229. static Epsilon: number;
  47230. private _impostors;
  47231. private _joints;
  47232. /**
  47233. * Gets the gravity vector used by the simulation
  47234. */
  47235. gravity: Vector3;
  47236. /**
  47237. * Factory used to create the default physics plugin.
  47238. * @returns The default physics plugin
  47239. */
  47240. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  47241. /**
  47242. * Creates a new Physics Engine
  47243. * @param gravity defines the gravity vector used by the simulation
  47244. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  47245. */
  47246. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  47247. /**
  47248. * Sets the gravity vector used by the simulation
  47249. * @param gravity defines the gravity vector to use
  47250. */
  47251. setGravity(gravity: Vector3): void;
  47252. /**
  47253. * Set the time step of the physics engine.
  47254. * Default is 1/60.
  47255. * To slow it down, enter 1/600 for example.
  47256. * To speed it up, 1/30
  47257. * @param newTimeStep defines the new timestep to apply to this world.
  47258. */
  47259. setTimeStep(newTimeStep?: number): void;
  47260. /**
  47261. * Get the time step of the physics engine.
  47262. * @returns the current time step
  47263. */
  47264. getTimeStep(): number;
  47265. /**
  47266. * Release all resources
  47267. */
  47268. dispose(): void;
  47269. /**
  47270. * Gets the name of the current physics plugin
  47271. * @returns the name of the plugin
  47272. */
  47273. getPhysicsPluginName(): string;
  47274. /**
  47275. * Adding a new impostor for the impostor tracking.
  47276. * This will be done by the impostor itself.
  47277. * @param impostor the impostor to add
  47278. */
  47279. addImpostor(impostor: PhysicsImpostor): void;
  47280. /**
  47281. * Remove an impostor from the engine.
  47282. * This impostor and its mesh will not longer be updated by the physics engine.
  47283. * @param impostor the impostor to remove
  47284. */
  47285. removeImpostor(impostor: PhysicsImpostor): void;
  47286. /**
  47287. * Add a joint to the physics engine
  47288. * @param mainImpostor defines the main impostor to which the joint is added.
  47289. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  47290. * @param joint defines the joint that will connect both impostors.
  47291. */
  47292. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  47293. /**
  47294. * Removes a joint from the simulation
  47295. * @param mainImpostor defines the impostor used with the joint
  47296. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  47297. * @param joint defines the joint to remove
  47298. */
  47299. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  47300. /**
  47301. * Called by the scene. No need to call it.
  47302. * @param delta defines the timespam between frames
  47303. */
  47304. _step(delta: number): void;
  47305. /**
  47306. * Gets the current plugin used to run the simulation
  47307. * @returns current plugin
  47308. */
  47309. getPhysicsPlugin(): IPhysicsEnginePlugin;
  47310. /**
  47311. * Gets the list of physic impostors
  47312. * @returns an array of PhysicsImpostor
  47313. */
  47314. getImpostors(): Array<PhysicsImpostor>;
  47315. /**
  47316. * Gets the impostor for a physics enabled object
  47317. * @param object defines the object impersonated by the impostor
  47318. * @returns the PhysicsImpostor or null if not found
  47319. */
  47320. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  47321. /**
  47322. * Gets the impostor for a physics body object
  47323. * @param body defines physics body used by the impostor
  47324. * @returns the PhysicsImpostor or null if not found
  47325. */
  47326. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  47327. /**
  47328. * Does a raycast in the physics world
  47329. * @param from when should the ray start?
  47330. * @param to when should the ray end?
  47331. * @returns PhysicsRaycastResult
  47332. */
  47333. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  47334. }
  47335. }
  47336. declare module BABYLON {
  47337. /** @hidden */
  47338. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  47339. private _useDeltaForWorldStep;
  47340. world: any;
  47341. name: string;
  47342. private _physicsMaterials;
  47343. private _fixedTimeStep;
  47344. private _cannonRaycastResult;
  47345. private _raycastResult;
  47346. BJSCANNON: any;
  47347. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  47348. setGravity(gravity: Vector3): void;
  47349. setTimeStep(timeStep: number): void;
  47350. getTimeStep(): number;
  47351. executeStep(delta: number): void;
  47352. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47353. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47354. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47355. private _processChildMeshes;
  47356. removePhysicsBody(impostor: PhysicsImpostor): void;
  47357. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  47358. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  47359. private _addMaterial;
  47360. private _checkWithEpsilon;
  47361. private _createShape;
  47362. private _createHeightmap;
  47363. private _minus90X;
  47364. private _plus90X;
  47365. private _tmpPosition;
  47366. private _tmpDeltaPosition;
  47367. private _tmpUnityRotation;
  47368. private _updatePhysicsBodyTransformation;
  47369. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  47370. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  47371. isSupported(): boolean;
  47372. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47373. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47374. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47375. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47376. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  47377. getBodyMass(impostor: PhysicsImpostor): number;
  47378. getBodyFriction(impostor: PhysicsImpostor): number;
  47379. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  47380. getBodyRestitution(impostor: PhysicsImpostor): number;
  47381. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  47382. sleepBody(impostor: PhysicsImpostor): void;
  47383. wakeUpBody(impostor: PhysicsImpostor): void;
  47384. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  47385. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  47386. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  47387. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  47388. getRadius(impostor: PhysicsImpostor): number;
  47389. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  47390. dispose(): void;
  47391. private _extendNamespace;
  47392. /**
  47393. * Does a raycast in the physics world
  47394. * @param from when should the ray start?
  47395. * @param to when should the ray end?
  47396. * @returns PhysicsRaycastResult
  47397. */
  47398. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  47399. }
  47400. }
  47401. declare module BABYLON {
  47402. /** @hidden */
  47403. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  47404. world: any;
  47405. name: string;
  47406. BJSOIMO: any;
  47407. private _raycastResult;
  47408. constructor(iterations?: number, oimoInjection?: any);
  47409. setGravity(gravity: Vector3): void;
  47410. setTimeStep(timeStep: number): void;
  47411. getTimeStep(): number;
  47412. private _tmpImpostorsArray;
  47413. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  47414. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47415. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47416. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47417. private _tmpPositionVector;
  47418. removePhysicsBody(impostor: PhysicsImpostor): void;
  47419. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  47420. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  47421. isSupported(): boolean;
  47422. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  47423. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  47424. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47425. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47426. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47427. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47428. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  47429. getBodyMass(impostor: PhysicsImpostor): number;
  47430. getBodyFriction(impostor: PhysicsImpostor): number;
  47431. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  47432. getBodyRestitution(impostor: PhysicsImpostor): number;
  47433. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  47434. sleepBody(impostor: PhysicsImpostor): void;
  47435. wakeUpBody(impostor: PhysicsImpostor): void;
  47436. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  47437. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  47438. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  47439. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  47440. getRadius(impostor: PhysicsImpostor): number;
  47441. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  47442. dispose(): void;
  47443. /**
  47444. * Does a raycast in the physics world
  47445. * @param from when should the ray start?
  47446. * @param to when should the ray end?
  47447. * @returns PhysicsRaycastResult
  47448. */
  47449. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  47450. }
  47451. }
  47452. declare module BABYLON {
  47453. interface AbstractScene {
  47454. /**
  47455. * The list of reflection probes added to the scene
  47456. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  47457. */
  47458. reflectionProbes: Array<ReflectionProbe>;
  47459. /**
  47460. * Removes the given reflection probe from this scene.
  47461. * @param toRemove The reflection probe to remove
  47462. * @returns The index of the removed reflection probe
  47463. */
  47464. removeReflectionProbe(toRemove: ReflectionProbe): number;
  47465. /**
  47466. * Adds the given reflection probe to this scene.
  47467. * @param newReflectionProbe The reflection probe to add
  47468. */
  47469. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  47470. }
  47471. /**
  47472. * Class used to generate realtime reflection / refraction cube textures
  47473. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  47474. */
  47475. export class ReflectionProbe {
  47476. /** defines the name of the probe */
  47477. name: string;
  47478. private _scene;
  47479. private _renderTargetTexture;
  47480. private _projectionMatrix;
  47481. private _viewMatrix;
  47482. private _target;
  47483. private _add;
  47484. private _attachedMesh;
  47485. private _invertYAxis;
  47486. /** Gets or sets probe position (center of the cube map) */
  47487. position: Vector3;
  47488. /**
  47489. * Creates a new reflection probe
  47490. * @param name defines the name of the probe
  47491. * @param size defines the texture resolution (for each face)
  47492. * @param scene defines the hosting scene
  47493. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  47494. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  47495. */
  47496. constructor(
  47497. /** defines the name of the probe */
  47498. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  47499. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  47500. samples: number;
  47501. /** Gets or sets the refresh rate to use (on every frame by default) */
  47502. refreshRate: number;
  47503. /**
  47504. * Gets the hosting scene
  47505. * @returns a Scene
  47506. */
  47507. getScene(): Scene;
  47508. /** Gets the internal CubeTexture used to render to */
  47509. readonly cubeTexture: RenderTargetTexture;
  47510. /** Gets the list of meshes to render */
  47511. readonly renderList: Nullable<AbstractMesh[]>;
  47512. /**
  47513. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  47514. * @param mesh defines the mesh to attach to
  47515. */
  47516. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  47517. /**
  47518. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  47519. * @param renderingGroupId The rendering group id corresponding to its index
  47520. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  47521. */
  47522. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  47523. /**
  47524. * Clean all associated resources
  47525. */
  47526. dispose(): void;
  47527. /**
  47528. * Converts the reflection probe information to a readable string for debug purpose.
  47529. * @param fullDetails Supports for multiple levels of logging within scene loading
  47530. * @returns the human readable reflection probe info
  47531. */
  47532. toString(fullDetails?: boolean): string;
  47533. /**
  47534. * Get the class name of the relfection probe.
  47535. * @returns "ReflectionProbe"
  47536. */
  47537. getClassName(): string;
  47538. /**
  47539. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  47540. * @returns The JSON representation of the texture
  47541. */
  47542. serialize(): any;
  47543. /**
  47544. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  47545. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  47546. * @param scene Define the scene the parsed reflection probe should be instantiated in
  47547. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  47548. * @returns The parsed reflection probe if successful
  47549. */
  47550. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  47551. }
  47552. }
  47553. declare module BABYLON {
  47554. /** @hidden */
  47555. export var _BabylonLoaderRegistered: boolean;
  47556. }
  47557. declare module BABYLON {
  47558. /**
  47559. * The Physically based simple base material of BJS.
  47560. *
  47561. * This enables better naming and convention enforcements on top of the pbrMaterial.
  47562. * It is used as the base class for both the specGloss and metalRough conventions.
  47563. */
  47564. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  47565. /**
  47566. * Number of Simultaneous lights allowed on the material.
  47567. */
  47568. maxSimultaneousLights: number;
  47569. /**
  47570. * If sets to true, disables all the lights affecting the material.
  47571. */
  47572. disableLighting: boolean;
  47573. /**
  47574. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  47575. */
  47576. environmentTexture: BaseTexture;
  47577. /**
  47578. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  47579. */
  47580. invertNormalMapX: boolean;
  47581. /**
  47582. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  47583. */
  47584. invertNormalMapY: boolean;
  47585. /**
  47586. * Normal map used in the model.
  47587. */
  47588. normalTexture: BaseTexture;
  47589. /**
  47590. * Emissivie color used to self-illuminate the model.
  47591. */
  47592. emissiveColor: Color3;
  47593. /**
  47594. * Emissivie texture used to self-illuminate the model.
  47595. */
  47596. emissiveTexture: BaseTexture;
  47597. /**
  47598. * Occlusion Channel Strenght.
  47599. */
  47600. occlusionStrength: number;
  47601. /**
  47602. * Occlusion Texture of the material (adding extra occlusion effects).
  47603. */
  47604. occlusionTexture: BaseTexture;
  47605. /**
  47606. * Defines the alpha limits in alpha test mode.
  47607. */
  47608. alphaCutOff: number;
  47609. /**
  47610. * Gets the current double sided mode.
  47611. */
  47612. /**
  47613. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47614. */
  47615. doubleSided: boolean;
  47616. /**
  47617. * Stores the pre-calculated light information of a mesh in a texture.
  47618. */
  47619. lightmapTexture: BaseTexture;
  47620. /**
  47621. * If true, the light map contains occlusion information instead of lighting info.
  47622. */
  47623. useLightmapAsShadowmap: boolean;
  47624. /**
  47625. * Instantiates a new PBRMaterial instance.
  47626. *
  47627. * @param name The material name
  47628. * @param scene The scene the material will be use in.
  47629. */
  47630. constructor(name: string, scene: Scene);
  47631. getClassName(): string;
  47632. }
  47633. }
  47634. declare module BABYLON {
  47635. /**
  47636. * The PBR material of BJS following the metal roughness convention.
  47637. *
  47638. * This fits to the PBR convention in the GLTF definition:
  47639. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  47640. */
  47641. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  47642. /**
  47643. * The base color has two different interpretations depending on the value of metalness.
  47644. * When the material is a metal, the base color is the specific measured reflectance value
  47645. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  47646. * of the material.
  47647. */
  47648. baseColor: Color3;
  47649. /**
  47650. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  47651. * well as opacity information in the alpha channel.
  47652. */
  47653. baseTexture: BaseTexture;
  47654. /**
  47655. * Specifies the metallic scalar value of the material.
  47656. * Can also be used to scale the metalness values of the metallic texture.
  47657. */
  47658. metallic: number;
  47659. /**
  47660. * Specifies the roughness scalar value of the material.
  47661. * Can also be used to scale the roughness values of the metallic texture.
  47662. */
  47663. roughness: number;
  47664. /**
  47665. * Texture containing both the metallic value in the B channel and the
  47666. * roughness value in the G channel to keep better precision.
  47667. */
  47668. metallicRoughnessTexture: BaseTexture;
  47669. /**
  47670. * Instantiates a new PBRMetalRoughnessMaterial instance.
  47671. *
  47672. * @param name The material name
  47673. * @param scene The scene the material will be use in.
  47674. */
  47675. constructor(name: string, scene: Scene);
  47676. /**
  47677. * Return the currrent class name of the material.
  47678. */
  47679. getClassName(): string;
  47680. /**
  47681. * Makes a duplicate of the current material.
  47682. * @param name - name to use for the new material.
  47683. */
  47684. clone(name: string): PBRMetallicRoughnessMaterial;
  47685. /**
  47686. * Serialize the material to a parsable JSON object.
  47687. */
  47688. serialize(): any;
  47689. /**
  47690. * Parses a JSON object correponding to the serialize function.
  47691. */
  47692. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  47693. }
  47694. }
  47695. declare module BABYLON {
  47696. /**
  47697. * The PBR material of BJS following the specular glossiness convention.
  47698. *
  47699. * This fits to the PBR convention in the GLTF definition:
  47700. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  47701. */
  47702. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  47703. /**
  47704. * Specifies the diffuse color of the material.
  47705. */
  47706. diffuseColor: Color3;
  47707. /**
  47708. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  47709. * channel.
  47710. */
  47711. diffuseTexture: BaseTexture;
  47712. /**
  47713. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  47714. */
  47715. specularColor: Color3;
  47716. /**
  47717. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  47718. */
  47719. glossiness: number;
  47720. /**
  47721. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  47722. */
  47723. specularGlossinessTexture: BaseTexture;
  47724. /**
  47725. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  47726. *
  47727. * @param name The material name
  47728. * @param scene The scene the material will be use in.
  47729. */
  47730. constructor(name: string, scene: Scene);
  47731. /**
  47732. * Return the currrent class name of the material.
  47733. */
  47734. getClassName(): string;
  47735. /**
  47736. * Makes a duplicate of the current material.
  47737. * @param name - name to use for the new material.
  47738. */
  47739. clone(name: string): PBRSpecularGlossinessMaterial;
  47740. /**
  47741. * Serialize the material to a parsable JSON object.
  47742. */
  47743. serialize(): any;
  47744. /**
  47745. * Parses a JSON object correponding to the serialize function.
  47746. */
  47747. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  47748. }
  47749. }
  47750. declare module BABYLON {
  47751. /**
  47752. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  47753. * It can help converting any input color in a desired output one. This can then be used to create effects
  47754. * from sepia, black and white to sixties or futuristic rendering...
  47755. *
  47756. * The only supported format is currently 3dl.
  47757. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  47758. */
  47759. export class ColorGradingTexture extends BaseTexture {
  47760. /**
  47761. * The current texture matrix. (will always be identity in color grading texture)
  47762. */
  47763. private _textureMatrix;
  47764. /**
  47765. * The texture URL.
  47766. */
  47767. url: string;
  47768. /**
  47769. * Empty line regex stored for GC.
  47770. */
  47771. private static _noneEmptyLineRegex;
  47772. private _engine;
  47773. /**
  47774. * Instantiates a ColorGradingTexture from the following parameters.
  47775. *
  47776. * @param url The location of the color gradind data (currently only supporting 3dl)
  47777. * @param scene The scene the texture will be used in
  47778. */
  47779. constructor(url: string, scene: Scene);
  47780. /**
  47781. * Returns the texture matrix used in most of the material.
  47782. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  47783. */
  47784. getTextureMatrix(): Matrix;
  47785. /**
  47786. * Occurs when the file being loaded is a .3dl LUT file.
  47787. */
  47788. private load3dlTexture;
  47789. /**
  47790. * Starts the loading process of the texture.
  47791. */
  47792. private loadTexture;
  47793. /**
  47794. * Clones the color gradind texture.
  47795. */
  47796. clone(): ColorGradingTexture;
  47797. /**
  47798. * Called during delayed load for textures.
  47799. */
  47800. delayLoad(): void;
  47801. /**
  47802. * Parses a color grading texture serialized by Babylon.
  47803. * @param parsedTexture The texture information being parsedTexture
  47804. * @param scene The scene to load the texture in
  47805. * @param rootUrl The root url of the data assets to load
  47806. * @return A color gradind texture
  47807. */
  47808. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  47809. /**
  47810. * Serializes the LUT texture to json format.
  47811. */
  47812. serialize(): any;
  47813. }
  47814. }
  47815. declare module BABYLON {
  47816. /**
  47817. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  47818. */
  47819. export class EquiRectangularCubeTexture extends BaseTexture {
  47820. /** The six faces of the cube. */
  47821. private static _FacesMapping;
  47822. private _noMipmap;
  47823. private _onLoad;
  47824. private _onError;
  47825. /** The size of the cubemap. */
  47826. private _size;
  47827. /** The buffer of the image. */
  47828. private _buffer;
  47829. /** The width of the input image. */
  47830. private _width;
  47831. /** The height of the input image. */
  47832. private _height;
  47833. /** The URL to the image. */
  47834. url: string;
  47835. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  47836. coordinatesMode: number;
  47837. /**
  47838. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  47839. * @param url The location of the image
  47840. * @param scene The scene the texture will be used in
  47841. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  47842. * @param noMipmap Forces to not generate the mipmap if true
  47843. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  47844. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  47845. * @param onLoad — defines a callback called when texture is loaded
  47846. * @param onError — defines a callback called if there is an error
  47847. */
  47848. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  47849. /**
  47850. * Load the image data, by putting the image on a canvas and extracting its buffer.
  47851. */
  47852. private loadImage;
  47853. /**
  47854. * Convert the image buffer into a cubemap and create a CubeTexture.
  47855. */
  47856. private loadTexture;
  47857. /**
  47858. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  47859. * @param buffer The ArrayBuffer that should be converted.
  47860. * @returns The buffer as Float32Array.
  47861. */
  47862. private getFloat32ArrayFromArrayBuffer;
  47863. /**
  47864. * Get the current class name of the texture useful for serialization or dynamic coding.
  47865. * @returns "EquiRectangularCubeTexture"
  47866. */
  47867. getClassName(): string;
  47868. /**
  47869. * Create a clone of the current EquiRectangularCubeTexture and return it.
  47870. * @returns A clone of the current EquiRectangularCubeTexture.
  47871. */
  47872. clone(): EquiRectangularCubeTexture;
  47873. }
  47874. }
  47875. declare module BABYLON {
  47876. /**
  47877. * Based on jsTGALoader - Javascript loader for TGA file
  47878. * By Vincent Thibault
  47879. * @see http://blog.robrowser.com/javascript-tga-loader.html
  47880. */
  47881. export class TGATools {
  47882. private static _TYPE_INDEXED;
  47883. private static _TYPE_RGB;
  47884. private static _TYPE_GREY;
  47885. private static _TYPE_RLE_INDEXED;
  47886. private static _TYPE_RLE_RGB;
  47887. private static _TYPE_RLE_GREY;
  47888. private static _ORIGIN_MASK;
  47889. private static _ORIGIN_SHIFT;
  47890. private static _ORIGIN_BL;
  47891. private static _ORIGIN_BR;
  47892. private static _ORIGIN_UL;
  47893. private static _ORIGIN_UR;
  47894. /**
  47895. * Gets the header of a TGA file
  47896. * @param data defines the TGA data
  47897. * @returns the header
  47898. */
  47899. static GetTGAHeader(data: Uint8Array): any;
  47900. /**
  47901. * Uploads TGA content to a Babylon Texture
  47902. * @hidden
  47903. */
  47904. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  47905. /** @hidden */
  47906. 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;
  47907. /** @hidden */
  47908. 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;
  47909. /** @hidden */
  47910. 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;
  47911. /** @hidden */
  47912. 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;
  47913. /** @hidden */
  47914. 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;
  47915. /** @hidden */
  47916. 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;
  47917. }
  47918. }
  47919. declare module BABYLON {
  47920. /**
  47921. * Implementation of the TGA Texture Loader.
  47922. * @hidden
  47923. */
  47924. export class _TGATextureLoader implements IInternalTextureLoader {
  47925. /**
  47926. * Defines wether the loader supports cascade loading the different faces.
  47927. */
  47928. readonly supportCascades: boolean;
  47929. /**
  47930. * This returns if the loader support the current file information.
  47931. * @param extension defines the file extension of the file being loaded
  47932. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47933. * @param fallback defines the fallback internal texture if any
  47934. * @param isBase64 defines whether the texture is encoded as a base64
  47935. * @param isBuffer defines whether the texture data are stored as a buffer
  47936. * @returns true if the loader can load the specified file
  47937. */
  47938. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47939. /**
  47940. * Transform the url before loading if required.
  47941. * @param rootUrl the url of the texture
  47942. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47943. * @returns the transformed texture
  47944. */
  47945. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47946. /**
  47947. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47948. * @param rootUrl the url of the texture
  47949. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47950. * @returns the fallback texture
  47951. */
  47952. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47953. /**
  47954. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47955. * @param data contains the texture data
  47956. * @param texture defines the BabylonJS internal texture
  47957. * @param createPolynomials will be true if polynomials have been requested
  47958. * @param onLoad defines the callback to trigger once the texture is ready
  47959. * @param onError defines the callback to trigger in case of error
  47960. */
  47961. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47962. /**
  47963. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47964. * @param data contains the texture data
  47965. * @param texture defines the BabylonJS internal texture
  47966. * @param callback defines the method to call once ready to upload
  47967. */
  47968. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  47969. }
  47970. }
  47971. declare module BABYLON {
  47972. /**
  47973. * 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.
  47974. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  47975. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  47976. */
  47977. export class CustomProceduralTexture extends ProceduralTexture {
  47978. private _animate;
  47979. private _time;
  47980. private _config;
  47981. private _texturePath;
  47982. /**
  47983. * Instantiates a new Custom Procedural Texture.
  47984. * 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.
  47985. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  47986. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  47987. * @param name Define the name of the texture
  47988. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  47989. * @param size Define the size of the texture to create
  47990. * @param scene Define the scene the texture belongs to
  47991. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  47992. * @param generateMipMaps Define if the texture should creates mip maps or not
  47993. */
  47994. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  47995. private _loadJson;
  47996. /**
  47997. * Is the texture ready to be used ? (rendered at least once)
  47998. * @returns true if ready, otherwise, false.
  47999. */
  48000. isReady(): boolean;
  48001. /**
  48002. * Render the texture to its associated render target.
  48003. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  48004. */
  48005. render(useCameraPostProcess?: boolean): void;
  48006. /**
  48007. * Update the list of dependant textures samplers in the shader.
  48008. */
  48009. updateTextures(): void;
  48010. /**
  48011. * Update the uniform values of the procedural texture in the shader.
  48012. */
  48013. updateShaderUniforms(): void;
  48014. /**
  48015. * Define if the texture animates or not.
  48016. */
  48017. animate: boolean;
  48018. }
  48019. }
  48020. declare module BABYLON {
  48021. /** @hidden */
  48022. export var noisePixelShader: {
  48023. name: string;
  48024. shader: string;
  48025. };
  48026. }
  48027. declare module BABYLON {
  48028. /**
  48029. * Class used to generate noise procedural textures
  48030. */
  48031. export class NoiseProceduralTexture extends ProceduralTexture {
  48032. private _time;
  48033. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  48034. brightness: number;
  48035. /** Defines the number of octaves to process */
  48036. octaves: number;
  48037. /** Defines the level of persistence (0.8 by default) */
  48038. persistence: number;
  48039. /** Gets or sets animation speed factor (default is 1) */
  48040. animationSpeedFactor: number;
  48041. /**
  48042. * Creates a new NoiseProceduralTexture
  48043. * @param name defines the name fo the texture
  48044. * @param size defines the size of the texture (default is 256)
  48045. * @param scene defines the hosting scene
  48046. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  48047. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  48048. */
  48049. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  48050. private _updateShaderUniforms;
  48051. protected _getDefines(): string;
  48052. /** Generate the current state of the procedural texture */
  48053. render(useCameraPostProcess?: boolean): void;
  48054. /**
  48055. * Serializes this noise procedural texture
  48056. * @returns a serialized noise procedural texture object
  48057. */
  48058. serialize(): any;
  48059. /**
  48060. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  48061. * @param parsedTexture defines parsed texture data
  48062. * @param scene defines the current scene
  48063. * @param rootUrl defines the root URL containing noise procedural texture information
  48064. * @returns a parsed NoiseProceduralTexture
  48065. */
  48066. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  48067. }
  48068. }
  48069. declare module BABYLON {
  48070. /**
  48071. * Raw cube texture where the raw buffers are passed in
  48072. */
  48073. export class RawCubeTexture extends CubeTexture {
  48074. /**
  48075. * Creates a cube texture where the raw buffers are passed in.
  48076. * @param scene defines the scene the texture is attached to
  48077. * @param data defines the array of data to use to create each face
  48078. * @param size defines the size of the textures
  48079. * @param format defines the format of the data
  48080. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  48081. * @param generateMipMaps defines if the engine should generate the mip levels
  48082. * @param invertY defines if data must be stored with Y axis inverted
  48083. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  48084. * @param compression defines the compression used (null by default)
  48085. */
  48086. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  48087. /**
  48088. * Updates the raw cube texture.
  48089. * @param data defines the data to store
  48090. * @param format defines the data format
  48091. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  48092. * @param invertY defines if data must be stored with Y axis inverted
  48093. * @param compression defines the compression used (null by default)
  48094. * @param level defines which level of the texture to update
  48095. */
  48096. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  48097. /**
  48098. * Updates a raw cube texture with RGBD encoded data.
  48099. * @param data defines the array of data [mipmap][face] to use to create each face
  48100. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  48101. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  48102. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  48103. * @returns a promsie that resolves when the operation is complete
  48104. */
  48105. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  48106. /**
  48107. * Clones the raw cube texture.
  48108. * @return a new cube texture
  48109. */
  48110. clone(): CubeTexture;
  48111. /** @hidden */
  48112. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48113. }
  48114. }
  48115. declare module BABYLON {
  48116. /**
  48117. * Class used to store 3D textures containing user data
  48118. */
  48119. export class RawTexture3D extends Texture {
  48120. /** Gets or sets the texture format to use */
  48121. format: number;
  48122. private _engine;
  48123. /**
  48124. * Create a new RawTexture3D
  48125. * @param data defines the data of the texture
  48126. * @param width defines the width of the texture
  48127. * @param height defines the height of the texture
  48128. * @param depth defines the depth of the texture
  48129. * @param format defines the texture format to use
  48130. * @param scene defines the hosting scene
  48131. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  48132. * @param invertY defines if texture must be stored with Y axis inverted
  48133. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  48134. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  48135. */
  48136. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  48137. /** Gets or sets the texture format to use */
  48138. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  48139. /**
  48140. * Update the texture with new data
  48141. * @param data defines the data to store in the texture
  48142. */
  48143. update(data: ArrayBufferView): void;
  48144. }
  48145. }
  48146. declare module BABYLON {
  48147. /**
  48148. * Creates a refraction texture used by refraction channel of the standard material.
  48149. * It is like a mirror but to see through a material.
  48150. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  48151. */
  48152. export class RefractionTexture extends RenderTargetTexture {
  48153. /**
  48154. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  48155. * It is possible to directly set the refractionPlane by directly using a 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.
  48156. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  48157. */
  48158. refractionPlane: Plane;
  48159. /**
  48160. * Define how deep under the surface we should see.
  48161. */
  48162. depth: number;
  48163. /**
  48164. * Creates a refraction texture used by refraction channel of the standard material.
  48165. * It is like a mirror but to see through a material.
  48166. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  48167. * @param name Define the texture name
  48168. * @param size Define the size of the underlying texture
  48169. * @param scene Define the scene the refraction belongs to
  48170. * @param generateMipMaps Define if we need to generate mips level for the refraction
  48171. */
  48172. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  48173. /**
  48174. * Clone the refraction texture.
  48175. * @returns the cloned texture
  48176. */
  48177. clone(): RefractionTexture;
  48178. /**
  48179. * Serialize the texture to a JSON representation you could use in Parse later on
  48180. * @returns the serialized JSON representation
  48181. */
  48182. serialize(): any;
  48183. }
  48184. }
  48185. declare module BABYLON {
  48186. /**
  48187. * Configuration for Draco compression
  48188. */
  48189. export interface IDracoCompressionConfiguration {
  48190. /**
  48191. * Configuration for the decoder.
  48192. */
  48193. decoder?: {
  48194. /**
  48195. * The url to the WebAssembly module.
  48196. */
  48197. wasmUrl?: string;
  48198. /**
  48199. * The url to the WebAssembly binary.
  48200. */
  48201. wasmBinaryUrl?: string;
  48202. /**
  48203. * The url to the fallback JavaScript module.
  48204. */
  48205. fallbackUrl?: string;
  48206. };
  48207. }
  48208. /**
  48209. * Draco compression (https://google.github.io/draco/)
  48210. *
  48211. * This class wraps the Draco module.
  48212. *
  48213. * **Encoder**
  48214. *
  48215. * The encoder is not currently implemented.
  48216. *
  48217. * **Decoder**
  48218. *
  48219. * 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.
  48220. *
  48221. * To update the configuration, use the following code:
  48222. * ```javascript
  48223. * DracoCompression.Configuration = {
  48224. * decoder: {
  48225. * wasmUrl: "<url to the WebAssembly library>",
  48226. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  48227. * fallbackUrl: "<url to the fallback JavaScript library>",
  48228. * }
  48229. * };
  48230. * ```
  48231. *
  48232. * 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.
  48233. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  48234. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  48235. *
  48236. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  48237. * ```javascript
  48238. * var dracoCompression = new DracoCompression();
  48239. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  48240. * [VertexBuffer.PositionKind]: 0
  48241. * });
  48242. * ```
  48243. *
  48244. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  48245. */
  48246. export class DracoCompression implements IDisposable {
  48247. private static _DecoderModulePromise;
  48248. /**
  48249. * The configuration. Defaults to the following urls:
  48250. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  48251. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  48252. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  48253. */
  48254. static Configuration: IDracoCompressionConfiguration;
  48255. /**
  48256. * Returns true if the decoder is available.
  48257. */
  48258. static readonly DecoderAvailable: boolean;
  48259. /**
  48260. * Constructor
  48261. */
  48262. constructor();
  48263. /**
  48264. * Stop all async operations and release resources.
  48265. */
  48266. dispose(): void;
  48267. /**
  48268. * Decode Draco compressed mesh data to vertex data.
  48269. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  48270. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  48271. * @returns A promise that resolves with the decoded vertex data
  48272. */
  48273. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  48274. [kind: string]: number;
  48275. }): Promise<VertexData>;
  48276. private static _GetDecoderModule;
  48277. private static _LoadScriptAsync;
  48278. private static _LoadFileAsync;
  48279. }
  48280. }
  48281. declare module BABYLON {
  48282. /**
  48283. * Class for building Constructive Solid Geometry
  48284. */
  48285. export class CSG {
  48286. private polygons;
  48287. /**
  48288. * The world matrix
  48289. */
  48290. matrix: Matrix;
  48291. /**
  48292. * Stores the position
  48293. */
  48294. position: Vector3;
  48295. /**
  48296. * Stores the rotation
  48297. */
  48298. rotation: Vector3;
  48299. /**
  48300. * Stores the rotation quaternion
  48301. */
  48302. rotationQuaternion: Nullable<Quaternion>;
  48303. /**
  48304. * Stores the scaling vector
  48305. */
  48306. scaling: Vector3;
  48307. /**
  48308. * Convert the Mesh to CSG
  48309. * @param mesh The Mesh to convert to CSG
  48310. * @returns A new CSG from the Mesh
  48311. */
  48312. static FromMesh(mesh: Mesh): CSG;
  48313. /**
  48314. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  48315. * @param polygons Polygons used to construct a CSG solid
  48316. */
  48317. private static FromPolygons;
  48318. /**
  48319. * Clones, or makes a deep copy, of the CSG
  48320. * @returns A new CSG
  48321. */
  48322. clone(): CSG;
  48323. /**
  48324. * Unions this CSG with another CSG
  48325. * @param csg The CSG to union against this CSG
  48326. * @returns The unioned CSG
  48327. */
  48328. union(csg: CSG): CSG;
  48329. /**
  48330. * Unions this CSG with another CSG in place
  48331. * @param csg The CSG to union against this CSG
  48332. */
  48333. unionInPlace(csg: CSG): void;
  48334. /**
  48335. * Subtracts this CSG with another CSG
  48336. * @param csg The CSG to subtract against this CSG
  48337. * @returns A new CSG
  48338. */
  48339. subtract(csg: CSG): CSG;
  48340. /**
  48341. * Subtracts this CSG with another CSG in place
  48342. * @param csg The CSG to subtact against this CSG
  48343. */
  48344. subtractInPlace(csg: CSG): void;
  48345. /**
  48346. * Intersect this CSG with another CSG
  48347. * @param csg The CSG to intersect against this CSG
  48348. * @returns A new CSG
  48349. */
  48350. intersect(csg: CSG): CSG;
  48351. /**
  48352. * Intersects this CSG with another CSG in place
  48353. * @param csg The CSG to intersect against this CSG
  48354. */
  48355. intersectInPlace(csg: CSG): void;
  48356. /**
  48357. * Return a new CSG solid with solid and empty space switched. This solid is
  48358. * not modified.
  48359. * @returns A new CSG solid with solid and empty space switched
  48360. */
  48361. inverse(): CSG;
  48362. /**
  48363. * Inverses the CSG in place
  48364. */
  48365. inverseInPlace(): void;
  48366. /**
  48367. * This is used to keep meshes transformations so they can be restored
  48368. * when we build back a Babylon Mesh
  48369. * NB : All CSG operations are performed in world coordinates
  48370. * @param csg The CSG to copy the transform attributes from
  48371. * @returns This CSG
  48372. */
  48373. copyTransformAttributes(csg: CSG): CSG;
  48374. /**
  48375. * Build Raw mesh from CSG
  48376. * Coordinates here are in world space
  48377. * @param name The name of the mesh geometry
  48378. * @param scene The Scene
  48379. * @param keepSubMeshes Specifies if the submeshes should be kept
  48380. * @returns A new Mesh
  48381. */
  48382. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  48383. /**
  48384. * Build Mesh from CSG taking material and transforms into account
  48385. * @param name The name of the Mesh
  48386. * @param material The material of the Mesh
  48387. * @param scene The Scene
  48388. * @param keepSubMeshes Specifies if submeshes should be kept
  48389. * @returns The new Mesh
  48390. */
  48391. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  48392. }
  48393. }
  48394. declare module BABYLON {
  48395. /**
  48396. * Class used to create a trail following a mesh
  48397. */
  48398. export class TrailMesh extends Mesh {
  48399. private _generator;
  48400. private _autoStart;
  48401. private _running;
  48402. private _diameter;
  48403. private _length;
  48404. private _sectionPolygonPointsCount;
  48405. private _sectionVectors;
  48406. private _sectionNormalVectors;
  48407. private _beforeRenderObserver;
  48408. /**
  48409. * @constructor
  48410. * @param name The value used by scene.getMeshByName() to do a lookup.
  48411. * @param generator The mesh to generate a trail.
  48412. * @param scene The scene to add this mesh to.
  48413. * @param diameter Diameter of trailing mesh. Default is 1.
  48414. * @param length Length of trailing mesh. Default is 60.
  48415. * @param autoStart Automatically start trailing mesh. Default true.
  48416. */
  48417. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  48418. /**
  48419. * "TrailMesh"
  48420. * @returns "TrailMesh"
  48421. */
  48422. getClassName(): string;
  48423. private _createMesh;
  48424. /**
  48425. * Start trailing mesh.
  48426. */
  48427. start(): void;
  48428. /**
  48429. * Stop trailing mesh.
  48430. */
  48431. stop(): void;
  48432. /**
  48433. * Update trailing mesh geometry.
  48434. */
  48435. update(): void;
  48436. /**
  48437. * Returns a new TrailMesh object.
  48438. * @param name is a string, the name given to the new mesh
  48439. * @param newGenerator use new generator object for cloned trail mesh
  48440. * @returns a new mesh
  48441. */
  48442. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  48443. /**
  48444. * Serializes this trail mesh
  48445. * @param serializationObject object to write serialization to
  48446. */
  48447. serialize(serializationObject: any): void;
  48448. /**
  48449. * Parses a serialized trail mesh
  48450. * @param parsedMesh the serialized mesh
  48451. * @param scene the scene to create the trail mesh in
  48452. * @returns the created trail mesh
  48453. */
  48454. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  48455. }
  48456. }
  48457. declare module BABYLON {
  48458. /**
  48459. * Class containing static functions to help procedurally build meshes
  48460. */
  48461. export class RibbonBuilder {
  48462. /**
  48463. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  48464. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  48465. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  48466. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  48467. * * 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
  48468. * * 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
  48469. * * 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
  48470. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48471. * * 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
  48472. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  48473. * * 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
  48474. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  48475. * * 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
  48476. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  48477. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48478. * @param name defines the name of the mesh
  48479. * @param options defines the options used to create the mesh
  48480. * @param scene defines the hosting scene
  48481. * @returns the ribbon mesh
  48482. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  48483. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  48484. */
  48485. static CreateRibbon(name: string, options: {
  48486. pathArray: Vector3[][];
  48487. closeArray?: boolean;
  48488. closePath?: boolean;
  48489. offset?: number;
  48490. updatable?: boolean;
  48491. sideOrientation?: number;
  48492. frontUVs?: Vector4;
  48493. backUVs?: Vector4;
  48494. instance?: Mesh;
  48495. invertUV?: boolean;
  48496. uvs?: Vector2[];
  48497. colors?: Color4[];
  48498. }, scene?: Nullable<Scene>): Mesh;
  48499. }
  48500. }
  48501. declare module BABYLON {
  48502. /**
  48503. * Class containing static functions to help procedurally build meshes
  48504. */
  48505. export class TorusKnotBuilder {
  48506. /**
  48507. * Creates a torus knot mesh
  48508. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  48509. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  48510. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  48511. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  48512. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48513. * * 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
  48514. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48515. * @param name defines the name of the mesh
  48516. * @param options defines the options used to create the mesh
  48517. * @param scene defines the hosting scene
  48518. * @returns the torus knot mesh
  48519. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  48520. */
  48521. static CreateTorusKnot(name: string, options: {
  48522. radius?: number;
  48523. tube?: number;
  48524. radialSegments?: number;
  48525. tubularSegments?: number;
  48526. p?: number;
  48527. q?: number;
  48528. updatable?: boolean;
  48529. sideOrientation?: number;
  48530. frontUVs?: Vector4;
  48531. backUVs?: Vector4;
  48532. }, scene: any): Mesh;
  48533. }
  48534. }
  48535. declare module BABYLON {
  48536. /**
  48537. * Polygon
  48538. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  48539. */
  48540. export class Polygon {
  48541. /**
  48542. * Creates a rectangle
  48543. * @param xmin bottom X coord
  48544. * @param ymin bottom Y coord
  48545. * @param xmax top X coord
  48546. * @param ymax top Y coord
  48547. * @returns points that make the resulting rectation
  48548. */
  48549. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  48550. /**
  48551. * Creates a circle
  48552. * @param radius radius of circle
  48553. * @param cx scale in x
  48554. * @param cy scale in y
  48555. * @param numberOfSides number of sides that make up the circle
  48556. * @returns points that make the resulting circle
  48557. */
  48558. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  48559. /**
  48560. * Creates a polygon from input string
  48561. * @param input Input polygon data
  48562. * @returns the parsed points
  48563. */
  48564. static Parse(input: string): Vector2[];
  48565. /**
  48566. * Starts building a polygon from x and y coordinates
  48567. * @param x x coordinate
  48568. * @param y y coordinate
  48569. * @returns the started path2
  48570. */
  48571. static StartingAt(x: number, y: number): Path2;
  48572. }
  48573. /**
  48574. * Builds a polygon
  48575. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  48576. */
  48577. export class PolygonMeshBuilder {
  48578. private _points;
  48579. private _outlinepoints;
  48580. private _holes;
  48581. private _name;
  48582. private _scene;
  48583. private _epoints;
  48584. private _eholes;
  48585. private _addToepoint;
  48586. /**
  48587. * Babylon reference to the earcut plugin.
  48588. */
  48589. bjsEarcut: any;
  48590. /**
  48591. * Creates a PolygonMeshBuilder
  48592. * @param name name of the builder
  48593. * @param contours Path of the polygon
  48594. * @param scene scene to add to when creating the mesh
  48595. * @param earcutInjection can be used to inject your own earcut reference
  48596. */
  48597. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  48598. /**
  48599. * Adds a whole within the polygon
  48600. * @param hole Array of points defining the hole
  48601. * @returns this
  48602. */
  48603. addHole(hole: Vector2[]): PolygonMeshBuilder;
  48604. /**
  48605. * Creates the polygon
  48606. * @param updatable If the mesh should be updatable
  48607. * @param depth The depth of the mesh created
  48608. * @returns the created mesh
  48609. */
  48610. build(updatable?: boolean, depth?: number): Mesh;
  48611. /**
  48612. * Creates the polygon
  48613. * @param depth The depth of the mesh created
  48614. * @returns the created VertexData
  48615. */
  48616. buildVertexData(depth?: number): VertexData;
  48617. /**
  48618. * Adds a side to the polygon
  48619. * @param positions points that make the polygon
  48620. * @param normals normals of the polygon
  48621. * @param uvs uvs of the polygon
  48622. * @param indices indices of the polygon
  48623. * @param bounds bounds of the polygon
  48624. * @param points points of the polygon
  48625. * @param depth depth of the polygon
  48626. * @param flip flip of the polygon
  48627. */
  48628. private addSide;
  48629. }
  48630. }
  48631. declare module BABYLON {
  48632. /**
  48633. * Class containing static functions to help procedurally build meshes
  48634. */
  48635. export class PolygonBuilder {
  48636. /**
  48637. * Creates a polygon mesh
  48638. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  48639. * * 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
  48640. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  48641. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48642. * * 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)
  48643. * * Remember you can only change the shape positions, not their number when updating a polygon
  48644. * @param name defines the name of the mesh
  48645. * @param options defines the options used to create the mesh
  48646. * @param scene defines the hosting scene
  48647. * @param earcutInjection can be used to inject your own earcut reference
  48648. * @returns the polygon mesh
  48649. */
  48650. static CreatePolygon(name: string, options: {
  48651. shape: Vector3[];
  48652. holes?: Vector3[][];
  48653. depth?: number;
  48654. faceUV?: Vector4[];
  48655. faceColors?: Color4[];
  48656. updatable?: boolean;
  48657. sideOrientation?: number;
  48658. frontUVs?: Vector4;
  48659. backUVs?: Vector4;
  48660. }, scene: Scene, earcutInjection?: any): Mesh;
  48661. /**
  48662. * Creates an extruded polygon mesh, with depth in the Y direction.
  48663. * * 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)
  48664. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  48665. * @param name defines the name of the mesh
  48666. * @param options defines the options used to create the mesh
  48667. * @param scene defines the hosting scene
  48668. * @param earcutInjection can be used to inject your own earcut reference
  48669. * @returns the polygon mesh
  48670. */
  48671. static ExtrudePolygon(name: string, options: {
  48672. shape: Vector3[];
  48673. holes?: Vector3[][];
  48674. depth?: number;
  48675. faceUV?: Vector4[];
  48676. faceColors?: Color4[];
  48677. updatable?: boolean;
  48678. sideOrientation?: number;
  48679. frontUVs?: Vector4;
  48680. backUVs?: Vector4;
  48681. }, scene: Scene, earcutInjection?: any): Mesh;
  48682. }
  48683. }
  48684. declare module BABYLON {
  48685. /**
  48686. * Class containing static functions to help procedurally build meshes
  48687. */
  48688. export class ShapeBuilder {
  48689. /**
  48690. * 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.
  48691. * * 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.
  48692. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  48693. * * 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.
  48694. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  48695. * * 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
  48696. * * 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
  48697. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  48698. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48699. * * 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
  48700. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  48701. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48702. * @param name defines the name of the mesh
  48703. * @param options defines the options used to create the mesh
  48704. * @param scene defines the hosting scene
  48705. * @returns the extruded shape mesh
  48706. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  48707. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  48708. */
  48709. static ExtrudeShape(name: string, options: {
  48710. shape: Vector3[];
  48711. path: Vector3[];
  48712. scale?: number;
  48713. rotation?: number;
  48714. cap?: number;
  48715. updatable?: boolean;
  48716. sideOrientation?: number;
  48717. frontUVs?: Vector4;
  48718. backUVs?: Vector4;
  48719. instance?: Mesh;
  48720. invertUV?: boolean;
  48721. }, scene?: Nullable<Scene>): Mesh;
  48722. /**
  48723. * Creates an custom extruded shape mesh.
  48724. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  48725. * * 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.
  48726. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  48727. * * 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
  48728. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  48729. * * 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
  48730. * * It must returns a float value that will be the scale value applied to the shape on each path point
  48731. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  48732. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  48733. * * 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
  48734. * * 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
  48735. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  48736. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48737. * * 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
  48738. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  48739. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48740. * @param name defines the name of the mesh
  48741. * @param options defines the options used to create the mesh
  48742. * @param scene defines the hosting scene
  48743. * @returns the custom extruded shape mesh
  48744. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  48745. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  48746. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  48747. */
  48748. static ExtrudeShapeCustom(name: string, options: {
  48749. shape: Vector3[];
  48750. path: Vector3[];
  48751. scaleFunction?: any;
  48752. rotationFunction?: any;
  48753. ribbonCloseArray?: boolean;
  48754. ribbonClosePath?: boolean;
  48755. cap?: number;
  48756. updatable?: boolean;
  48757. sideOrientation?: number;
  48758. frontUVs?: Vector4;
  48759. backUVs?: Vector4;
  48760. instance?: Mesh;
  48761. invertUV?: boolean;
  48762. }, scene: Scene): Mesh;
  48763. private static _ExtrudeShapeGeneric;
  48764. }
  48765. }
  48766. declare module BABYLON {
  48767. /**
  48768. * Class containing static functions to help procedurally build meshes
  48769. */
  48770. export class LatheBuilder {
  48771. /**
  48772. * Creates lathe mesh.
  48773. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  48774. * * 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
  48775. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  48776. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  48777. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  48778. * * 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
  48779. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  48780. * * 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
  48781. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48782. * * 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
  48783. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  48784. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48785. * @param name defines the name of the mesh
  48786. * @param options defines the options used to create the mesh
  48787. * @param scene defines the hosting scene
  48788. * @returns the lathe mesh
  48789. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  48790. */
  48791. static CreateLathe(name: string, options: {
  48792. shape: Vector3[];
  48793. radius?: number;
  48794. tessellation?: number;
  48795. clip?: number;
  48796. arc?: number;
  48797. closed?: boolean;
  48798. updatable?: boolean;
  48799. sideOrientation?: number;
  48800. frontUVs?: Vector4;
  48801. backUVs?: Vector4;
  48802. cap?: number;
  48803. invertUV?: boolean;
  48804. }, scene: Scene): Mesh;
  48805. }
  48806. }
  48807. declare module BABYLON {
  48808. /**
  48809. * Class containing static functions to help procedurally build meshes
  48810. */
  48811. export class TubeBuilder {
  48812. /**
  48813. * Creates a tube mesh.
  48814. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  48815. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  48816. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  48817. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  48818. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  48819. * * 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)
  48820. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  48821. * * 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
  48822. * * 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
  48823. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48824. * * 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
  48825. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  48826. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48827. * @param name defines the name of the mesh
  48828. * @param options defines the options used to create the mesh
  48829. * @param scene defines the hosting scene
  48830. * @returns the tube mesh
  48831. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  48832. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  48833. */
  48834. static CreateTube(name: string, options: {
  48835. path: Vector3[];
  48836. radius?: number;
  48837. tessellation?: number;
  48838. radiusFunction?: {
  48839. (i: number, distance: number): number;
  48840. };
  48841. cap?: number;
  48842. arc?: number;
  48843. updatable?: boolean;
  48844. sideOrientation?: number;
  48845. frontUVs?: Vector4;
  48846. backUVs?: Vector4;
  48847. instance?: Mesh;
  48848. invertUV?: boolean;
  48849. }, scene: Scene): Mesh;
  48850. }
  48851. }
  48852. declare module BABYLON {
  48853. /**
  48854. * Class containing static functions to help procedurally build meshes
  48855. */
  48856. export class IcoSphereBuilder {
  48857. /**
  48858. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  48859. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  48860. * * 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`)
  48861. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  48862. * * 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
  48863. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48864. * * 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
  48865. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48866. * @param name defines the name of the mesh
  48867. * @param options defines the options used to create the mesh
  48868. * @param scene defines the hosting scene
  48869. * @returns the icosahedron mesh
  48870. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  48871. */
  48872. static CreateIcoSphere(name: string, options: {
  48873. radius?: number;
  48874. radiusX?: number;
  48875. radiusY?: number;
  48876. radiusZ?: number;
  48877. flat?: boolean;
  48878. subdivisions?: number;
  48879. sideOrientation?: number;
  48880. frontUVs?: Vector4;
  48881. backUVs?: Vector4;
  48882. updatable?: boolean;
  48883. }, scene: Scene): Mesh;
  48884. }
  48885. }
  48886. declare module BABYLON {
  48887. /**
  48888. * Class containing static functions to help procedurally build meshes
  48889. */
  48890. export class DecalBuilder {
  48891. /**
  48892. * Creates a decal mesh.
  48893. * 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
  48894. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  48895. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  48896. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  48897. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  48898. * @param name defines the name of the mesh
  48899. * @param sourceMesh defines the mesh where the decal must be applied
  48900. * @param options defines the options used to create the mesh
  48901. * @param scene defines the hosting scene
  48902. * @returns the decal mesh
  48903. * @see https://doc.babylonjs.com/how_to/decals
  48904. */
  48905. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  48906. position?: Vector3;
  48907. normal?: Vector3;
  48908. size?: Vector3;
  48909. angle?: number;
  48910. }): Mesh;
  48911. }
  48912. }
  48913. declare module BABYLON {
  48914. /**
  48915. * Class containing static functions to help procedurally build meshes
  48916. */
  48917. export class MeshBuilder {
  48918. /**
  48919. * Creates a box mesh
  48920. * * The parameter `size` sets the size (float) of each box side (default 1)
  48921. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  48922. * * 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)
  48923. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  48924. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48925. * * 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
  48926. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48927. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  48928. * @param name defines the name of the mesh
  48929. * @param options defines the options used to create the mesh
  48930. * @param scene defines the hosting scene
  48931. * @returns the box mesh
  48932. */
  48933. static CreateBox(name: string, options: {
  48934. size?: number;
  48935. width?: number;
  48936. height?: number;
  48937. depth?: number;
  48938. faceUV?: Vector4[];
  48939. faceColors?: Color4[];
  48940. sideOrientation?: number;
  48941. frontUVs?: Vector4;
  48942. backUVs?: Vector4;
  48943. updatable?: boolean;
  48944. }, scene?: Nullable<Scene>): Mesh;
  48945. /**
  48946. * Creates a sphere mesh
  48947. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  48948. * * 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`)
  48949. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  48950. * * 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
  48951. * * 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)
  48952. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48953. * * 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
  48954. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48955. * @param name defines the name of the mesh
  48956. * @param options defines the options used to create the mesh
  48957. * @param scene defines the hosting scene
  48958. * @returns the sphere mesh
  48959. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  48960. */
  48961. static CreateSphere(name: string, options: {
  48962. segments?: number;
  48963. diameter?: number;
  48964. diameterX?: number;
  48965. diameterY?: number;
  48966. diameterZ?: number;
  48967. arc?: number;
  48968. slice?: number;
  48969. sideOrientation?: number;
  48970. frontUVs?: Vector4;
  48971. backUVs?: Vector4;
  48972. updatable?: boolean;
  48973. }, scene: any): Mesh;
  48974. /**
  48975. * Creates a plane polygonal mesh. By default, this is a disc
  48976. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  48977. * * 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
  48978. * * 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
  48979. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48980. * * 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
  48981. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48982. * @param name defines the name of the mesh
  48983. * @param options defines the options used to create the mesh
  48984. * @param scene defines the hosting scene
  48985. * @returns the plane polygonal mesh
  48986. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  48987. */
  48988. static CreateDisc(name: string, options: {
  48989. radius?: number;
  48990. tessellation?: number;
  48991. arc?: number;
  48992. updatable?: boolean;
  48993. sideOrientation?: number;
  48994. frontUVs?: Vector4;
  48995. backUVs?: Vector4;
  48996. }, scene?: Nullable<Scene>): Mesh;
  48997. /**
  48998. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  48999. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  49000. * * 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`)
  49001. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  49002. * * 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
  49003. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49004. * * 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
  49005. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49006. * @param name defines the name of the mesh
  49007. * @param options defines the options used to create the mesh
  49008. * @param scene defines the hosting scene
  49009. * @returns the icosahedron mesh
  49010. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  49011. */
  49012. static CreateIcoSphere(name: string, options: {
  49013. radius?: number;
  49014. radiusX?: number;
  49015. radiusY?: number;
  49016. radiusZ?: number;
  49017. flat?: boolean;
  49018. subdivisions?: number;
  49019. sideOrientation?: number;
  49020. frontUVs?: Vector4;
  49021. backUVs?: Vector4;
  49022. updatable?: boolean;
  49023. }, scene: Scene): Mesh;
  49024. /**
  49025. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49026. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  49027. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  49028. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  49029. * * 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
  49030. * * 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
  49031. * * 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
  49032. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49033. * * 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
  49034. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49035. * * 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
  49036. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  49037. * * 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
  49038. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  49039. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49040. * @param name defines the name of the mesh
  49041. * @param options defines the options used to create the mesh
  49042. * @param scene defines the hosting scene
  49043. * @returns the ribbon mesh
  49044. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  49045. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49046. */
  49047. static CreateRibbon(name: string, options: {
  49048. pathArray: Vector3[][];
  49049. closeArray?: boolean;
  49050. closePath?: boolean;
  49051. offset?: number;
  49052. updatable?: boolean;
  49053. sideOrientation?: number;
  49054. frontUVs?: Vector4;
  49055. backUVs?: Vector4;
  49056. instance?: Mesh;
  49057. invertUV?: boolean;
  49058. uvs?: Vector2[];
  49059. colors?: Color4[];
  49060. }, scene?: Nullable<Scene>): Mesh;
  49061. /**
  49062. * Creates a cylinder or a cone mesh
  49063. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  49064. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  49065. * * 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.
  49066. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  49067. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  49068. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  49069. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  49070. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  49071. * * 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).
  49072. * * 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
  49073. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  49074. * * 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
  49075. * * 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.
  49076. * * If `enclose` is false, a ring surface is one element.
  49077. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  49078. * * 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
  49079. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49080. * * 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
  49081. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49082. * @param name defines the name of the mesh
  49083. * @param options defines the options used to create the mesh
  49084. * @param scene defines the hosting scene
  49085. * @returns the cylinder mesh
  49086. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  49087. */
  49088. static CreateCylinder(name: string, options: {
  49089. height?: number;
  49090. diameterTop?: number;
  49091. diameterBottom?: number;
  49092. diameter?: number;
  49093. tessellation?: number;
  49094. subdivisions?: number;
  49095. arc?: number;
  49096. faceColors?: Color4[];
  49097. faceUV?: Vector4[];
  49098. updatable?: boolean;
  49099. hasRings?: boolean;
  49100. enclose?: boolean;
  49101. sideOrientation?: number;
  49102. frontUVs?: Vector4;
  49103. backUVs?: Vector4;
  49104. }, scene: any): Mesh;
  49105. /**
  49106. * Creates a torus mesh
  49107. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  49108. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  49109. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  49110. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49111. * * 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
  49112. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49113. * @param name defines the name of the mesh
  49114. * @param options defines the options used to create the mesh
  49115. * @param scene defines the hosting scene
  49116. * @returns the torus mesh
  49117. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  49118. */
  49119. static CreateTorus(name: string, options: {
  49120. diameter?: number;
  49121. thickness?: number;
  49122. tessellation?: number;
  49123. updatable?: boolean;
  49124. sideOrientation?: number;
  49125. frontUVs?: Vector4;
  49126. backUVs?: Vector4;
  49127. }, scene: any): Mesh;
  49128. /**
  49129. * Creates a torus knot mesh
  49130. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  49131. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  49132. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  49133. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  49134. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49135. * * 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
  49136. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49137. * @param name defines the name of the mesh
  49138. * @param options defines the options used to create the mesh
  49139. * @param scene defines the hosting scene
  49140. * @returns the torus knot mesh
  49141. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  49142. */
  49143. static CreateTorusKnot(name: string, options: {
  49144. radius?: number;
  49145. tube?: number;
  49146. radialSegments?: number;
  49147. tubularSegments?: number;
  49148. p?: number;
  49149. q?: number;
  49150. updatable?: boolean;
  49151. sideOrientation?: number;
  49152. frontUVs?: Vector4;
  49153. backUVs?: Vector4;
  49154. }, scene: any): Mesh;
  49155. /**
  49156. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  49157. * * 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
  49158. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  49159. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  49160. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  49161. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  49162. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  49163. * * 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
  49164. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  49165. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49166. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  49167. * @param name defines the name of the new line system
  49168. * @param options defines the options used to create the line system
  49169. * @param scene defines the hosting scene
  49170. * @returns a new line system mesh
  49171. */
  49172. static CreateLineSystem(name: string, options: {
  49173. lines: Vector3[][];
  49174. updatable?: boolean;
  49175. instance?: Nullable<LinesMesh>;
  49176. colors?: Nullable<Color4[][]>;
  49177. useVertexAlpha?: boolean;
  49178. }, scene: Nullable<Scene>): LinesMesh;
  49179. /**
  49180. * Creates a line mesh
  49181. * 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
  49182. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49183. * * The parameter `points` is an array successive Vector3
  49184. * * 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
  49185. * * The optional parameter `colors` is an array of successive Color4, one per line point
  49186. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  49187. * * When updating an instance, remember that only point positions can change, not the number of points
  49188. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49189. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  49190. * @param name defines the name of the new line system
  49191. * @param options defines the options used to create the line system
  49192. * @param scene defines the hosting scene
  49193. * @returns a new line mesh
  49194. */
  49195. static CreateLines(name: string, options: {
  49196. points: Vector3[];
  49197. updatable?: boolean;
  49198. instance?: Nullable<LinesMesh>;
  49199. colors?: Color4[];
  49200. useVertexAlpha?: boolean;
  49201. }, scene?: Nullable<Scene>): LinesMesh;
  49202. /**
  49203. * Creates a dashed line mesh
  49204. * * 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
  49205. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49206. * * The parameter `points` is an array successive Vector3
  49207. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  49208. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  49209. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  49210. * * 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
  49211. * * When updating an instance, remember that only point positions can change, not the number of points
  49212. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49213. * @param name defines the name of the mesh
  49214. * @param options defines the options used to create the mesh
  49215. * @param scene defines the hosting scene
  49216. * @returns the dashed line mesh
  49217. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  49218. */
  49219. static CreateDashedLines(name: string, options: {
  49220. points: Vector3[];
  49221. dashSize?: number;
  49222. gapSize?: number;
  49223. dashNb?: number;
  49224. updatable?: boolean;
  49225. instance?: LinesMesh;
  49226. }, scene?: Nullable<Scene>): LinesMesh;
  49227. /**
  49228. * 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.
  49229. * * 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.
  49230. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49231. * * 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.
  49232. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  49233. * * 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
  49234. * * 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
  49235. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  49236. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49237. * * 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
  49238. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  49239. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49240. * @param name defines the name of the mesh
  49241. * @param options defines the options used to create the mesh
  49242. * @param scene defines the hosting scene
  49243. * @returns the extruded shape mesh
  49244. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49245. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49246. */
  49247. static ExtrudeShape(name: string, options: {
  49248. shape: Vector3[];
  49249. path: Vector3[];
  49250. scale?: number;
  49251. rotation?: number;
  49252. cap?: number;
  49253. updatable?: boolean;
  49254. sideOrientation?: number;
  49255. frontUVs?: Vector4;
  49256. backUVs?: Vector4;
  49257. instance?: Mesh;
  49258. invertUV?: boolean;
  49259. }, scene?: Nullable<Scene>): Mesh;
  49260. /**
  49261. * Creates an custom extruded shape mesh.
  49262. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  49263. * * 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.
  49264. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49265. * * 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
  49266. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  49267. * * 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
  49268. * * It must returns a float value that will be the scale value applied to the shape on each path point
  49269. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  49270. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  49271. * * 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
  49272. * * 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
  49273. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  49274. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49275. * * 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
  49276. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49277. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49278. * @param name defines the name of the mesh
  49279. * @param options defines the options used to create the mesh
  49280. * @param scene defines the hosting scene
  49281. * @returns the custom extruded shape mesh
  49282. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  49283. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49284. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49285. */
  49286. static ExtrudeShapeCustom(name: string, options: {
  49287. shape: Vector3[];
  49288. path: Vector3[];
  49289. scaleFunction?: any;
  49290. rotationFunction?: any;
  49291. ribbonCloseArray?: boolean;
  49292. ribbonClosePath?: boolean;
  49293. cap?: number;
  49294. updatable?: boolean;
  49295. sideOrientation?: number;
  49296. frontUVs?: Vector4;
  49297. backUVs?: Vector4;
  49298. instance?: Mesh;
  49299. invertUV?: boolean;
  49300. }, scene: Scene): Mesh;
  49301. /**
  49302. * Creates lathe mesh.
  49303. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  49304. * * 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
  49305. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  49306. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  49307. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  49308. * * 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
  49309. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  49310. * * 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
  49311. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49312. * * 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
  49313. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49314. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49315. * @param name defines the name of the mesh
  49316. * @param options defines the options used to create the mesh
  49317. * @param scene defines the hosting scene
  49318. * @returns the lathe mesh
  49319. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  49320. */
  49321. static CreateLathe(name: string, options: {
  49322. shape: Vector3[];
  49323. radius?: number;
  49324. tessellation?: number;
  49325. clip?: number;
  49326. arc?: number;
  49327. closed?: boolean;
  49328. updatable?: boolean;
  49329. sideOrientation?: number;
  49330. frontUVs?: Vector4;
  49331. backUVs?: Vector4;
  49332. cap?: number;
  49333. invertUV?: boolean;
  49334. }, scene: Scene): Mesh;
  49335. /**
  49336. * Creates a plane mesh
  49337. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  49338. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  49339. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  49340. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49341. * * 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
  49342. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49343. * @param name defines the name of the mesh
  49344. * @param options defines the options used to create the mesh
  49345. * @param scene defines the hosting scene
  49346. * @returns the plane mesh
  49347. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  49348. */
  49349. static CreatePlane(name: string, options: {
  49350. size?: number;
  49351. width?: number;
  49352. height?: number;
  49353. sideOrientation?: number;
  49354. frontUVs?: Vector4;
  49355. backUVs?: Vector4;
  49356. updatable?: boolean;
  49357. sourcePlane?: Plane;
  49358. }, scene: Scene): Mesh;
  49359. /**
  49360. * Creates a ground mesh
  49361. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  49362. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  49363. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49364. * @param name defines the name of the mesh
  49365. * @param options defines the options used to create the mesh
  49366. * @param scene defines the hosting scene
  49367. * @returns the ground mesh
  49368. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  49369. */
  49370. static CreateGround(name: string, options: {
  49371. width?: number;
  49372. height?: number;
  49373. subdivisions?: number;
  49374. subdivisionsX?: number;
  49375. subdivisionsY?: number;
  49376. updatable?: boolean;
  49377. }, scene: any): Mesh;
  49378. /**
  49379. * Creates a tiled ground mesh
  49380. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  49381. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  49382. * * 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
  49383. * * 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
  49384. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49385. * @param name defines the name of the mesh
  49386. * @param options defines the options used to create the mesh
  49387. * @param scene defines the hosting scene
  49388. * @returns the tiled ground mesh
  49389. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  49390. */
  49391. static CreateTiledGround(name: string, options: {
  49392. xmin: number;
  49393. zmin: number;
  49394. xmax: number;
  49395. zmax: number;
  49396. subdivisions?: {
  49397. w: number;
  49398. h: number;
  49399. };
  49400. precision?: {
  49401. w: number;
  49402. h: number;
  49403. };
  49404. updatable?: boolean;
  49405. }, scene: Scene): Mesh;
  49406. /**
  49407. * Creates a ground mesh from a height map
  49408. * * The parameter `url` sets the URL of the height map image resource.
  49409. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  49410. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  49411. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  49412. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  49413. * * 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.
  49414. * * 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).
  49415. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  49416. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49417. * @param name defines the name of the mesh
  49418. * @param url defines the url to the height map
  49419. * @param options defines the options used to create the mesh
  49420. * @param scene defines the hosting scene
  49421. * @returns the ground mesh
  49422. * @see https://doc.babylonjs.com/babylon101/height_map
  49423. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  49424. */
  49425. static CreateGroundFromHeightMap(name: string, url: string, options: {
  49426. width?: number;
  49427. height?: number;
  49428. subdivisions?: number;
  49429. minHeight?: number;
  49430. maxHeight?: number;
  49431. colorFilter?: Color3;
  49432. alphaFilter?: number;
  49433. updatable?: boolean;
  49434. onReady?: (mesh: GroundMesh) => void;
  49435. }, scene: Scene): GroundMesh;
  49436. /**
  49437. * Creates a polygon mesh
  49438. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  49439. * * 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
  49440. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  49441. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49442. * * 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)
  49443. * * Remember you can only change the shape positions, not their number when updating a polygon
  49444. * @param name defines the name of the mesh
  49445. * @param options defines the options used to create the mesh
  49446. * @param scene defines the hosting scene
  49447. * @param earcutInjection can be used to inject your own earcut reference
  49448. * @returns the polygon mesh
  49449. */
  49450. static CreatePolygon(name: string, options: {
  49451. shape: Vector3[];
  49452. holes?: Vector3[][];
  49453. depth?: number;
  49454. faceUV?: Vector4[];
  49455. faceColors?: Color4[];
  49456. updatable?: boolean;
  49457. sideOrientation?: number;
  49458. frontUVs?: Vector4;
  49459. backUVs?: Vector4;
  49460. }, scene: Scene, earcutInjection?: any): Mesh;
  49461. /**
  49462. * Creates an extruded polygon mesh, with depth in the Y direction.
  49463. * * 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)
  49464. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  49465. * @param name defines the name of the mesh
  49466. * @param options defines the options used to create the mesh
  49467. * @param scene defines the hosting scene
  49468. * @param earcutInjection can be used to inject your own earcut reference
  49469. * @returns the polygon mesh
  49470. */
  49471. static ExtrudePolygon(name: string, options: {
  49472. shape: Vector3[];
  49473. holes?: Vector3[][];
  49474. depth?: number;
  49475. faceUV?: Vector4[];
  49476. faceColors?: Color4[];
  49477. updatable?: boolean;
  49478. sideOrientation?: number;
  49479. frontUVs?: Vector4;
  49480. backUVs?: Vector4;
  49481. }, scene: Scene, earcutInjection?: any): Mesh;
  49482. /**
  49483. * Creates a tube mesh.
  49484. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49485. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  49486. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  49487. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  49488. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  49489. * * 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)
  49490. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  49491. * * 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
  49492. * * 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
  49493. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49494. * * 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
  49495. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49496. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49497. * @param name defines the name of the mesh
  49498. * @param options defines the options used to create the mesh
  49499. * @param scene defines the hosting scene
  49500. * @returns the tube mesh
  49501. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49502. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  49503. */
  49504. static CreateTube(name: string, options: {
  49505. path: Vector3[];
  49506. radius?: number;
  49507. tessellation?: number;
  49508. radiusFunction?: {
  49509. (i: number, distance: number): number;
  49510. };
  49511. cap?: number;
  49512. arc?: number;
  49513. updatable?: boolean;
  49514. sideOrientation?: number;
  49515. frontUVs?: Vector4;
  49516. backUVs?: Vector4;
  49517. instance?: Mesh;
  49518. invertUV?: boolean;
  49519. }, scene: Scene): Mesh;
  49520. /**
  49521. * Creates a polyhedron mesh
  49522. * * 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
  49523. * * The parameter `size` (positive float, default 1) sets the polygon size
  49524. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  49525. * * 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`
  49526. * * 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
  49527. * * 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)`)
  49528. * * 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
  49529. * * 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
  49530. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49531. * * 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
  49532. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49533. * @param name defines the name of the mesh
  49534. * @param options defines the options used to create the mesh
  49535. * @param scene defines the hosting scene
  49536. * @returns the polyhedron mesh
  49537. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  49538. */
  49539. static CreatePolyhedron(name: string, options: {
  49540. type?: number;
  49541. size?: number;
  49542. sizeX?: number;
  49543. sizeY?: number;
  49544. sizeZ?: number;
  49545. custom?: any;
  49546. faceUV?: Vector4[];
  49547. faceColors?: Color4[];
  49548. flat?: boolean;
  49549. updatable?: boolean;
  49550. sideOrientation?: number;
  49551. frontUVs?: Vector4;
  49552. backUVs?: Vector4;
  49553. }, scene: Scene): Mesh;
  49554. /**
  49555. * Creates a decal mesh.
  49556. * 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
  49557. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  49558. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  49559. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  49560. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  49561. * @param name defines the name of the mesh
  49562. * @param sourceMesh defines the mesh where the decal must be applied
  49563. * @param options defines the options used to create the mesh
  49564. * @param scene defines the hosting scene
  49565. * @returns the decal mesh
  49566. * @see https://doc.babylonjs.com/how_to/decals
  49567. */
  49568. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  49569. position?: Vector3;
  49570. normal?: Vector3;
  49571. size?: Vector3;
  49572. angle?: number;
  49573. }): Mesh;
  49574. }
  49575. }
  49576. declare module BABYLON {
  49577. /**
  49578. * A simplifier interface for future simplification implementations
  49579. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49580. */
  49581. export interface ISimplifier {
  49582. /**
  49583. * Simplification of a given mesh according to the given settings.
  49584. * Since this requires computation, it is assumed that the function runs async.
  49585. * @param settings The settings of the simplification, including quality and distance
  49586. * @param successCallback A callback that will be called after the mesh was simplified.
  49587. * @param errorCallback in case of an error, this callback will be called. optional.
  49588. */
  49589. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  49590. }
  49591. /**
  49592. * Expected simplification settings.
  49593. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  49594. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49595. */
  49596. export interface ISimplificationSettings {
  49597. /**
  49598. * Gets or sets the expected quality
  49599. */
  49600. quality: number;
  49601. /**
  49602. * Gets or sets the distance when this optimized version should be used
  49603. */
  49604. distance: number;
  49605. /**
  49606. * Gets an already optimized mesh
  49607. */
  49608. optimizeMesh?: boolean;
  49609. }
  49610. /**
  49611. * Class used to specify simplification options
  49612. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49613. */
  49614. export class SimplificationSettings implements ISimplificationSettings {
  49615. /** expected quality */
  49616. quality: number;
  49617. /** distance when this optimized version should be used */
  49618. distance: number;
  49619. /** already optimized mesh */
  49620. optimizeMesh?: boolean | undefined;
  49621. /**
  49622. * Creates a SimplificationSettings
  49623. * @param quality expected quality
  49624. * @param distance distance when this optimized version should be used
  49625. * @param optimizeMesh already optimized mesh
  49626. */
  49627. constructor(
  49628. /** expected quality */
  49629. quality: number,
  49630. /** distance when this optimized version should be used */
  49631. distance: number,
  49632. /** already optimized mesh */
  49633. optimizeMesh?: boolean | undefined);
  49634. }
  49635. /**
  49636. * Interface used to define a simplification task
  49637. */
  49638. export interface ISimplificationTask {
  49639. /**
  49640. * Array of settings
  49641. */
  49642. settings: Array<ISimplificationSettings>;
  49643. /**
  49644. * Simplification type
  49645. */
  49646. simplificationType: SimplificationType;
  49647. /**
  49648. * Mesh to simplify
  49649. */
  49650. mesh: Mesh;
  49651. /**
  49652. * Callback called on success
  49653. */
  49654. successCallback?: () => void;
  49655. /**
  49656. * Defines if parallel processing can be used
  49657. */
  49658. parallelProcessing: boolean;
  49659. }
  49660. /**
  49661. * Queue used to order the simplification tasks
  49662. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49663. */
  49664. export class SimplificationQueue {
  49665. private _simplificationArray;
  49666. /**
  49667. * Gets a boolean indicating that the process is still running
  49668. */
  49669. running: boolean;
  49670. /**
  49671. * Creates a new queue
  49672. */
  49673. constructor();
  49674. /**
  49675. * Adds a new simplification task
  49676. * @param task defines a task to add
  49677. */
  49678. addTask(task: ISimplificationTask): void;
  49679. /**
  49680. * Execute next task
  49681. */
  49682. executeNext(): void;
  49683. /**
  49684. * Execute a simplification task
  49685. * @param task defines the task to run
  49686. */
  49687. runSimplification(task: ISimplificationTask): void;
  49688. private getSimplifier;
  49689. }
  49690. /**
  49691. * The implemented types of simplification
  49692. * At the moment only Quadratic Error Decimation is implemented
  49693. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49694. */
  49695. export enum SimplificationType {
  49696. /** Quadratic error decimation */
  49697. QUADRATIC = 0
  49698. }
  49699. }
  49700. declare module BABYLON {
  49701. interface Scene {
  49702. /** @hidden (Backing field) */
  49703. _simplificationQueue: SimplificationQueue;
  49704. /**
  49705. * Gets or sets the simplification queue attached to the scene
  49706. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49707. */
  49708. simplificationQueue: SimplificationQueue;
  49709. }
  49710. interface Mesh {
  49711. /**
  49712. * Simplify the mesh according to the given array of settings.
  49713. * Function will return immediately and will simplify async
  49714. * @param settings a collection of simplification settings
  49715. * @param parallelProcessing should all levels calculate parallel or one after the other
  49716. * @param simplificationType the type of simplification to run
  49717. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  49718. * @returns the current mesh
  49719. */
  49720. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  49721. }
  49722. /**
  49723. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  49724. * created in a scene
  49725. */
  49726. export class SimplicationQueueSceneComponent implements ISceneComponent {
  49727. /**
  49728. * The component name helpfull to identify the component in the list of scene components.
  49729. */
  49730. readonly name: string;
  49731. /**
  49732. * The scene the component belongs to.
  49733. */
  49734. scene: Scene;
  49735. /**
  49736. * Creates a new instance of the component for the given scene
  49737. * @param scene Defines the scene to register the component in
  49738. */
  49739. constructor(scene: Scene);
  49740. /**
  49741. * Registers the component in a given scene
  49742. */
  49743. register(): void;
  49744. /**
  49745. * Rebuilds the elements related to this component in case of
  49746. * context lost for instance.
  49747. */
  49748. rebuild(): void;
  49749. /**
  49750. * Disposes the component and the associated ressources
  49751. */
  49752. dispose(): void;
  49753. private _beforeCameraUpdate;
  49754. }
  49755. }
  49756. declare module BABYLON {
  49757. /**
  49758. * Class used to enable access to IndexedDB
  49759. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  49760. */
  49761. export class Database implements IOfflineProvider {
  49762. private _callbackManifestChecked;
  49763. private _currentSceneUrl;
  49764. private _db;
  49765. private _enableSceneOffline;
  49766. private _enableTexturesOffline;
  49767. private _manifestVersionFound;
  49768. private _mustUpdateRessources;
  49769. private _hasReachedQuota;
  49770. private _isSupported;
  49771. private _idbFactory;
  49772. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  49773. private static IsUASupportingBlobStorage;
  49774. /**
  49775. * Gets a boolean indicating if Database storate is enabled (off by default)
  49776. */
  49777. static IDBStorageEnabled: boolean;
  49778. /**
  49779. * Gets a boolean indicating if scene must be saved in the database
  49780. */
  49781. readonly enableSceneOffline: boolean;
  49782. /**
  49783. * Gets a boolean indicating if textures must be saved in the database
  49784. */
  49785. readonly enableTexturesOffline: boolean;
  49786. /**
  49787. * Creates a new Database
  49788. * @param urlToScene defines the url to load the scene
  49789. * @param callbackManifestChecked defines the callback to use when manifest is checked
  49790. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  49791. */
  49792. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  49793. private static _ParseURL;
  49794. private static _ReturnFullUrlLocation;
  49795. private _checkManifestFile;
  49796. /**
  49797. * Open the database and make it available
  49798. * @param successCallback defines the callback to call on success
  49799. * @param errorCallback defines the callback to call on error
  49800. */
  49801. open(successCallback: () => void, errorCallback: () => void): void;
  49802. /**
  49803. * Loads an image from the database
  49804. * @param url defines the url to load from
  49805. * @param image defines the target DOM image
  49806. */
  49807. loadImage(url: string, image: HTMLImageElement): void;
  49808. private _loadImageFromDBAsync;
  49809. private _saveImageIntoDBAsync;
  49810. private _checkVersionFromDB;
  49811. private _loadVersionFromDBAsync;
  49812. private _saveVersionIntoDBAsync;
  49813. /**
  49814. * Loads a file from database
  49815. * @param url defines the URL to load from
  49816. * @param sceneLoaded defines a callback to call on success
  49817. * @param progressCallBack defines a callback to call when progress changed
  49818. * @param errorCallback defines a callback to call on error
  49819. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  49820. */
  49821. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  49822. private _loadFileAsync;
  49823. private _saveFileAsync;
  49824. /**
  49825. * Validates if xhr data is correct
  49826. * @param xhr defines the request to validate
  49827. * @param dataType defines the expected data type
  49828. * @returns true if data is correct
  49829. */
  49830. private static _ValidateXHRData;
  49831. }
  49832. }
  49833. declare module BABYLON {
  49834. /** @hidden */
  49835. export var gpuUpdateParticlesPixelShader: {
  49836. name: string;
  49837. shader: string;
  49838. };
  49839. }
  49840. declare module BABYLON {
  49841. /** @hidden */
  49842. export var gpuUpdateParticlesVertexShader: {
  49843. name: string;
  49844. shader: string;
  49845. };
  49846. }
  49847. declare module BABYLON {
  49848. /** @hidden */
  49849. export var clipPlaneFragmentDeclaration2: {
  49850. name: string;
  49851. shader: string;
  49852. };
  49853. }
  49854. declare module BABYLON {
  49855. /** @hidden */
  49856. export var gpuRenderParticlesPixelShader: {
  49857. name: string;
  49858. shader: string;
  49859. };
  49860. }
  49861. declare module BABYLON {
  49862. /** @hidden */
  49863. export var clipPlaneVertexDeclaration2: {
  49864. name: string;
  49865. shader: string;
  49866. };
  49867. }
  49868. declare module BABYLON {
  49869. /** @hidden */
  49870. export var gpuRenderParticlesVertexShader: {
  49871. name: string;
  49872. shader: string;
  49873. };
  49874. }
  49875. declare module BABYLON {
  49876. /**
  49877. * This represents a GPU particle system in Babylon
  49878. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  49879. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  49880. */
  49881. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  49882. /**
  49883. * The layer mask we are rendering the particles through.
  49884. */
  49885. layerMask: number;
  49886. private _capacity;
  49887. private _activeCount;
  49888. private _currentActiveCount;
  49889. private _accumulatedCount;
  49890. private _renderEffect;
  49891. private _updateEffect;
  49892. private _buffer0;
  49893. private _buffer1;
  49894. private _spriteBuffer;
  49895. private _updateVAO;
  49896. private _renderVAO;
  49897. private _targetIndex;
  49898. private _sourceBuffer;
  49899. private _targetBuffer;
  49900. private _engine;
  49901. private _currentRenderId;
  49902. private _started;
  49903. private _stopped;
  49904. private _timeDelta;
  49905. private _randomTexture;
  49906. private _randomTexture2;
  49907. private _attributesStrideSize;
  49908. private _updateEffectOptions;
  49909. private _randomTextureSize;
  49910. private _actualFrame;
  49911. private readonly _rawTextureWidth;
  49912. /**
  49913. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  49914. */
  49915. static readonly IsSupported: boolean;
  49916. /**
  49917. * An event triggered when the system is disposed.
  49918. */
  49919. onDisposeObservable: Observable<GPUParticleSystem>;
  49920. /**
  49921. * Gets the maximum number of particles active at the same time.
  49922. * @returns The max number of active particles.
  49923. */
  49924. getCapacity(): number;
  49925. /**
  49926. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  49927. * to override the particles.
  49928. */
  49929. forceDepthWrite: boolean;
  49930. /**
  49931. * Gets or set the number of active particles
  49932. */
  49933. activeParticleCount: number;
  49934. private _preWarmDone;
  49935. /**
  49936. * Is this system ready to be used/rendered
  49937. * @return true if the system is ready
  49938. */
  49939. isReady(): boolean;
  49940. /**
  49941. * Gets if the system has been started. (Note: this will still be true after stop is called)
  49942. * @returns True if it has been started, otherwise false.
  49943. */
  49944. isStarted(): boolean;
  49945. /**
  49946. * Starts the particle system and begins to emit
  49947. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  49948. */
  49949. start(delay?: number): void;
  49950. /**
  49951. * Stops the particle system.
  49952. */
  49953. stop(): void;
  49954. /**
  49955. * Remove all active particles
  49956. */
  49957. reset(): void;
  49958. /**
  49959. * Returns the string "GPUParticleSystem"
  49960. * @returns a string containing the class name
  49961. */
  49962. getClassName(): string;
  49963. private _colorGradientsTexture;
  49964. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  49965. /**
  49966. * Adds a new color gradient
  49967. * @param gradient defines the gradient to use (between 0 and 1)
  49968. * @param color1 defines the color to affect to the specified gradient
  49969. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  49970. * @returns the current particle system
  49971. */
  49972. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  49973. /**
  49974. * Remove a specific color gradient
  49975. * @param gradient defines the gradient to remove
  49976. * @returns the current particle system
  49977. */
  49978. removeColorGradient(gradient: number): GPUParticleSystem;
  49979. private _angularSpeedGradientsTexture;
  49980. private _sizeGradientsTexture;
  49981. private _velocityGradientsTexture;
  49982. private _limitVelocityGradientsTexture;
  49983. private _dragGradientsTexture;
  49984. private _addFactorGradient;
  49985. /**
  49986. * Adds a new size gradient
  49987. * @param gradient defines the gradient to use (between 0 and 1)
  49988. * @param factor defines the size factor to affect to the specified gradient
  49989. * @returns the current particle system
  49990. */
  49991. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  49992. /**
  49993. * Remove a specific size gradient
  49994. * @param gradient defines the gradient to remove
  49995. * @returns the current particle system
  49996. */
  49997. removeSizeGradient(gradient: number): GPUParticleSystem;
  49998. /**
  49999. * Adds a new angular speed gradient
  50000. * @param gradient defines the gradient to use (between 0 and 1)
  50001. * @param factor defines the angular speed to affect to the specified gradient
  50002. * @returns the current particle system
  50003. */
  50004. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  50005. /**
  50006. * Remove a specific angular speed gradient
  50007. * @param gradient defines the gradient to remove
  50008. * @returns the current particle system
  50009. */
  50010. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  50011. /**
  50012. * Adds a new velocity gradient
  50013. * @param gradient defines the gradient to use (between 0 and 1)
  50014. * @param factor defines the velocity to affect to the specified gradient
  50015. * @returns the current particle system
  50016. */
  50017. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  50018. /**
  50019. * Remove a specific velocity gradient
  50020. * @param gradient defines the gradient to remove
  50021. * @returns the current particle system
  50022. */
  50023. removeVelocityGradient(gradient: number): GPUParticleSystem;
  50024. /**
  50025. * Adds a new limit velocity gradient
  50026. * @param gradient defines the gradient to use (between 0 and 1)
  50027. * @param factor defines the limit velocity value to affect to the specified gradient
  50028. * @returns the current particle system
  50029. */
  50030. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  50031. /**
  50032. * Remove a specific limit velocity gradient
  50033. * @param gradient defines the gradient to remove
  50034. * @returns the current particle system
  50035. */
  50036. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  50037. /**
  50038. * Adds a new drag gradient
  50039. * @param gradient defines the gradient to use (between 0 and 1)
  50040. * @param factor defines the drag value to affect to the specified gradient
  50041. * @returns the current particle system
  50042. */
  50043. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  50044. /**
  50045. * Remove a specific drag gradient
  50046. * @param gradient defines the gradient to remove
  50047. * @returns the current particle system
  50048. */
  50049. removeDragGradient(gradient: number): GPUParticleSystem;
  50050. /**
  50051. * Not supported by GPUParticleSystem
  50052. * @param gradient defines the gradient to use (between 0 and 1)
  50053. * @param factor defines the emit rate value to affect to the specified gradient
  50054. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  50055. * @returns the current particle system
  50056. */
  50057. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  50058. /**
  50059. * Not supported by GPUParticleSystem
  50060. * @param gradient defines the gradient to remove
  50061. * @returns the current particle system
  50062. */
  50063. removeEmitRateGradient(gradient: number): IParticleSystem;
  50064. /**
  50065. * Not supported by GPUParticleSystem
  50066. * @param gradient defines the gradient to use (between 0 and 1)
  50067. * @param factor defines the start size value to affect to the specified gradient
  50068. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  50069. * @returns the current particle system
  50070. */
  50071. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  50072. /**
  50073. * Not supported by GPUParticleSystem
  50074. * @param gradient defines the gradient to remove
  50075. * @returns the current particle system
  50076. */
  50077. removeStartSizeGradient(gradient: number): IParticleSystem;
  50078. /**
  50079. * Not supported by GPUParticleSystem
  50080. * @param gradient defines the gradient to use (between 0 and 1)
  50081. * @param min defines the color remap minimal range
  50082. * @param max defines the color remap maximal range
  50083. * @returns the current particle system
  50084. */
  50085. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  50086. /**
  50087. * Not supported by GPUParticleSystem
  50088. * @param gradient defines the gradient to remove
  50089. * @returns the current particle system
  50090. */
  50091. removeColorRemapGradient(): IParticleSystem;
  50092. /**
  50093. * Not supported by GPUParticleSystem
  50094. * @param gradient defines the gradient to use (between 0 and 1)
  50095. * @param min defines the alpha remap minimal range
  50096. * @param max defines the alpha remap maximal range
  50097. * @returns the current particle system
  50098. */
  50099. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  50100. /**
  50101. * Not supported by GPUParticleSystem
  50102. * @param gradient defines the gradient to remove
  50103. * @returns the current particle system
  50104. */
  50105. removeAlphaRemapGradient(): IParticleSystem;
  50106. /**
  50107. * Not supported by GPUParticleSystem
  50108. * @param gradient defines the gradient to use (between 0 and 1)
  50109. * @param color defines the color to affect to the specified gradient
  50110. * @returns the current particle system
  50111. */
  50112. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  50113. /**
  50114. * Not supported by GPUParticleSystem
  50115. * @param gradient defines the gradient to remove
  50116. * @returns the current particle system
  50117. */
  50118. removeRampGradient(): IParticleSystem;
  50119. /**
  50120. * Not supported by GPUParticleSystem
  50121. * @returns the list of ramp gradients
  50122. */
  50123. getRampGradients(): Nullable<Array<Color3Gradient>>;
  50124. /**
  50125. * Not supported by GPUParticleSystem
  50126. * Gets or sets a boolean indicating that ramp gradients must be used
  50127. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  50128. */
  50129. useRampGradients: boolean;
  50130. /**
  50131. * Not supported by GPUParticleSystem
  50132. * @param gradient defines the gradient to use (between 0 and 1)
  50133. * @param factor defines the life time factor to affect to the specified gradient
  50134. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  50135. * @returns the current particle system
  50136. */
  50137. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  50138. /**
  50139. * Not supported by GPUParticleSystem
  50140. * @param gradient defines the gradient to remove
  50141. * @returns the current particle system
  50142. */
  50143. removeLifeTimeGradient(gradient: number): IParticleSystem;
  50144. /**
  50145. * Instantiates a GPU particle system.
  50146. * 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.
  50147. * @param name The name of the particle system
  50148. * @param options The options used to create the system
  50149. * @param scene The scene the particle system belongs to
  50150. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  50151. */
  50152. constructor(name: string, options: Partial<{
  50153. capacity: number;
  50154. randomTextureSize: number;
  50155. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  50156. protected _reset(): void;
  50157. private _createUpdateVAO;
  50158. private _createRenderVAO;
  50159. private _initialize;
  50160. /** @hidden */
  50161. _recreateUpdateEffect(): void;
  50162. /** @hidden */
  50163. _recreateRenderEffect(): void;
  50164. /**
  50165. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  50166. * @param preWarm defines if we are in the pre-warmimg phase
  50167. */
  50168. animate(preWarm?: boolean): void;
  50169. private _createFactorGradientTexture;
  50170. private _createSizeGradientTexture;
  50171. private _createAngularSpeedGradientTexture;
  50172. private _createVelocityGradientTexture;
  50173. private _createLimitVelocityGradientTexture;
  50174. private _createDragGradientTexture;
  50175. private _createColorGradientTexture;
  50176. /**
  50177. * Renders the particle system in its current state
  50178. * @param preWarm defines if the system should only update the particles but not render them
  50179. * @returns the current number of particles
  50180. */
  50181. render(preWarm?: boolean): number;
  50182. /**
  50183. * Rebuilds the particle system
  50184. */
  50185. rebuild(): void;
  50186. private _releaseBuffers;
  50187. private _releaseVAOs;
  50188. /**
  50189. * Disposes the particle system and free the associated resources
  50190. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  50191. */
  50192. dispose(disposeTexture?: boolean): void;
  50193. /**
  50194. * Clones the particle system.
  50195. * @param name The name of the cloned object
  50196. * @param newEmitter The new emitter to use
  50197. * @returns the cloned particle system
  50198. */
  50199. clone(name: string, newEmitter: any): GPUParticleSystem;
  50200. /**
  50201. * Serializes the particle system to a JSON object.
  50202. * @returns the JSON object
  50203. */
  50204. serialize(): any;
  50205. /**
  50206. * Parses a JSON object to create a GPU particle system.
  50207. * @param parsedParticleSystem The JSON object to parse
  50208. * @param scene The scene to create the particle system in
  50209. * @param rootUrl The root url to use to load external dependencies like texture
  50210. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  50211. * @returns the parsed GPU particle system
  50212. */
  50213. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  50214. }
  50215. }
  50216. declare module BABYLON {
  50217. /**
  50218. * Represents a set of particle systems working together to create a specific effect
  50219. */
  50220. export class ParticleSystemSet implements IDisposable {
  50221. private _emitterCreationOptions;
  50222. private _emitterNode;
  50223. /**
  50224. * Gets the particle system list
  50225. */
  50226. systems: IParticleSystem[];
  50227. /**
  50228. * Gets the emitter node used with this set
  50229. */
  50230. readonly emitterNode: Nullable<TransformNode>;
  50231. /**
  50232. * Creates a new emitter mesh as a sphere
  50233. * @param options defines the options used to create the sphere
  50234. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  50235. * @param scene defines the hosting scene
  50236. */
  50237. setEmitterAsSphere(options: {
  50238. diameter: number;
  50239. segments: number;
  50240. color: Color3;
  50241. }, renderingGroupId: number, scene: Scene): void;
  50242. /**
  50243. * Starts all particle systems of the set
  50244. * @param emitter defines an optional mesh to use as emitter for the particle systems
  50245. */
  50246. start(emitter?: AbstractMesh): void;
  50247. /**
  50248. * Release all associated resources
  50249. */
  50250. dispose(): void;
  50251. /**
  50252. * Serialize the set into a JSON compatible object
  50253. * @returns a JSON compatible representation of the set
  50254. */
  50255. serialize(): any;
  50256. /**
  50257. * Parse a new ParticleSystemSet from a serialized source
  50258. * @param data defines a JSON compatible representation of the set
  50259. * @param scene defines the hosting scene
  50260. * @param gpu defines if we want GPU particles or CPU particles
  50261. * @returns a new ParticleSystemSet
  50262. */
  50263. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  50264. }
  50265. }
  50266. declare module BABYLON {
  50267. /**
  50268. * This class is made for on one-liner static method to help creating particle system set.
  50269. */
  50270. export class ParticleHelper {
  50271. /**
  50272. * Gets or sets base Assets URL
  50273. */
  50274. static BaseAssetsUrl: string;
  50275. /**
  50276. * Create a default particle system that you can tweak
  50277. * @param emitter defines the emitter to use
  50278. * @param capacity defines the system capacity (default is 500 particles)
  50279. * @param scene defines the hosting scene
  50280. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  50281. * @returns the new Particle system
  50282. */
  50283. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  50284. /**
  50285. * This is the main static method (one-liner) of this helper to create different particle systems
  50286. * @param type This string represents the type to the particle system to create
  50287. * @param scene The scene where the particle system should live
  50288. * @param gpu If the system will use gpu
  50289. * @returns the ParticleSystemSet created
  50290. */
  50291. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  50292. /**
  50293. * Static function used to export a particle system to a ParticleSystemSet variable.
  50294. * Please note that the emitter shape is not exported
  50295. * @param systems defines the particle systems to export
  50296. * @returns the created particle system set
  50297. */
  50298. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  50299. }
  50300. }
  50301. declare module BABYLON {
  50302. interface Engine {
  50303. /**
  50304. * Create an effect to use with particle systems.
  50305. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  50306. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  50307. * @param uniformsNames defines a list of attribute names
  50308. * @param samplers defines an array of string used to represent textures
  50309. * @param defines defines the string containing the defines to use to compile the shaders
  50310. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  50311. * @param onCompiled defines a function to call when the effect creation is successful
  50312. * @param onError defines a function to call when the effect creation has failed
  50313. * @returns the new Effect
  50314. */
  50315. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  50316. }
  50317. interface Mesh {
  50318. /**
  50319. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  50320. * @returns an array of IParticleSystem
  50321. */
  50322. getEmittedParticleSystems(): IParticleSystem[];
  50323. /**
  50324. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  50325. * @returns an array of IParticleSystem
  50326. */
  50327. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  50328. }
  50329. /**
  50330. * @hidden
  50331. */
  50332. export var _IDoNeedToBeInTheBuild: number;
  50333. }
  50334. declare module BABYLON {
  50335. interface Scene {
  50336. /** @hidden (Backing field) */
  50337. _physicsEngine: Nullable<IPhysicsEngine>;
  50338. /**
  50339. * Gets the current physics engine
  50340. * @returns a IPhysicsEngine or null if none attached
  50341. */
  50342. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  50343. /**
  50344. * Enables physics to the current scene
  50345. * @param gravity defines the scene's gravity for the physics engine
  50346. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  50347. * @return a boolean indicating if the physics engine was initialized
  50348. */
  50349. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  50350. /**
  50351. * Disables and disposes the physics engine associated with the scene
  50352. */
  50353. disablePhysicsEngine(): void;
  50354. /**
  50355. * Gets a boolean indicating if there is an active physics engine
  50356. * @returns a boolean indicating if there is an active physics engine
  50357. */
  50358. isPhysicsEnabled(): boolean;
  50359. /**
  50360. * Deletes a physics compound impostor
  50361. * @param compound defines the compound to delete
  50362. */
  50363. deleteCompoundImpostor(compound: any): void;
  50364. /**
  50365. * An event triggered when physic simulation is about to be run
  50366. */
  50367. onBeforePhysicsObservable: Observable<Scene>;
  50368. /**
  50369. * An event triggered when physic simulation has been done
  50370. */
  50371. onAfterPhysicsObservable: Observable<Scene>;
  50372. }
  50373. interface AbstractMesh {
  50374. /** @hidden */
  50375. _physicsImpostor: Nullable<PhysicsImpostor>;
  50376. /**
  50377. * Gets or sets impostor used for physic simulation
  50378. * @see http://doc.babylonjs.com/features/physics_engine
  50379. */
  50380. physicsImpostor: Nullable<PhysicsImpostor>;
  50381. /**
  50382. * Gets the current physics impostor
  50383. * @see http://doc.babylonjs.com/features/physics_engine
  50384. * @returns a physics impostor or null
  50385. */
  50386. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  50387. /** Apply a physic impulse to the mesh
  50388. * @param force defines the force to apply
  50389. * @param contactPoint defines where to apply the force
  50390. * @returns the current mesh
  50391. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  50392. */
  50393. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  50394. /**
  50395. * Creates a physic joint between two meshes
  50396. * @param otherMesh defines the other mesh to use
  50397. * @param pivot1 defines the pivot to use on this mesh
  50398. * @param pivot2 defines the pivot to use on the other mesh
  50399. * @param options defines additional options (can be plugin dependent)
  50400. * @returns the current mesh
  50401. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  50402. */
  50403. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  50404. /** @hidden */
  50405. _disposePhysicsObserver: Nullable<Observer<Node>>;
  50406. }
  50407. /**
  50408. * Defines the physics engine scene component responsible to manage a physics engine
  50409. */
  50410. export class PhysicsEngineSceneComponent implements ISceneComponent {
  50411. /**
  50412. * The component name helpful to identify the component in the list of scene components.
  50413. */
  50414. readonly name: string;
  50415. /**
  50416. * The scene the component belongs to.
  50417. */
  50418. scene: Scene;
  50419. /**
  50420. * Creates a new instance of the component for the given scene
  50421. * @param scene Defines the scene to register the component in
  50422. */
  50423. constructor(scene: Scene);
  50424. /**
  50425. * Registers the component in a given scene
  50426. */
  50427. register(): void;
  50428. /**
  50429. * Rebuilds the elements related to this component in case of
  50430. * context lost for instance.
  50431. */
  50432. rebuild(): void;
  50433. /**
  50434. * Disposes the component and the associated ressources
  50435. */
  50436. dispose(): void;
  50437. }
  50438. }
  50439. declare module BABYLON {
  50440. /**
  50441. * A helper for physics simulations
  50442. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  50443. */
  50444. export class PhysicsHelper {
  50445. private _scene;
  50446. private _physicsEngine;
  50447. /**
  50448. * Initializes the Physics helper
  50449. * @param scene Babylon.js scene
  50450. */
  50451. constructor(scene: Scene);
  50452. /**
  50453. * Applies a radial explosion impulse
  50454. * @param origin the origin of the explosion
  50455. * @param radiusOrEventOptions the radius or the options of radial explosion
  50456. * @param strength the explosion strength
  50457. * @param falloff possible options: Constant & Linear. Defaults to Constant
  50458. * @returns A physics radial explosion event, or null
  50459. */
  50460. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  50461. /**
  50462. * Applies a radial explosion force
  50463. * @param origin the origin of the explosion
  50464. * @param radiusOrEventOptions the radius or the options of radial explosion
  50465. * @param strength the explosion strength
  50466. * @param falloff possible options: Constant & Linear. Defaults to Constant
  50467. * @returns A physics radial explosion event, or null
  50468. */
  50469. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  50470. /**
  50471. * Creates a gravitational field
  50472. * @param origin the origin of the explosion
  50473. * @param radiusOrEventOptions the radius or the options of radial explosion
  50474. * @param strength the explosion strength
  50475. * @param falloff possible options: Constant & Linear. Defaults to Constant
  50476. * @returns A physics gravitational field event, or null
  50477. */
  50478. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  50479. /**
  50480. * Creates a physics updraft event
  50481. * @param origin the origin of the updraft
  50482. * @param radiusOrEventOptions the radius or the options of the updraft
  50483. * @param strength the strength of the updraft
  50484. * @param height the height of the updraft
  50485. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  50486. * @returns A physics updraft event, or null
  50487. */
  50488. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  50489. /**
  50490. * Creates a physics vortex event
  50491. * @param origin the of the vortex
  50492. * @param radiusOrEventOptions the radius or the options of the vortex
  50493. * @param strength the strength of the vortex
  50494. * @param height the height of the vortex
  50495. * @returns a Physics vortex event, or null
  50496. * A physics vortex event or null
  50497. */
  50498. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  50499. }
  50500. /**
  50501. * Represents a physics radial explosion event
  50502. */
  50503. class PhysicsRadialExplosionEvent {
  50504. private _scene;
  50505. private _options;
  50506. private _sphere;
  50507. private _dataFetched;
  50508. /**
  50509. * Initializes a radial explosioin event
  50510. * @param _scene BabylonJS scene
  50511. * @param _options The options for the vortex event
  50512. */
  50513. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  50514. /**
  50515. * Returns the data related to the radial explosion event (sphere).
  50516. * @returns The radial explosion event data
  50517. */
  50518. getData(): PhysicsRadialExplosionEventData;
  50519. /**
  50520. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  50521. * @param impostor A physics imposter
  50522. * @param origin the origin of the explosion
  50523. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  50524. */
  50525. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsForceAndContactPoint>;
  50526. /**
  50527. * Disposes the sphere.
  50528. * @param force Specifies if the sphere should be disposed by force
  50529. */
  50530. dispose(force?: boolean): void;
  50531. /*** Helpers ***/
  50532. private _prepareSphere;
  50533. private _intersectsWithSphere;
  50534. }
  50535. /**
  50536. * Represents a gravitational field event
  50537. */
  50538. class PhysicsGravitationalFieldEvent {
  50539. private _physicsHelper;
  50540. private _scene;
  50541. private _origin;
  50542. private _options;
  50543. private _tickCallback;
  50544. private _sphere;
  50545. private _dataFetched;
  50546. /**
  50547. * Initializes the physics gravitational field event
  50548. * @param _physicsHelper A physics helper
  50549. * @param _scene BabylonJS scene
  50550. * @param _origin The origin position of the gravitational field event
  50551. * @param _options The options for the vortex event
  50552. */
  50553. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  50554. /**
  50555. * Returns the data related to the gravitational field event (sphere).
  50556. * @returns A gravitational field event
  50557. */
  50558. getData(): PhysicsGravitationalFieldEventData;
  50559. /**
  50560. * Enables the gravitational field.
  50561. */
  50562. enable(): void;
  50563. /**
  50564. * Disables the gravitational field.
  50565. */
  50566. disable(): void;
  50567. /**
  50568. * Disposes the sphere.
  50569. * @param force The force to dispose from the gravitational field event
  50570. */
  50571. dispose(force?: boolean): void;
  50572. private _tick;
  50573. }
  50574. /**
  50575. * Represents a physics updraft event
  50576. */
  50577. class PhysicsUpdraftEvent {
  50578. private _scene;
  50579. private _origin;
  50580. private _options;
  50581. private _physicsEngine;
  50582. private _originTop;
  50583. private _originDirection;
  50584. private _tickCallback;
  50585. private _cylinder;
  50586. private _cylinderPosition;
  50587. private _dataFetched;
  50588. /**
  50589. * Initializes the physics updraft event
  50590. * @param _scene BabylonJS scene
  50591. * @param _origin The origin position of the updraft
  50592. * @param _options The options for the updraft event
  50593. */
  50594. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  50595. /**
  50596. * Returns the data related to the updraft event (cylinder).
  50597. * @returns A physics updraft event
  50598. */
  50599. getData(): PhysicsUpdraftEventData;
  50600. /**
  50601. * Enables the updraft.
  50602. */
  50603. enable(): void;
  50604. /**
  50605. * Disables the updraft.
  50606. */
  50607. disable(): void;
  50608. /**
  50609. * Disposes the cylinder.
  50610. * @param force Specifies if the updraft should be disposed by force
  50611. */
  50612. dispose(force?: boolean): void;
  50613. private getImpostorForceAndContactPoint;
  50614. private _tick;
  50615. /*** Helpers ***/
  50616. private _prepareCylinder;
  50617. private _intersectsWithCylinder;
  50618. }
  50619. /**
  50620. * Represents a physics vortex event
  50621. */
  50622. class PhysicsVortexEvent {
  50623. private _scene;
  50624. private _origin;
  50625. private _options;
  50626. private _physicsEngine;
  50627. private _originTop;
  50628. private _tickCallback;
  50629. private _cylinder;
  50630. private _cylinderPosition;
  50631. private _dataFetched;
  50632. /**
  50633. * Initializes the physics vortex event
  50634. * @param _scene The BabylonJS scene
  50635. * @param _origin The origin position of the vortex
  50636. * @param _options The options for the vortex event
  50637. */
  50638. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  50639. /**
  50640. * Returns the data related to the vortex event (cylinder).
  50641. * @returns The physics vortex event data
  50642. */
  50643. getData(): PhysicsVortexEventData;
  50644. /**
  50645. * Enables the vortex.
  50646. */
  50647. enable(): void;
  50648. /**
  50649. * Disables the cortex.
  50650. */
  50651. disable(): void;
  50652. /**
  50653. * Disposes the sphere.
  50654. * @param force
  50655. */
  50656. dispose(force?: boolean): void;
  50657. private getImpostorForceAndContactPoint;
  50658. private _tick;
  50659. /*** Helpers ***/
  50660. private _prepareCylinder;
  50661. private _intersectsWithCylinder;
  50662. }
  50663. /**
  50664. * Options fot the radial explosion event
  50665. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  50666. */
  50667. export class PhysicsRadialExplosionEventOptions {
  50668. /**
  50669. * The radius of the sphere for the radial explosion.
  50670. */
  50671. radius: number;
  50672. /**
  50673. * The strenth of the explosion.
  50674. */
  50675. strength: number;
  50676. /**
  50677. * The strenght of the force in correspondence to the distance of the affected object
  50678. */
  50679. falloff: PhysicsRadialImpulseFalloff;
  50680. /**
  50681. * Sphere options for the radial explosion.
  50682. */
  50683. sphere: {
  50684. segments: number;
  50685. diameter: number;
  50686. };
  50687. }
  50688. /**
  50689. * Options fot the updraft event
  50690. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  50691. */
  50692. export class PhysicsUpdraftEventOptions {
  50693. /**
  50694. * The radius of the cylinder for the vortex
  50695. */
  50696. radius: number;
  50697. /**
  50698. * The strenth of the updraft.
  50699. */
  50700. strength: number;
  50701. /**
  50702. * The height of the cylinder for the updraft.
  50703. */
  50704. height: number;
  50705. /**
  50706. * The mode for the the updraft.
  50707. */
  50708. updraftMode: PhysicsUpdraftMode;
  50709. }
  50710. /**
  50711. * Options fot the vortex event
  50712. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  50713. */
  50714. export class PhysicsVortexEventOptions {
  50715. /**
  50716. * The radius of the cylinder for the vortex
  50717. */
  50718. radius: number;
  50719. /**
  50720. * The strenth of the vortex.
  50721. */
  50722. strength: number;
  50723. /**
  50724. * The height of the cylinder for the vortex.
  50725. */
  50726. height: number;
  50727. /**
  50728. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  50729. */
  50730. centripetalForceThreshold: number;
  50731. /**
  50732. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  50733. */
  50734. centripetalForceMultiplier: number;
  50735. /**
  50736. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  50737. */
  50738. centrifugalForceMultiplier: number;
  50739. /**
  50740. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  50741. */
  50742. updraftForceMultiplier: number;
  50743. }
  50744. /**
  50745. * The strenght of the force in correspondence to the distance of the affected object
  50746. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  50747. */
  50748. export enum PhysicsRadialImpulseFalloff {
  50749. /** Defines that impulse is constant in strength across it's whole radius */
  50750. Constant = 0,
  50751. /** Defines that impulse gets weaker if it's further from the origin */
  50752. Linear = 1
  50753. }
  50754. /**
  50755. * The strength of the force in correspondence to the distance of the affected object
  50756. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  50757. */
  50758. export enum PhysicsUpdraftMode {
  50759. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  50760. Center = 0,
  50761. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  50762. Perpendicular = 1
  50763. }
  50764. /**
  50765. * Interface for a physics force and contact point
  50766. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  50767. */
  50768. export interface PhysicsForceAndContactPoint {
  50769. /**
  50770. * The force applied at the contact point
  50771. */
  50772. force: Vector3;
  50773. /**
  50774. * The contact point
  50775. */
  50776. contactPoint: Vector3;
  50777. }
  50778. /**
  50779. * Interface for radial explosion event data
  50780. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  50781. */
  50782. export interface PhysicsRadialExplosionEventData {
  50783. /**
  50784. * A sphere used for the radial explosion event
  50785. */
  50786. sphere: Mesh;
  50787. }
  50788. /**
  50789. * Interface for gravitational field event data
  50790. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  50791. */
  50792. export interface PhysicsGravitationalFieldEventData {
  50793. /**
  50794. * A sphere mesh used for the gravitational field event
  50795. */
  50796. sphere: Mesh;
  50797. }
  50798. /**
  50799. * Interface for updraft event data
  50800. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  50801. */
  50802. export interface PhysicsUpdraftEventData {
  50803. /**
  50804. * A cylinder used for the updraft event
  50805. */
  50806. cylinder: Mesh;
  50807. }
  50808. /**
  50809. * Interface for vortex event data
  50810. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  50811. */
  50812. export interface PhysicsVortexEventData {
  50813. /**
  50814. * A cylinder used for the vortex event
  50815. */
  50816. cylinder: Mesh;
  50817. }
  50818. }
  50819. declare module BABYLON {
  50820. /**
  50821. * AmmoJS Physics plugin
  50822. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50823. * @see https://github.com/kripken/ammo.js/
  50824. */
  50825. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  50826. private _useDeltaForWorldStep;
  50827. /**
  50828. * Reference to the Ammo library
  50829. */
  50830. bjsAMMO: any;
  50831. /**
  50832. * Created ammoJS world which physics bodies are added to
  50833. */
  50834. world: any;
  50835. /**
  50836. * Name of the plugin
  50837. */
  50838. name: string;
  50839. private _timeStep;
  50840. private _fixedTimeStep;
  50841. private _maxSteps;
  50842. private _tmpQuaternion;
  50843. private _tmpAmmoTransform;
  50844. private _tmpAmmoQuaternion;
  50845. private _tmpAmmoConcreteContactResultCallback;
  50846. private _collisionConfiguration;
  50847. private _dispatcher;
  50848. private _overlappingPairCache;
  50849. private _solver;
  50850. private _softBodySolver;
  50851. private _tmpAmmoVectorA;
  50852. private _tmpAmmoVectorB;
  50853. private _tmpAmmoVectorC;
  50854. private _tmpAmmoVectorD;
  50855. private _tmpContactCallbackResult;
  50856. private _tmpAmmoVectorRCA;
  50857. private _tmpAmmoVectorRCB;
  50858. private _raycastResult;
  50859. private static readonly DISABLE_COLLISION_FLAG;
  50860. private static readonly KINEMATIC_FLAG;
  50861. private static readonly DISABLE_DEACTIVATION_FLAG;
  50862. /**
  50863. * Initializes the ammoJS plugin
  50864. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  50865. * @param ammoInjection can be used to inject your own ammo reference
  50866. */
  50867. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  50868. /**
  50869. * Sets the gravity of the physics world (m/(s^2))
  50870. * @param gravity Gravity to set
  50871. */
  50872. setGravity(gravity: Vector3): void;
  50873. /**
  50874. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  50875. * @param timeStep timestep to use in seconds
  50876. */
  50877. setTimeStep(timeStep: number): void;
  50878. /**
  50879. * 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)
  50880. * @param fixedTimeStep fixedTimeStep to use in seconds
  50881. */
  50882. setFixedTimeStep(fixedTimeStep: number): void;
  50883. /**
  50884. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  50885. * @param maxSteps the maximum number of steps by the physics engine per frame
  50886. */
  50887. setMaxSteps(maxSteps: number): void;
  50888. /**
  50889. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  50890. * @returns the current timestep in seconds
  50891. */
  50892. getTimeStep(): number;
  50893. private _isImpostorInContact;
  50894. private _isImpostorPairInContact;
  50895. private _stepSimulation;
  50896. /**
  50897. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  50898. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  50899. * After the step the babylon meshes are set to the position of the physics imposters
  50900. * @param delta amount of time to step forward
  50901. * @param impostors array of imposters to update before/after the step
  50902. */
  50903. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50904. /**
  50905. * Update babylon mesh to match physics world object
  50906. * @param impostor imposter to match
  50907. */
  50908. private _afterSoftStep;
  50909. /**
  50910. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  50911. * @param impostor imposter to match
  50912. */
  50913. private _ropeStep;
  50914. /**
  50915. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  50916. * @param impostor imposter to match
  50917. */
  50918. private _softbodyOrClothStep;
  50919. private _tmpVector;
  50920. private _tmpMatrix;
  50921. /**
  50922. * Applies an impulse on the imposter
  50923. * @param impostor imposter to apply impulse to
  50924. * @param force amount of force to be applied to the imposter
  50925. * @param contactPoint the location to apply the impulse on the imposter
  50926. */
  50927. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50928. /**
  50929. * Applies a force on the imposter
  50930. * @param impostor imposter to apply force
  50931. * @param force amount of force to be applied to the imposter
  50932. * @param contactPoint the location to apply the force on the imposter
  50933. */
  50934. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50935. /**
  50936. * Creates a physics body using the plugin
  50937. * @param impostor the imposter to create the physics body on
  50938. */
  50939. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50940. /**
  50941. * Removes the physics body from the imposter and disposes of the body's memory
  50942. * @param impostor imposter to remove the physics body from
  50943. */
  50944. removePhysicsBody(impostor: PhysicsImpostor): void;
  50945. /**
  50946. * Generates a joint
  50947. * @param impostorJoint the imposter joint to create the joint with
  50948. */
  50949. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50950. /**
  50951. * Removes a joint
  50952. * @param impostorJoint the imposter joint to remove the joint from
  50953. */
  50954. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50955. private _addMeshVerts;
  50956. /**
  50957. * Initialise the soft body vertices to match its object's (mesh) vertices
  50958. * Softbody vertices (nodes) are in world space and to match this
  50959. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  50960. * @param impostor to create the softbody for
  50961. */
  50962. private _softVertexData;
  50963. /**
  50964. * Create an impostor's soft body
  50965. * @param impostor to create the softbody for
  50966. */
  50967. private _createSoftbody;
  50968. /**
  50969. * Create cloth for an impostor
  50970. * @param impostor to create the softbody for
  50971. */
  50972. private _createCloth;
  50973. /**
  50974. * Create rope for an impostor
  50975. * @param impostor to create the softbody for
  50976. */
  50977. private _createRope;
  50978. private _addHullVerts;
  50979. private _createShape;
  50980. /**
  50981. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  50982. * @param impostor imposter containing the physics body and babylon object
  50983. */
  50984. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50985. /**
  50986. * Sets the babylon object's position/rotation from the physics body's position/rotation
  50987. * @param impostor imposter containing the physics body and babylon object
  50988. * @param newPosition new position
  50989. * @param newRotation new rotation
  50990. */
  50991. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50992. /**
  50993. * If this plugin is supported
  50994. * @returns true if its supported
  50995. */
  50996. isSupported(): boolean;
  50997. /**
  50998. * Sets the linear velocity of the physics body
  50999. * @param impostor imposter to set the velocity on
  51000. * @param velocity velocity to set
  51001. */
  51002. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51003. /**
  51004. * Sets the angular velocity of the physics body
  51005. * @param impostor imposter to set the velocity on
  51006. * @param velocity velocity to set
  51007. */
  51008. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51009. /**
  51010. * gets the linear velocity
  51011. * @param impostor imposter to get linear velocity from
  51012. * @returns linear velocity
  51013. */
  51014. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51015. /**
  51016. * gets the angular velocity
  51017. * @param impostor imposter to get angular velocity from
  51018. * @returns angular velocity
  51019. */
  51020. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51021. /**
  51022. * Sets the mass of physics body
  51023. * @param impostor imposter to set the mass on
  51024. * @param mass mass to set
  51025. */
  51026. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51027. /**
  51028. * Gets the mass of the physics body
  51029. * @param impostor imposter to get the mass from
  51030. * @returns mass
  51031. */
  51032. getBodyMass(impostor: PhysicsImpostor): number;
  51033. /**
  51034. * Gets friction of the impostor
  51035. * @param impostor impostor to get friction from
  51036. * @returns friction value
  51037. */
  51038. getBodyFriction(impostor: PhysicsImpostor): number;
  51039. /**
  51040. * Sets friction of the impostor
  51041. * @param impostor impostor to set friction on
  51042. * @param friction friction value
  51043. */
  51044. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51045. /**
  51046. * Gets restitution of the impostor
  51047. * @param impostor impostor to get restitution from
  51048. * @returns restitution value
  51049. */
  51050. getBodyRestitution(impostor: PhysicsImpostor): number;
  51051. /**
  51052. * Sets resitution of the impostor
  51053. * @param impostor impostor to set resitution on
  51054. * @param restitution resitution value
  51055. */
  51056. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51057. /**
  51058. * Gets pressure inside the impostor
  51059. * @param impostor impostor to get pressure from
  51060. * @returns pressure value
  51061. */
  51062. getBodyPressure(impostor: PhysicsImpostor): number;
  51063. /**
  51064. * Sets pressure inside a soft body impostor
  51065. * Cloth and rope must remain 0 pressure
  51066. * @param impostor impostor to set pressure on
  51067. * @param pressure pressure value
  51068. */
  51069. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  51070. /**
  51071. * Gets stiffness of the impostor
  51072. * @param impostor impostor to get stiffness from
  51073. * @returns pressure value
  51074. */
  51075. getBodyStiffness(impostor: PhysicsImpostor): number;
  51076. /**
  51077. * Sets stiffness of the impostor
  51078. * @param impostor impostor to set stiffness on
  51079. * @param stiffness stiffness value from 0 to 1
  51080. */
  51081. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  51082. /**
  51083. * Gets velocityIterations of the impostor
  51084. * @param impostor impostor to get velocity iterations from
  51085. * @returns velocityIterations value
  51086. */
  51087. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  51088. /**
  51089. * Sets velocityIterations of the impostor
  51090. * @param impostor impostor to set velocity iterations on
  51091. * @param velocityIterations velocityIterations value
  51092. */
  51093. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  51094. /**
  51095. * Gets positionIterations of the impostor
  51096. * @param impostor impostor to get position iterations from
  51097. * @returns positionIterations value
  51098. */
  51099. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  51100. /**
  51101. * Sets positionIterations of the impostor
  51102. * @param impostor impostor to set position on
  51103. * @param positionIterations positionIterations value
  51104. */
  51105. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  51106. /**
  51107. * Append an anchor to a cloth object
  51108. * @param impostor is the cloth impostor to add anchor to
  51109. * @param otherImpostor is the rigid impostor to anchor to
  51110. * @param width ratio across width from 0 to 1
  51111. * @param height ratio up height from 0 to 1
  51112. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  51113. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  51114. */
  51115. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  51116. /**
  51117. * Append an hook to a rope object
  51118. * @param impostor is the rope impostor to add hook to
  51119. * @param otherImpostor is the rigid impostor to hook to
  51120. * @param length ratio along the rope from 0 to 1
  51121. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  51122. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  51123. */
  51124. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  51125. /**
  51126. * Sleeps the physics body and stops it from being active
  51127. * @param impostor impostor to sleep
  51128. */
  51129. sleepBody(impostor: PhysicsImpostor): void;
  51130. /**
  51131. * Activates the physics body
  51132. * @param impostor impostor to activate
  51133. */
  51134. wakeUpBody(impostor: PhysicsImpostor): void;
  51135. /**
  51136. * Updates the distance parameters of the joint
  51137. * @param joint joint to update
  51138. * @param maxDistance maximum distance of the joint
  51139. * @param minDistance minimum distance of the joint
  51140. */
  51141. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  51142. /**
  51143. * Sets a motor on the joint
  51144. * @param joint joint to set motor on
  51145. * @param speed speed of the motor
  51146. * @param maxForce maximum force of the motor
  51147. * @param motorIndex index of the motor
  51148. */
  51149. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  51150. /**
  51151. * Sets the motors limit
  51152. * @param joint joint to set limit on
  51153. * @param upperLimit upper limit
  51154. * @param lowerLimit lower limit
  51155. */
  51156. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  51157. /**
  51158. * Syncs the position and rotation of a mesh with the impostor
  51159. * @param mesh mesh to sync
  51160. * @param impostor impostor to update the mesh with
  51161. */
  51162. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51163. /**
  51164. * Gets the radius of the impostor
  51165. * @param impostor impostor to get radius from
  51166. * @returns the radius
  51167. */
  51168. getRadius(impostor: PhysicsImpostor): number;
  51169. /**
  51170. * Gets the box size of the impostor
  51171. * @param impostor impostor to get box size from
  51172. * @param result the resulting box size
  51173. */
  51174. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51175. /**
  51176. * Disposes of the impostor
  51177. */
  51178. dispose(): void;
  51179. /**
  51180. * Does a raycast in the physics world
  51181. * @param from when should the ray start?
  51182. * @param to when should the ray end?
  51183. * @returns PhysicsRaycastResult
  51184. */
  51185. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51186. }
  51187. }
  51188. declare module BABYLON {
  51189. /** @hidden */
  51190. export var blackAndWhitePixelShader: {
  51191. name: string;
  51192. shader: string;
  51193. };
  51194. }
  51195. declare module BABYLON {
  51196. /**
  51197. * Post process used to render in black and white
  51198. */
  51199. export class BlackAndWhitePostProcess extends PostProcess {
  51200. /**
  51201. * Linear about to convert he result to black and white (default: 1)
  51202. */
  51203. degree: number;
  51204. /**
  51205. * Creates a black and white post process
  51206. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  51207. * @param name The name of the effect.
  51208. * @param options The required width/height ratio to downsize to before computing the render pass.
  51209. * @param camera The camera to apply the render pass to.
  51210. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51211. * @param engine The engine which the post process will be applied. (default: current engine)
  51212. * @param reusable If the post process can be reused on the same frame. (default: false)
  51213. */
  51214. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  51215. }
  51216. }
  51217. declare module BABYLON {
  51218. /**
  51219. * This represents a set of one or more post processes in Babylon.
  51220. * A post process can be used to apply a shader to a texture after it is rendered.
  51221. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  51222. */
  51223. export class PostProcessRenderEffect {
  51224. private _postProcesses;
  51225. private _getPostProcesses;
  51226. private _singleInstance;
  51227. private _cameras;
  51228. private _indicesForCamera;
  51229. /**
  51230. * Name of the effect
  51231. * @hidden
  51232. */
  51233. _name: string;
  51234. /**
  51235. * Instantiates a post process render effect.
  51236. * A post process can be used to apply a shader to a texture after it is rendered.
  51237. * @param engine The engine the effect is tied to
  51238. * @param name The name of the effect
  51239. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  51240. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  51241. */
  51242. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  51243. /**
  51244. * Checks if all the post processes in the effect are supported.
  51245. */
  51246. readonly isSupported: boolean;
  51247. /**
  51248. * Updates the current state of the effect
  51249. * @hidden
  51250. */
  51251. _update(): void;
  51252. /**
  51253. * Attaches the effect on cameras
  51254. * @param cameras The camera to attach to.
  51255. * @hidden
  51256. */
  51257. _attachCameras(cameras: Camera): void;
  51258. /**
  51259. * Attaches the effect on cameras
  51260. * @param cameras The camera to attach to.
  51261. * @hidden
  51262. */
  51263. _attachCameras(cameras: Camera[]): void;
  51264. /**
  51265. * Detatches the effect on cameras
  51266. * @param cameras The camera to detatch from.
  51267. * @hidden
  51268. */
  51269. _detachCameras(cameras: Camera): void;
  51270. /**
  51271. * Detatches the effect on cameras
  51272. * @param cameras The camera to detatch from.
  51273. * @hidden
  51274. */
  51275. _detachCameras(cameras: Camera[]): void;
  51276. /**
  51277. * Enables the effect on given cameras
  51278. * @param cameras The camera to enable.
  51279. * @hidden
  51280. */
  51281. _enable(cameras: Camera): void;
  51282. /**
  51283. * Enables the effect on given cameras
  51284. * @param cameras The camera to enable.
  51285. * @hidden
  51286. */
  51287. _enable(cameras: Nullable<Camera[]>): void;
  51288. /**
  51289. * Disables the effect on the given cameras
  51290. * @param cameras The camera to disable.
  51291. * @hidden
  51292. */
  51293. _disable(cameras: Camera): void;
  51294. /**
  51295. * Disables the effect on the given cameras
  51296. * @param cameras The camera to disable.
  51297. * @hidden
  51298. */
  51299. _disable(cameras: Nullable<Camera[]>): void;
  51300. /**
  51301. * Gets a list of the post processes contained in the effect.
  51302. * @param camera The camera to get the post processes on.
  51303. * @returns The list of the post processes in the effect.
  51304. */
  51305. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  51306. }
  51307. }
  51308. declare module BABYLON {
  51309. /** @hidden */
  51310. export var extractHighlightsPixelShader: {
  51311. name: string;
  51312. shader: string;
  51313. };
  51314. }
  51315. declare module BABYLON {
  51316. /**
  51317. * 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.
  51318. */
  51319. export class ExtractHighlightsPostProcess extends PostProcess {
  51320. /**
  51321. * The luminance threshold, pixels below this value will be set to black.
  51322. */
  51323. threshold: number;
  51324. /** @hidden */
  51325. _exposure: number;
  51326. /**
  51327. * Post process which has the input texture to be used when performing highlight extraction
  51328. * @hidden
  51329. */
  51330. _inputPostProcess: Nullable<PostProcess>;
  51331. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51332. }
  51333. }
  51334. declare module BABYLON {
  51335. /** @hidden */
  51336. export var bloomMergePixelShader: {
  51337. name: string;
  51338. shader: string;
  51339. };
  51340. }
  51341. declare module BABYLON {
  51342. /**
  51343. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  51344. */
  51345. export class BloomMergePostProcess extends PostProcess {
  51346. /** Weight of the bloom to be added to the original input. */
  51347. weight: number;
  51348. /**
  51349. * Creates a new instance of @see BloomMergePostProcess
  51350. * @param name The name of the effect.
  51351. * @param originalFromInput Post process which's input will be used for the merge.
  51352. * @param blurred Blurred highlights post process which's output will be used.
  51353. * @param weight Weight of the bloom to be added to the original input.
  51354. * @param options The required width/height ratio to downsize to before computing the render pass.
  51355. * @param camera The camera to apply the render pass to.
  51356. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51357. * @param engine The engine which the post process will be applied. (default: current engine)
  51358. * @param reusable If the post process can be reused on the same frame. (default: false)
  51359. * @param textureType Type of textures used when performing the post process. (default: 0)
  51360. * @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)
  51361. */
  51362. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  51363. /** Weight of the bloom to be added to the original input. */
  51364. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51365. }
  51366. }
  51367. declare module BABYLON {
  51368. /**
  51369. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  51370. */
  51371. export class BloomEffect extends PostProcessRenderEffect {
  51372. private bloomScale;
  51373. /**
  51374. * @hidden Internal
  51375. */
  51376. _effects: Array<PostProcess>;
  51377. /**
  51378. * @hidden Internal
  51379. */
  51380. _downscale: ExtractHighlightsPostProcess;
  51381. private _blurX;
  51382. private _blurY;
  51383. private _merge;
  51384. /**
  51385. * The luminance threshold to find bright areas of the image to bloom.
  51386. */
  51387. threshold: number;
  51388. /**
  51389. * The strength of the bloom.
  51390. */
  51391. weight: number;
  51392. /**
  51393. * Specifies the size of the bloom blur kernel, relative to the final output size
  51394. */
  51395. kernel: number;
  51396. /**
  51397. * Creates a new instance of @see BloomEffect
  51398. * @param scene The scene the effect belongs to.
  51399. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  51400. * @param bloomKernel The size of the kernel to be used when applying the blur.
  51401. * @param bloomWeight The the strength of bloom.
  51402. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  51403. * @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)
  51404. */
  51405. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  51406. /**
  51407. * Disposes each of the internal effects for a given camera.
  51408. * @param camera The camera to dispose the effect on.
  51409. */
  51410. disposeEffects(camera: Camera): void;
  51411. /**
  51412. * @hidden Internal
  51413. */
  51414. _updateEffects(): void;
  51415. /**
  51416. * Internal
  51417. * @returns if all the contained post processes are ready.
  51418. * @hidden
  51419. */
  51420. _isReady(): boolean;
  51421. }
  51422. }
  51423. declare module BABYLON {
  51424. /** @hidden */
  51425. export var chromaticAberrationPixelShader: {
  51426. name: string;
  51427. shader: string;
  51428. };
  51429. }
  51430. declare module BABYLON {
  51431. /**
  51432. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  51433. */
  51434. export class ChromaticAberrationPostProcess extends PostProcess {
  51435. /**
  51436. * The amount of seperation of rgb channels (default: 30)
  51437. */
  51438. aberrationAmount: number;
  51439. /**
  51440. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  51441. */
  51442. radialIntensity: number;
  51443. /**
  51444. * 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))
  51445. */
  51446. direction: Vector2;
  51447. /**
  51448. * 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))
  51449. */
  51450. centerPosition: Vector2;
  51451. /**
  51452. * Creates a new instance ChromaticAberrationPostProcess
  51453. * @param name The name of the effect.
  51454. * @param screenWidth The width of the screen to apply the effect on.
  51455. * @param screenHeight The height of the screen to apply the effect on.
  51456. * @param options The required width/height ratio to downsize to before computing the render pass.
  51457. * @param camera The camera to apply the render pass to.
  51458. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51459. * @param engine The engine which the post process will be applied. (default: current engine)
  51460. * @param reusable If the post process can be reused on the same frame. (default: false)
  51461. * @param textureType Type of textures used when performing the post process. (default: 0)
  51462. * @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)
  51463. */
  51464. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51465. }
  51466. }
  51467. declare module BABYLON {
  51468. /** @hidden */
  51469. export var circleOfConfusionPixelShader: {
  51470. name: string;
  51471. shader: string;
  51472. };
  51473. }
  51474. declare module BABYLON {
  51475. /**
  51476. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  51477. */
  51478. export class CircleOfConfusionPostProcess extends PostProcess {
  51479. /**
  51480. * 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.
  51481. */
  51482. lensSize: number;
  51483. /**
  51484. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  51485. */
  51486. fStop: number;
  51487. /**
  51488. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  51489. */
  51490. focusDistance: number;
  51491. /**
  51492. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  51493. */
  51494. focalLength: number;
  51495. private _depthTexture;
  51496. /**
  51497. * Creates a new instance CircleOfConfusionPostProcess
  51498. * @param name The name of the effect.
  51499. * @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.
  51500. * @param options The required width/height ratio to downsize to before computing the render pass.
  51501. * @param camera The camera to apply the render pass to.
  51502. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51503. * @param engine The engine which the post process will be applied. (default: current engine)
  51504. * @param reusable If the post process can be reused on the same frame. (default: false)
  51505. * @param textureType Type of textures used when performing the post process. (default: 0)
  51506. * @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)
  51507. */
  51508. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51509. /**
  51510. * 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.
  51511. */
  51512. depthTexture: RenderTargetTexture;
  51513. }
  51514. }
  51515. declare module BABYLON {
  51516. /** @hidden */
  51517. export var colorCorrectionPixelShader: {
  51518. name: string;
  51519. shader: string;
  51520. };
  51521. }
  51522. declare module BABYLON {
  51523. /**
  51524. *
  51525. * This post-process allows the modification of rendered colors by using
  51526. * a 'look-up table' (LUT). This effect is also called Color Grading.
  51527. *
  51528. * The object needs to be provided an url to a texture containing the color
  51529. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  51530. * Use an image editing software to tweak the LUT to match your needs.
  51531. *
  51532. * For an example of a color LUT, see here:
  51533. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  51534. * For explanations on color grading, see here:
  51535. * @see http://udn.epicgames.com/Three/ColorGrading.html
  51536. *
  51537. */
  51538. export class ColorCorrectionPostProcess extends PostProcess {
  51539. private _colorTableTexture;
  51540. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  51541. }
  51542. }
  51543. declare module BABYLON {
  51544. /** @hidden */
  51545. export var convolutionPixelShader: {
  51546. name: string;
  51547. shader: string;
  51548. };
  51549. }
  51550. declare module BABYLON {
  51551. /**
  51552. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  51553. * input texture to perform effects such as edge detection or sharpening
  51554. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  51555. */
  51556. export class ConvolutionPostProcess extends PostProcess {
  51557. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  51558. kernel: number[];
  51559. /**
  51560. * Creates a new instance ConvolutionPostProcess
  51561. * @param name The name of the effect.
  51562. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  51563. * @param options The required width/height ratio to downsize to before computing the render pass.
  51564. * @param camera The camera to apply the render pass to.
  51565. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51566. * @param engine The engine which the post process will be applied. (default: current engine)
  51567. * @param reusable If the post process can be reused on the same frame. (default: false)
  51568. * @param textureType Type of textures used when performing the post process. (default: 0)
  51569. */
  51570. constructor(name: string,
  51571. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  51572. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  51573. /**
  51574. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51575. */
  51576. static EdgeDetect0Kernel: number[];
  51577. /**
  51578. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51579. */
  51580. static EdgeDetect1Kernel: number[];
  51581. /**
  51582. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51583. */
  51584. static EdgeDetect2Kernel: number[];
  51585. /**
  51586. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51587. */
  51588. static SharpenKernel: number[];
  51589. /**
  51590. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51591. */
  51592. static EmbossKernel: number[];
  51593. /**
  51594. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51595. */
  51596. static GaussianKernel: number[];
  51597. }
  51598. }
  51599. declare module BABYLON {
  51600. /**
  51601. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  51602. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  51603. * based on samples that have a large difference in distance than the center pixel.
  51604. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  51605. */
  51606. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  51607. direction: Vector2;
  51608. /**
  51609. * Creates a new instance CircleOfConfusionPostProcess
  51610. * @param name The name of the effect.
  51611. * @param scene The scene the effect belongs to.
  51612. * @param direction The direction the blur should be applied.
  51613. * @param kernel The size of the kernel used to blur.
  51614. * @param options The required width/height ratio to downsize to before computing the render pass.
  51615. * @param camera The camera to apply the render pass to.
  51616. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  51617. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  51618. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51619. * @param engine The engine which the post process will be applied. (default: current engine)
  51620. * @param reusable If the post process can be reused on the same frame. (default: false)
  51621. * @param textureType Type of textures used when performing the post process. (default: 0)
  51622. * @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)
  51623. */
  51624. 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);
  51625. }
  51626. }
  51627. declare module BABYLON {
  51628. /** @hidden */
  51629. export var depthOfFieldMergePixelShader: {
  51630. name: string;
  51631. shader: string;
  51632. };
  51633. }
  51634. declare module BABYLON {
  51635. /**
  51636. * Options to be set when merging outputs from the default pipeline.
  51637. */
  51638. export class DepthOfFieldMergePostProcessOptions {
  51639. /**
  51640. * The original image to merge on top of
  51641. */
  51642. originalFromInput: PostProcess;
  51643. /**
  51644. * Parameters to perform the merge of the depth of field effect
  51645. */
  51646. depthOfField?: {
  51647. circleOfConfusion: PostProcess;
  51648. blurSteps: Array<PostProcess>;
  51649. };
  51650. /**
  51651. * Parameters to perform the merge of bloom effect
  51652. */
  51653. bloom?: {
  51654. blurred: PostProcess;
  51655. weight: number;
  51656. };
  51657. }
  51658. /**
  51659. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  51660. */
  51661. export class DepthOfFieldMergePostProcess extends PostProcess {
  51662. private blurSteps;
  51663. /**
  51664. * Creates a new instance of DepthOfFieldMergePostProcess
  51665. * @param name The name of the effect.
  51666. * @param originalFromInput Post process which's input will be used for the merge.
  51667. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  51668. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  51669. * @param options The required width/height ratio to downsize to before computing the render pass.
  51670. * @param camera The camera to apply the render pass to.
  51671. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51672. * @param engine The engine which the post process will be applied. (default: current engine)
  51673. * @param reusable If the post process can be reused on the same frame. (default: false)
  51674. * @param textureType Type of textures used when performing the post process. (default: 0)
  51675. * @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)
  51676. */
  51677. 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);
  51678. /**
  51679. * Updates the effect with the current post process compile time values and recompiles the shader.
  51680. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  51681. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  51682. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  51683. * @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
  51684. * @param onCompiled Called when the shader has been compiled.
  51685. * @param onError Called if there is an error when compiling a shader.
  51686. */
  51687. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  51688. }
  51689. }
  51690. declare module BABYLON {
  51691. /**
  51692. * Specifies the level of max blur that should be applied when using the depth of field effect
  51693. */
  51694. export enum DepthOfFieldEffectBlurLevel {
  51695. /**
  51696. * Subtle blur
  51697. */
  51698. Low = 0,
  51699. /**
  51700. * Medium blur
  51701. */
  51702. Medium = 1,
  51703. /**
  51704. * Large blur
  51705. */
  51706. High = 2
  51707. }
  51708. /**
  51709. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  51710. */
  51711. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  51712. private _circleOfConfusion;
  51713. /**
  51714. * @hidden Internal, blurs from high to low
  51715. */
  51716. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  51717. private _depthOfFieldBlurY;
  51718. private _dofMerge;
  51719. /**
  51720. * @hidden Internal post processes in depth of field effect
  51721. */
  51722. _effects: Array<PostProcess>;
  51723. /**
  51724. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  51725. */
  51726. focalLength: number;
  51727. /**
  51728. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  51729. */
  51730. fStop: number;
  51731. /**
  51732. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  51733. */
  51734. focusDistance: number;
  51735. /**
  51736. * 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.
  51737. */
  51738. lensSize: number;
  51739. /**
  51740. * Creates a new instance DepthOfFieldEffect
  51741. * @param scene The scene the effect belongs to.
  51742. * @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.
  51743. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  51744. * @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)
  51745. */
  51746. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  51747. /**
  51748. * 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.
  51749. */
  51750. depthTexture: RenderTargetTexture;
  51751. /**
  51752. * Disposes each of the internal effects for a given camera.
  51753. * @param camera The camera to dispose the effect on.
  51754. */
  51755. disposeEffects(camera: Camera): void;
  51756. /**
  51757. * @hidden Internal
  51758. */
  51759. _updateEffects(): void;
  51760. /**
  51761. * Internal
  51762. * @returns if all the contained post processes are ready.
  51763. * @hidden
  51764. */
  51765. _isReady(): boolean;
  51766. }
  51767. }
  51768. declare module BABYLON {
  51769. /** @hidden */
  51770. export var displayPassPixelShader: {
  51771. name: string;
  51772. shader: string;
  51773. };
  51774. }
  51775. declare module BABYLON {
  51776. /**
  51777. * DisplayPassPostProcess which produces an output the same as it's input
  51778. */
  51779. export class DisplayPassPostProcess extends PostProcess {
  51780. /**
  51781. * Creates the DisplayPassPostProcess
  51782. * @param name The name of the effect.
  51783. * @param options The required width/height ratio to downsize to before computing the render pass.
  51784. * @param camera The camera to apply the render pass to.
  51785. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51786. * @param engine The engine which the post process will be applied. (default: current engine)
  51787. * @param reusable If the post process can be reused on the same frame. (default: false)
  51788. */
  51789. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  51790. }
  51791. }
  51792. declare module BABYLON {
  51793. /** @hidden */
  51794. export var filterPixelShader: {
  51795. name: string;
  51796. shader: string;
  51797. };
  51798. }
  51799. declare module BABYLON {
  51800. /**
  51801. * Applies a kernel filter to the image
  51802. */
  51803. export class FilterPostProcess extends PostProcess {
  51804. /** The matrix to be applied to the image */
  51805. kernelMatrix: Matrix;
  51806. /**
  51807. *
  51808. * @param name The name of the effect.
  51809. * @param kernelMatrix The matrix to be applied to the image
  51810. * @param options The required width/height ratio to downsize to before computing the render pass.
  51811. * @param camera The camera to apply the render pass to.
  51812. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51813. * @param engine The engine which the post process will be applied. (default: current engine)
  51814. * @param reusable If the post process can be reused on the same frame. (default: false)
  51815. */
  51816. constructor(name: string,
  51817. /** The matrix to be applied to the image */
  51818. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  51819. }
  51820. }
  51821. declare module BABYLON {
  51822. /** @hidden */
  51823. export var fxaaPixelShader: {
  51824. name: string;
  51825. shader: string;
  51826. };
  51827. }
  51828. declare module BABYLON {
  51829. /** @hidden */
  51830. export var fxaaVertexShader: {
  51831. name: string;
  51832. shader: string;
  51833. };
  51834. }
  51835. declare module BABYLON {
  51836. /**
  51837. * Fxaa post process
  51838. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  51839. */
  51840. export class FxaaPostProcess extends PostProcess {
  51841. /** @hidden */
  51842. texelWidth: number;
  51843. /** @hidden */
  51844. texelHeight: number;
  51845. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  51846. private _getDefines;
  51847. }
  51848. }
  51849. declare module BABYLON {
  51850. /** @hidden */
  51851. export var grainPixelShader: {
  51852. name: string;
  51853. shader: string;
  51854. };
  51855. }
  51856. declare module BABYLON {
  51857. /**
  51858. * The GrainPostProcess adds noise to the image at mid luminance levels
  51859. */
  51860. export class GrainPostProcess extends PostProcess {
  51861. /**
  51862. * The intensity of the grain added (default: 30)
  51863. */
  51864. intensity: number;
  51865. /**
  51866. * If the grain should be randomized on every frame
  51867. */
  51868. animated: boolean;
  51869. /**
  51870. * Creates a new instance of @see GrainPostProcess
  51871. * @param name The name of the effect.
  51872. * @param options The required width/height ratio to downsize to before computing the render pass.
  51873. * @param camera The camera to apply the render pass to.
  51874. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51875. * @param engine The engine which the post process will be applied. (default: current engine)
  51876. * @param reusable If the post process can be reused on the same frame. (default: false)
  51877. * @param textureType Type of textures used when performing the post process. (default: 0)
  51878. * @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)
  51879. */
  51880. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51881. }
  51882. }
  51883. declare module BABYLON {
  51884. /** @hidden */
  51885. export var highlightsPixelShader: {
  51886. name: string;
  51887. shader: string;
  51888. };
  51889. }
  51890. declare module BABYLON {
  51891. /**
  51892. * Extracts highlights from the image
  51893. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  51894. */
  51895. export class HighlightsPostProcess extends PostProcess {
  51896. /**
  51897. * Extracts highlights from the image
  51898. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  51899. * @param name The name of the effect.
  51900. * @param options The required width/height ratio to downsize to before computing the render pass.
  51901. * @param camera The camera to apply the render pass to.
  51902. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51903. * @param engine The engine which the post process will be applied. (default: current engine)
  51904. * @param reusable If the post process can be reused on the same frame. (default: false)
  51905. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  51906. */
  51907. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  51908. }
  51909. }
  51910. declare module BABYLON {
  51911. /** @hidden */
  51912. export var mrtFragmentDeclaration: {
  51913. name: string;
  51914. shader: string;
  51915. };
  51916. }
  51917. declare module BABYLON {
  51918. /** @hidden */
  51919. export var geometryPixelShader: {
  51920. name: string;
  51921. shader: string;
  51922. };
  51923. }
  51924. declare module BABYLON {
  51925. /** @hidden */
  51926. export var geometryVertexShader: {
  51927. name: string;
  51928. shader: string;
  51929. };
  51930. }
  51931. declare module BABYLON {
  51932. /**
  51933. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  51934. */
  51935. export class GeometryBufferRenderer {
  51936. /**
  51937. * Constant used to retrieve the position texture index in the G-Buffer textures array
  51938. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  51939. */
  51940. static readonly POSITION_TEXTURE_TYPE: number;
  51941. /**
  51942. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  51943. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  51944. */
  51945. static readonly VELOCITY_TEXTURE_TYPE: number;
  51946. /**
  51947. * Dictionary used to store the previous transformation matrices of each rendered mesh
  51948. * in order to compute objects velocities when enableVelocity is set to "true"
  51949. * @hidden
  51950. */
  51951. _previousTransformationMatrices: {
  51952. [index: number]: Matrix;
  51953. };
  51954. private _scene;
  51955. private _multiRenderTarget;
  51956. private _ratio;
  51957. private _enablePosition;
  51958. private _enableVelocity;
  51959. private _positionIndex;
  51960. private _velocityIndex;
  51961. protected _effect: Effect;
  51962. protected _cachedDefines: string;
  51963. /**
  51964. * Set the render list (meshes to be rendered) used in the G buffer.
  51965. */
  51966. renderList: Mesh[];
  51967. /**
  51968. * Gets wether or not G buffer are supported by the running hardware.
  51969. * This requires draw buffer supports
  51970. */
  51971. readonly isSupported: boolean;
  51972. /**
  51973. * Returns the index of the given texture type in the G-Buffer textures array
  51974. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  51975. * @returns the index of the given texture type in the G-Buffer textures array
  51976. */
  51977. getTextureIndex(textureType: number): number;
  51978. /**
  51979. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  51980. */
  51981. /**
  51982. * Sets whether or not objects positions are enabled for the G buffer.
  51983. */
  51984. enablePosition: boolean;
  51985. /**
  51986. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  51987. */
  51988. /**
  51989. * Sets wether or not objects velocities are enabled for the G buffer.
  51990. */
  51991. enableVelocity: boolean;
  51992. /**
  51993. * Gets the scene associated with the buffer.
  51994. */
  51995. readonly scene: Scene;
  51996. /**
  51997. * Gets the ratio used by the buffer during its creation.
  51998. * How big is the buffer related to the main canvas.
  51999. */
  52000. readonly ratio: number;
  52001. /** @hidden */
  52002. static _SceneComponentInitialization: (scene: Scene) => void;
  52003. /**
  52004. * Creates a new G Buffer for the scene
  52005. * @param scene The scene the buffer belongs to
  52006. * @param ratio How big is the buffer related to the main canvas.
  52007. */
  52008. constructor(scene: Scene, ratio?: number);
  52009. /**
  52010. * Checks wether everything is ready to render a submesh to the G buffer.
  52011. * @param subMesh the submesh to check readiness for
  52012. * @param useInstances is the mesh drawn using instance or not
  52013. * @returns true if ready otherwise false
  52014. */
  52015. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52016. /**
  52017. * Gets the current underlying G Buffer.
  52018. * @returns the buffer
  52019. */
  52020. getGBuffer(): MultiRenderTarget;
  52021. /**
  52022. * Gets the number of samples used to render the buffer (anti aliasing).
  52023. */
  52024. /**
  52025. * Sets the number of samples used to render the buffer (anti aliasing).
  52026. */
  52027. samples: number;
  52028. /**
  52029. * Disposes the renderer and frees up associated resources.
  52030. */
  52031. dispose(): void;
  52032. protected _createRenderTargets(): void;
  52033. }
  52034. }
  52035. declare module BABYLON {
  52036. interface Scene {
  52037. /** @hidden (Backing field) */
  52038. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  52039. /**
  52040. * Gets or Sets the current geometry buffer associated to the scene.
  52041. */
  52042. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  52043. /**
  52044. * Enables a GeometryBufferRender and associates it with the scene
  52045. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  52046. * @returns the GeometryBufferRenderer
  52047. */
  52048. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  52049. /**
  52050. * Disables the GeometryBufferRender associated with the scene
  52051. */
  52052. disableGeometryBufferRenderer(): void;
  52053. }
  52054. /**
  52055. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  52056. * in several rendering techniques.
  52057. */
  52058. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  52059. /**
  52060. * The component name helpful to identify the component in the list of scene components.
  52061. */
  52062. readonly name: string;
  52063. /**
  52064. * The scene the component belongs to.
  52065. */
  52066. scene: Scene;
  52067. /**
  52068. * Creates a new instance of the component for the given scene
  52069. * @param scene Defines the scene to register the component in
  52070. */
  52071. constructor(scene: Scene);
  52072. /**
  52073. * Registers the component in a given scene
  52074. */
  52075. register(): void;
  52076. /**
  52077. * Rebuilds the elements related to this component in case of
  52078. * context lost for instance.
  52079. */
  52080. rebuild(): void;
  52081. /**
  52082. * Disposes the component and the associated ressources
  52083. */
  52084. dispose(): void;
  52085. private _gatherRenderTargets;
  52086. }
  52087. }
  52088. declare module BABYLON {
  52089. /** @hidden */
  52090. export var motionBlurPixelShader: {
  52091. name: string;
  52092. shader: string;
  52093. };
  52094. }
  52095. declare module BABYLON {
  52096. /**
  52097. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  52098. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  52099. * As an example, all you have to do is to create the post-process:
  52100. * var mb = new BABYLON.MotionBlurPostProcess(
  52101. * 'mb', // The name of the effect.
  52102. * scene, // The scene containing the objects to blur according to their velocity.
  52103. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  52104. * camera // The camera to apply the render pass to.
  52105. * );
  52106. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  52107. */
  52108. export class MotionBlurPostProcess extends PostProcess {
  52109. /**
  52110. * Defines how much the image is blurred by the movement. Default value is equal to 1
  52111. */
  52112. motionStrength: number;
  52113. /**
  52114. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  52115. */
  52116. /**
  52117. * Sets the number of iterations to be used for motion blur quality
  52118. */
  52119. motionBlurSamples: number;
  52120. private _motionBlurSamples;
  52121. private _geometryBufferRenderer;
  52122. /**
  52123. * Creates a new instance MotionBlurPostProcess
  52124. * @param name The name of the effect.
  52125. * @param scene The scene containing the objects to blur according to their velocity.
  52126. * @param options The required width/height ratio to downsize to before computing the render pass.
  52127. * @param camera The camera to apply the render pass to.
  52128. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52129. * @param engine The engine which the post process will be applied. (default: current engine)
  52130. * @param reusable If the post process can be reused on the same frame. (default: false)
  52131. * @param textureType Type of textures used when performing the post process. (default: 0)
  52132. * @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)
  52133. */
  52134. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52135. /**
  52136. * Disposes the post process.
  52137. * @param camera The camera to dispose the post process on.
  52138. */
  52139. dispose(camera?: Camera): void;
  52140. }
  52141. }
  52142. declare module BABYLON {
  52143. /** @hidden */
  52144. export var refractionPixelShader: {
  52145. name: string;
  52146. shader: string;
  52147. };
  52148. }
  52149. declare module BABYLON {
  52150. /**
  52151. * Post process which applies a refractin texture
  52152. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  52153. */
  52154. export class RefractionPostProcess extends PostProcess {
  52155. /** the base color of the refraction (used to taint the rendering) */
  52156. color: Color3;
  52157. /** simulated refraction depth */
  52158. depth: number;
  52159. /** the coefficient of the base color (0 to remove base color tainting) */
  52160. colorLevel: number;
  52161. private _refTexture;
  52162. private _ownRefractionTexture;
  52163. /**
  52164. * Gets or sets the refraction texture
  52165. * Please note that you are responsible for disposing the texture if you set it manually
  52166. */
  52167. refractionTexture: Texture;
  52168. /**
  52169. * Initializes the RefractionPostProcess
  52170. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  52171. * @param name The name of the effect.
  52172. * @param refractionTextureUrl Url of the refraction texture to use
  52173. * @param color the base color of the refraction (used to taint the rendering)
  52174. * @param depth simulated refraction depth
  52175. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  52176. * @param camera The camera to apply the render pass to.
  52177. * @param options The required width/height ratio to downsize to before computing the render pass.
  52178. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52179. * @param engine The engine which the post process will be applied. (default: current engine)
  52180. * @param reusable If the post process can be reused on the same frame. (default: false)
  52181. */
  52182. constructor(name: string, refractionTextureUrl: string,
  52183. /** the base color of the refraction (used to taint the rendering) */
  52184. color: Color3,
  52185. /** simulated refraction depth */
  52186. depth: number,
  52187. /** the coefficient of the base color (0 to remove base color tainting) */
  52188. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52189. /**
  52190. * Disposes of the post process
  52191. * @param camera Camera to dispose post process on
  52192. */
  52193. dispose(camera: Camera): void;
  52194. }
  52195. }
  52196. declare module BABYLON {
  52197. /** @hidden */
  52198. export var sharpenPixelShader: {
  52199. name: string;
  52200. shader: string;
  52201. };
  52202. }
  52203. declare module BABYLON {
  52204. /**
  52205. * The SharpenPostProcess applies a sharpen kernel to every pixel
  52206. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  52207. */
  52208. export class SharpenPostProcess extends PostProcess {
  52209. /**
  52210. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  52211. */
  52212. colorAmount: number;
  52213. /**
  52214. * How much sharpness should be applied (default: 0.3)
  52215. */
  52216. edgeAmount: number;
  52217. /**
  52218. * Creates a new instance ConvolutionPostProcess
  52219. * @param name The name of the effect.
  52220. * @param options The required width/height ratio to downsize to before computing the render pass.
  52221. * @param camera The camera to apply the render pass to.
  52222. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52223. * @param engine The engine which the post process will be applied. (default: current engine)
  52224. * @param reusable If the post process can be reused on the same frame. (default: false)
  52225. * @param textureType Type of textures used when performing the post process. (default: 0)
  52226. * @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)
  52227. */
  52228. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52229. }
  52230. }
  52231. declare module BABYLON {
  52232. /**
  52233. * PostProcessRenderPipeline
  52234. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52235. */
  52236. export class PostProcessRenderPipeline {
  52237. private engine;
  52238. private _renderEffects;
  52239. private _renderEffectsForIsolatedPass;
  52240. /**
  52241. * List of inspectable custom properties (used by the Inspector)
  52242. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  52243. */
  52244. inspectableCustomProperties: IInspectable[];
  52245. /**
  52246. * @hidden
  52247. */
  52248. protected _cameras: Camera[];
  52249. /** @hidden */
  52250. _name: string;
  52251. /**
  52252. * Gets pipeline name
  52253. */
  52254. readonly name: string;
  52255. /**
  52256. * Initializes a PostProcessRenderPipeline
  52257. * @param engine engine to add the pipeline to
  52258. * @param name name of the pipeline
  52259. */
  52260. constructor(engine: Engine, name: string);
  52261. /**
  52262. * Gets the class name
  52263. * @returns "PostProcessRenderPipeline"
  52264. */
  52265. getClassName(): string;
  52266. /**
  52267. * If all the render effects in the pipeline are supported
  52268. */
  52269. readonly isSupported: boolean;
  52270. /**
  52271. * Adds an effect to the pipeline
  52272. * @param renderEffect the effect to add
  52273. */
  52274. addEffect(renderEffect: PostProcessRenderEffect): void;
  52275. /** @hidden */
  52276. _rebuild(): void;
  52277. /** @hidden */
  52278. _enableEffect(renderEffectName: string, cameras: Camera): void;
  52279. /** @hidden */
  52280. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  52281. /** @hidden */
  52282. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  52283. /** @hidden */
  52284. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  52285. /** @hidden */
  52286. _attachCameras(cameras: Camera, unique: boolean): void;
  52287. /** @hidden */
  52288. _attachCameras(cameras: Camera[], unique: boolean): void;
  52289. /** @hidden */
  52290. _detachCameras(cameras: Camera): void;
  52291. /** @hidden */
  52292. _detachCameras(cameras: Nullable<Camera[]>): void;
  52293. /** @hidden */
  52294. _update(): void;
  52295. /** @hidden */
  52296. _reset(): void;
  52297. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  52298. /**
  52299. * Disposes of the pipeline
  52300. */
  52301. dispose(): void;
  52302. }
  52303. }
  52304. declare module BABYLON {
  52305. /**
  52306. * PostProcessRenderPipelineManager class
  52307. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52308. */
  52309. export class PostProcessRenderPipelineManager {
  52310. private _renderPipelines;
  52311. /**
  52312. * Initializes a PostProcessRenderPipelineManager
  52313. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52314. */
  52315. constructor();
  52316. /**
  52317. * Gets the list of supported render pipelines
  52318. */
  52319. readonly supportedPipelines: PostProcessRenderPipeline[];
  52320. /**
  52321. * Adds a pipeline to the manager
  52322. * @param renderPipeline The pipeline to add
  52323. */
  52324. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  52325. /**
  52326. * Attaches a camera to the pipeline
  52327. * @param renderPipelineName The name of the pipeline to attach to
  52328. * @param cameras the camera to attach
  52329. * @param unique if the camera can be attached multiple times to the pipeline
  52330. */
  52331. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  52332. /**
  52333. * Detaches a camera from the pipeline
  52334. * @param renderPipelineName The name of the pipeline to detach from
  52335. * @param cameras the camera to detach
  52336. */
  52337. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  52338. /**
  52339. * Enables an effect by name on a pipeline
  52340. * @param renderPipelineName the name of the pipeline to enable the effect in
  52341. * @param renderEffectName the name of the effect to enable
  52342. * @param cameras the cameras that the effect should be enabled on
  52343. */
  52344. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  52345. /**
  52346. * Disables an effect by name on a pipeline
  52347. * @param renderPipelineName the name of the pipeline to disable the effect in
  52348. * @param renderEffectName the name of the effect to disable
  52349. * @param cameras the cameras that the effect should be disabled on
  52350. */
  52351. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  52352. /**
  52353. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  52354. */
  52355. update(): void;
  52356. /** @hidden */
  52357. _rebuild(): void;
  52358. /**
  52359. * Disposes of the manager and pipelines
  52360. */
  52361. dispose(): void;
  52362. }
  52363. }
  52364. declare module BABYLON {
  52365. interface Scene {
  52366. /** @hidden (Backing field) */
  52367. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  52368. /**
  52369. * Gets the postprocess render pipeline manager
  52370. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52371. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  52372. */
  52373. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  52374. }
  52375. /**
  52376. * Defines the Render Pipeline scene component responsible to rendering pipelines
  52377. */
  52378. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  52379. /**
  52380. * The component name helpfull to identify the component in the list of scene components.
  52381. */
  52382. readonly name: string;
  52383. /**
  52384. * The scene the component belongs to.
  52385. */
  52386. scene: Scene;
  52387. /**
  52388. * Creates a new instance of the component for the given scene
  52389. * @param scene Defines the scene to register the component in
  52390. */
  52391. constructor(scene: Scene);
  52392. /**
  52393. * Registers the component in a given scene
  52394. */
  52395. register(): void;
  52396. /**
  52397. * Rebuilds the elements related to this component in case of
  52398. * context lost for instance.
  52399. */
  52400. rebuild(): void;
  52401. /**
  52402. * Disposes the component and the associated ressources
  52403. */
  52404. dispose(): void;
  52405. private _gatherRenderTargets;
  52406. }
  52407. }
  52408. declare module BABYLON {
  52409. /**
  52410. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  52411. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  52412. */
  52413. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  52414. private _scene;
  52415. private _camerasToBeAttached;
  52416. /**
  52417. * ID of the sharpen post process,
  52418. */
  52419. private readonly SharpenPostProcessId;
  52420. /**
  52421. * @ignore
  52422. * ID of the image processing post process;
  52423. */
  52424. readonly ImageProcessingPostProcessId: string;
  52425. /**
  52426. * @ignore
  52427. * ID of the Fast Approximate Anti-Aliasing post process;
  52428. */
  52429. readonly FxaaPostProcessId: string;
  52430. /**
  52431. * ID of the chromatic aberration post process,
  52432. */
  52433. private readonly ChromaticAberrationPostProcessId;
  52434. /**
  52435. * ID of the grain post process
  52436. */
  52437. private readonly GrainPostProcessId;
  52438. /**
  52439. * Sharpen post process which will apply a sharpen convolution to enhance edges
  52440. */
  52441. sharpen: SharpenPostProcess;
  52442. private _sharpenEffect;
  52443. private bloom;
  52444. /**
  52445. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  52446. */
  52447. depthOfField: DepthOfFieldEffect;
  52448. /**
  52449. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  52450. */
  52451. fxaa: FxaaPostProcess;
  52452. /**
  52453. * Image post processing pass used to perform operations such as tone mapping or color grading.
  52454. */
  52455. imageProcessing: ImageProcessingPostProcess;
  52456. /**
  52457. * Chromatic aberration post process which will shift rgb colors in the image
  52458. */
  52459. chromaticAberration: ChromaticAberrationPostProcess;
  52460. private _chromaticAberrationEffect;
  52461. /**
  52462. * Grain post process which add noise to the image
  52463. */
  52464. grain: GrainPostProcess;
  52465. private _grainEffect;
  52466. /**
  52467. * Glow post process which adds a glow to emissive areas of the image
  52468. */
  52469. private _glowLayer;
  52470. /**
  52471. * Animations which can be used to tweak settings over a period of time
  52472. */
  52473. animations: Animation[];
  52474. private _imageProcessingConfigurationObserver;
  52475. private _sharpenEnabled;
  52476. private _bloomEnabled;
  52477. private _depthOfFieldEnabled;
  52478. private _depthOfFieldBlurLevel;
  52479. private _fxaaEnabled;
  52480. private _imageProcessingEnabled;
  52481. private _defaultPipelineTextureType;
  52482. private _bloomScale;
  52483. private _chromaticAberrationEnabled;
  52484. private _grainEnabled;
  52485. private _buildAllowed;
  52486. /**
  52487. * Gets active scene
  52488. */
  52489. readonly scene: Scene;
  52490. /**
  52491. * Enable or disable the sharpen process from the pipeline
  52492. */
  52493. sharpenEnabled: boolean;
  52494. private _resizeObserver;
  52495. private _hardwareScaleLevel;
  52496. private _bloomKernel;
  52497. /**
  52498. * Specifies the size of the bloom blur kernel, relative to the final output size
  52499. */
  52500. bloomKernel: number;
  52501. /**
  52502. * Specifies the weight of the bloom in the final rendering
  52503. */
  52504. private _bloomWeight;
  52505. /**
  52506. * Specifies the luma threshold for the area that will be blurred by the bloom
  52507. */
  52508. private _bloomThreshold;
  52509. private _hdr;
  52510. /**
  52511. * The strength of the bloom.
  52512. */
  52513. bloomWeight: number;
  52514. /**
  52515. * The strength of the bloom.
  52516. */
  52517. bloomThreshold: number;
  52518. /**
  52519. * The scale of the bloom, lower value will provide better performance.
  52520. */
  52521. bloomScale: number;
  52522. /**
  52523. * Enable or disable the bloom from the pipeline
  52524. */
  52525. bloomEnabled: boolean;
  52526. private _rebuildBloom;
  52527. /**
  52528. * If the depth of field is enabled.
  52529. */
  52530. depthOfFieldEnabled: boolean;
  52531. /**
  52532. * Blur level of the depth of field effect. (Higher blur will effect performance)
  52533. */
  52534. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  52535. /**
  52536. * If the anti aliasing is enabled.
  52537. */
  52538. fxaaEnabled: boolean;
  52539. private _samples;
  52540. /**
  52541. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  52542. */
  52543. samples: number;
  52544. /**
  52545. * If image processing is enabled.
  52546. */
  52547. imageProcessingEnabled: boolean;
  52548. /**
  52549. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  52550. */
  52551. glowLayerEnabled: boolean;
  52552. /**
  52553. * Enable or disable the chromaticAberration process from the pipeline
  52554. */
  52555. chromaticAberrationEnabled: boolean;
  52556. /**
  52557. * Enable or disable the grain process from the pipeline
  52558. */
  52559. grainEnabled: boolean;
  52560. /**
  52561. * @constructor
  52562. * @param name - The rendering pipeline name (default: "")
  52563. * @param hdr - If high dynamic range textures should be used (default: true)
  52564. * @param scene - The scene linked to this pipeline (default: the last created scene)
  52565. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  52566. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  52567. */
  52568. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  52569. /**
  52570. * Get the class name
  52571. * @returns "DefaultRenderingPipeline"
  52572. */
  52573. getClassName(): string;
  52574. /**
  52575. * Force the compilation of the entire pipeline.
  52576. */
  52577. prepare(): void;
  52578. private _hasCleared;
  52579. private _prevPostProcess;
  52580. private _prevPrevPostProcess;
  52581. private _setAutoClearAndTextureSharing;
  52582. private _depthOfFieldSceneObserver;
  52583. private _buildPipeline;
  52584. private _disposePostProcesses;
  52585. /**
  52586. * Adds a camera to the pipeline
  52587. * @param camera the camera to be added
  52588. */
  52589. addCamera(camera: Camera): void;
  52590. /**
  52591. * Removes a camera from the pipeline
  52592. * @param camera the camera to remove
  52593. */
  52594. removeCamera(camera: Camera): void;
  52595. /**
  52596. * Dispose of the pipeline and stop all post processes
  52597. */
  52598. dispose(): void;
  52599. /**
  52600. * Serialize the rendering pipeline (Used when exporting)
  52601. * @returns the serialized object
  52602. */
  52603. serialize(): any;
  52604. /**
  52605. * Parse the serialized pipeline
  52606. * @param source Source pipeline.
  52607. * @param scene The scene to load the pipeline to.
  52608. * @param rootUrl The URL of the serialized pipeline.
  52609. * @returns An instantiated pipeline from the serialized object.
  52610. */
  52611. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  52612. }
  52613. }
  52614. declare module BABYLON {
  52615. /** @hidden */
  52616. export var lensHighlightsPixelShader: {
  52617. name: string;
  52618. shader: string;
  52619. };
  52620. }
  52621. declare module BABYLON {
  52622. /** @hidden */
  52623. export var depthOfFieldPixelShader: {
  52624. name: string;
  52625. shader: string;
  52626. };
  52627. }
  52628. declare module BABYLON {
  52629. /**
  52630. * BABYLON.JS Chromatic Aberration GLSL Shader
  52631. * Author: Olivier Guyot
  52632. * Separates very slightly R, G and B colors on the edges of the screen
  52633. * Inspired by Francois Tarlier & Martins Upitis
  52634. */
  52635. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  52636. /**
  52637. * @ignore
  52638. * The chromatic aberration PostProcess id in the pipeline
  52639. */
  52640. LensChromaticAberrationEffect: string;
  52641. /**
  52642. * @ignore
  52643. * The highlights enhancing PostProcess id in the pipeline
  52644. */
  52645. HighlightsEnhancingEffect: string;
  52646. /**
  52647. * @ignore
  52648. * The depth-of-field PostProcess id in the pipeline
  52649. */
  52650. LensDepthOfFieldEffect: string;
  52651. private _scene;
  52652. private _depthTexture;
  52653. private _grainTexture;
  52654. private _chromaticAberrationPostProcess;
  52655. private _highlightsPostProcess;
  52656. private _depthOfFieldPostProcess;
  52657. private _edgeBlur;
  52658. private _grainAmount;
  52659. private _chromaticAberration;
  52660. private _distortion;
  52661. private _highlightsGain;
  52662. private _highlightsThreshold;
  52663. private _dofDistance;
  52664. private _dofAperture;
  52665. private _dofDarken;
  52666. private _dofPentagon;
  52667. private _blurNoise;
  52668. /**
  52669. * @constructor
  52670. *
  52671. * Effect parameters are as follow:
  52672. * {
  52673. * chromatic_aberration: number; // from 0 to x (1 for realism)
  52674. * edge_blur: number; // from 0 to x (1 for realism)
  52675. * distortion: number; // from 0 to x (1 for realism)
  52676. * grain_amount: number; // from 0 to 1
  52677. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  52678. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  52679. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  52680. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  52681. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  52682. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  52683. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  52684. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  52685. * }
  52686. * Note: if an effect parameter is unset, effect is disabled
  52687. *
  52688. * @param name The rendering pipeline name
  52689. * @param parameters - An object containing all parameters (see above)
  52690. * @param scene The scene linked to this pipeline
  52691. * @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)
  52692. * @param cameras The array of cameras that the rendering pipeline will be attached to
  52693. */
  52694. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  52695. /**
  52696. * Get the class name
  52697. * @returns "LensRenderingPipeline"
  52698. */
  52699. getClassName(): string;
  52700. /**
  52701. * Gets associated scene
  52702. */
  52703. readonly scene: Scene;
  52704. /**
  52705. * Gets or sets the edge blur
  52706. */
  52707. edgeBlur: number;
  52708. /**
  52709. * Gets or sets the grain amount
  52710. */
  52711. grainAmount: number;
  52712. /**
  52713. * Gets or sets the chromatic aberration amount
  52714. */
  52715. chromaticAberration: number;
  52716. /**
  52717. * Gets or sets the depth of field aperture
  52718. */
  52719. dofAperture: number;
  52720. /**
  52721. * Gets or sets the edge distortion
  52722. */
  52723. edgeDistortion: number;
  52724. /**
  52725. * Gets or sets the depth of field distortion
  52726. */
  52727. dofDistortion: number;
  52728. /**
  52729. * Gets or sets the darken out of focus amount
  52730. */
  52731. darkenOutOfFocus: number;
  52732. /**
  52733. * Gets or sets a boolean indicating if blur noise is enabled
  52734. */
  52735. blurNoise: boolean;
  52736. /**
  52737. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  52738. */
  52739. pentagonBokeh: boolean;
  52740. /**
  52741. * Gets or sets the highlight grain amount
  52742. */
  52743. highlightsGain: number;
  52744. /**
  52745. * Gets or sets the highlight threshold
  52746. */
  52747. highlightsThreshold: number;
  52748. /**
  52749. * Sets the amount of blur at the edges
  52750. * @param amount blur amount
  52751. */
  52752. setEdgeBlur(amount: number): void;
  52753. /**
  52754. * Sets edge blur to 0
  52755. */
  52756. disableEdgeBlur(): void;
  52757. /**
  52758. * Sets the amout of grain
  52759. * @param amount Amount of grain
  52760. */
  52761. setGrainAmount(amount: number): void;
  52762. /**
  52763. * Set grain amount to 0
  52764. */
  52765. disableGrain(): void;
  52766. /**
  52767. * Sets the chromatic aberration amount
  52768. * @param amount amount of chromatic aberration
  52769. */
  52770. setChromaticAberration(amount: number): void;
  52771. /**
  52772. * Sets chromatic aberration amount to 0
  52773. */
  52774. disableChromaticAberration(): void;
  52775. /**
  52776. * Sets the EdgeDistortion amount
  52777. * @param amount amount of EdgeDistortion
  52778. */
  52779. setEdgeDistortion(amount: number): void;
  52780. /**
  52781. * Sets edge distortion to 0
  52782. */
  52783. disableEdgeDistortion(): void;
  52784. /**
  52785. * Sets the FocusDistance amount
  52786. * @param amount amount of FocusDistance
  52787. */
  52788. setFocusDistance(amount: number): void;
  52789. /**
  52790. * Disables depth of field
  52791. */
  52792. disableDepthOfField(): void;
  52793. /**
  52794. * Sets the Aperture amount
  52795. * @param amount amount of Aperture
  52796. */
  52797. setAperture(amount: number): void;
  52798. /**
  52799. * Sets the DarkenOutOfFocus amount
  52800. * @param amount amount of DarkenOutOfFocus
  52801. */
  52802. setDarkenOutOfFocus(amount: number): void;
  52803. private _pentagonBokehIsEnabled;
  52804. /**
  52805. * Creates a pentagon bokeh effect
  52806. */
  52807. enablePentagonBokeh(): void;
  52808. /**
  52809. * Disables the pentagon bokeh effect
  52810. */
  52811. disablePentagonBokeh(): void;
  52812. /**
  52813. * Enables noise blur
  52814. */
  52815. enableNoiseBlur(): void;
  52816. /**
  52817. * Disables noise blur
  52818. */
  52819. disableNoiseBlur(): void;
  52820. /**
  52821. * Sets the HighlightsGain amount
  52822. * @param amount amount of HighlightsGain
  52823. */
  52824. setHighlightsGain(amount: number): void;
  52825. /**
  52826. * Sets the HighlightsThreshold amount
  52827. * @param amount amount of HighlightsThreshold
  52828. */
  52829. setHighlightsThreshold(amount: number): void;
  52830. /**
  52831. * Disables highlights
  52832. */
  52833. disableHighlights(): void;
  52834. /**
  52835. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  52836. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  52837. */
  52838. dispose(disableDepthRender?: boolean): void;
  52839. private _createChromaticAberrationPostProcess;
  52840. private _createHighlightsPostProcess;
  52841. private _createDepthOfFieldPostProcess;
  52842. private _createGrainTexture;
  52843. }
  52844. }
  52845. declare module BABYLON {
  52846. /** @hidden */
  52847. export var ssao2PixelShader: {
  52848. name: string;
  52849. shader: string;
  52850. };
  52851. }
  52852. declare module BABYLON {
  52853. /** @hidden */
  52854. export var ssaoCombinePixelShader: {
  52855. name: string;
  52856. shader: string;
  52857. };
  52858. }
  52859. declare module BABYLON {
  52860. /**
  52861. * Render pipeline to produce ssao effect
  52862. */
  52863. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  52864. /**
  52865. * @ignore
  52866. * The PassPostProcess id in the pipeline that contains the original scene color
  52867. */
  52868. SSAOOriginalSceneColorEffect: string;
  52869. /**
  52870. * @ignore
  52871. * The SSAO PostProcess id in the pipeline
  52872. */
  52873. SSAORenderEffect: string;
  52874. /**
  52875. * @ignore
  52876. * The horizontal blur PostProcess id in the pipeline
  52877. */
  52878. SSAOBlurHRenderEffect: string;
  52879. /**
  52880. * @ignore
  52881. * The vertical blur PostProcess id in the pipeline
  52882. */
  52883. SSAOBlurVRenderEffect: string;
  52884. /**
  52885. * @ignore
  52886. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  52887. */
  52888. SSAOCombineRenderEffect: string;
  52889. /**
  52890. * The output strength of the SSAO post-process. Default value is 1.0.
  52891. */
  52892. totalStrength: number;
  52893. /**
  52894. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  52895. */
  52896. maxZ: number;
  52897. /**
  52898. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  52899. */
  52900. minZAspect: number;
  52901. private _samples;
  52902. /**
  52903. * Number of samples used for the SSAO calculations. Default value is 8
  52904. */
  52905. samples: number;
  52906. private _textureSamples;
  52907. /**
  52908. * Number of samples to use for antialiasing
  52909. */
  52910. textureSamples: number;
  52911. /**
  52912. * Ratio object used for SSAO ratio and blur ratio
  52913. */
  52914. private _ratio;
  52915. /**
  52916. * Dynamically generated sphere sampler.
  52917. */
  52918. private _sampleSphere;
  52919. /**
  52920. * Blur filter offsets
  52921. */
  52922. private _samplerOffsets;
  52923. private _expensiveBlur;
  52924. /**
  52925. * If bilateral blur should be used
  52926. */
  52927. expensiveBlur: boolean;
  52928. /**
  52929. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  52930. */
  52931. radius: number;
  52932. /**
  52933. * The base color of the SSAO post-process
  52934. * The final result is "base + ssao" between [0, 1]
  52935. */
  52936. base: number;
  52937. /**
  52938. * Support test.
  52939. */
  52940. static readonly IsSupported: boolean;
  52941. private _scene;
  52942. private _depthTexture;
  52943. private _normalTexture;
  52944. private _randomTexture;
  52945. private _originalColorPostProcess;
  52946. private _ssaoPostProcess;
  52947. private _blurHPostProcess;
  52948. private _blurVPostProcess;
  52949. private _ssaoCombinePostProcess;
  52950. private _firstUpdate;
  52951. /**
  52952. * Gets active scene
  52953. */
  52954. readonly scene: Scene;
  52955. /**
  52956. * @constructor
  52957. * @param name The rendering pipeline name
  52958. * @param scene The scene linked to this pipeline
  52959. * @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 }
  52960. * @param cameras The array of cameras that the rendering pipeline will be attached to
  52961. */
  52962. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  52963. /**
  52964. * Get the class name
  52965. * @returns "SSAO2RenderingPipeline"
  52966. */
  52967. getClassName(): string;
  52968. /**
  52969. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  52970. */
  52971. dispose(disableGeometryBufferRenderer?: boolean): void;
  52972. private _createBlurPostProcess;
  52973. /** @hidden */
  52974. _rebuild(): void;
  52975. private _bits;
  52976. private _radicalInverse_VdC;
  52977. private _hammersley;
  52978. private _hemisphereSample_uniform;
  52979. private _generateHemisphere;
  52980. private _createSSAOPostProcess;
  52981. private _createSSAOCombinePostProcess;
  52982. private _createRandomTexture;
  52983. /**
  52984. * Serialize the rendering pipeline (Used when exporting)
  52985. * @returns the serialized object
  52986. */
  52987. serialize(): any;
  52988. /**
  52989. * Parse the serialized pipeline
  52990. * @param source Source pipeline.
  52991. * @param scene The scene to load the pipeline to.
  52992. * @param rootUrl The URL of the serialized pipeline.
  52993. * @returns An instantiated pipeline from the serialized object.
  52994. */
  52995. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  52996. }
  52997. }
  52998. declare module BABYLON {
  52999. /** @hidden */
  53000. export var ssaoPixelShader: {
  53001. name: string;
  53002. shader: string;
  53003. };
  53004. }
  53005. declare module BABYLON {
  53006. /**
  53007. * Render pipeline to produce ssao effect
  53008. */
  53009. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  53010. /**
  53011. * @ignore
  53012. * The PassPostProcess id in the pipeline that contains the original scene color
  53013. */
  53014. SSAOOriginalSceneColorEffect: string;
  53015. /**
  53016. * @ignore
  53017. * The SSAO PostProcess id in the pipeline
  53018. */
  53019. SSAORenderEffect: string;
  53020. /**
  53021. * @ignore
  53022. * The horizontal blur PostProcess id in the pipeline
  53023. */
  53024. SSAOBlurHRenderEffect: string;
  53025. /**
  53026. * @ignore
  53027. * The vertical blur PostProcess id in the pipeline
  53028. */
  53029. SSAOBlurVRenderEffect: string;
  53030. /**
  53031. * @ignore
  53032. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  53033. */
  53034. SSAOCombineRenderEffect: string;
  53035. /**
  53036. * The output strength of the SSAO post-process. Default value is 1.0.
  53037. */
  53038. totalStrength: number;
  53039. /**
  53040. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  53041. */
  53042. radius: number;
  53043. /**
  53044. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  53045. * Must not be equal to fallOff and superior to fallOff.
  53046. * Default value is 0.0075
  53047. */
  53048. area: number;
  53049. /**
  53050. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  53051. * Must not be equal to area and inferior to area.
  53052. * Default value is 0.000001
  53053. */
  53054. fallOff: number;
  53055. /**
  53056. * The base color of the SSAO post-process
  53057. * The final result is "base + ssao" between [0, 1]
  53058. */
  53059. base: number;
  53060. private _scene;
  53061. private _depthTexture;
  53062. private _randomTexture;
  53063. private _originalColorPostProcess;
  53064. private _ssaoPostProcess;
  53065. private _blurHPostProcess;
  53066. private _blurVPostProcess;
  53067. private _ssaoCombinePostProcess;
  53068. private _firstUpdate;
  53069. /**
  53070. * Gets active scene
  53071. */
  53072. readonly scene: Scene;
  53073. /**
  53074. * @constructor
  53075. * @param name - The rendering pipeline name
  53076. * @param scene - The scene linked to this pipeline
  53077. * @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 }
  53078. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  53079. */
  53080. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  53081. /**
  53082. * Get the class name
  53083. * @returns "SSAORenderingPipeline"
  53084. */
  53085. getClassName(): string;
  53086. /**
  53087. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  53088. */
  53089. dispose(disableDepthRender?: boolean): void;
  53090. private _createBlurPostProcess;
  53091. /** @hidden */
  53092. _rebuild(): void;
  53093. private _createSSAOPostProcess;
  53094. private _createSSAOCombinePostProcess;
  53095. private _createRandomTexture;
  53096. }
  53097. }
  53098. declare module BABYLON {
  53099. /** @hidden */
  53100. export var standardPixelShader: {
  53101. name: string;
  53102. shader: string;
  53103. };
  53104. }
  53105. declare module BABYLON {
  53106. /**
  53107. * Standard rendering pipeline
  53108. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  53109. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  53110. */
  53111. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  53112. /**
  53113. * Public members
  53114. */
  53115. /**
  53116. * Post-process which contains the original scene color before the pipeline applies all the effects
  53117. */
  53118. originalPostProcess: Nullable<PostProcess>;
  53119. /**
  53120. * Post-process used to down scale an image x4
  53121. */
  53122. downSampleX4PostProcess: Nullable<PostProcess>;
  53123. /**
  53124. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  53125. */
  53126. brightPassPostProcess: Nullable<PostProcess>;
  53127. /**
  53128. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  53129. */
  53130. blurHPostProcesses: PostProcess[];
  53131. /**
  53132. * Post-process array storing all the vertical blur post-processes used by the pipeline
  53133. */
  53134. blurVPostProcesses: PostProcess[];
  53135. /**
  53136. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  53137. */
  53138. textureAdderPostProcess: Nullable<PostProcess>;
  53139. /**
  53140. * Post-process used to create volumetric lighting effect
  53141. */
  53142. volumetricLightPostProcess: Nullable<PostProcess>;
  53143. /**
  53144. * Post-process used to smooth the previous volumetric light post-process on the X axis
  53145. */
  53146. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  53147. /**
  53148. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  53149. */
  53150. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  53151. /**
  53152. * Post-process used to merge the volumetric light effect and the real scene color
  53153. */
  53154. volumetricLightMergePostProces: Nullable<PostProcess>;
  53155. /**
  53156. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  53157. */
  53158. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  53159. /**
  53160. * Base post-process used to calculate the average luminance of the final image for HDR
  53161. */
  53162. luminancePostProcess: Nullable<PostProcess>;
  53163. /**
  53164. * Post-processes used to create down sample post-processes in order to get
  53165. * the average luminance of the final image for HDR
  53166. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  53167. */
  53168. luminanceDownSamplePostProcesses: PostProcess[];
  53169. /**
  53170. * Post-process used to create a HDR effect (light adaptation)
  53171. */
  53172. hdrPostProcess: Nullable<PostProcess>;
  53173. /**
  53174. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  53175. */
  53176. textureAdderFinalPostProcess: Nullable<PostProcess>;
  53177. /**
  53178. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  53179. */
  53180. lensFlareFinalPostProcess: Nullable<PostProcess>;
  53181. /**
  53182. * Post-process used to merge the final HDR post-process and the real scene color
  53183. */
  53184. hdrFinalPostProcess: Nullable<PostProcess>;
  53185. /**
  53186. * Post-process used to create a lens flare effect
  53187. */
  53188. lensFlarePostProcess: Nullable<PostProcess>;
  53189. /**
  53190. * Post-process that merges the result of the lens flare post-process and the real scene color
  53191. */
  53192. lensFlareComposePostProcess: Nullable<PostProcess>;
  53193. /**
  53194. * Post-process used to create a motion blur effect
  53195. */
  53196. motionBlurPostProcess: Nullable<PostProcess>;
  53197. /**
  53198. * Post-process used to create a depth of field effect
  53199. */
  53200. depthOfFieldPostProcess: Nullable<PostProcess>;
  53201. /**
  53202. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  53203. */
  53204. fxaaPostProcess: Nullable<FxaaPostProcess>;
  53205. /**
  53206. * Represents the brightness threshold in order to configure the illuminated surfaces
  53207. */
  53208. brightThreshold: number;
  53209. /**
  53210. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  53211. */
  53212. blurWidth: number;
  53213. /**
  53214. * Sets if the blur for highlighted surfaces must be only horizontal
  53215. */
  53216. horizontalBlur: boolean;
  53217. /**
  53218. * Sets the overall exposure used by the pipeline
  53219. */
  53220. exposure: number;
  53221. /**
  53222. * Texture used typically to simulate "dirty" on camera lens
  53223. */
  53224. lensTexture: Nullable<Texture>;
  53225. /**
  53226. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  53227. */
  53228. volumetricLightCoefficient: number;
  53229. /**
  53230. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  53231. */
  53232. volumetricLightPower: number;
  53233. /**
  53234. * Used the set the blur intensity to smooth the volumetric lights
  53235. */
  53236. volumetricLightBlurScale: number;
  53237. /**
  53238. * Light (spot or directional) used to generate the volumetric lights rays
  53239. * The source light must have a shadow generate so the pipeline can get its
  53240. * depth map
  53241. */
  53242. sourceLight: Nullable<SpotLight | DirectionalLight>;
  53243. /**
  53244. * For eye adaptation, represents the minimum luminance the eye can see
  53245. */
  53246. hdrMinimumLuminance: number;
  53247. /**
  53248. * For eye adaptation, represents the decrease luminance speed
  53249. */
  53250. hdrDecreaseRate: number;
  53251. /**
  53252. * For eye adaptation, represents the increase luminance speed
  53253. */
  53254. hdrIncreaseRate: number;
  53255. /**
  53256. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  53257. */
  53258. lensColorTexture: Nullable<Texture>;
  53259. /**
  53260. * The overall strengh for the lens flare effect
  53261. */
  53262. lensFlareStrength: number;
  53263. /**
  53264. * Dispersion coefficient for lens flare ghosts
  53265. */
  53266. lensFlareGhostDispersal: number;
  53267. /**
  53268. * Main lens flare halo width
  53269. */
  53270. lensFlareHaloWidth: number;
  53271. /**
  53272. * Based on the lens distortion effect, defines how much the lens flare result
  53273. * is distorted
  53274. */
  53275. lensFlareDistortionStrength: number;
  53276. /**
  53277. * Lens star texture must be used to simulate rays on the flares and is available
  53278. * in the documentation
  53279. */
  53280. lensStarTexture: Nullable<Texture>;
  53281. /**
  53282. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  53283. * flare effect by taking account of the dirt texture
  53284. */
  53285. lensFlareDirtTexture: Nullable<Texture>;
  53286. /**
  53287. * Represents the focal length for the depth of field effect
  53288. */
  53289. depthOfFieldDistance: number;
  53290. /**
  53291. * Represents the blur intensity for the blurred part of the depth of field effect
  53292. */
  53293. depthOfFieldBlurWidth: number;
  53294. /**
  53295. * For motion blur, defines how much the image is blurred by the movement
  53296. */
  53297. motionStrength: number;
  53298. /**
  53299. * List of animations for the pipeline (IAnimatable implementation)
  53300. */
  53301. animations: Animation[];
  53302. /**
  53303. * Private members
  53304. */
  53305. private _scene;
  53306. private _currentDepthOfFieldSource;
  53307. private _basePostProcess;
  53308. private _hdrCurrentLuminance;
  53309. private _floatTextureType;
  53310. private _ratio;
  53311. private _bloomEnabled;
  53312. private _depthOfFieldEnabled;
  53313. private _vlsEnabled;
  53314. private _lensFlareEnabled;
  53315. private _hdrEnabled;
  53316. private _motionBlurEnabled;
  53317. private _fxaaEnabled;
  53318. private _motionBlurSamples;
  53319. private _volumetricLightStepsCount;
  53320. private _samples;
  53321. /**
  53322. * @ignore
  53323. * Specifies if the bloom pipeline is enabled
  53324. */
  53325. BloomEnabled: boolean;
  53326. /**
  53327. * @ignore
  53328. * Specifies if the depth of field pipeline is enabed
  53329. */
  53330. DepthOfFieldEnabled: boolean;
  53331. /**
  53332. * @ignore
  53333. * Specifies if the lens flare pipeline is enabed
  53334. */
  53335. LensFlareEnabled: boolean;
  53336. /**
  53337. * @ignore
  53338. * Specifies if the HDR pipeline is enabled
  53339. */
  53340. HDREnabled: boolean;
  53341. /**
  53342. * @ignore
  53343. * Specifies if the volumetric lights scattering effect is enabled
  53344. */
  53345. VLSEnabled: boolean;
  53346. /**
  53347. * @ignore
  53348. * Specifies if the motion blur effect is enabled
  53349. */
  53350. MotionBlurEnabled: boolean;
  53351. /**
  53352. * Specifies if anti-aliasing is enabled
  53353. */
  53354. fxaaEnabled: boolean;
  53355. /**
  53356. * Specifies the number of steps used to calculate the volumetric lights
  53357. * Typically in interval [50, 200]
  53358. */
  53359. volumetricLightStepsCount: number;
  53360. /**
  53361. * Specifies the number of samples used for the motion blur effect
  53362. * Typically in interval [16, 64]
  53363. */
  53364. motionBlurSamples: number;
  53365. /**
  53366. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  53367. */
  53368. samples: number;
  53369. /**
  53370. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  53371. * @constructor
  53372. * @param name The rendering pipeline name
  53373. * @param scene The scene linked to this pipeline
  53374. * @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)
  53375. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  53376. * @param cameras The array of cameras that the rendering pipeline will be attached to
  53377. */
  53378. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  53379. private _buildPipeline;
  53380. private _createDownSampleX4PostProcess;
  53381. private _createBrightPassPostProcess;
  53382. private _createBlurPostProcesses;
  53383. private _createTextureAdderPostProcess;
  53384. private _createVolumetricLightPostProcess;
  53385. private _createLuminancePostProcesses;
  53386. private _createHdrPostProcess;
  53387. private _createLensFlarePostProcess;
  53388. private _createDepthOfFieldPostProcess;
  53389. private _createMotionBlurPostProcess;
  53390. private _getDepthTexture;
  53391. private _disposePostProcesses;
  53392. /**
  53393. * Dispose of the pipeline and stop all post processes
  53394. */
  53395. dispose(): void;
  53396. /**
  53397. * Serialize the rendering pipeline (Used when exporting)
  53398. * @returns the serialized object
  53399. */
  53400. serialize(): any;
  53401. /**
  53402. * Parse the serialized pipeline
  53403. * @param source Source pipeline.
  53404. * @param scene The scene to load the pipeline to.
  53405. * @param rootUrl The URL of the serialized pipeline.
  53406. * @returns An instantiated pipeline from the serialized object.
  53407. */
  53408. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  53409. /**
  53410. * Luminance steps
  53411. */
  53412. static LuminanceSteps: number;
  53413. }
  53414. }
  53415. declare module BABYLON {
  53416. /** @hidden */
  53417. export var tonemapPixelShader: {
  53418. name: string;
  53419. shader: string;
  53420. };
  53421. }
  53422. declare module BABYLON {
  53423. /** Defines operator used for tonemapping */
  53424. export enum TonemappingOperator {
  53425. /** Hable */
  53426. Hable = 0,
  53427. /** Reinhard */
  53428. Reinhard = 1,
  53429. /** HejiDawson */
  53430. HejiDawson = 2,
  53431. /** Photographic */
  53432. Photographic = 3
  53433. }
  53434. /**
  53435. * Defines a post process to apply tone mapping
  53436. */
  53437. export class TonemapPostProcess extends PostProcess {
  53438. private _operator;
  53439. /** Defines the required exposure adjustement */
  53440. exposureAdjustment: number;
  53441. /**
  53442. * Creates a new TonemapPostProcess
  53443. * @param name defines the name of the postprocess
  53444. * @param _operator defines the operator to use
  53445. * @param exposureAdjustment defines the required exposure adjustement
  53446. * @param camera defines the camera to use (can be null)
  53447. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  53448. * @param engine defines the hosting engine (can be ignore if camera is set)
  53449. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  53450. */
  53451. constructor(name: string, _operator: TonemappingOperator,
  53452. /** Defines the required exposure adjustement */
  53453. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  53454. }
  53455. }
  53456. declare module BABYLON {
  53457. /** @hidden */
  53458. export var depthVertexShader: {
  53459. name: string;
  53460. shader: string;
  53461. };
  53462. }
  53463. declare module BABYLON {
  53464. /** @hidden */
  53465. export var volumetricLightScatteringPixelShader: {
  53466. name: string;
  53467. shader: string;
  53468. };
  53469. }
  53470. declare module BABYLON {
  53471. /** @hidden */
  53472. export var volumetricLightScatteringPassPixelShader: {
  53473. name: string;
  53474. shader: string;
  53475. };
  53476. }
  53477. declare module BABYLON {
  53478. /**
  53479. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  53480. */
  53481. export class VolumetricLightScatteringPostProcess extends PostProcess {
  53482. private _volumetricLightScatteringPass;
  53483. private _volumetricLightScatteringRTT;
  53484. private _viewPort;
  53485. private _screenCoordinates;
  53486. private _cachedDefines;
  53487. /**
  53488. * If not undefined, the mesh position is computed from the attached node position
  53489. */
  53490. attachedNode: {
  53491. position: Vector3;
  53492. };
  53493. /**
  53494. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  53495. */
  53496. customMeshPosition: Vector3;
  53497. /**
  53498. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  53499. */
  53500. useCustomMeshPosition: boolean;
  53501. /**
  53502. * If the post-process should inverse the light scattering direction
  53503. */
  53504. invert: boolean;
  53505. /**
  53506. * The internal mesh used by the post-process
  53507. */
  53508. mesh: Mesh;
  53509. /**
  53510. * @hidden
  53511. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  53512. */
  53513. useDiffuseColor: boolean;
  53514. /**
  53515. * Array containing the excluded meshes not rendered in the internal pass
  53516. */
  53517. excludedMeshes: AbstractMesh[];
  53518. /**
  53519. * Controls the overall intensity of the post-process
  53520. */
  53521. exposure: number;
  53522. /**
  53523. * Dissipates each sample's contribution in range [0, 1]
  53524. */
  53525. decay: number;
  53526. /**
  53527. * Controls the overall intensity of each sample
  53528. */
  53529. weight: number;
  53530. /**
  53531. * Controls the density of each sample
  53532. */
  53533. density: number;
  53534. /**
  53535. * @constructor
  53536. * @param name The post-process name
  53537. * @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)
  53538. * @param camera The camera that the post-process will be attached to
  53539. * @param mesh The mesh used to create the light scattering
  53540. * @param samples The post-process quality, default 100
  53541. * @param samplingModeThe post-process filtering mode
  53542. * @param engine The babylon engine
  53543. * @param reusable If the post-process is reusable
  53544. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  53545. */
  53546. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  53547. /**
  53548. * Returns the string "VolumetricLightScatteringPostProcess"
  53549. * @returns "VolumetricLightScatteringPostProcess"
  53550. */
  53551. getClassName(): string;
  53552. private _isReady;
  53553. /**
  53554. * Sets the new light position for light scattering effect
  53555. * @param position The new custom light position
  53556. */
  53557. setCustomMeshPosition(position: Vector3): void;
  53558. /**
  53559. * Returns the light position for light scattering effect
  53560. * @return Vector3 The custom light position
  53561. */
  53562. getCustomMeshPosition(): Vector3;
  53563. /**
  53564. * Disposes the internal assets and detaches the post-process from the camera
  53565. */
  53566. dispose(camera: Camera): void;
  53567. /**
  53568. * Returns the render target texture used by the post-process
  53569. * @return the render target texture used by the post-process
  53570. */
  53571. getPass(): RenderTargetTexture;
  53572. private _meshExcluded;
  53573. private _createPass;
  53574. private _updateMeshScreenCoordinates;
  53575. /**
  53576. * Creates a default mesh for the Volumeric Light Scattering post-process
  53577. * @param name The mesh name
  53578. * @param scene The scene where to create the mesh
  53579. * @return the default mesh
  53580. */
  53581. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  53582. }
  53583. }
  53584. declare module BABYLON {
  53585. interface Scene {
  53586. /** @hidden (Backing field) */
  53587. _boundingBoxRenderer: BoundingBoxRenderer;
  53588. /** @hidden (Backing field) */
  53589. _forceShowBoundingBoxes: boolean;
  53590. /**
  53591. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  53592. */
  53593. forceShowBoundingBoxes: boolean;
  53594. /**
  53595. * Gets the bounding box renderer associated with the scene
  53596. * @returns a BoundingBoxRenderer
  53597. */
  53598. getBoundingBoxRenderer(): BoundingBoxRenderer;
  53599. }
  53600. interface AbstractMesh {
  53601. /** @hidden (Backing field) */
  53602. _showBoundingBox: boolean;
  53603. /**
  53604. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  53605. */
  53606. showBoundingBox: boolean;
  53607. }
  53608. /**
  53609. * Component responsible of rendering the bounding box of the meshes in a scene.
  53610. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  53611. */
  53612. export class BoundingBoxRenderer implements ISceneComponent {
  53613. /**
  53614. * The component name helpfull to identify the component in the list of scene components.
  53615. */
  53616. readonly name: string;
  53617. /**
  53618. * The scene the component belongs to.
  53619. */
  53620. scene: Scene;
  53621. /**
  53622. * Color of the bounding box lines placed in front of an object
  53623. */
  53624. frontColor: Color3;
  53625. /**
  53626. * Color of the bounding box lines placed behind an object
  53627. */
  53628. backColor: Color3;
  53629. /**
  53630. * Defines if the renderer should show the back lines or not
  53631. */
  53632. showBackLines: boolean;
  53633. /**
  53634. * @hidden
  53635. */
  53636. renderList: SmartArray<BoundingBox>;
  53637. private _colorShader;
  53638. private _vertexBuffers;
  53639. private _indexBuffer;
  53640. /**
  53641. * Instantiates a new bounding box renderer in a scene.
  53642. * @param scene the scene the renderer renders in
  53643. */
  53644. constructor(scene: Scene);
  53645. /**
  53646. * Registers the component in a given scene
  53647. */
  53648. register(): void;
  53649. private _evaluateSubMesh;
  53650. private _activeMesh;
  53651. private _prepareRessources;
  53652. private _createIndexBuffer;
  53653. /**
  53654. * Rebuilds the elements related to this component in case of
  53655. * context lost for instance.
  53656. */
  53657. rebuild(): void;
  53658. /**
  53659. * @hidden
  53660. */
  53661. reset(): void;
  53662. /**
  53663. * Render the bounding boxes of a specific rendering group
  53664. * @param renderingGroupId defines the rendering group to render
  53665. */
  53666. render(renderingGroupId: number): void;
  53667. /**
  53668. * In case of occlusion queries, we can render the occlusion bounding box through this method
  53669. * @param mesh Define the mesh to render the occlusion bounding box for
  53670. */
  53671. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  53672. /**
  53673. * Dispose and release the resources attached to this renderer.
  53674. */
  53675. dispose(): void;
  53676. }
  53677. }
  53678. declare module BABYLON {
  53679. /** @hidden */
  53680. export var depthPixelShader: {
  53681. name: string;
  53682. shader: string;
  53683. };
  53684. }
  53685. declare module BABYLON {
  53686. /**
  53687. * This represents a depth renderer in Babylon.
  53688. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  53689. */
  53690. export class DepthRenderer {
  53691. private _scene;
  53692. private _depthMap;
  53693. private _effect;
  53694. private _cachedDefines;
  53695. private _camera;
  53696. /**
  53697. * Specifiess that the depth renderer will only be used within
  53698. * the camera it is created for.
  53699. * This can help forcing its rendering during the camera processing.
  53700. */
  53701. useOnlyInActiveCamera: boolean;
  53702. /** @hidden */
  53703. static _SceneComponentInitialization: (scene: Scene) => void;
  53704. /**
  53705. * Instantiates a depth renderer
  53706. * @param scene The scene the renderer belongs to
  53707. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  53708. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  53709. */
  53710. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  53711. /**
  53712. * Creates the depth rendering effect and checks if the effect is ready.
  53713. * @param subMesh The submesh to be used to render the depth map of
  53714. * @param useInstances If multiple world instances should be used
  53715. * @returns if the depth renderer is ready to render the depth map
  53716. */
  53717. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53718. /**
  53719. * Gets the texture which the depth map will be written to.
  53720. * @returns The depth map texture
  53721. */
  53722. getDepthMap(): RenderTargetTexture;
  53723. /**
  53724. * Disposes of the depth renderer.
  53725. */
  53726. dispose(): void;
  53727. }
  53728. }
  53729. declare module BABYLON {
  53730. interface Scene {
  53731. /** @hidden (Backing field) */
  53732. _depthRenderer: {
  53733. [id: string]: DepthRenderer;
  53734. };
  53735. /**
  53736. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  53737. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  53738. * @returns the created depth renderer
  53739. */
  53740. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  53741. /**
  53742. * Disables a depth renderer for a given camera
  53743. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  53744. */
  53745. disableDepthRenderer(camera?: Nullable<Camera>): void;
  53746. }
  53747. /**
  53748. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  53749. * in several rendering techniques.
  53750. */
  53751. export class DepthRendererSceneComponent implements ISceneComponent {
  53752. /**
  53753. * The component name helpfull to identify the component in the list of scene components.
  53754. */
  53755. readonly name: string;
  53756. /**
  53757. * The scene the component belongs to.
  53758. */
  53759. scene: Scene;
  53760. /**
  53761. * Creates a new instance of the component for the given scene
  53762. * @param scene Defines the scene to register the component in
  53763. */
  53764. constructor(scene: Scene);
  53765. /**
  53766. * Registers the component in a given scene
  53767. */
  53768. register(): void;
  53769. /**
  53770. * Rebuilds the elements related to this component in case of
  53771. * context lost for instance.
  53772. */
  53773. rebuild(): void;
  53774. /**
  53775. * Disposes the component and the associated ressources
  53776. */
  53777. dispose(): void;
  53778. private _gatherRenderTargets;
  53779. private _gatherActiveCameraRenderTargets;
  53780. }
  53781. }
  53782. declare module BABYLON {
  53783. /** @hidden */
  53784. export var outlinePixelShader: {
  53785. name: string;
  53786. shader: string;
  53787. };
  53788. }
  53789. declare module BABYLON {
  53790. /** @hidden */
  53791. export var outlineVertexShader: {
  53792. name: string;
  53793. shader: string;
  53794. };
  53795. }
  53796. declare module BABYLON {
  53797. interface Scene {
  53798. /** @hidden */
  53799. _outlineRenderer: OutlineRenderer;
  53800. /**
  53801. * Gets the outline renderer associated with the scene
  53802. * @returns a OutlineRenderer
  53803. */
  53804. getOutlineRenderer(): OutlineRenderer;
  53805. }
  53806. interface AbstractMesh {
  53807. /** @hidden (Backing field) */
  53808. _renderOutline: boolean;
  53809. /**
  53810. * Gets or sets a boolean indicating if the outline must be rendered as well
  53811. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  53812. */
  53813. renderOutline: boolean;
  53814. /** @hidden (Backing field) */
  53815. _renderOverlay: boolean;
  53816. /**
  53817. * Gets or sets a boolean indicating if the overlay must be rendered as well
  53818. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  53819. */
  53820. renderOverlay: boolean;
  53821. }
  53822. /**
  53823. * This class is responsible to draw bothe outline/overlay of meshes.
  53824. * It should not be used directly but through the available method on mesh.
  53825. */
  53826. export class OutlineRenderer implements ISceneComponent {
  53827. /**
  53828. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  53829. */
  53830. private static _StencilReference;
  53831. /**
  53832. * The name of the component. Each component must have a unique name.
  53833. */
  53834. name: string;
  53835. /**
  53836. * The scene the component belongs to.
  53837. */
  53838. scene: Scene;
  53839. /**
  53840. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  53841. */
  53842. zOffset: number;
  53843. private _engine;
  53844. private _effect;
  53845. private _cachedDefines;
  53846. private _savedDepthWrite;
  53847. /**
  53848. * Instantiates a new outline renderer. (There could be only one per scene).
  53849. * @param scene Defines the scene it belongs to
  53850. */
  53851. constructor(scene: Scene);
  53852. /**
  53853. * Register the component to one instance of a scene.
  53854. */
  53855. register(): void;
  53856. /**
  53857. * Rebuilds the elements related to this component in case of
  53858. * context lost for instance.
  53859. */
  53860. rebuild(): void;
  53861. /**
  53862. * Disposes the component and the associated ressources.
  53863. */
  53864. dispose(): void;
  53865. /**
  53866. * Renders the outline in the canvas.
  53867. * @param subMesh Defines the sumesh to render
  53868. * @param batch Defines the batch of meshes in case of instances
  53869. * @param useOverlay Defines if the rendering is for the overlay or the outline
  53870. */
  53871. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  53872. /**
  53873. * Returns whether or not the outline renderer is ready for a given submesh.
  53874. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  53875. * @param subMesh Defines the submesh to check readyness for
  53876. * @param useInstances Defines wheter wee are trying to render instances or not
  53877. * @returns true if ready otherwise false
  53878. */
  53879. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53880. private _beforeRenderingMesh;
  53881. private _afterRenderingMesh;
  53882. }
  53883. }
  53884. declare module BABYLON {
  53885. /**
  53886. * Defines the list of states available for a task inside a AssetsManager
  53887. */
  53888. export enum AssetTaskState {
  53889. /**
  53890. * Initialization
  53891. */
  53892. INIT = 0,
  53893. /**
  53894. * Running
  53895. */
  53896. RUNNING = 1,
  53897. /**
  53898. * Done
  53899. */
  53900. DONE = 2,
  53901. /**
  53902. * Error
  53903. */
  53904. ERROR = 3
  53905. }
  53906. /**
  53907. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  53908. */
  53909. export abstract class AbstractAssetTask {
  53910. /**
  53911. * Task name
  53912. */ name: string;
  53913. /**
  53914. * Callback called when the task is successful
  53915. */
  53916. onSuccess: (task: any) => void;
  53917. /**
  53918. * Callback called when the task is not successful
  53919. */
  53920. onError: (task: any, message?: string, exception?: any) => void;
  53921. /**
  53922. * Creates a new AssetsManager
  53923. * @param name defines the name of the task
  53924. */
  53925. constructor(
  53926. /**
  53927. * Task name
  53928. */ name: string);
  53929. private _isCompleted;
  53930. private _taskState;
  53931. private _errorObject;
  53932. /**
  53933. * Get if the task is completed
  53934. */
  53935. readonly isCompleted: boolean;
  53936. /**
  53937. * Gets the current state of the task
  53938. */
  53939. readonly taskState: AssetTaskState;
  53940. /**
  53941. * Gets the current error object (if task is in error)
  53942. */
  53943. readonly errorObject: {
  53944. message?: string;
  53945. exception?: any;
  53946. };
  53947. /**
  53948. * Internal only
  53949. * @hidden
  53950. */
  53951. _setErrorObject(message?: string, exception?: any): void;
  53952. /**
  53953. * Execute the current task
  53954. * @param scene defines the scene where you want your assets to be loaded
  53955. * @param onSuccess is a callback called when the task is successfully executed
  53956. * @param onError is a callback called if an error occurs
  53957. */
  53958. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  53959. /**
  53960. * Execute the current task
  53961. * @param scene defines the scene where you want your assets to be loaded
  53962. * @param onSuccess is a callback called when the task is successfully executed
  53963. * @param onError is a callback called if an error occurs
  53964. */
  53965. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  53966. /**
  53967. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  53968. * This can be used with failed tasks that have the reason for failure fixed.
  53969. */
  53970. reset(): void;
  53971. private onErrorCallback;
  53972. private onDoneCallback;
  53973. }
  53974. /**
  53975. * Define the interface used by progress events raised during assets loading
  53976. */
  53977. export interface IAssetsProgressEvent {
  53978. /**
  53979. * Defines the number of remaining tasks to process
  53980. */
  53981. remainingCount: number;
  53982. /**
  53983. * Defines the total number of tasks
  53984. */
  53985. totalCount: number;
  53986. /**
  53987. * Defines the task that was just processed
  53988. */
  53989. task: AbstractAssetTask;
  53990. }
  53991. /**
  53992. * Class used to share progress information about assets loading
  53993. */
  53994. export class AssetsProgressEvent implements IAssetsProgressEvent {
  53995. /**
  53996. * Defines the number of remaining tasks to process
  53997. */
  53998. remainingCount: number;
  53999. /**
  54000. * Defines the total number of tasks
  54001. */
  54002. totalCount: number;
  54003. /**
  54004. * Defines the task that was just processed
  54005. */
  54006. task: AbstractAssetTask;
  54007. /**
  54008. * Creates a AssetsProgressEvent
  54009. * @param remainingCount defines the number of remaining tasks to process
  54010. * @param totalCount defines the total number of tasks
  54011. * @param task defines the task that was just processed
  54012. */
  54013. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  54014. }
  54015. /**
  54016. * Define a task used by AssetsManager to load meshes
  54017. */
  54018. export class MeshAssetTask extends AbstractAssetTask {
  54019. /**
  54020. * Defines the name of the task
  54021. */
  54022. name: string;
  54023. /**
  54024. * Defines the list of mesh's names you want to load
  54025. */
  54026. meshesNames: any;
  54027. /**
  54028. * Defines the root url to use as a base to load your meshes and associated resources
  54029. */
  54030. rootUrl: string;
  54031. /**
  54032. * Defines the filename of the scene to load from
  54033. */
  54034. sceneFilename: string;
  54035. /**
  54036. * Gets the list of loaded meshes
  54037. */
  54038. loadedMeshes: Array<AbstractMesh>;
  54039. /**
  54040. * Gets the list of loaded particle systems
  54041. */
  54042. loadedParticleSystems: Array<IParticleSystem>;
  54043. /**
  54044. * Gets the list of loaded skeletons
  54045. */
  54046. loadedSkeletons: Array<Skeleton>;
  54047. /**
  54048. * Gets the list of loaded animation groups
  54049. */
  54050. loadedAnimationGroups: Array<AnimationGroup>;
  54051. /**
  54052. * Callback called when the task is successful
  54053. */
  54054. onSuccess: (task: MeshAssetTask) => void;
  54055. /**
  54056. * Callback called when the task is successful
  54057. */
  54058. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  54059. /**
  54060. * Creates a new MeshAssetTask
  54061. * @param name defines the name of the task
  54062. * @param meshesNames defines the list of mesh's names you want to load
  54063. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  54064. * @param sceneFilename defines the filename of the scene to load from
  54065. */
  54066. constructor(
  54067. /**
  54068. * Defines the name of the task
  54069. */
  54070. name: string,
  54071. /**
  54072. * Defines the list of mesh's names you want to load
  54073. */
  54074. meshesNames: any,
  54075. /**
  54076. * Defines the root url to use as a base to load your meshes and associated resources
  54077. */
  54078. rootUrl: string,
  54079. /**
  54080. * Defines the filename of the scene to load from
  54081. */
  54082. sceneFilename: string);
  54083. /**
  54084. * Execute the current task
  54085. * @param scene defines the scene where you want your assets to be loaded
  54086. * @param onSuccess is a callback called when the task is successfully executed
  54087. * @param onError is a callback called if an error occurs
  54088. */
  54089. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54090. }
  54091. /**
  54092. * Define a task used by AssetsManager to load text content
  54093. */
  54094. export class TextFileAssetTask extends AbstractAssetTask {
  54095. /**
  54096. * Defines the name of the task
  54097. */
  54098. name: string;
  54099. /**
  54100. * Defines the location of the file to load
  54101. */
  54102. url: string;
  54103. /**
  54104. * Gets the loaded text string
  54105. */
  54106. text: string;
  54107. /**
  54108. * Callback called when the task is successful
  54109. */
  54110. onSuccess: (task: TextFileAssetTask) => void;
  54111. /**
  54112. * Callback called when the task is successful
  54113. */
  54114. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  54115. /**
  54116. * Creates a new TextFileAssetTask object
  54117. * @param name defines the name of the task
  54118. * @param url defines the location of the file to load
  54119. */
  54120. constructor(
  54121. /**
  54122. * Defines the name of the task
  54123. */
  54124. name: string,
  54125. /**
  54126. * Defines the location of the file to load
  54127. */
  54128. url: string);
  54129. /**
  54130. * Execute the current task
  54131. * @param scene defines the scene where you want your assets to be loaded
  54132. * @param onSuccess is a callback called when the task is successfully executed
  54133. * @param onError is a callback called if an error occurs
  54134. */
  54135. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54136. }
  54137. /**
  54138. * Define a task used by AssetsManager to load binary data
  54139. */
  54140. export class BinaryFileAssetTask extends AbstractAssetTask {
  54141. /**
  54142. * Defines the name of the task
  54143. */
  54144. name: string;
  54145. /**
  54146. * Defines the location of the file to load
  54147. */
  54148. url: string;
  54149. /**
  54150. * Gets the lodaded data (as an array buffer)
  54151. */
  54152. data: ArrayBuffer;
  54153. /**
  54154. * Callback called when the task is successful
  54155. */
  54156. onSuccess: (task: BinaryFileAssetTask) => void;
  54157. /**
  54158. * Callback called when the task is successful
  54159. */
  54160. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  54161. /**
  54162. * Creates a new BinaryFileAssetTask object
  54163. * @param name defines the name of the new task
  54164. * @param url defines the location of the file to load
  54165. */
  54166. constructor(
  54167. /**
  54168. * Defines the name of the task
  54169. */
  54170. name: string,
  54171. /**
  54172. * Defines the location of the file to load
  54173. */
  54174. url: string);
  54175. /**
  54176. * Execute the current task
  54177. * @param scene defines the scene where you want your assets to be loaded
  54178. * @param onSuccess is a callback called when the task is successfully executed
  54179. * @param onError is a callback called if an error occurs
  54180. */
  54181. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54182. }
  54183. /**
  54184. * Define a task used by AssetsManager to load images
  54185. */
  54186. export class ImageAssetTask extends AbstractAssetTask {
  54187. /**
  54188. * Defines the name of the task
  54189. */
  54190. name: string;
  54191. /**
  54192. * Defines the location of the image to load
  54193. */
  54194. url: string;
  54195. /**
  54196. * Gets the loaded images
  54197. */
  54198. image: HTMLImageElement;
  54199. /**
  54200. * Callback called when the task is successful
  54201. */
  54202. onSuccess: (task: ImageAssetTask) => void;
  54203. /**
  54204. * Callback called when the task is successful
  54205. */
  54206. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  54207. /**
  54208. * Creates a new ImageAssetTask
  54209. * @param name defines the name of the task
  54210. * @param url defines the location of the image to load
  54211. */
  54212. constructor(
  54213. /**
  54214. * Defines the name of the task
  54215. */
  54216. name: string,
  54217. /**
  54218. * Defines the location of the image to load
  54219. */
  54220. url: string);
  54221. /**
  54222. * Execute the current task
  54223. * @param scene defines the scene where you want your assets to be loaded
  54224. * @param onSuccess is a callback called when the task is successfully executed
  54225. * @param onError is a callback called if an error occurs
  54226. */
  54227. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54228. }
  54229. /**
  54230. * Defines the interface used by texture loading tasks
  54231. */
  54232. export interface ITextureAssetTask<TEX extends BaseTexture> {
  54233. /**
  54234. * Gets the loaded texture
  54235. */
  54236. texture: TEX;
  54237. }
  54238. /**
  54239. * Define a task used by AssetsManager to load 2D textures
  54240. */
  54241. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  54242. /**
  54243. * Defines the name of the task
  54244. */
  54245. name: string;
  54246. /**
  54247. * Defines the location of the file to load
  54248. */
  54249. url: string;
  54250. /**
  54251. * Defines if mipmap should not be generated (default is false)
  54252. */
  54253. noMipmap?: boolean | undefined;
  54254. /**
  54255. * Defines if texture must be inverted on Y axis (default is false)
  54256. */
  54257. invertY?: boolean | undefined;
  54258. /**
  54259. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  54260. */
  54261. samplingMode: number;
  54262. /**
  54263. * Gets the loaded texture
  54264. */
  54265. texture: Texture;
  54266. /**
  54267. * Callback called when the task is successful
  54268. */
  54269. onSuccess: (task: TextureAssetTask) => void;
  54270. /**
  54271. * Callback called when the task is successful
  54272. */
  54273. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  54274. /**
  54275. * Creates a new TextureAssetTask object
  54276. * @param name defines the name of the task
  54277. * @param url defines the location of the file to load
  54278. * @param noMipmap defines if mipmap should not be generated (default is false)
  54279. * @param invertY defines if texture must be inverted on Y axis (default is false)
  54280. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  54281. */
  54282. constructor(
  54283. /**
  54284. * Defines the name of the task
  54285. */
  54286. name: string,
  54287. /**
  54288. * Defines the location of the file to load
  54289. */
  54290. url: string,
  54291. /**
  54292. * Defines if mipmap should not be generated (default is false)
  54293. */
  54294. noMipmap?: boolean | undefined,
  54295. /**
  54296. * Defines if texture must be inverted on Y axis (default is false)
  54297. */
  54298. invertY?: boolean | undefined,
  54299. /**
  54300. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  54301. */
  54302. samplingMode?: number);
  54303. /**
  54304. * Execute the current task
  54305. * @param scene defines the scene where you want your assets to be loaded
  54306. * @param onSuccess is a callback called when the task is successfully executed
  54307. * @param onError is a callback called if an error occurs
  54308. */
  54309. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54310. }
  54311. /**
  54312. * Define a task used by AssetsManager to load cube textures
  54313. */
  54314. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  54315. /**
  54316. * Defines the name of the task
  54317. */
  54318. name: string;
  54319. /**
  54320. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  54321. */
  54322. url: string;
  54323. /**
  54324. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  54325. */
  54326. extensions?: string[] | undefined;
  54327. /**
  54328. * Defines if mipmaps should not be generated (default is false)
  54329. */
  54330. noMipmap?: boolean | undefined;
  54331. /**
  54332. * Defines the explicit list of files (undefined by default)
  54333. */
  54334. files?: string[] | undefined;
  54335. /**
  54336. * Gets the loaded texture
  54337. */
  54338. texture: CubeTexture;
  54339. /**
  54340. * Callback called when the task is successful
  54341. */
  54342. onSuccess: (task: CubeTextureAssetTask) => void;
  54343. /**
  54344. * Callback called when the task is successful
  54345. */
  54346. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  54347. /**
  54348. * Creates a new CubeTextureAssetTask
  54349. * @param name defines the name of the task
  54350. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  54351. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  54352. * @param noMipmap defines if mipmaps should not be generated (default is false)
  54353. * @param files defines the explicit list of files (undefined by default)
  54354. */
  54355. constructor(
  54356. /**
  54357. * Defines the name of the task
  54358. */
  54359. name: string,
  54360. /**
  54361. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  54362. */
  54363. url: string,
  54364. /**
  54365. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  54366. */
  54367. extensions?: string[] | undefined,
  54368. /**
  54369. * Defines if mipmaps should not be generated (default is false)
  54370. */
  54371. noMipmap?: boolean | undefined,
  54372. /**
  54373. * Defines the explicit list of files (undefined by default)
  54374. */
  54375. files?: string[] | undefined);
  54376. /**
  54377. * Execute the current task
  54378. * @param scene defines the scene where you want your assets to be loaded
  54379. * @param onSuccess is a callback called when the task is successfully executed
  54380. * @param onError is a callback called if an error occurs
  54381. */
  54382. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54383. }
  54384. /**
  54385. * Define a task used by AssetsManager to load HDR cube textures
  54386. */
  54387. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  54388. /**
  54389. * Defines the name of the task
  54390. */
  54391. name: string;
  54392. /**
  54393. * Defines the location of the file to load
  54394. */
  54395. url: string;
  54396. /**
  54397. * Defines the desired size (the more it increases the longer the generation will be)
  54398. */
  54399. size: number;
  54400. /**
  54401. * Defines if mipmaps should not be generated (default is false)
  54402. */
  54403. noMipmap: boolean;
  54404. /**
  54405. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  54406. */
  54407. generateHarmonics: boolean;
  54408. /**
  54409. * 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)
  54410. */
  54411. gammaSpace: boolean;
  54412. /**
  54413. * Internal Use Only
  54414. */
  54415. reserved: boolean;
  54416. /**
  54417. * Gets the loaded texture
  54418. */
  54419. texture: HDRCubeTexture;
  54420. /**
  54421. * Callback called when the task is successful
  54422. */
  54423. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  54424. /**
  54425. * Callback called when the task is successful
  54426. */
  54427. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  54428. /**
  54429. * Creates a new HDRCubeTextureAssetTask object
  54430. * @param name defines the name of the task
  54431. * @param url defines the location of the file to load
  54432. * @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.
  54433. * @param noMipmap defines if mipmaps should not be generated (default is false)
  54434. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  54435. * @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)
  54436. * @param reserved Internal use only
  54437. */
  54438. constructor(
  54439. /**
  54440. * Defines the name of the task
  54441. */
  54442. name: string,
  54443. /**
  54444. * Defines the location of the file to load
  54445. */
  54446. url: string,
  54447. /**
  54448. * Defines the desired size (the more it increases the longer the generation will be)
  54449. */
  54450. size: number,
  54451. /**
  54452. * Defines if mipmaps should not be generated (default is false)
  54453. */
  54454. noMipmap?: boolean,
  54455. /**
  54456. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  54457. */
  54458. generateHarmonics?: boolean,
  54459. /**
  54460. * 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)
  54461. */
  54462. gammaSpace?: boolean,
  54463. /**
  54464. * Internal Use Only
  54465. */
  54466. reserved?: boolean);
  54467. /**
  54468. * Execute the current task
  54469. * @param scene defines the scene where you want your assets to be loaded
  54470. * @param onSuccess is a callback called when the task is successfully executed
  54471. * @param onError is a callback called if an error occurs
  54472. */
  54473. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54474. }
  54475. /**
  54476. * This class can be used to easily import assets into a scene
  54477. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  54478. */
  54479. export class AssetsManager {
  54480. private _scene;
  54481. private _isLoading;
  54482. protected _tasks: AbstractAssetTask[];
  54483. protected _waitingTasksCount: number;
  54484. protected _totalTasksCount: number;
  54485. /**
  54486. * Callback called when all tasks are processed
  54487. */
  54488. onFinish: (tasks: AbstractAssetTask[]) => void;
  54489. /**
  54490. * Callback called when a task is successful
  54491. */
  54492. onTaskSuccess: (task: AbstractAssetTask) => void;
  54493. /**
  54494. * Callback called when a task had an error
  54495. */
  54496. onTaskError: (task: AbstractAssetTask) => void;
  54497. /**
  54498. * Callback called when a task is done (whatever the result is)
  54499. */
  54500. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  54501. /**
  54502. * Observable called when all tasks are processed
  54503. */
  54504. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  54505. /**
  54506. * Observable called when a task had an error
  54507. */
  54508. onTaskErrorObservable: Observable<AbstractAssetTask>;
  54509. /**
  54510. * Observable called when all tasks were executed
  54511. */
  54512. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  54513. /**
  54514. * Observable called when a task is done (whatever the result is)
  54515. */
  54516. onProgressObservable: Observable<IAssetsProgressEvent>;
  54517. /**
  54518. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  54519. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  54520. */
  54521. useDefaultLoadingScreen: boolean;
  54522. /**
  54523. * Creates a new AssetsManager
  54524. * @param scene defines the scene to work on
  54525. */
  54526. constructor(scene: Scene);
  54527. /**
  54528. * Add a MeshAssetTask to the list of active tasks
  54529. * @param taskName defines the name of the new task
  54530. * @param meshesNames defines the name of meshes to load
  54531. * @param rootUrl defines the root url to use to locate files
  54532. * @param sceneFilename defines the filename of the scene file
  54533. * @returns a new MeshAssetTask object
  54534. */
  54535. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  54536. /**
  54537. * Add a TextFileAssetTask to the list of active tasks
  54538. * @param taskName defines the name of the new task
  54539. * @param url defines the url of the file to load
  54540. * @returns a new TextFileAssetTask object
  54541. */
  54542. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  54543. /**
  54544. * Add a BinaryFileAssetTask to the list of active tasks
  54545. * @param taskName defines the name of the new task
  54546. * @param url defines the url of the file to load
  54547. * @returns a new BinaryFileAssetTask object
  54548. */
  54549. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  54550. /**
  54551. * Add a ImageAssetTask to the list of active tasks
  54552. * @param taskName defines the name of the new task
  54553. * @param url defines the url of the file to load
  54554. * @returns a new ImageAssetTask object
  54555. */
  54556. addImageTask(taskName: string, url: string): ImageAssetTask;
  54557. /**
  54558. * Add a TextureAssetTask to the list of active tasks
  54559. * @param taskName defines the name of the new task
  54560. * @param url defines the url of the file to load
  54561. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  54562. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  54563. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  54564. * @returns a new TextureAssetTask object
  54565. */
  54566. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  54567. /**
  54568. * Add a CubeTextureAssetTask to the list of active tasks
  54569. * @param taskName defines the name of the new task
  54570. * @param url defines the url of the file to load
  54571. * @param extensions defines the extension to use to load the cube map (can be null)
  54572. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  54573. * @param files defines the list of files to load (can be null)
  54574. * @returns a new CubeTextureAssetTask object
  54575. */
  54576. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  54577. /**
  54578. *
  54579. * Add a HDRCubeTextureAssetTask to the list of active tasks
  54580. * @param taskName defines the name of the new task
  54581. * @param url defines the url of the file to load
  54582. * @param size defines the size you want for the cubemap (can be null)
  54583. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  54584. * @param generateHarmonics defines if you want to automatically generate (true by default)
  54585. * @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)
  54586. * @param reserved Internal use only
  54587. * @returns a new HDRCubeTextureAssetTask object
  54588. */
  54589. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  54590. /**
  54591. * Remove a task from the assets manager.
  54592. * @param task the task to remove
  54593. */
  54594. removeTask(task: AbstractAssetTask): void;
  54595. private _decreaseWaitingTasksCount;
  54596. private _runTask;
  54597. /**
  54598. * Reset the AssetsManager and remove all tasks
  54599. * @return the current instance of the AssetsManager
  54600. */
  54601. reset(): AssetsManager;
  54602. /**
  54603. * Start the loading process
  54604. * @return the current instance of the AssetsManager
  54605. */
  54606. load(): AssetsManager;
  54607. /**
  54608. * Start the loading process as an async operation
  54609. * @return a promise returning the list of failed tasks
  54610. */
  54611. loadAsync(): Promise<void>;
  54612. }
  54613. }
  54614. declare module BABYLON {
  54615. /**
  54616. * Wrapper class for promise with external resolve and reject.
  54617. */
  54618. export class Deferred<T> {
  54619. /**
  54620. * The promise associated with this deferred object.
  54621. */
  54622. readonly promise: Promise<T>;
  54623. private _resolve;
  54624. private _reject;
  54625. /**
  54626. * The resolve method of the promise associated with this deferred object.
  54627. */
  54628. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  54629. /**
  54630. * The reject method of the promise associated with this deferred object.
  54631. */
  54632. readonly reject: (reason?: any) => void;
  54633. /**
  54634. * Constructor for this deferred object.
  54635. */
  54636. constructor();
  54637. }
  54638. }
  54639. declare module BABYLON {
  54640. /**
  54641. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  54642. */
  54643. export class MeshExploder {
  54644. private _centerMesh;
  54645. private _meshes;
  54646. private _meshesOrigins;
  54647. private _toCenterVectors;
  54648. private _scaledDirection;
  54649. private _newPosition;
  54650. private _centerPosition;
  54651. /**
  54652. * Explodes meshes from a center mesh.
  54653. * @param meshes The meshes to explode.
  54654. * @param centerMesh The mesh to be center of explosion.
  54655. */
  54656. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  54657. private _setCenterMesh;
  54658. /**
  54659. * Get class name
  54660. * @returns "MeshExploder"
  54661. */
  54662. getClassName(): string;
  54663. /**
  54664. * "Exploded meshes"
  54665. * @returns Array of meshes with the centerMesh at index 0.
  54666. */
  54667. getMeshes(): Array<Mesh>;
  54668. /**
  54669. * Explodes meshes giving a specific direction
  54670. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  54671. */
  54672. explode(direction?: number): void;
  54673. }
  54674. }
  54675. declare module BABYLON {
  54676. /**
  54677. * Class used to help managing file picking and drag'n'drop
  54678. */
  54679. export class FilesInput {
  54680. /**
  54681. * List of files ready to be loaded
  54682. */
  54683. static readonly FilesToLoad: {
  54684. [key: string]: File;
  54685. };
  54686. /**
  54687. * Callback called when a file is processed
  54688. */
  54689. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  54690. private _engine;
  54691. private _currentScene;
  54692. private _sceneLoadedCallback;
  54693. private _progressCallback;
  54694. private _additionalRenderLoopLogicCallback;
  54695. private _textureLoadingCallback;
  54696. private _startingProcessingFilesCallback;
  54697. private _onReloadCallback;
  54698. private _errorCallback;
  54699. private _elementToMonitor;
  54700. private _sceneFileToLoad;
  54701. private _filesToLoad;
  54702. /**
  54703. * Creates a new FilesInput
  54704. * @param engine defines the rendering engine
  54705. * @param scene defines the hosting scene
  54706. * @param sceneLoadedCallback callback called when scene is loaded
  54707. * @param progressCallback callback called to track progress
  54708. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  54709. * @param textureLoadingCallback callback called when a texture is loading
  54710. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  54711. * @param onReloadCallback callback called when a reload is requested
  54712. * @param errorCallback callback call if an error occurs
  54713. */
  54714. 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);
  54715. private _dragEnterHandler;
  54716. private _dragOverHandler;
  54717. private _dropHandler;
  54718. /**
  54719. * Calls this function to listen to drag'n'drop events on a specific DOM element
  54720. * @param elementToMonitor defines the DOM element to track
  54721. */
  54722. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  54723. /**
  54724. * Release all associated resources
  54725. */
  54726. dispose(): void;
  54727. private renderFunction;
  54728. private drag;
  54729. private drop;
  54730. private _traverseFolder;
  54731. private _processFiles;
  54732. /**
  54733. * Load files from a drop event
  54734. * @param event defines the drop event to use as source
  54735. */
  54736. loadFiles(event: any): void;
  54737. private _processReload;
  54738. /**
  54739. * Reload the current scene from the loaded files
  54740. */
  54741. reload(): void;
  54742. }
  54743. }
  54744. declare module BABYLON {
  54745. /**
  54746. * Defines the root class used to create scene optimization to use with SceneOptimizer
  54747. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54748. */
  54749. export class SceneOptimization {
  54750. /**
  54751. * Defines the priority of this optimization (0 by default which means first in the list)
  54752. */
  54753. priority: number;
  54754. /**
  54755. * Gets a string describing the action executed by the current optimization
  54756. * @returns description string
  54757. */
  54758. getDescription(): string;
  54759. /**
  54760. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54761. * @param scene defines the current scene where to apply this optimization
  54762. * @param optimizer defines the current optimizer
  54763. * @returns true if everything that can be done was applied
  54764. */
  54765. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54766. /**
  54767. * Creates the SceneOptimization object
  54768. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  54769. * @param desc defines the description associated with the optimization
  54770. */
  54771. constructor(
  54772. /**
  54773. * Defines the priority of this optimization (0 by default which means first in the list)
  54774. */
  54775. priority?: number);
  54776. }
  54777. /**
  54778. * Defines an optimization used to reduce the size of render target textures
  54779. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54780. */
  54781. export class TextureOptimization extends SceneOptimization {
  54782. /**
  54783. * Defines the priority of this optimization (0 by default which means first in the list)
  54784. */
  54785. priority: number;
  54786. /**
  54787. * 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
  54788. */
  54789. maximumSize: number;
  54790. /**
  54791. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  54792. */
  54793. step: number;
  54794. /**
  54795. * Gets a string describing the action executed by the current optimization
  54796. * @returns description string
  54797. */
  54798. getDescription(): string;
  54799. /**
  54800. * Creates the TextureOptimization object
  54801. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  54802. * @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
  54803. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  54804. */
  54805. constructor(
  54806. /**
  54807. * Defines the priority of this optimization (0 by default which means first in the list)
  54808. */
  54809. priority?: number,
  54810. /**
  54811. * 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
  54812. */
  54813. maximumSize?: number,
  54814. /**
  54815. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  54816. */
  54817. step?: number);
  54818. /**
  54819. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54820. * @param scene defines the current scene where to apply this optimization
  54821. * @param optimizer defines the current optimizer
  54822. * @returns true if everything that can be done was applied
  54823. */
  54824. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54825. }
  54826. /**
  54827. * Defines an optimization used to increase or decrease the rendering resolution
  54828. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54829. */
  54830. export class HardwareScalingOptimization extends SceneOptimization {
  54831. /**
  54832. * Defines the priority of this optimization (0 by default which means first in the list)
  54833. */
  54834. priority: number;
  54835. /**
  54836. * Defines the maximum scale to use (2 by default)
  54837. */
  54838. maximumScale: number;
  54839. /**
  54840. * Defines the step to use between two passes (0.5 by default)
  54841. */
  54842. step: number;
  54843. private _currentScale;
  54844. private _directionOffset;
  54845. /**
  54846. * Gets a string describing the action executed by the current optimization
  54847. * @return description string
  54848. */
  54849. getDescription(): string;
  54850. /**
  54851. * Creates the HardwareScalingOptimization object
  54852. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  54853. * @param maximumScale defines the maximum scale to use (2 by default)
  54854. * @param step defines the step to use between two passes (0.5 by default)
  54855. */
  54856. constructor(
  54857. /**
  54858. * Defines the priority of this optimization (0 by default which means first in the list)
  54859. */
  54860. priority?: number,
  54861. /**
  54862. * Defines the maximum scale to use (2 by default)
  54863. */
  54864. maximumScale?: number,
  54865. /**
  54866. * Defines the step to use between two passes (0.5 by default)
  54867. */
  54868. step?: number);
  54869. /**
  54870. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54871. * @param scene defines the current scene where to apply this optimization
  54872. * @param optimizer defines the current optimizer
  54873. * @returns true if everything that can be done was applied
  54874. */
  54875. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54876. }
  54877. /**
  54878. * Defines an optimization used to remove shadows
  54879. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54880. */
  54881. export class ShadowsOptimization extends SceneOptimization {
  54882. /**
  54883. * Gets a string describing the action executed by the current optimization
  54884. * @return description string
  54885. */
  54886. getDescription(): string;
  54887. /**
  54888. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54889. * @param scene defines the current scene where to apply this optimization
  54890. * @param optimizer defines the current optimizer
  54891. * @returns true if everything that can be done was applied
  54892. */
  54893. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54894. }
  54895. /**
  54896. * Defines an optimization used to turn post-processes off
  54897. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54898. */
  54899. export class PostProcessesOptimization extends SceneOptimization {
  54900. /**
  54901. * Gets a string describing the action executed by the current optimization
  54902. * @return description string
  54903. */
  54904. getDescription(): string;
  54905. /**
  54906. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54907. * @param scene defines the current scene where to apply this optimization
  54908. * @param optimizer defines the current optimizer
  54909. * @returns true if everything that can be done was applied
  54910. */
  54911. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54912. }
  54913. /**
  54914. * Defines an optimization used to turn lens flares off
  54915. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54916. */
  54917. export class LensFlaresOptimization extends SceneOptimization {
  54918. /**
  54919. * Gets a string describing the action executed by the current optimization
  54920. * @return description string
  54921. */
  54922. getDescription(): string;
  54923. /**
  54924. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54925. * @param scene defines the current scene where to apply this optimization
  54926. * @param optimizer defines the current optimizer
  54927. * @returns true if everything that can be done was applied
  54928. */
  54929. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54930. }
  54931. /**
  54932. * Defines an optimization based on user defined callback.
  54933. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54934. */
  54935. export class CustomOptimization extends SceneOptimization {
  54936. /**
  54937. * Callback called to apply the custom optimization.
  54938. */
  54939. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  54940. /**
  54941. * Callback called to get custom description
  54942. */
  54943. onGetDescription: () => string;
  54944. /**
  54945. * Gets a string describing the action executed by the current optimization
  54946. * @returns description string
  54947. */
  54948. getDescription(): string;
  54949. /**
  54950. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54951. * @param scene defines the current scene where to apply this optimization
  54952. * @param optimizer defines the current optimizer
  54953. * @returns true if everything that can be done was applied
  54954. */
  54955. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54956. }
  54957. /**
  54958. * Defines an optimization used to turn particles off
  54959. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54960. */
  54961. export class ParticlesOptimization extends SceneOptimization {
  54962. /**
  54963. * Gets a string describing the action executed by the current optimization
  54964. * @return description string
  54965. */
  54966. getDescription(): string;
  54967. /**
  54968. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54969. * @param scene defines the current scene where to apply this optimization
  54970. * @param optimizer defines the current optimizer
  54971. * @returns true if everything that can be done was applied
  54972. */
  54973. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54974. }
  54975. /**
  54976. * Defines an optimization used to turn render targets off
  54977. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54978. */
  54979. export class RenderTargetsOptimization extends SceneOptimization {
  54980. /**
  54981. * Gets a string describing the action executed by the current optimization
  54982. * @return description string
  54983. */
  54984. getDescription(): string;
  54985. /**
  54986. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54987. * @param scene defines the current scene where to apply this optimization
  54988. * @param optimizer defines the current optimizer
  54989. * @returns true if everything that can be done was applied
  54990. */
  54991. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54992. }
  54993. /**
  54994. * Defines an optimization used to merge meshes with compatible materials
  54995. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54996. */
  54997. export class MergeMeshesOptimization extends SceneOptimization {
  54998. private static _UpdateSelectionTree;
  54999. /**
  55000. * Gets or sets a boolean which defines if optimization octree has to be updated
  55001. */
  55002. /**
  55003. * Gets or sets a boolean which defines if optimization octree has to be updated
  55004. */
  55005. static UpdateSelectionTree: boolean;
  55006. /**
  55007. * Gets a string describing the action executed by the current optimization
  55008. * @return description string
  55009. */
  55010. getDescription(): string;
  55011. private _canBeMerged;
  55012. /**
  55013. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55014. * @param scene defines the current scene where to apply this optimization
  55015. * @param optimizer defines the current optimizer
  55016. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  55017. * @returns true if everything that can be done was applied
  55018. */
  55019. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  55020. }
  55021. /**
  55022. * Defines a list of options used by SceneOptimizer
  55023. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55024. */
  55025. export class SceneOptimizerOptions {
  55026. /**
  55027. * Defines the target frame rate to reach (60 by default)
  55028. */
  55029. targetFrameRate: number;
  55030. /**
  55031. * Defines the interval between two checkes (2000ms by default)
  55032. */
  55033. trackerDuration: number;
  55034. /**
  55035. * Gets the list of optimizations to apply
  55036. */
  55037. optimizations: SceneOptimization[];
  55038. /**
  55039. * Creates a new list of options used by SceneOptimizer
  55040. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  55041. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  55042. */
  55043. constructor(
  55044. /**
  55045. * Defines the target frame rate to reach (60 by default)
  55046. */
  55047. targetFrameRate?: number,
  55048. /**
  55049. * Defines the interval between two checkes (2000ms by default)
  55050. */
  55051. trackerDuration?: number);
  55052. /**
  55053. * Add a new optimization
  55054. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  55055. * @returns the current SceneOptimizerOptions
  55056. */
  55057. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  55058. /**
  55059. * Add a new custom optimization
  55060. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  55061. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  55062. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55063. * @returns the current SceneOptimizerOptions
  55064. */
  55065. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  55066. /**
  55067. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  55068. * @param targetFrameRate defines the target frame rate (60 by default)
  55069. * @returns a SceneOptimizerOptions object
  55070. */
  55071. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  55072. /**
  55073. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  55074. * @param targetFrameRate defines the target frame rate (60 by default)
  55075. * @returns a SceneOptimizerOptions object
  55076. */
  55077. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  55078. /**
  55079. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  55080. * @param targetFrameRate defines the target frame rate (60 by default)
  55081. * @returns a SceneOptimizerOptions object
  55082. */
  55083. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  55084. }
  55085. /**
  55086. * Class used to run optimizations in order to reach a target frame rate
  55087. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55088. */
  55089. export class SceneOptimizer implements IDisposable {
  55090. private _isRunning;
  55091. private _options;
  55092. private _scene;
  55093. private _currentPriorityLevel;
  55094. private _targetFrameRate;
  55095. private _trackerDuration;
  55096. private _currentFrameRate;
  55097. private _sceneDisposeObserver;
  55098. private _improvementMode;
  55099. /**
  55100. * Defines an observable called when the optimizer reaches the target frame rate
  55101. */
  55102. onSuccessObservable: Observable<SceneOptimizer>;
  55103. /**
  55104. * Defines an observable called when the optimizer enables an optimization
  55105. */
  55106. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  55107. /**
  55108. * Defines an observable called when the optimizer is not able to reach the target frame rate
  55109. */
  55110. onFailureObservable: Observable<SceneOptimizer>;
  55111. /**
  55112. * Gets a boolean indicating if the optimizer is in improvement mode
  55113. */
  55114. readonly isInImprovementMode: boolean;
  55115. /**
  55116. * Gets the current priority level (0 at start)
  55117. */
  55118. readonly currentPriorityLevel: number;
  55119. /**
  55120. * Gets the current frame rate checked by the SceneOptimizer
  55121. */
  55122. readonly currentFrameRate: number;
  55123. /**
  55124. * Gets or sets the current target frame rate (60 by default)
  55125. */
  55126. /**
  55127. * Gets or sets the current target frame rate (60 by default)
  55128. */
  55129. targetFrameRate: number;
  55130. /**
  55131. * Gets or sets the current interval between two checks (every 2000ms by default)
  55132. */
  55133. /**
  55134. * Gets or sets the current interval between two checks (every 2000ms by default)
  55135. */
  55136. trackerDuration: number;
  55137. /**
  55138. * Gets the list of active optimizations
  55139. */
  55140. readonly optimizations: SceneOptimization[];
  55141. /**
  55142. * Creates a new SceneOptimizer
  55143. * @param scene defines the scene to work on
  55144. * @param options defines the options to use with the SceneOptimizer
  55145. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  55146. * @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)
  55147. */
  55148. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  55149. /**
  55150. * Stops the current optimizer
  55151. */
  55152. stop(): void;
  55153. /**
  55154. * Reset the optimizer to initial step (current priority level = 0)
  55155. */
  55156. reset(): void;
  55157. /**
  55158. * Start the optimizer. By default it will try to reach a specific framerate
  55159. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  55160. */
  55161. start(): void;
  55162. private _checkCurrentState;
  55163. /**
  55164. * Release all resources
  55165. */
  55166. dispose(): void;
  55167. /**
  55168. * Helper function to create a SceneOptimizer with one single line of code
  55169. * @param scene defines the scene to work on
  55170. * @param options defines the options to use with the SceneOptimizer
  55171. * @param onSuccess defines a callback to call on success
  55172. * @param onFailure defines a callback to call on failure
  55173. * @returns the new SceneOptimizer object
  55174. */
  55175. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  55176. }
  55177. }
  55178. declare module BABYLON {
  55179. /**
  55180. * Class used to serialize a scene into a string
  55181. */
  55182. export class SceneSerializer {
  55183. /**
  55184. * Clear cache used by a previous serialization
  55185. */
  55186. static ClearCache(): void;
  55187. /**
  55188. * Serialize a scene into a JSON compatible object
  55189. * @param scene defines the scene to serialize
  55190. * @returns a JSON compatible object
  55191. */
  55192. static Serialize(scene: Scene): any;
  55193. /**
  55194. * Serialize a mesh into a JSON compatible object
  55195. * @param toSerialize defines the mesh to serialize
  55196. * @param withParents defines if parents must be serialized as well
  55197. * @param withChildren defines if children must be serialized as well
  55198. * @returns a JSON compatible object
  55199. */
  55200. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  55201. }
  55202. }
  55203. declare module BABYLON {
  55204. /**
  55205. * Class used to host texture specific utilities
  55206. */
  55207. export class TextureTools {
  55208. /**
  55209. * Uses the GPU to create a copy texture rescaled at a given size
  55210. * @param texture Texture to copy from
  55211. * @param width defines the desired width
  55212. * @param height defines the desired height
  55213. * @param useBilinearMode defines if bilinear mode has to be used
  55214. * @return the generated texture
  55215. */
  55216. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  55217. }
  55218. }
  55219. declare module BABYLON {
  55220. /**
  55221. * This represents the different options avilable for the video capture.
  55222. */
  55223. export interface VideoRecorderOptions {
  55224. /** Defines the mime type of the video */
  55225. mimeType: string;
  55226. /** Defines the video the video should be recorded at */
  55227. fps: number;
  55228. /** Defines the chunk size for the recording data */
  55229. recordChunckSize: number;
  55230. /** The audio tracks to attach to the record */
  55231. audioTracks?: MediaStreamTrack[];
  55232. }
  55233. /**
  55234. * This can helps recording videos from BabylonJS.
  55235. * This is based on the available WebRTC functionalities of the browser.
  55236. *
  55237. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  55238. */
  55239. export class VideoRecorder {
  55240. private static readonly _defaultOptions;
  55241. /**
  55242. * Returns wehther or not the VideoRecorder is available in your browser.
  55243. * @param engine Defines the Babylon Engine to check the support for
  55244. * @returns true if supported otherwise false
  55245. */
  55246. static IsSupported(engine: Engine): boolean;
  55247. private readonly _options;
  55248. private _canvas;
  55249. private _mediaRecorder;
  55250. private _recordedChunks;
  55251. private _fileName;
  55252. private _resolve;
  55253. private _reject;
  55254. /**
  55255. * True wether a recording is already in progress.
  55256. */
  55257. readonly isRecording: boolean;
  55258. /**
  55259. * Create a new VideoCapture object which can help converting what you see in Babylon to
  55260. * a video file.
  55261. * @param engine Defines the BabylonJS Engine you wish to record
  55262. * @param options Defines options that can be used to customized the capture
  55263. */
  55264. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  55265. /**
  55266. * Stops the current recording before the default capture timeout passed in the startRecording
  55267. * functions.
  55268. */
  55269. stopRecording(): void;
  55270. /**
  55271. * Starts recording the canvas for a max duration specified in parameters.
  55272. * @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.
  55273. * @param maxDuration Defines the maximum recording time in seconds.
  55274. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  55275. * @return a promise callback at the end of the recording with the video data in Blob.
  55276. */
  55277. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  55278. /**
  55279. * Releases internal resources used during the recording.
  55280. */
  55281. dispose(): void;
  55282. private _handleDataAvailable;
  55283. private _handleError;
  55284. private _handleStop;
  55285. }
  55286. }
  55287. declare module BABYLON {
  55288. /**
  55289. * Helper class to push actions to a pool of workers.
  55290. */
  55291. export class WorkerPool implements IDisposable {
  55292. private _workerInfos;
  55293. private _pendingActions;
  55294. /**
  55295. * Constructor
  55296. * @param workers Array of workers to use for actions
  55297. */
  55298. constructor(workers: Array<Worker>);
  55299. /**
  55300. * Terminates all workers and clears any pending actions.
  55301. */
  55302. dispose(): void;
  55303. /**
  55304. * Pushes an action to the worker pool. If all the workers are active, the action will be
  55305. * pended until a worker has completed its action.
  55306. * @param action The action to perform. Call onComplete when the action is complete.
  55307. */
  55308. push(action: (worker: Worker, onComplete: () => void) => void): void;
  55309. private _execute;
  55310. }
  55311. }
  55312. declare module BABYLON {
  55313. /**
  55314. * Class containing a set of static utilities functions for screenshots
  55315. */
  55316. export class ScreenshotTools {
  55317. /**
  55318. * Captures a screenshot of the current rendering
  55319. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  55320. * @param engine defines the rendering engine
  55321. * @param camera defines the source camera
  55322. * @param size This parameter can be set to a single number or to an object with the
  55323. * following (optional) properties: precision, width, height. If a single number is passed,
  55324. * it will be used for both width and height. If an object is passed, the screenshot size
  55325. * will be derived from the parameters. The precision property is a multiplier allowing
  55326. * rendering at a higher or lower resolution
  55327. * @param successCallback defines the callback receives a single parameter which contains the
  55328. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  55329. * src parameter of an <img> to display it
  55330. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  55331. * Check your browser for supported MIME types
  55332. */
  55333. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  55334. /**
  55335. * Generates an image screenshot from the specified camera.
  55336. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  55337. * @param engine The engine to use for rendering
  55338. * @param camera The camera to use for rendering
  55339. * @param size This parameter can be set to a single number or to an object with the
  55340. * following (optional) properties: precision, width, height. If a single number is passed,
  55341. * it will be used for both width and height. If an object is passed, the screenshot size
  55342. * will be derived from the parameters. The precision property is a multiplier allowing
  55343. * rendering at a higher or lower resolution
  55344. * @param successCallback The callback receives a single parameter which contains the
  55345. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  55346. * src parameter of an <img> to display it
  55347. * @param mimeType The MIME type of the screenshot image (default: image/png).
  55348. * Check your browser for supported MIME types
  55349. * @param samples Texture samples (default: 1)
  55350. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  55351. * @param fileName A name for for the downloaded file.
  55352. */
  55353. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  55354. }
  55355. }
  55356. declare module BABYLON {
  55357. /**
  55358. * A cursor which tracks a point on a path
  55359. */
  55360. export class PathCursor {
  55361. private path;
  55362. /**
  55363. * Stores path cursor callbacks for when an onchange event is triggered
  55364. */
  55365. private _onchange;
  55366. /**
  55367. * The value of the path cursor
  55368. */
  55369. value: number;
  55370. /**
  55371. * The animation array of the path cursor
  55372. */
  55373. animations: Animation[];
  55374. /**
  55375. * Initializes the path cursor
  55376. * @param path The path to track
  55377. */
  55378. constructor(path: Path2);
  55379. /**
  55380. * Gets the cursor point on the path
  55381. * @returns A point on the path cursor at the cursor location
  55382. */
  55383. getPoint(): Vector3;
  55384. /**
  55385. * Moves the cursor ahead by the step amount
  55386. * @param step The amount to move the cursor forward
  55387. * @returns This path cursor
  55388. */
  55389. moveAhead(step?: number): PathCursor;
  55390. /**
  55391. * Moves the cursor behind by the step amount
  55392. * @param step The amount to move the cursor back
  55393. * @returns This path cursor
  55394. */
  55395. moveBack(step?: number): PathCursor;
  55396. /**
  55397. * Moves the cursor by the step amount
  55398. * If the step amount is greater than one, an exception is thrown
  55399. * @param step The amount to move the cursor
  55400. * @returns This path cursor
  55401. */
  55402. move(step: number): PathCursor;
  55403. /**
  55404. * Ensures that the value is limited between zero and one
  55405. * @returns This path cursor
  55406. */
  55407. private ensureLimits;
  55408. /**
  55409. * Runs onchange callbacks on change (used by the animation engine)
  55410. * @returns This path cursor
  55411. */
  55412. private raiseOnChange;
  55413. /**
  55414. * Executes a function on change
  55415. * @param f A path cursor onchange callback
  55416. * @returns This path cursor
  55417. */
  55418. onchange(f: (cursor: PathCursor) => void): PathCursor;
  55419. }
  55420. }
  55421. declare module BABYLON {
  55422. /** @hidden */
  55423. export var blurPixelShader: {
  55424. name: string;
  55425. shader: string;
  55426. };
  55427. }
  55428. declare module BABYLON {
  55429. /** @hidden */
  55430. export var vrMultiviewToSingleviewPixelShader: {
  55431. name: string;
  55432. shader: string;
  55433. };
  55434. }
  55435. declare module BABYLON {
  55436. /** @hidden */
  55437. export var bones300Declaration: {
  55438. name: string;
  55439. shader: string;
  55440. };
  55441. }
  55442. declare module BABYLON {
  55443. /** @hidden */
  55444. export var instances300Declaration: {
  55445. name: string;
  55446. shader: string;
  55447. };
  55448. }
  55449. declare module BABYLON {
  55450. /** @hidden */
  55451. export var pointCloudVertexDeclaration: {
  55452. name: string;
  55453. shader: string;
  55454. };
  55455. }
  55456. // Mixins
  55457. interface Window {
  55458. mozIndexedDB: IDBFactory;
  55459. webkitIndexedDB: IDBFactory;
  55460. msIndexedDB: IDBFactory;
  55461. webkitURL: typeof URL;
  55462. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  55463. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  55464. WebGLRenderingContext: WebGLRenderingContext;
  55465. MSGesture: MSGesture;
  55466. CANNON: any;
  55467. AudioContext: AudioContext;
  55468. webkitAudioContext: AudioContext;
  55469. PointerEvent: any;
  55470. Math: Math;
  55471. Uint8Array: Uint8ArrayConstructor;
  55472. Float32Array: Float32ArrayConstructor;
  55473. mozURL: typeof URL;
  55474. msURL: typeof URL;
  55475. VRFrameData: any; // WebVR, from specs 1.1
  55476. DracoDecoderModule: any;
  55477. setImmediate(handler: (...args: any[]) => void): number;
  55478. }
  55479. interface HTMLCanvasElement {
  55480. requestPointerLock(): void;
  55481. msRequestPointerLock?(): void;
  55482. mozRequestPointerLock?(): void;
  55483. webkitRequestPointerLock?(): void;
  55484. /** Track wether a record is in progress */
  55485. isRecording: boolean;
  55486. /** Capture Stream method defined by some browsers */
  55487. captureStream(fps?: number): MediaStream;
  55488. }
  55489. interface CanvasRenderingContext2D {
  55490. msImageSmoothingEnabled: boolean;
  55491. }
  55492. interface MouseEvent {
  55493. mozMovementX: number;
  55494. mozMovementY: number;
  55495. webkitMovementX: number;
  55496. webkitMovementY: number;
  55497. msMovementX: number;
  55498. msMovementY: number;
  55499. }
  55500. interface Navigator {
  55501. mozGetVRDevices: (any: any) => any;
  55502. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  55503. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  55504. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  55505. webkitGetGamepads(): Gamepad[];
  55506. msGetGamepads(): Gamepad[];
  55507. webkitGamepads(): Gamepad[];
  55508. }
  55509. interface HTMLVideoElement {
  55510. mozSrcObject: any;
  55511. }
  55512. interface Math {
  55513. fround(x: number): number;
  55514. imul(a: number, b: number): number;
  55515. }
  55516. interface WebGLProgram {
  55517. context?: WebGLRenderingContext;
  55518. vertexShader?: WebGLShader;
  55519. fragmentShader?: WebGLShader;
  55520. isParallelCompiled: boolean;
  55521. onCompiled?: () => void;
  55522. }
  55523. interface WebGLRenderingContext {
  55524. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  55525. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  55526. vertexAttribDivisor(index: number, divisor: number): void;
  55527. createVertexArray(): any;
  55528. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  55529. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  55530. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  55531. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  55532. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  55533. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  55534. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  55535. // Queries
  55536. createQuery(): WebGLQuery;
  55537. deleteQuery(query: WebGLQuery): void;
  55538. beginQuery(target: number, query: WebGLQuery): void;
  55539. endQuery(target: number): void;
  55540. getQueryParameter(query: WebGLQuery, pname: number): any;
  55541. getQuery(target: number, pname: number): any;
  55542. MAX_SAMPLES: number;
  55543. RGBA8: number;
  55544. READ_FRAMEBUFFER: number;
  55545. DRAW_FRAMEBUFFER: number;
  55546. UNIFORM_BUFFER: number;
  55547. HALF_FLOAT_OES: number;
  55548. RGBA16F: number;
  55549. RGBA32F: number;
  55550. R32F: number;
  55551. RG32F: number;
  55552. RGB32F: number;
  55553. R16F: number;
  55554. RG16F: number;
  55555. RGB16F: number;
  55556. RED: number;
  55557. RG: number;
  55558. R8: number;
  55559. RG8: number;
  55560. UNSIGNED_INT_24_8: number;
  55561. DEPTH24_STENCIL8: number;
  55562. /* Multiple Render Targets */
  55563. drawBuffers(buffers: number[]): void;
  55564. readBuffer(src: number): void;
  55565. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  55566. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  55567. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  55568. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  55569. // Occlusion Query
  55570. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  55571. ANY_SAMPLES_PASSED: number;
  55572. QUERY_RESULT_AVAILABLE: number;
  55573. QUERY_RESULT: number;
  55574. }
  55575. interface WebGLBuffer {
  55576. references: number;
  55577. capacity: number;
  55578. is32Bits: boolean;
  55579. }
  55580. interface WebGLProgram {
  55581. transformFeedback?: WebGLTransformFeedback | null;
  55582. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  55583. }
  55584. interface EXT_disjoint_timer_query {
  55585. QUERY_COUNTER_BITS_EXT: number;
  55586. TIME_ELAPSED_EXT: number;
  55587. TIMESTAMP_EXT: number;
  55588. GPU_DISJOINT_EXT: number;
  55589. QUERY_RESULT_EXT: number;
  55590. QUERY_RESULT_AVAILABLE_EXT: number;
  55591. queryCounterEXT(query: WebGLQuery, target: number): void;
  55592. createQueryEXT(): WebGLQuery;
  55593. beginQueryEXT(target: number, query: WebGLQuery): void;
  55594. endQueryEXT(target: number): void;
  55595. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  55596. deleteQueryEXT(query: WebGLQuery): void;
  55597. }
  55598. interface WebGLUniformLocation {
  55599. _currentState: any;
  55600. }
  55601. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  55602. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  55603. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  55604. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  55605. interface WebGLRenderingContext {
  55606. readonly RASTERIZER_DISCARD: number;
  55607. readonly DEPTH_COMPONENT24: number;
  55608. readonly TEXTURE_3D: number;
  55609. readonly TEXTURE_2D_ARRAY: number;
  55610. readonly TEXTURE_COMPARE_FUNC: number;
  55611. readonly TEXTURE_COMPARE_MODE: number;
  55612. readonly COMPARE_REF_TO_TEXTURE: number;
  55613. readonly TEXTURE_WRAP_R: number;
  55614. readonly HALF_FLOAT: number;
  55615. readonly RGB8: number;
  55616. readonly RED_INTEGER: number;
  55617. readonly RG_INTEGER: number;
  55618. readonly RGB_INTEGER: number;
  55619. readonly RGBA_INTEGER: number;
  55620. readonly R8_SNORM: number;
  55621. readonly RG8_SNORM: number;
  55622. readonly RGB8_SNORM: number;
  55623. readonly RGBA8_SNORM: number;
  55624. readonly R8I: number;
  55625. readonly RG8I: number;
  55626. readonly RGB8I: number;
  55627. readonly RGBA8I: number;
  55628. readonly R8UI: number;
  55629. readonly RG8UI: number;
  55630. readonly RGB8UI: number;
  55631. readonly RGBA8UI: number;
  55632. readonly R16I: number;
  55633. readonly RG16I: number;
  55634. readonly RGB16I: number;
  55635. readonly RGBA16I: number;
  55636. readonly R16UI: number;
  55637. readonly RG16UI: number;
  55638. readonly RGB16UI: number;
  55639. readonly RGBA16UI: number;
  55640. readonly R32I: number;
  55641. readonly RG32I: number;
  55642. readonly RGB32I: number;
  55643. readonly RGBA32I: number;
  55644. readonly R32UI: number;
  55645. readonly RG32UI: number;
  55646. readonly RGB32UI: number;
  55647. readonly RGBA32UI: number;
  55648. readonly RGB10_A2UI: number;
  55649. readonly R11F_G11F_B10F: number;
  55650. readonly RGB9_E5: number;
  55651. readonly RGB10_A2: number;
  55652. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  55653. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  55654. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  55655. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  55656. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  55657. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  55658. 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;
  55659. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  55660. readonly TRANSFORM_FEEDBACK: number;
  55661. readonly INTERLEAVED_ATTRIBS: number;
  55662. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  55663. createTransformFeedback(): WebGLTransformFeedback;
  55664. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  55665. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  55666. beginTransformFeedback(primitiveMode: number): void;
  55667. endTransformFeedback(): void;
  55668. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  55669. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  55670. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  55671. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  55672. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  55673. }
  55674. interface ImageBitmap {
  55675. readonly width: number;
  55676. readonly height: number;
  55677. close(): void;
  55678. }
  55679. interface WebGLQuery extends WebGLObject {
  55680. }
  55681. declare var WebGLQuery: {
  55682. prototype: WebGLQuery;
  55683. new(): WebGLQuery;
  55684. };
  55685. interface WebGLSampler extends WebGLObject {
  55686. }
  55687. declare var WebGLSampler: {
  55688. prototype: WebGLSampler;
  55689. new(): WebGLSampler;
  55690. };
  55691. interface WebGLSync extends WebGLObject {
  55692. }
  55693. declare var WebGLSync: {
  55694. prototype: WebGLSync;
  55695. new(): WebGLSync;
  55696. };
  55697. interface WebGLTransformFeedback extends WebGLObject {
  55698. }
  55699. declare var WebGLTransformFeedback: {
  55700. prototype: WebGLTransformFeedback;
  55701. new(): WebGLTransformFeedback;
  55702. };
  55703. interface WebGLVertexArrayObject extends WebGLObject {
  55704. }
  55705. declare var WebGLVertexArrayObject: {
  55706. prototype: WebGLVertexArrayObject;
  55707. new(): WebGLVertexArrayObject;
  55708. };
  55709. // Type definitions for WebVR API
  55710. // Project: https://w3c.github.io/webvr/
  55711. // Definitions by: six a <https://github.com/lostfictions>
  55712. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  55713. interface VRDisplay extends EventTarget {
  55714. /**
  55715. * Dictionary of capabilities describing the VRDisplay.
  55716. */
  55717. readonly capabilities: VRDisplayCapabilities;
  55718. /**
  55719. * z-depth defining the far plane of the eye view frustum
  55720. * enables mapping of values in the render target depth
  55721. * attachment to scene coordinates. Initially set to 10000.0.
  55722. */
  55723. depthFar: number;
  55724. /**
  55725. * z-depth defining the near plane of the eye view frustum
  55726. * enables mapping of values in the render target depth
  55727. * attachment to scene coordinates. Initially set to 0.01.
  55728. */
  55729. depthNear: number;
  55730. /**
  55731. * An identifier for this distinct VRDisplay. Used as an
  55732. * association point in the Gamepad API.
  55733. */
  55734. readonly displayId: number;
  55735. /**
  55736. * A display name, a user-readable name identifying it.
  55737. */
  55738. readonly displayName: string;
  55739. readonly isConnected: boolean;
  55740. readonly isPresenting: boolean;
  55741. /**
  55742. * If this VRDisplay supports room-scale experiences, the optional
  55743. * stage attribute contains details on the room-scale parameters.
  55744. */
  55745. readonly stageParameters: VRStageParameters | null;
  55746. /**
  55747. * Passing the value returned by `requestAnimationFrame` to
  55748. * `cancelAnimationFrame` will unregister the callback.
  55749. * @param handle Define the hanle of the request to cancel
  55750. */
  55751. cancelAnimationFrame(handle: number): void;
  55752. /**
  55753. * Stops presenting to the VRDisplay.
  55754. * @returns a promise to know when it stopped
  55755. */
  55756. exitPresent(): Promise<void>;
  55757. /**
  55758. * Return the current VREyeParameters for the given eye.
  55759. * @param whichEye Define the eye we want the parameter for
  55760. * @returns the eye parameters
  55761. */
  55762. getEyeParameters(whichEye: string): VREyeParameters;
  55763. /**
  55764. * Populates the passed VRFrameData with the information required to render
  55765. * the current frame.
  55766. * @param frameData Define the data structure to populate
  55767. * @returns true if ok otherwise false
  55768. */
  55769. getFrameData(frameData: VRFrameData): boolean;
  55770. /**
  55771. * Get the layers currently being presented.
  55772. * @returns the list of VR layers
  55773. */
  55774. getLayers(): VRLayer[];
  55775. /**
  55776. * Return a VRPose containing the future predicted pose of the VRDisplay
  55777. * when the current frame will be presented. The value returned will not
  55778. * change until JavaScript has returned control to the browser.
  55779. *
  55780. * The VRPose will contain the position, orientation, velocity,
  55781. * and acceleration of each of these properties.
  55782. * @returns the pose object
  55783. */
  55784. getPose(): VRPose;
  55785. /**
  55786. * Return the current instantaneous pose of the VRDisplay, with no
  55787. * prediction applied.
  55788. * @returns the current instantaneous pose
  55789. */
  55790. getImmediatePose(): VRPose;
  55791. /**
  55792. * The callback passed to `requestAnimationFrame` will be called
  55793. * any time a new frame should be rendered. When the VRDisplay is
  55794. * presenting the callback will be called at the native refresh
  55795. * rate of the HMD. When not presenting this function acts
  55796. * identically to how window.requestAnimationFrame acts. Content should
  55797. * make no assumptions of frame rate or vsync behavior as the HMD runs
  55798. * asynchronously from other displays and at differing refresh rates.
  55799. * @param callback Define the eaction to run next frame
  55800. * @returns the request handle it
  55801. */
  55802. requestAnimationFrame(callback: FrameRequestCallback): number;
  55803. /**
  55804. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  55805. * Repeat calls while already presenting will update the VRLayers being displayed.
  55806. * @param layers Define the list of layer to present
  55807. * @returns a promise to know when the request has been fulfilled
  55808. */
  55809. requestPresent(layers: VRLayer[]): Promise<void>;
  55810. /**
  55811. * Reset the pose for this display, treating its current position and
  55812. * orientation as the "origin/zero" values. VRPose.position,
  55813. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  55814. * updated when calling resetPose(). This should be called in only
  55815. * sitting-space experiences.
  55816. */
  55817. resetPose(): void;
  55818. /**
  55819. * The VRLayer provided to the VRDisplay will be captured and presented
  55820. * in the HMD. Calling this function has the same effect on the source
  55821. * canvas as any other operation that uses its source image, and canvases
  55822. * created without preserveDrawingBuffer set to true will be cleared.
  55823. * @param pose Define the pose to submit
  55824. */
  55825. submitFrame(pose?: VRPose): void;
  55826. }
  55827. declare var VRDisplay: {
  55828. prototype: VRDisplay;
  55829. new(): VRDisplay;
  55830. };
  55831. interface VRLayer {
  55832. leftBounds?: number[] | Float32Array | null;
  55833. rightBounds?: number[] | Float32Array | null;
  55834. source?: HTMLCanvasElement | null;
  55835. }
  55836. interface VRDisplayCapabilities {
  55837. readonly canPresent: boolean;
  55838. readonly hasExternalDisplay: boolean;
  55839. readonly hasOrientation: boolean;
  55840. readonly hasPosition: boolean;
  55841. readonly maxLayers: number;
  55842. }
  55843. interface VREyeParameters {
  55844. /** @deprecated */
  55845. readonly fieldOfView: VRFieldOfView;
  55846. readonly offset: Float32Array;
  55847. readonly renderHeight: number;
  55848. readonly renderWidth: number;
  55849. }
  55850. interface VRFieldOfView {
  55851. readonly downDegrees: number;
  55852. readonly leftDegrees: number;
  55853. readonly rightDegrees: number;
  55854. readonly upDegrees: number;
  55855. }
  55856. interface VRFrameData {
  55857. readonly leftProjectionMatrix: Float32Array;
  55858. readonly leftViewMatrix: Float32Array;
  55859. readonly pose: VRPose;
  55860. readonly rightProjectionMatrix: Float32Array;
  55861. readonly rightViewMatrix: Float32Array;
  55862. readonly timestamp: number;
  55863. }
  55864. interface VRPose {
  55865. readonly angularAcceleration: Float32Array | null;
  55866. readonly angularVelocity: Float32Array | null;
  55867. readonly linearAcceleration: Float32Array | null;
  55868. readonly linearVelocity: Float32Array | null;
  55869. readonly orientation: Float32Array | null;
  55870. readonly position: Float32Array | null;
  55871. readonly timestamp: number;
  55872. }
  55873. interface VRStageParameters {
  55874. sittingToStandingTransform?: Float32Array;
  55875. sizeX?: number;
  55876. sizeY?: number;
  55877. }
  55878. interface Navigator {
  55879. getVRDisplays(): Promise<VRDisplay[]>;
  55880. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  55881. }
  55882. interface Window {
  55883. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  55884. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  55885. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  55886. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  55887. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  55888. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  55889. }
  55890. interface Gamepad {
  55891. readonly displayId: number;
  55892. }
  55893. interface XRDevice {
  55894. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  55895. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  55896. }
  55897. interface XRSession {
  55898. getInputSources(): Array<any>;
  55899. baseLayer: XRWebGLLayer;
  55900. requestFrameOfReference(type: string): Promise<void>;
  55901. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  55902. end(): Promise<void>;
  55903. requestAnimationFrame: Function;
  55904. addEventListener: Function;
  55905. }
  55906. interface XRSessionCreationOptions {
  55907. outputContext?: WebGLRenderingContext | null;
  55908. immersive?: boolean;
  55909. environmentIntegration?: boolean;
  55910. }
  55911. interface XRLayer {
  55912. getViewport: Function;
  55913. framebufferWidth: number;
  55914. framebufferHeight: number;
  55915. }
  55916. interface XRView {
  55917. projectionMatrix: Float32Array;
  55918. }
  55919. interface XRFrame {
  55920. getDevicePose: Function;
  55921. getInputPose: Function;
  55922. views: Array<XRView>;
  55923. baseLayer: XRLayer;
  55924. }
  55925. interface XRFrameOfReference {
  55926. }
  55927. interface XRWebGLLayer extends XRLayer {
  55928. framebuffer: WebGLFramebuffer;
  55929. }
  55930. declare var XRWebGLLayer: {
  55931. prototype: XRWebGLLayer;
  55932. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  55933. };